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

Add bacon scripts #212

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 29 additions & 0 deletions .bacon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
test_suites:
- name: lint
script_path: /root/okta/okta-sdk-nodejs/scripts
sort_order: '1'
timeout: '60'
script_name: lint
criteria: MERGE
queue_name: small
- name: unit
script_path: /root/okta/okta-sdk-nodejs/scripts
sort_order: '2'
timeout: '10'
script_name: unit
criteria: MERGE
queue_name: small
# - name: e2e
# script_path: /root/okta/okta-sdk-nodejs/scripts
# sort_order: '1'
# timeout: '10'
# script_name: e2e
# criteria: MERGE
# queue_name: small
- name: publish
script_path: /root/okta/okta-sdk-nodejs/scripts
sort_order: '2'
timeout: '60'
script_name: publish
criteria: MERGE
queue_name: small
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ jsdoc/
.DS_Store
.idea
okta.yaml
test-reports/

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ node_js:
- 14

script:
- sh ./scripts/run-test.sh
- sh ./scripts/travis.sh

deploy:
provider: pages
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
"prebuild": "rimraf ./src/models ./src/factories ./src/generated-client.js",
"build": "okta-sdk-generator -t templates/ -o .",
"eslint": "eslint -c src/.eslintrc src/ && eslint -c test/.eslintrc test/it test/unit && eslint -c test/jest/.eslintrc test/jest/ && eslint -c src/.eslintrc utils/",
"jest": "jest --coverage test/jest/*.js",
"jest": "JEST_JUNIT_OUTPUT_DIR=./test-reports jest --coverage --ci --testResultsProcessor=jest-junit test/jest/*.js",
"predocs": "rimraf ./jsdocs && mkdir jsdocs/ && ./utils/make-jsdoc-readme.js > ./jsdocs/jsdoc-temp.md",
"docs": "./node_modules/.bin/jsdoc src/ -c ./docs/config.json -d ./jsdocs/ -P ./package.json -R ./jsdocs/jsdoc-temp.md -r",
"test:integration": "yarn test:integration:oauth && yarn test:integration:ssws",
"test:integration:ssws": "OKTA_CLIENT_AUTHORIZATIONMODE=SSWS nyc --reporter=text --reporter=html mocha test/it/*.js --no-timeouts",
"test:integration:ssws": "MOCHA_FILE=./test-reports/it-results.xml OKTA_CLIENT_AUTHORIZATIONMODE=SSWS nyc --reporter=text --reporter=html mocha --reporter=mocha-junit-reporter test/it/*.js --no-timeouts",
"test:integration:oauth": "OKTA_CLIENT_AUTHORIZATIONMODE=PrivateKey nyc --reporter=text --reporter=html mocha test/it/user-get.js --no-timeouts",
"test:unit": "nyc --reporter=text --reporter=html mocha test/unit/*.js --no-timeouts",
"test:unit": "MOCHA_FILE=./test-reports/junit-results.xml nyc --reporter=text --reporter=html mocha --reporter=mocha-junit-reporter test/unit/*.js --no-timeouts",
"test": "npm run eslint && npm run test:unit && npm run test:integration && npm run jest"
},
"keywords": [],
Expand All @@ -33,6 +33,7 @@
"isomorphic-fetch": "^3.0.0",
"js-yaml": "^3.14.1",
"lodash": "^4.17.20",
"mocha-junit-reporter": "^2.0.0",
"njwt": "^1.0.0",
"parse-link-header": "^1.0.1",
"rasha": "^1.2.5"
Expand All @@ -48,6 +49,7 @@
"ink-docstrap": "^1.3.2",
"jest": "^26.6.3",
"jest-date-mock": "^1.0.8",
"jest-junit": "^12.0.0",
"jsdoc": "^3.6.6",
"mocha": "^8.2.1",
"nyc": "^15.1.0",
Expand All @@ -62,4 +64,4 @@
"jest-date-mock"
]
}
}
}
24 changes: 24 additions & 0 deletions scripts/e2e.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash -x

source ${OKTA_HOME}/${REPO}/scripts/setup.sh

aws s3 --quiet --region us-east-1 cp s3://ci-secret-stash/prod/okta-sdk-nodejs/privateKey.pem ${OKTA_HOME}/${REPO}/scripts/privateKey.pem

