Skip to content

Commit

Permalink
revert e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
EliMoshkovich committed Mar 31, 2024
1 parent 37fd121 commit 3b083c8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
26 changes: 13 additions & 13 deletions src/tests/e2e/rbac.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test('Permission check e2e test', async (t) => {
try {
logger.info('initial setup of objects');
const document = await permit.api.resources.create({
key: 'document_test_rbac',
key: 'document',
name: 'Document',
urn: 'prn:gdrive:document',
description: 'google drive document',
Expand All @@ -35,7 +35,7 @@ test('Permission check e2e test', async (t) => {
// verify create output
t.not(document, null);
t.not(document.id, null);
t.is(document.key, 'document_test_rbac');
t.is(document.key, 'document');
t.is(document.name, 'Document');
t.is(document.description, 'google drive document');
t.is(document.urn, 'prn:gdrive:document');
Expand All @@ -56,14 +56,14 @@ test('Permission check e2e test', async (t) => {

// create admin role
const admin = await permit.api.roles.create({
key: 'admin_test_rbac',
key: 'admin',
name: 'Admin',
description: 'an admin role',
permissions: ['document:create', 'document:read'],
});

t.not(admin, null);
t.is(admin.key, 'admin_test_rbac');
t.is(admin.key, 'admin');
t.is(admin.name, 'Admin');
t.is(admin.description, 'an admin role');
t.not(admin.permissions, undefined);
Expand All @@ -72,13 +72,13 @@ test('Permission check e2e test', async (t) => {

// create viewer role
const viewer = await permit.api.roles.create({
key: 'viewer_test_rbac',
key: 'viewer',
name: 'Viewer',
description: 'an viewer role',
});

t.not(viewer, null);
t.is(viewer.key, 'viewer_test_rbac');
t.is(viewer.key, 'viewer');
t.is(viewer.name, 'Viewer');
t.is(viewer.description, 'an viewer role');
t.not(viewer.permissions, undefined);
Expand All @@ -94,12 +94,12 @@ test('Permission check e2e test', async (t) => {

// create a tenant
const tenant = await permit.api.tenants.create({
key: 'tesla_test_rbac',
key: 'tesla',
name: 'Tesla Inc',
description: 'The car company',
});

t.is(tenant.key, 'tesla_test_rbac');
t.is(tenant.key, 'tesla');
t.is(tenant.name, 'Tesla Inc');
t.is(tenant.description, 'The car company');
t.is(tenant.attributes, null);
Expand Down Expand Up @@ -152,7 +152,7 @@ test('Permission check e2e test', async (t) => {
'auth0|elon',
'read',
// a 'document' belonging to 'tesla' (ownership based on tenant)
{ type: 'document_test_rbac', tenant: 'tesla_test_rbac', attributes: resourceAttributes },
{ type: 'document', tenant: 'tesla', attributes: resourceAttributes },
),
);

Expand Down Expand Up @@ -229,10 +229,10 @@ test('Permission check e2e test', async (t) => {
// cleanup
try {
await permit.api.users.delete('auth0|elon');
await permit.api.tenants.delete('tesla_test_rbac');
await permit.api.roles.delete('admin_test_rbac');
await permit.api.roles.delete('viewer_test_rbac');
await permit.api.resources.delete('document_test_rbac');
await permit.api.tenants.delete('tesla');
await permit.api.roles.delete('admin');
await permit.api.roles.delete('viewer');
await permit.api.resources.delete('document');
t.is((await permit.api.resources.list()).length, 0);
t.is((await permit.api.roles.list()).length, 0);
t.is((await permit.api.tenants.list()).length, 1); // the default tenant
Expand Down
40 changes: 20 additions & 20 deletions src/tests/e2e/rebac.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import { printBreak, provideTestExecutionContext, TestContext } from '../fixture
const test = anyTest as TestInterface<TestContext>;
test.before(provideTestExecutionContext);

const viewerRoleKey = 'viewer_test';
const commenterRoleKey = 'commenter_test';
const editorRoleKey = 'editor_test';
const adminRoleKey = 'admin_test';
const memberRoleKey = 'member_test';
const watcherRoleKey = 'watcher_test';
const viewerRoleKey = 'viewer';
const commenterRoleKey = 'commenter';
const editorRoleKey = 'editor';
const adminRoleKey = 'admin';
const memberRoleKey = 'member';
const watcherRoleKey = 'watcher';

const account = {
key: 'account_test',
key: 'account',
name: 'Account',
urn: 'prn:gdrive:account',
description: 'google drive account',
Expand All @@ -38,7 +38,7 @@ const account = {
},
};
const folder = {
key: 'folder_test',
key: 'folder',
name: 'Folder',
urn: 'prn:gdrive:folder',
description: 'google drive folder',
Expand All @@ -53,7 +53,7 @@ const folder = {
},
};
const document = {
key: 'document_test',
key: 'document',
name: 'Document',
urn: 'prn:gdrive:document',
description: 'google drive document',
Expand All @@ -68,7 +68,7 @@ const document = {
const resourcesToCreate = [account, folder, document];

const permitUser = {
key: 'user_permit_test',
key: 'user_permit',
email: 'user@permit.io',
first_name: 'Permit',
last_name: 'User',
Expand All @@ -77,7 +77,7 @@ const permitUser = {
},
};
const authzUser = {
key: 'user_authz_test',
key: 'user_authz',
email: 'member@auth0.com',
first_name: 'Member',
last_name: 'User',
Expand Down Expand Up @@ -178,11 +178,11 @@ const allResourceRolesToCreate = [
];

const permitTenant = {
key: 'permit_test',
key: 'permit',
name: 'Permit',
};
const cocacolaTenant = {
key: 'cocacola_test',
key: 'cocacola',
name: 'Coca Cola',
};
const tenantsToCreate = [permitTenant, cocacolaTenant];
Expand Down Expand Up @@ -594,13 +594,13 @@ test('Permission check e2e test', async (t) => {
// cleanup
try {
console.log('cleaning up');
await permit.api.tenants.delete('cocacola_test');
await permit.api.tenants.delete('permit_test');
await permit.api.resources.delete('account_test');
await permit.api.resources.delete('folder_test');
await permit.api.resources.delete('document_test');
await permit.api.users.delete('user_authz_test');
await permit.api.users.delete('user_permit_test');
await permit.api.tenants.delete('cocacola');
await permit.api.tenants.delete('permit');
await permit.api.resources.delete('account');
await permit.api.resources.delete('folder');
await permit.api.resources.delete('document');
await permit.api.users.delete('user_authz');
await permit.api.users.delete('user_permit');
} catch (error) {
logger.error(`GOT ERROR: ${error}`);
t.fail(`got error: ${error}`);
Expand Down

0 comments on commit 3b083c8

Please sign in to comment.