diff --git a/src/tests/e2e/rbac.e2e.spec.ts b/src/tests/e2e/rbac.e2e.spec.ts index e173192..d9d46e1 100644 --- a/src/tests/e2e/rbac.e2e.spec.ts +++ b/src/tests/e2e/rbac.e2e.spec.ts @@ -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', @@ -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'); @@ -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); @@ -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); @@ -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); @@ -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 }, ), ); @@ -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 diff --git a/src/tests/e2e/rebac.e2e.spec.ts b/src/tests/e2e/rebac.e2e.spec.ts index a43196b..5bc2e3b 100644 --- a/src/tests/e2e/rebac.e2e.spec.ts +++ b/src/tests/e2e/rebac.e2e.spec.ts @@ -6,15 +6,15 @@ import { printBreak, provideTestExecutionContext, TestContext } from '../fixture const test = anyTest as TestInterface; 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', @@ -38,7 +38,7 @@ const account = { }, }; const folder = { - key: 'folder_test', + key: 'folder', name: 'Folder', urn: 'prn:gdrive:folder', description: 'google drive folder', @@ -53,7 +53,7 @@ const folder = { }, }; const document = { - key: 'document_test', + key: 'document', name: 'Document', urn: 'prn:gdrive:document', description: 'google drive document', @@ -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', @@ -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', @@ -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]; @@ -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}`);