Skip to content

Commit

Permalink
fix(e2e): get access token from an existing source
Browse files Browse the repository at this point in the history
  • Loading branch information
jrichter1 committed Dec 6, 2023
1 parent 2900fc0 commit c30fe30
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
1 change: 1 addition & 0 deletions integration-tests/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export default defineConfig({
resolution: 'high',
REMOVE_APP_ON_FAIL: false,
SNYK_TOKEN: '',
SSO_URL: 'https://sso.redhat.com/auth/',
};

for (const key in defaultValues) {
Expand Down
28 changes: 14 additions & 14 deletions integration-tests/utils/APIHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ export class APIHelper {
'X-GitHub-Api-Version': '2022-11-28',
};

static requestHACAPI(options: object) {
return cy
.getCookie('cs_jwt')
.should('exist')
.its('value')
.then((token) => {
options.headers = {
authorization: `Bearer ${token}`,
accept: 'application/json',
};
return cy.request(options);
});
static requestHACAPI(options: Partial<Cypress.RequestOptions>) {
const oidcUser = JSON.parse(
localStorage.getItem(`oidc.user:${Cypress.env('SSO_URL')}:cloud-services`),
);
const token = oidcUser.access_token as string;

options.headers = {
authorization: `Bearer ${token}`,
accept: 'application/json',
};

return cy.request(options);
}

static githubRequest(method: Cypress.HttpMethod, url: string, body?: Cypress.RequestBody) {
const options = {
const options: Partial<Cypress.RequestOptions> = {
method,
url,
headers: this.githubHeaders,
Expand All @@ -42,7 +42,7 @@ export class APIHelper {
headers?: object,
) {
expect(retryNum).to.be.lessThan(maxRetryNum);
const options = {
const options: Partial<Cypress.RequestOptions> = {
url,
timeout: 30000,
failOnStatusCode: false,
Expand Down
1 change: 1 addition & 0 deletions pr_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ COMMON_SETUP="-v $WORKSPACE/artifacts:/tmp/artifacts:Z \
-e CYPRESS_USERNAME=`echo ${B64_USER} | base64 -d` \
-e CYPRESS_PASSWORD=`echo ${B64_PASS} | base64 -d` \
-e CYPRESS_GH_PR_TITLE=${PR_TITLE} \
-e CYPRESS_SSO_URL=${HAC_KC_SSO_URL} \
-e GH_COMMENTBODY=${GH_COMMENTBODY}"
TEST_IMAGE="quay.io/hacdev/hac-tests:next"

Expand Down

0 comments on commit c30fe30

Please sign in to comment.