Skip to content

Commit

Permalink
chore: upgrade npm packages (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
AleF83 authored Dec 9, 2024
1 parent a78a070 commit 9d3d5b0
Show file tree
Hide file tree
Showing 24 changed files with 6,121 additions and 17,036 deletions.
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

85 changes: 0 additions & 85 deletions .eslintrc

This file was deleted.

17 changes: 10 additions & 7 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ concurrency:
cancel-in-progress: true

env:
TILT_VERSION: '0.33.17'
TILT_VERSION: '0.33.21'

jobs:
tests:
Expand All @@ -22,22 +22,25 @@ jobs:
- uses: actions/checkout@v4

- name: Setup Tilt
uses: yokawasa/[email protected].1
uses: yokawasa/[email protected].2
with:
setup-tools: |
tilt
tilt: ${{ env.TILT_VERSION }}

- name: Setup pnpm
uses: pnpm/action-setup@v4

- uses: actions/setup-node@v4
with:
node-version: '20'
cache: npm
node-version-file: .nvmrc
cache: pnpm

- name: Run npm install
run: npm ci
run: pnpm install --frozen-lockfile

- name: Eslint
run: npm run lint
run: pnpm run lint

- name: Run Tests
run: npm run tilt:ci
run: pnpm run tilt:ci
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v22
26 changes: 26 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.detectIndentation": false,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[properties]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"[dotenv]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"files.eol": "\n",
"eslint.workingDirectories": [
{
"mode": "auto"
}
],
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}
4 changes: 2 additions & 2 deletions e2e/helpers/authorization-endpoint.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect } from '@jest/globals';
import { Page } from 'playwright-chromium';

import { User } from '../types';
Expand All @@ -16,9 +17,8 @@ const authorizationEndpoint = async (
await page.type('[id=Input_Username]', user.Username);
await page.type('[id=Input_Password]', user.Password);
await page.keyboard.press('Enter');
await page.waitForNavigation();
await page.waitForURL(url => url.origin === redirect_uri);
const redirectedUrl = new URL(page.url());
expect(redirectedUrl.origin).toEqual(redirect_uri);
return redirectedUrl;
};

Expand Down
1 change: 1 addition & 0 deletions e2e/helpers/grants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect } from '@jest/globals';
import { Page } from 'playwright-chromium';

import { User } from '../types';
Expand Down
6 changes: 4 additions & 2 deletions e2e/helpers/introspect-endpoint.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect } from '@jest/globals';
import { ApiResource } from 'e2e/types';
import * as fs from 'fs/promises';
import path from 'path';

Expand All @@ -10,7 +12,7 @@ const introspectEndpoint = async (
): Promise<void> => {
const apiResources = yaml.parse(
await fs.readFile(path.join(process.cwd(), './config/api-resources.yaml'), { encoding: 'utf8' }),
);
) as ApiResource[];
const apiResource = apiResources.find(aR => aR.Name === apiResourceId);
expect(apiResource).toBeDefined();
const auth = Buffer.from(`${apiResource.Name}:${apiResource.ApiSecrets?.[0]}`).toString('base64');
Expand All @@ -29,7 +31,7 @@ const introspectEndpoint = async (
});

expect(response).toBeDefined();
const result = await response.json();
const result = (await response.json()) as unknown;
expect(result).toMatchSnapshot(snapshotPropertyMatchers);
};

Expand Down
5 changes: 3 additions & 2 deletions e2e/helpers/token-endpoint.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect } from '@jest/globals';
import { decode as decodeJWT } from 'jws';

const tokenEndpoint = async (
Expand All @@ -11,13 +12,13 @@ const tokenEndpoint = async (
},
body: parameters.toString(),
});
const result = await tokenEndpointResponse.json();
const result = (await tokenEndpointResponse.json()) as { access_token: string };
expect(result.access_token).toBeDefined();
const token = result.access_token;
const decodedToken = decodeJWT(token);

expect(decodedToken).toMatchSnapshot(snapshotPropertyMatchers);
return token as string;
return token;
};

export default tokenEndpoint;
4 changes: 3 additions & 1 deletion e2e/helpers/user-info-endpoint.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { expect } from '@jest/globals';

const userInfoEndpoint = async (
token: string,
snapshotPropertyMatchers: Record<string, unknown> = {},
): Promise<void> => {
const response = await fetch(process.env.OIDC_USERINFO_URL, {
headers: { authorization: `Bearer ${token}` },
});
const result = await response.json();
const result = (await response.json()) as unknown;
expect(result).toMatchSnapshot(snapshotPropertyMatchers);
};

