Skip to content

Commit

Permalink
Eslint for E2E and Nuget Updates (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
AleF83 authored Jul 19, 2020
1 parent 5beac04 commit 5cbe252
Show file tree
Hide file tree
Showing 12 changed files with 1,484 additions and 526 deletions.
6 changes: 6 additions & 0 deletions e2e/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# don't ever lint node_modules
node_modules
# don't lint build output (make sure it's set to your correct build folder name)
dist
# don't lint nyc coverage output
coverage
44 changes: 44 additions & 0 deletions e2e/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2019,
"project": ["./tsconfig.json"]
},
"plugins": [
"@typescript-eslint",
"unicorn",
"promise",
"prettier",
"jest"
],
"extends": [
"eslint:recommended",
"plugin:node/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"plugin:unicorn/recommended",
"plugin:prettier/recommended",
"plugin:promise/recommended",
"plugin:jest/style"
],
"rules": {
"import/order": "error",
"node/no-unsupported-features/es-syntax": "off",
"node/no-unpublished-import": "off",
"unicorn/prevent-abbreviations": ["error", {
"checkFilenames": false
}]
},
"settings": {
"node": {
"allowModules": [
"chai",
"wait-on"
],
"tryExtensions": [".ts", ".json", ".node"]
}
}
}
3 changes: 3 additions & 0 deletions e2e/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
coverage
4 changes: 4 additions & 0 deletions e2e/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"printWidth": 120,
"singleQuote": true
}
34 changes: 23 additions & 11 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,38 @@
"name": "e2e",
"version": "1.0.0",
"scripts": {
"test": "mocha --require ts-node/register ./**/*.spec.ts --exit"
"test": "mocha --require ts-node/register ./**/*.spec.ts --exit",
"lint": "eslint . --ext .ts",
"format": "prettier --write **/*.ts"
},
"license": "MIT",
"dependencies": {
"axios": "0.19.2",
"chai": "4.2.0",
"jws": "^4.0.0",
"jws": "4.0.0",
"querystring": "0.2.0",
"wait-on": "4.0.2"
"wait-on": "5.1.0"
},
"devDependencies": {
"@types/axios": "^0.14.0",
"@types/chai": "4.2.11",
"@types/jws": "^3.2.2",
"@types/mocha": "7.0.2",
"@types/node": "^12.12.37",
"@types/wait-on": "^4.0.0",
"mocha": "7.1.1",
"ts-node": "8.9.0",
"tslint": "6.1.1",
"typescript": "3.8.3"
"@types/jws": "3.2.2",
"@types/mocha": "8.0.0",
"@types/node": "14.0.23",
"@types/wait-on": "4.0.0",
"@typescript-eslint/eslint-plugin": "3.6.1",
"@typescript-eslint/parser": "3.6.1",
"eslint": "7.5.0",
"eslint-config-prettier": "6.11.0",
"eslint-plugin-import": "2.22.0",
"eslint-plugin-jest": "23.18.0",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-prettier": "3.1.4",
"eslint-plugin-promise": "4.2.1",
"eslint-plugin-unicorn": "21.0.0",
"mocha": "8.0.1",
"prettier": "2.0.5",
"ts-node": "8.10.2",
"typescript": "3.9.7"
}
}
13 changes: 13 additions & 0 deletions e2e/tests/global-before.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import waitOn = require('wait-on');

before('waiting for oidc server & airbag', async function () {
this.timeout(10000);
await waitOn({
resources: [`tcp:oidc-server-mock:80`],
// tslint:disable-next-line:object-literal-sort-keys
delay: 1000,
interval: 100,
timeout: 60000,
window: 1000,
});
});
16 changes: 0 additions & 16 deletions e2e/tests/globalBefore.spec.ts

This file was deleted.

52 changes: 26 additions & 26 deletions e2e/tests/test.spec.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
import axios from "axios";
import { expect } from "chai";
import * as querystring from "querystring";
import { decode } from "jws";
import * as querystring from 'querystring';
import axios from 'axios';
import { expect } from 'chai';
import { decode } from 'jws';

describe("Test", () => {
it("should work", async () => {
const { CLIENT_CREDENTIALS_CLIENT_ID, CLIENT_CREDENTIALS_CLIENT_SECRET, API_RESOURCE } = process.env;
const params = {
client_id: CLIENT_CREDENTIALS_CLIENT_ID,
client_secret: CLIENT_CREDENTIALS_CLIENT_SECRET,
grant_type: "client_credentials",
scope: API_RESOURCE,
describe('Test', () => {
it('should work', async () => {
const { CLIENT_CREDENTIALS_CLIENT_ID, CLIENT_CREDENTIALS_CLIENT_SECRET, API_RESOURCE } = process.env;
const parameters = {
client_id: CLIENT_CREDENTIALS_CLIENT_ID,
client_secret: CLIENT_CREDENTIALS_CLIENT_SECRET,
grant_type: 'client_credentials',
scope: API_RESOURCE,
};

const response = await axios.post(process.env.OIDC_TOKEN_URL, querystring.stringify(params));
const response = await axios.post(process.env.OIDC_TOKEN_URL, querystring.stringify(parameters));

// tslint:disable-next-line:no-unused-expression
expect(response).to.exist;
// tslint:disable-next-line:no-unused-expression
expect(response.data.access_token).to.exist;
const token = decode(response.data.access_token);
// tslint:disable-next-line:no-unused-expression
expect(response).to.exist;
// tslint:disable-next-line:no-unused-expression
expect(response.data.access_token).to.exist;
const token = decode(response.data.access_token);

expect(token.header.typ).to.equal('JWT');
expect(token.payload['iss']).to.equal('http://oidc-server-mock');
expect(token.payload['aud']).to.equal('user-service');
expect(token.payload['scope']).to.deep.equal([ 'user-service-scope' ])
expect(token.payload['client_id']).to.equal('e2e-client-id');
expect(token.payload['string_claim']).to.equal('string_claim_value');
expect(token.payload['json_claim']).to.deep.equal(['value1', 'value2']);
});
expect(token.header.typ).to.equal('JWT');
expect(token.payload['iss']).to.equal('http://oidc-server-mock');
expect(token.payload['aud']).to.equal('user-service');
expect(token.payload['scope']).to.deep.equal(['user-service-scope']);
expect(token.payload['client_id']).to.equal('e2e-client-id');
expect(token.payload['string_claim']).to.equal('string_claim_value');
expect(token.payload['json_claim']).to.deep.equal(['value1', 'value2']);
});
});
Loading

0 comments on commit 5cbe252

Please sign in to comment.