-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathauthorize.request.utils.test.ts
More file actions
67 lines (62 loc) · 1.93 KB
/
Copy pathauthorize.request.utils.test.ts
File metadata and controls
67 lines (62 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* Copyright (c) 2025 Ping Identity Corporation. All rights reserved.
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
import { it, expect } from '@effect/vitest';
import { Micro } from 'effect';
import { buildAuthorizeOptionsµ } from './authorize.request.utils.js';
import { OidcConfig } from './config.types.js';
import { WellKnownResponse } from '@forgerock/sdk-types';
const clientId = '123456789';
const redirectUri = 'https://example.com/callback.html';
const scope = 'openid profile';
const responseType = 'code';
const config: OidcConfig = {
clientId,
redirectUri,
scope,
serverConfig: {
wellknown: 'https://example.com/wellknown',
},
responseType,
};
const wellknown: WellKnownResponse = {
issuer: 'https://example.com/issuer',
authorization_endpoint: 'https://example.com/authorize',
token_endpoint: 'https://example.com/token',
userinfo_endpoint: 'https://example.com/userinfo',
end_session_endpoint: 'https://example.com/endSession',
introspection_endpoint: 'https://example.com/introspect',
revocation_endpoint: 'https://example.com/revoke',
};
it.effect('buildAuthorizeOptionsµ succeeds with BuildAuthorizationData', () =>
Micro.gen(function* () {
const result = yield* buildAuthorizeOptionsµ(wellknown, config);
expect(result).toStrictEqual([
wellknown.authorization_endpoint,
{
clientId,
redirectUri,
scope,
responseType,
},
]);
}),
);
it.effect('buildAuthorizeOptionsµ with pi.flow succeeds with BuildAuthorizationData', () =>
Micro.gen(function* () {
const result = yield* buildAuthorizeOptionsµ(wellknown, config, { responseMode: 'pi.flow' });
expect(result).toStrictEqual([
wellknown.authorization_endpoint,
{
clientId,
redirectUri,
scope,
responseType,
responseMode: 'pi.flow',
},
]);
}),
);