Expand Down
19 changes: 10 additions & 9 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,24 @@
"node": ">=20.0.0"
},
"dependencies": {
"chance": "^1.1.11",
"dotenv": "^16.4.5",
"chance": "^1.1.12",
"dotenv": "^16.4.7",
"jws": "^4.0.0",
"playwright-chromium": "^1.39.0",
"wait-on": "^7.2.0",
"yaml": "^2.4.5"
"playwright-chromium": "^1.49.0",
"wait-on": "^8.0.1",
"yaml": "^2.6.1"
},
"devDependencies": {
"@jest/types": "^29.6.3",
"@types/chance": "^1.1.6",
"@types/jest": "^29.5.12",
"@types/jest": "^29.5.14",
"@types/jws": "^3.2.10",
"@types/node": "^20.14.8",
"@types/node": "^22.10.1",
"@types/wait-on": "^5.3.4",
"jest": "^29.7.0",
"jest-playwright-preset": "^4.0.0",
"ts-jest": "^29.1.5",
"typescript": "^5.5.2"
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"typescript": "^5.7.2"
}
}
3 changes: 2 additions & 1 deletion e2e/tests/base-path.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, test, beforeAll, expect } from '@jest/globals';
import * as dotenv from 'dotenv';

import clients from '../config/clients.json';
Expand All @@ -14,7 +15,7 @@ describe('Base path', () => {

test('Discovery Endpoint', async () => {
const response = await fetch(process.env.OIDC_DISCOVERY_ENDPOINT_WITH_BASE_PATH);
const result = await response.json();
const result = (await response.json()) as unknown;
expect(result).toHaveProperty('token_endpoint', process.env.OIDC_TOKEN_URL_WITH_BASE_PATH);
});

Expand Down
19 changes: 10 additions & 9 deletions e2e/tests/custom-endpoints/user-management.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, test, beforeAll, expect } from '@jest/globals';
import Chance from 'chance';
import * as dotenv from 'dotenv';

Expand Down Expand Up @@ -28,7 +29,7 @@ describe('User management', () => {
const configUsername = 'user_with_all_claim_types';
const response = await fetch(`${process.env.OIDC_MANAGE_USERS_URL}/${configUserId}`);
expect(response.status).toBe(200);
const receivedUser: User = await response.json();
const receivedUser = (await response.json()) as User;
expect(receivedUser).toHaveProperty('username', configUsername);
});

Expand Down Expand Up @@ -66,14 +67,14 @@ describe('User management', () => {
headers: { 'Content-Type': 'application/json' },
});
expect(response.status).toBe(200);
const result = await response.json();
const result = (await response.json()) as unknown;
expect(result).toEqual(subjectId);
});

test('Get user', async () => {
const response = await fetch(`${process.env.OIDC_MANAGE_USERS_URL}/${subjectId}`);
expect(response.status).toBe(200);
const receivedUser: User = await response.json();
const receivedUser = (await response.json()) as User;
expect(receivedUser).toHaveProperty('username', username);
expect(receivedUser).toHaveProperty('isActive', true);
});
Expand All @@ -89,9 +90,9 @@ describe('User management', () => {

token = await tokenEndpoint(parameters, {
payload: {
sub: expect.any(String),
['some-app-user-custom-claim']: expect.any(String),
['some-app-scope-1-custom-user-claim']: expect.any(String),
sub: expect.any(String) as unknown,
['some-app-user-custom-claim']: expect.any(String) as unknown,
['some-app-scope-1-custom-user-claim']: expect.any(String) as unknown,
},
});
});
Expand All @@ -101,15 +102,15 @@ describe('User management', () => {
sub: expect.any(String),
name: expect.any(String),
email: expect.any(String),
['some-custom-identity-user-claim']: expect.any(String),
['some-custom-identity-user-claim']: expect.any(String) as unknown,
});
}, 10000);

test('Introspection Endpoint', async () => {
await introspectEndpoint(token, 'some-app', {
sub: expect.any(String),
['some-app-user-custom-claim']: expect.any(String),
['some-app-scope-1-custom-user-claim']: expect.any(String),
['some-app-user-custom-claim']: expect.any(String) as unknown,
['some-app-scope-1-custom-user-claim']: expect.any(String) as unknown,
});
});
});
7 changes: 5 additions & 2 deletions e2e/tests/flows/authorization-code-pkce.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, test, beforeAll, afterAll, beforeEach, afterEach, expect } from '@jest/globals';
import * as crypto from 'crypto';
import * as fs from 'fs';
import path from 'path';
Expand All @@ -10,13 +11,15 @@ import clients from '../../config/clients.json';
import { authorizationEndpoint, introspectEndpoint, tokenEndpoint, userInfoEndpoint } from '../../helpers';
import type { Client, User } from '../../types';

const users = yaml.parse(fs.readFileSync(path.join(process.cwd(), './config/users.yaml'), { encoding: 'utf8' }));
const users = yaml.parse(
fs.readFileSync(path.join(process.cwd(), './config/users.yaml'), { encoding: 'utf8' }),
) as User[];

const testCases: User[] = users
.map(u => ({
...u,
toString: function () {
return this.SubjectId;
return (this as User).SubjectId;
},
}))
.sort((u1, u2) => (u1.SubjectId < u2.SubjectId ? -1 : 1));
Expand Down
Loading

0 comments on commit 9d3d5b0

Please sign in to comment.