Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with adding env file during image build #148

Merged
merged 21 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
56a588d
fix: fixed the context path
NithinKuruba Jul 26, 2022
5757ca8
fix: updated hostname var to remove quotes
NithinKuruba Jul 26, 2022
c2292d6
fix: removing quotes on hostname and always executing upload results …
NithinKuruba Jul 26, 2022
355a9a2
fix: adding env file to docker run command
NithinKuruba Jul 26, 2022
28e5dfd
fix: pass env file through volume
NithinKuruba Jul 26, 2022
6c983db
fix: generating env file before build
NithinKuruba Jul 26, 2022
d8bff2a
fix: updated logic to click on continue button
NithinKuruba Jul 26, 2022
adf5d4d
fix: waiting before clicking on continue button
NithinKuruba Jul 26, 2022
1188c96
fix: removed this reference
NithinKuruba Jul 26, 2022
5d64655
fix: updated timeout function
NithinKuruba Jul 26, 2022
c37e334
chore: add new env var for timeout setting
NithinKuruba Jul 26, 2022
490501b
fix: added waitfornavigation
NithinKuruba Jul 26, 2022
e716a05
fix: clicking twice to make sure its clicked
NithinKuruba Jul 26, 2022
22d991b
fix: using native function to click the button
NithinKuruba Jul 26, 2022
3e823e1
fix: using incognito browser for tests
NithinKuruba Jul 27, 2022
95e2350
fix: using good practices
NithinKuruba Jul 27, 2022
7f4a2a9
fix: using timeout for initial goto website
NithinKuruba Jul 27, 2022
d6dc49a
fix: using google chrome instead of chromium
NithinKuruba Jul 27, 2022
039ce62
fix: removing screenshots code for testing
NithinKuruba Jul 27, 2022
ece5eae
fix: removed redundant code
NithinKuruba Jul 27, 2022
c5a1d8c
fix: running jobs parrallely and updated readme
NithinKuruba Jul 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions .github/workflows/siteminder-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run Siteminder Tests to Validate SAML Payload
name: Run siteminder tests to validate saml payload

on:
workflow_dispatch:
Expand Down Expand Up @@ -27,9 +27,9 @@ jobs:
id: set-matrix
run: |
datacenters=$(echo "${{ secrets.SITEMINDER_TESTS_DATACENTERS }}" | jq '."${{ github.event.inputs.environment }}".datacenters')
hostname=$(echo "${{ secrets.SITEMINDER_TESTS_DATACENTERS }}" | jq '."${{ github.event.inputs.environment }}".hostname')
hostname=$(echo "${{ secrets.SITEMINDER_TESTS_DATACENTERS }}" | jq -r '."${{ github.event.inputs.environment }}".hostname')
echo ::set-output name=datacenters::{\"include\":$(echo $datacenters)}
echo ::set-output name=hostname::$(echo $hostname)
echo ::set-output name=hostname::$(echo "$hostname")

run-siteminder-tests:
runs-on: ubuntu-20.04
Expand All @@ -42,6 +42,10 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Generate env file
run: |
cd ${{ github.workspace }}/siteminder-tests
echo "${{ secrets.SITEMINDER_TESTS_ENV }}" | base64 --decode > .env
- name: Set up docker buildx
uses: docker/setup-buildx-action@v2
- name: Cache docker layers
Expand All @@ -53,11 +57,10 @@ jobs:
- name: Build docker image
uses: docker/build-push-action@v3
with:
context: ./siteminder-tests
context: siteminder-tests/
push: false
load: true
tags: siteminder-tests
file: Dockerfile
cache-from: type=local,src=/tmp/.buildx-test-cache
cache-to: type=local,dest=/tmp/.buildx-test-cache-new
- name: Move cache
Expand All @@ -67,13 +70,13 @@ jobs:
- name: Run siteminder tests
run: |
cd ${{ github.workspace }}/siteminder-tests
echo "${{ secrets.SITEMINDER_TESTS_ENV }}" | base64 --decode > .env
docker run --rm -e ENVIRONMENT=${{ github.event.inputs.environment }} \
-e CLUSTER=${{ github.event.inputs.cluster }} \
-v $(pwd)/results:/app/results \
--add-host=${{ needs.matrix-prep.outputs.hostname }}:${{ matrix.ip }} \
siteminder-tests
- name: Upload test results
if: always()
uses: actions/upload-artifact@v2
with:
name: ${{ github.event.inputs.cluster }}-${{ github.event.inputs.environment }}-${{ matrix.name }}-results
Expand Down
12 changes: 12 additions & 0 deletions siteminder-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ Executes all the tests and generates screenshots under `results/assets`

Executes all the tests and generates screenshots and html report under `results` directory

**Note**: To run the tests on browser visually, update `beforeEach` hook in `./tests/index.test.js` file as shown below

```js
beforeEach(async function () {
browser = await puppeteer.launch({
headless: false,
});
page = await browser.newPage();
await page.setViewport({ width: 800, height: 600 });
});
```

### Docker

- Create `.env`
Expand Down
7 changes: 3 additions & 4 deletions siteminder-tests/tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,24 @@ const { testsite, screenShotsDir } = require('../util');
const { idir_config, bceid_basic_config, bceid_business_config, fetchSsoUrl } = require('../config');
const assert = require('assert');
const { describe, it, beforeEach, afterEach } = require('mocha');
const timeout = process.env.TIMEOUTSETTING ?? 3000;
const addContext = require('mochawesome/addContext');

describe('siteminder test suite', function () {
let browser;
let page;

beforeEach(async function () {
browser = await puppeteer.launch({
headless: true,
args: ['--disable-gpu', '--disable-dev-shm-usage', '--disable-setuid-sandbox', '--no-sandbox'],
});
page = await browser.newPage();
await page.setViewport({ width: 800, height: 600 });
});

afterEach(async function () {
await page.waitForTimeout(timeout);
await page.waitForTimeout(process.env.TIMEOUTSETTING);
await page.screenshot({ path: `${screenShotsDir}/${this.currentTest.title}.png` });
await page.waitForTimeout(timeout);
await page.waitForTimeout(process.env.TIMEOUTSETTING);
await page.close();
await browser.close();
addContext(this, `assets/${this.currentTest.title}.png`);
Expand Down
21 changes: 9 additions & 12 deletions siteminder-tests/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,24 @@ module.exports = {
screenShotsDir,
testsite: async function (website, idp_username, idp_password, test_name, page) {
const siteminder_values = {};
await page.goto(website, { timeout: 0, waitUntil: 'domcontentloaded' });
await page.waitForSelector('title');
await page.waitForSelector('input[name=user]');
await page.type('#user', idp_username);
await page.type('#password', idp_password);
await page.keyboard.press('Enter');

await page.waitForTimeout(1000);
await page.goto(website);
await page.waitForNavigation();
await page.waitForSelector('title');

await page.waitForSelector('input[name=user]');
await page.type('#user', idp_username);
await page.type('#password', idp_password);

await page.keyboard.press('Enter');

const isIDIR = test_name.indexOf('IDIR') > -1;

if (!isIDIR) {
await page.waitForSelector('input[type=submit]');
const continueButton = await page.$('input[type=submit]');
await continueButton.evaluate((continueButton) => continueButton.click());
await page.waitForTimeout(1000);
await page.waitForSelector('input[value=Continue]');
await page.evaluate(() => {
const $button = document.querySelector('input[value=Continue]');
$button.click();
});
}

return new Promise((resolve) => {
Expand Down