Skip to content

Commit 213d878

Browse files
committed
Fix tests broken by non-JSON config being parsed
Jira ticket: CAMS-283
1 parent 0de51c0 commit 213d878

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

backend/functions/lib/adapters/gateways/okta/okta-user-group-gateway.test.ts

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const configuration: UserGroupGatewayConfig = {
2323
provider: 'okta',
2424
url: 'http://somedomain/',
2525
clientId: 'clientId',
26-
privateKey: 'privateKey', // pragma: allowlist secret
26+
privateKey: '{}', // pragma: allowlist secret
2727
keyId: 'keyId',
2828
};
2929

@@ -48,11 +48,11 @@ describe('OktaGroupGateway', () => {
4848
}
4949
});
5050

51-
test('unknown error on initialization', async () => {
52-
// TODO: Must be able to mock the Client class from the Okta SDK
53-
// const testError = 'Test Error';
54-
// await expect(OktaUserGroupGateway.initialize(configuration)).rejects.toThrow(testError);
55-
});
51+
// test('unknown error on initialization', async () => {
52+
// // TODO: Must be able to mock the Client class from the Okta SDK
53+
// // const testError = 'Test Error';
54+
// // await expect(OktaUserGroupGateway.initialize(configuration)).rejects.toThrow(testError);
55+
// });
5656
});
5757

5858
describe('getUserGroups', () => {
@@ -112,22 +112,36 @@ describe('OktaGroupGateway', () => {
112112
name: 'cams group name',
113113
};
114114

115-
const user: User = {
116-
117-
profile: {
118-
displayName: 'Abe Lincoln',
119-
},
120-
};
121-
122115
test('should return a list of CamsUsers', async () => {
123-
listGroupUsers.mockResolvedValue(buildMockCollection<User>([user]));
116+
const user1: User = {
117+
id: '00123abc',
118+
profile: {
119+
120+
displayName: 'Abe Lincoln',
121+
},
122+
};
123+
124+
const user2: User = {
125+
id: '99123abc',
126+
profile: {
127+
128+
firstName: 'Mary',
129+
lastName: 'Lincoln',
130+
},
131+
};
132+
133+
listGroupUsers.mockResolvedValue(buildMockCollection<User>([user1, user2]));
124134

125135
const actual = await OktaUserGroupGateway.getUserGroupUsers(configuration, camsUserGroup);
126136

127137
const expected: CamsUserReference[] = [
128138
{
129-
id: user.id,
130-
name: user.profile.displayName,
139+
id: user1.profile.login,
140+
name: user1.profile.displayName,
141+
},
142+
{
143+
id: user2.profile.login,
144+
name: user2.profile.lastName + ', ' + user2.profile.firstName,
131145
},
132146
];
133147
expect(actual).toEqual(expected);

0 commit comments

Comments
 (0)