Skip to content

Commit

Permalink
chore: remove node-fetch module
Browse files Browse the repository at this point in the history
  • Loading branch information
AleF83 committed Jul 4, 2024
1 parent 017f095 commit 44beeb3
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 10,051 deletions.
7 changes: 3 additions & 4 deletions e2e/helpers/introspect-endpoint.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import * as fs from 'fs/promises';
import { Agent } from 'https';
import path from 'path';

import fetch from 'node-fetch';
import * as yaml from 'yaml';

export default async (
const introspectEndpoint = async (
token: string,
apiResourceId: string,
snapshotPropertyMatchers: Record<string, unknown> = {},
Expand All @@ -28,10 +26,11 @@ export default async (
method: 'POST',
body: requestBody,
headers,
agent: new Agent({ rejectUnauthorized: false }),
});

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

export default introspectEndpoint;
8 changes: 3 additions & 5 deletions e2e/helpers/token-endpoint.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { Agent } from 'https';

import { decode as decodeJWT } from 'jws';
import fetch from 'node-fetch';

export default async (
const tokenEndpoint = async (
parameters: URLSearchParams,
snapshotPropertyMatchers: Record<string, unknown> = {},
): Promise<string> => {
Expand All @@ -13,7 +10,6 @@ export default async (
'Content-Type': 'application/x-www-form-urlencoded',
},
body: parameters.toString(),
agent: new Agent({ rejectUnauthorized: false }),
});
const result = await tokenEndpointResponse.json();
expect(result.access_token).toBeDefined();
Expand All @@ -23,3 +19,5 @@ export default async (
expect(decodedToken).toMatchSnapshot(snapshotPropertyMatchers);
return token as string;
};

export default tokenEndpoint;
12 changes: 6 additions & 6 deletions e2e/helpers/user-info-endpoint.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Agent } from 'https';

import fetch from 'node-fetch';

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

export default userInfoEndpoint;
Loading

0 comments on commit 44beeb3

Please sign in to comment.