export OKTA_CLIENT_ORGURL=https://node-sdk.okta.com
export OKTA_CLIENT_TOKEN="$(aws s3 --quiet --region us-east-1 cp s3://ci-secret-stash/prod/okta-sdk-nodejs/apiKey /dev/stdout)"
export OKTA_CLIENT_CLIENTID=0oa1jnkiuz6FCTchz4x7
export OKTA_CLIENT_PRIVATEKEY=$(cat ${OKTA_HOME}/${REPO}/scripts/privateKey.pem)

export TEST_SUITE_TYPE="junit"
export TEST_RESULT_FILE_DIR="${REPO}/test-reports"

if ! yarn test:integration; then
echo "Integration tests failed! Exiting..."
exit ${PUBLISH_TYPE_AND_RESULT_DIR_BUT_ALWAYS_FAIL}
fi

ls -al ${OKTA_HOME}/${REPO}/test-reports

echo ${TEST_SUITE_TYPE} > ${TEST_SUITE_TYPE_FILE}
echo ${TEST_RESULT_FILE_DIR} > ${TEST_RESULT_FILE_DIR_FILE}
exit ${PUBLISH_TYPE_AND_RESULT_DIR}
10 changes: 10 additions & 0 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash -xe

source ${OKTA_HOME}/${REPO}/scripts/setup.sh

if ! yarn eslint; then
echo "lint failed! Exiting..."
exit ${TEST_FAILURE}
fi

exit ${SUCCESS}
5 changes: 4 additions & 1 deletion scripts/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ source ${OKTA_HOME}/${REPO}/scripts/setup.sh

REGISTRY="${ARTIFACTORY_URL}/api/npm/npm-topic"

npm install -g @okta/ci-append-sha
yarn global add @okta/ci-append-sha

# Add yarn to the $PATH so npm cli commands do not fail
export PATH="${PATH}:$(yarn global bin)"

export TEST_SUITE_TYPE="build"

Expand Down
32 changes: 27 additions & 5 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,37 @@
#!/bin/bash

cd ${OKTA_HOME}/${REPO}
# Add yarn to the $PATH so npm cli commands do not fail
export PATH="${PATH}:$(yarn global bin)"

# Install required node version
export NVM_DIR="/root/.nvm"
setup_service node v12.13.0

# Revert the cache-min setting, since the internal cache does not apply to
# these repos (and causes problems in lookups)
npm config set cache-min 10

# Add yarn to the $PATH so npm cli commands do not fail
export PATH="${PATH}:$(yarn global bin)"
cd ${OKTA_HOME}/${REPO}

# Yarn does not utilize the npmrc/yarnrc registry configuration
# if a lockfile is present. This results in `yarn install` problems
# for private registries. Until yarn@2.0.0 is released, this is our current
# workaround.
#
# Related issues:
# - https://github.com/yarnpkg/yarn/issues/5892
# - https://github.com/yarnpkg/yarn/issues/3330

YARN_REGISTRY=https://registry.yarnpkg.com
OKTA_REGISTRY=${ARTIFACTORY_URL}/api/npm/npm-okta-master

if ! npm install; then
echo "npm install failed! Exiting..."
# Replace yarn artifactory with Okta's
sed -i "s#${YARN_REGISTRY}#${OKTA_REGISTRY}#g" yarn.lock

if ! yarn install --frozen-lockfile; then
echo "yarn install failed! Exiting..."
exit ${FAILED_SETUP}
fi

# Revert the original change
sed -i "s#${OKTA_REGISTRY}#${YARN_REGISTRY}#" yarn.lock
8 changes: 4 additions & 4 deletions scripts/run-test.sh → scripts/travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# Add yarn to the $PATH so npm cli commands do not fail
export PATH="${PATH}:$(yarn global bin)"

if ! npm install; then
echo "npm install failed! Exiting..."
if ! yarn install --frozen-lockfile; then
echo "yarn install failed! Exiting..."
exit ${FAILED_SETUP}
fi

npm run test:unit
npm run test:integration
yarn eslint
yarn test:unit
28 changes: 28 additions & 0 deletions scripts/unit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash -x

source ${OKTA_HOME}/${REPO}/scripts/setup.sh

aws s3 --quiet --region us-east-1 cp s3://ci-secret-stash/prod/okta-sdk-nodejs/privateKey.pem ${OKTA_HOME}/${REPO}/scripts/privateKey.pem

