-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab8155c
commit c9ad5de
Showing
7 changed files
with
87 additions
and
17 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
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
4 changes: 4 additions & 0 deletions
4
frontend/cypress/e2e/side_window/reporting_list/actions.spec.ts
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
34 changes: 34 additions & 0 deletions
34
frontend/cypress/support/commands/getAuthorizationHeader.ts
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,34 @@ | ||
import { User } from 'oidc-client-ts' | ||
|
||
export function getAuthorizationHeader() { | ||
return getOIDCUser().then(user => { | ||
const token = user?.access_token | ||
|
||
// If we have a token set in state, we pass it. | ||
if (token) { | ||
return Promise.resolve(`Bearer ${token}`) | ||
} | ||
|
||
return Promise.resolve(undefined) | ||
}) | ||
} | ||
|
||
function getOIDCUser() { | ||
const OIDC_AUTHORITY = Cypress.env('FRONTEND_OIDC_AUTHORITY') | ||
const OIDC_CLIENT_ID = Cypress.env('FRONTEND_OIDC_CLIENT_ID') | ||
const LOCALSTORAGE_URL = Cypress.env('LOCALSTORAGE_URL') | ||
|
||
return cy.getAllLocalStorage().then(localStorages => { | ||
const testLocalStorage = localStorages[LOCALSTORAGE_URL] | ||
if (!testLocalStorage) { | ||
return Promise.resolve(undefined) | ||
} | ||
|
||
const oidcStorage = testLocalStorage[`oidc.user:${OIDC_AUTHORITY}:${OIDC_CLIENT_ID}`] | ||
if (!oidcStorage) { | ||
return Promise.resolve(undefined) | ||
} | ||
|
||
return Promise.resolve(User.fromStorageString(oidcStorage as string)) | ||
}) | ||
} |