Skip to content

Commit

Permalink
Addressing comments by Robert & Jordan
Browse files Browse the repository at this point in the history
  • Loading branch information
vijetmahabaleshwar-okta committed Mar 15, 2018
1 parent e57c2d1 commit 710437b
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 58 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ addons:
install:
- npm install

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

before_install:
- "npm install -g npm@5.6.0"
17 changes: 6 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,14 @@ For Windows, please set the following environment variables - ISSUER, CLIENT_ID,

> **NOTE:** Windows has USERNAME as a built-in system variable, hence set the USER_NAME environment variable for testing.
After setting up the environment variables, run this node script to copy the configuration into the JSON configuration files:

```
node scripts/setup-env.js
```

If you're on a *nix based machine, run the E2E tests:
Then run the E2E tests:

```bash
npm test
```

If you're on Windows, run the following command:
```bash
npm run test-windows
```
> **NOTE:** If you want to execute individual tests such as `npm run test:okta-hosted-login`, you will need to update the enviroment by running the following node script
>
> ```
> node scripts/setup-env.js
> ```
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
"version": "0.0.1",
"description": "Angular Sample Applications for Okta",
"scripts": {
"test": "npm run test:e2e",
"test": ".\\scripts\\runTests.sh || npm run test:e2e",
"okta-hosted-login-server": "npm start --prefix okta-hosted-login/",
"test:okta-hosted-login": "export TEST_TYPE=implicit && protractor okta-oidc-tck/e2e-tests/okta-hosted-login/conf.js",
"custom-login-server": "npm start --prefix custom-login/",
"test:custom-login": "export TEST_TYPE=implicit && protractor okta-oidc-tck/e2e-tests/custom-login/conf.js",
"resource-server": "mvn -Dokta.oauth2.issuer=$ISSUER -f samples-java-spring-mvc/resource-server/pom.xml",
"test:e2e": "export TEST_TYPE=implicit && npm run test:okta-hosted-login && npm run test:custom-login",
"pretest": "webdriver-manager update --gecko false",
"pretest": "webdriver-manager update --gecko false && node scripts/setup-env.js",
"postinstall": "npm run install-custom-login && npm run install-okta-hosted-login",
"install-custom-login": "cd custom-login && npm install",
"install-okta-hosted-login": "cd okta-hosted-login && npm install",
"test-windows": ".\\scripts\\runTests.sh"
"install-okta-hosted-login": "cd okta-hosted-login && npm install"
},
"author": "",
"license": "Apache-2.0",
Expand Down
70 changes: 32 additions & 38 deletions scripts/setup-env.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,40 @@
let fs = require('fs')
let exec = require('child_process').exec;
/* eslint-disable consistent-return, no-console */

if (process.env.ISSUER === undefined || process.env.CLIENT_ID === undefined) {
console.log("[ERROR] Please set the ISSUER and CLIENT_ID Environment variables");
return;
}

updateConfig("custom-login");
updateConfig("okta-hosted-login");
cloneRepository("https://github.com/okta/samples-java-spring-mvc.git", "samples-java-spring-mvc");
cloneRepository("https://github.com/okta/okta-oidc-tck.git", "okta-oidc-tck");
const fs = require('fs');
const { exec } = require('child_process');
const path = require('path');

function updateConfig(directory) {
let file = __dirname + "/../" + directory + "/src/app/.samples.config.ts"
fs.readFile(file, 'utf8', function (err,data) {
if (err) {
return console.log(err);
}
let result = data.replace(/{clientId}/g, process.env.CLIENT_ID);
result = result.replace(/https:\/\/{yourOktaDomain}.com\/oauth2\/default/g, process.env.ISSUER);
if (process.env.ISSUER === undefined || process.env.CLIENT_ID === undefined) {
console.log('[ERROR] Please set the ISSUER and CLIENT_ID Environment variables');
return;
}

fs.writeFile(file, result, 'utf8', function (err) {
if (err) return console.log(err);
});
});
const file = path.join(__dirname, '/../', directory, '/src/app/.samples.config.ts');
const data = fs.readFileSync(file, 'utf8');
let result = data.replace(/{clientId}/g, process.env.CLIENT_ID);
result = result.replace(/https:\/\/{yourOktaDomain}.com\/oauth2\/default/g, process.env.ISSUER);
fs.writeFileSync(file, result, 'utf8');
}

function cloneRepository(repository, directory){
let dir = __dirname + '/../' + directory;
if (fs.existsSync(dir)) {
console.log(directory + " is already cloned.");
return;
}

let command = "git clone " + repository;
function cloneRepository(repository, directory) {
const dir = path.join(__dirname, '/../', directory);
if (fs.existsSync(dir)) {
console.log(`${directory} is already cloned.`);
return;
}

console.log("Cloning repository " + directory);
let child = exec(command, function(err, stdout, stderr){
if(err != null){
return console.log(err);
} else {
return console.log(stdout);
}
});
const command = `git clone ${repository}`;
console.log(`Cloning repository ${directory}`);
exec(command, (err, stdout) => {
if (err !== null) {
return console.error(err);
}
return console.log(stdout);
});
}

updateConfig('custom-login');
updateConfig('okta-hosted-login');
cloneRepository('https://github.com/okta/samples-java-spring-mvc.git', 'samples-java-spring-mvc');
cloneRepository('https://github.com/okta/okta-oidc-tck.git', 'okta-oidc-tck');
4 changes: 0 additions & 4 deletions scripts/travis.sh

This file was deleted.

0 comments on commit 710437b

Please sign in to comment.