export OKTA_CLIENT_ORGURL=https://node-sdk.okta.com
export OKTA_CLIENT_TOKEN="$(aws s3 --quiet --region us-east-1 cp s3://ci-secret-stash/prod/okta-sdk-nodejs/apiKey /dev/stdout)"
export OKTA_CLIENT_CLIENTID=0oa1jnkiuz6FCTchz4x7
export OKTA_CLIENT_PRIVATEKEY=$(cat ${OKTA_HOME}/${REPO}/scripts/privateKey.pem)

export TEST_SUITE_TYPE="junit"
export TEST_RESULT_FILE_DIR="${REPO}/test-reports"

# Runs unit and jest tests
if ! yarn test:unit; then
echo "Unit tests failed! Exiting..."
exit $PUBLISH_TYPE_AND_RESULT_DIR_BUT_ALWAYS_FAIL
fi

if ! yarn jest; then
echo "jest tests failed! Exiting..."
exit $PUBLISH_TYPE_AND_RESULT_DIR_BUT_ALWAYS_FAIL
fi

echo ${TEST_SUITE_TYPE} > ${TEST_SUITE_TYPE_FILE}
echo ${TEST_RESULT_FILE_DIR} > ${TEST_RESULT_FILE_DIR_FILE}
exit ${PUBLISH_TYPE_AND_RESULT_DIR}
5 changes: 5 additions & 0 deletions test/it/authserver-crud.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('Authorization Server Crud API', () => {
describe('Create Auth Server', () => {
let authServer;
afterEach(async () => {
await authServer.deactivate();
await authServer.delete();
});

Expand All @@ -37,6 +38,7 @@ describe('Authorization Server Crud API', () => {
authServer = await client.createAuthorizationServer(getMockAuthorizationServer());
});
afterEach(async () => {
await authServer.deactivate();
await authServer.delete();
});

Expand All @@ -57,6 +59,7 @@ describe('Authorization Server Crud API', () => {
});

afterEach(async () => {
await authServer.deactivate();
await authServer.delete();
});

Expand All @@ -73,6 +76,7 @@ describe('Authorization Server Crud API', () => {
authServer = await client.createAuthorizationServer(getMockAuthorizationServer());
});
afterEach(async () => {
await authServer.deactivate();
await authServer.delete();
});

Expand All @@ -92,6 +96,7 @@ describe('Authorization Server Crud API', () => {
});

it('should not get authserver after deletion', async () => {
await authServer.deactivate();
const res = await authServer.delete();
expect(res.status).to.equal(204);
try {
Expand Down
1 change: 1 addition & 0 deletions test/it/authserver-lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('Authorization Server Lifecycle API', () => {
authServer = await client.createAuthorizationServer(getMockAuthorizationServer());
});
afterEach(async () => {
await authServer.deactivate();
await authServer.delete();
});

Expand Down
1 change: 1 addition & 0 deletions test/it/authserver-policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('Authorization Server Policies API', () => {
authServer = await client.createAuthorizationServer(getMockAuthorizationServer());
});
after(async () => {
await authServer.deactivate();
await authServer.delete();
});

Expand Down
1 change: 1 addition & 0 deletions test/it/authserver-scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('Authorization Server Scope API', () => {
authServer = await client.createAuthorizationServer(getMockAuthorizationServer());
});
after(async () => {
await authServer.deactivate();
await authServer.delete();
});

Expand Down
2 changes: 1 addition & 1 deletion test/it/mocks/authorization-server.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const faker = require('faker');

module.exports = () => ({
name: faker.random.word().substring(0, 49),
name: faker.random.words().substring(0, 99),
description: faker.random.word(),
audiences: [
'https://api.resource.com'
Expand Down
2 changes: 1 addition & 1 deletion test/it/mocks/inlinehook.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const faker = require('faker');

module.exports = () => ({
name: faker.random.word().substring(0, 49),
name: faker.random.words().substring(0, 49),
type: 'com.okta.oauth2.tokens.transform',
version: '1.0.0',
channel: {
Expand Down
1 change: 1 addition & 0 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ async function cleanupGroup(client, expectedGroup) {
await client.listGroups(queryParameters).each(async (group) => {
expect(group).to.be.an.instanceof(models.Group);
// If search doesn't return any results, listGroups() returns empty collection
// eslint-disable-next-line no-prototype-builtins
if (group.hasOwnProperty('profile')) {
if (group.profile.name === expectedGroup.profile.name) {
await group.delete();
Expand Down
Loading