-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow for testing of different roles in playwright config
- Loading branch information
Showing
6 changed files
with
85 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { expect, test as setup } from '@playwright/test' | ||
|
||
const authFile = '__playwright__/.auth/adminUser.json' | ||
|
||
const testAdminUsername = 'admin' | ||
const testAdminPassword = 'TEST_PASSWORD' | ||
|
||
setup('authenticate', async ({ page }) => { | ||
await page.goto('/login') | ||
await page.getByPlaceholder('Enter any login').fill(testAdminUsername) | ||
await page.getByPlaceholder('and password').fill(testAdminPassword) | ||
await page.getByRole('button', { name: 'Sign-in' }).click() | ||
await page.waitForURL('/') | ||
await expect( | ||
page.getByRole('button', { name: '[email protected]' }) | ||
).toBeVisible() | ||
await page.context().storageState({ path: authFile }) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { expect, test } from '@playwright/test' | ||
|
||
test.describe('Example Admin Test Suite', () => { | ||
test('has title', async ({ page }) => { | ||
await page.goto('/') | ||
|
||
// Expect a title "to contain" a substring. | ||
await expect(page).toHaveTitle('GCN - General Coordinates Network') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,27 @@ export const set = { | |
}, | ||
} | ||
|
||
const localSandboxProfiles = { | ||
admin: { | ||
sub: '1234abcd-1234-abcd-1234-abcd1234abcd', | ||
email: '[email protected]', | ||
'cognito:username': '[email protected]', | ||
'cognito:groups': ['gcn.nasa.gov/gcn-admin'], | ||
identities: [{ providerName: 'Local Sandbox' }], | ||
}, | ||
default: { | ||
sub: '1234abcd-1234-abcd-1234-abcd1234abcd', | ||
email: '[email protected]', | ||
'cognito:username': '[email protected]', | ||
'cognito:groups': [ | ||
'gcn.nasa.gov/kafka-public-consumer', | ||
'gcn.nasa.gov/circular-submitter', | ||
'gcn.nasa.gov/circular-moderator', | ||
], | ||
identities: [{ providerName: 'Local Sandbox' }], | ||
}, | ||
} | ||
|
||
export const sandbox = { | ||
async start() { | ||
if (!process.env.ARC_OIDC_IDP_PORT) return | ||
|
@@ -42,17 +63,7 @@ export const sandbox = { | |
return { | ||
accountId: id, | ||
claims() { | ||
return { | ||
sub: id, | ||
email: '[email protected]', | ||
'cognito:username': id, | ||
'cognito:groups': [ | ||
'gcn.nasa.gov/kafka-public-consumer', | ||
'gcn.nasa.gov/circular-submitter', | ||
'gcn.nasa.gov/circular-moderator', | ||
], | ||
identities: [{ providerName: 'Local Sandbox' }], | ||
} | ||
return localSandboxProfiles[id] ?? localSandboxProfiles['default'] | ||
}, | ||
} | ||
}, | ||
|