Skip to content

Commit

Permalink
PMM-7 fixed jobs vars
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadym Yarosh committed Aug 16, 2023
1 parent 9efffda commit b34c113
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 90 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/portal-ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
SERVICENOW_DEV_URL: 'https://perconadev.service-now.com/api/x_pellc_percona_pl/platform/settest'

steps:
- name: PMM server version ${{ inputs.pmm_server_version }} and UI tests for flag "${{ inputs.pmm_test_flag }}" and pmm-ui-tests branch ${{ inputs.pmm_ui_tests_branch }}
- name: PMM server version ${{ env.PMM_SERVER_VERSION }} and UI tests for flag "${{ env.PMM_TEST_FLAG }}" and pmm-ui-tests branch ${{ env.UI_TESTS_BRANCH }}
if: ${{ env.SHA != 'null' }}
uses: percona/gh-action-Sibz-github-status-action@v1
continue-on-error: true
Expand All @@ -87,28 +87,27 @@ jobs:
target_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
sha: ${{ env.SHA }}

- name: 'Checkout UI tests: "${{ inputs.pmm_ui_tests_branch }}"'
- name: 'Checkout UI tests: "${{ env.UI_TESTS_BRANCH }}"'
uses: actions/checkout@v3
with:
ref: ${{ inputs.pmm_ui_tests_branch }}
ref: ${{ env.UI_TESTS_BRANCH }}
repository: percona/pmm-ui-tests
path: ./pmm-ui-tests

- name: 'Install playwright'
working-directory: ./pmm-ui-tests/playwright-tests
run: |
npm install
npm ci
npx playwright install
- name: 'Checkout pmm-qa: "${{ inputs.pmm_qa_branch }}"'
- name: 'Checkout pmm-qa: "${{ PMM_QA_BRANCH }}"'
uses: actions/checkout@v3
with:
# token: ${{ secrets.ROBOT_TOKEN }}
repository: percona/pmm-qa
ref: ${{ inputs.pmm_qa_branch }}
ref: ${{ PMM_QA_BRANCH }}
path: ./pmm-qa

- name: 'Setup <PMM Sever>: "${{ inputs.pmm_server_version }}"'
- name: 'Setup <PMM Sever>: "${{ env.PMM_SERVER_VERSION }}"'
working-directory: pmm-qa/pmm-integration
run: |
npm install
Expand Down Expand Up @@ -142,7 +141,7 @@ jobs:
if: failure()
run: |
# TODO: add job id for matrix call
job_tag=$(echo "${{ inputs.pmm_test_flag }}" | sed -e "s/-pre-upgrade//" -e "s/@//")
job_tag=$(echo "${{ env.PMM_TEST_FLAG }}" | sed -e "s/-pre-upgrade//" -e "s/@//")
report_name="$job_tag"-report
echo $report_name
echo "REPORT_NAME=$report_name" >> $GITHUB_ENV
Expand Down
81 changes: 0 additions & 81 deletions playwright-tests/api/oktaApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,58 +31,6 @@ const oktaRequest = async (method: Method, apiPath: string, payload = {}): Promi
};

export const oktaApi = {
async loginByOktaApi(user: PortalUser, page: Page) {
const credentials = {
username: user.email,
password: user.password,
};
const response = await oktaRequest('post', '/authn', credentials);
const authConfig = {
baseUrl: Constants.okta.url,
clientId: process.env.REACT_APP_OAUTH_DEV_CLIENT_ID,
redirectUri: `${portalUrl}/login/callback`,
issuer: process.env.REACT_APP_OAUTH_DEV_ISSUER_URI,
features: {
registration: true,
rememberMe: true,
idpDiscovery: true,
},
authParams: {
pkce: true,
},
scopes: ['openid', 'profile', 'email', 'percona'],
postLogoutRedirectUri: portalUrl,
idpDiscovery: {
requestContext: `${portalUrl}/login/callback`,
},
idps: [
{ type: 'GOOGLE', id: process.env.REACT_APP_DEV_GOOGLE_IDP_ID },
{ type: 'GITHUB', id: process.env.REACT_APP_DEV_GITHUB_IDP_ID },
],
};

await page.addScriptTag({
path: './node_modules/@okta/okta-auth-js/dist/okta-auth-js.min.js',
});

await page.evaluate(
// eslint-disable-next-line @typescript-eslint/no-shadow
async ({ authConfig, response }) => {
// @ts-ignore
const authClient = new window.OktaAuth(authConfig);
const { tokens } = await authClient.token.getWithoutPrompt({
sessionToken: response.data.sessionToken,
});

const userToken = { accessToken: tokens.accessToken, idToken: tokens.idToken };

localStorage.setItem('okta-token-storage', JSON.stringify(userToken));
},
{ authConfig, response },
);
await page.reload();
},

async createUser(user: PortalUser, activate = true) {
const data = {
profile: {
Expand All @@ -106,21 +54,6 @@ export const oktaApi = {
return user;
},

async createUserWithoutMarketingConsent(user: PortalUser, activate = true) {
const data = {
profile: {
firstName: user.firstName,
lastName: user.lastName,
email: user.email,
login: user.email,
},
credentials: {
password: { value: user.password },
},
};
return oktaRequest('post', `/users?activate=${activate}`, data);
},

async getUser(email: string): Promise<PortalUser> {
const response = await oktaRequest('GET', `/users?q=${email}`);
expect(response.data[0], `Found user must have email: ${response.data[0]}`).toHaveProperty(email);
Expand All @@ -141,19 +74,6 @@ export const oktaApi = {
return response;
},

async getUserInfo(userToken: string) {
console.log(`GET: ${Constants.okta.issuerUrl}/v1/userinfo`);
const response = await axios({
url: `${Constants.okta.issuerUrl}/v1/userinfo`,
headers: { 'X-Requested-With': 'XMLHttpRequest', Authorization: `Bearer ${userToken}` },
method: 'GET',
httpsAgent: new https.Agent({ rejectUnauthorized: false }),
});
expect(response.status, `Expected to be 200: ${response.status} ${response.statusText}`).toEqual(200);
console.log(`Status: ${response.status} ${response.statusText}`);
return response;
},

async getUserId(user: PortalUser) {
const response = await oktaRequest('POST', '/api/v1/authn', {
password: user.password,
Expand Down Expand Up @@ -189,7 +109,6 @@ export const oktaApi = {
},

async deleteUsers(users: PortalUser[]) {
// eslint-disable-next-line no-restricted-syntax
for await (const user of users) {
await this.deleteUserByEmail(user.email);
}
Expand Down

0 comments on commit b34c113

Please sign in to comment.