Skip to content

Commit

Permalink
Adding unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nandan-bhat committed Aug 2, 2024
1 parent 63cedbe commit 1792956
Show file tree
Hide file tree
Showing 7 changed files with 237 additions and 352 deletions.
4 changes: 2 additions & 2 deletions src/tools/auth0/handlers/scimHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class ScimHandler {
constructor(config, connectionsManager, poolClient: PromisePoolExecutor) {
this.config = config;
this.connectionsManager = connectionsManager;
this.scimClient = connectionsManager._getRestClient('/connections/:id/scim-configuration');
this.scimClient = connectionsManager?._getRestClient('/connections/:id/scim-configuration');
this.poolClient = poolClient;
this.idMap = new Map<string, IdMapValue>();
}
Expand Down Expand Up @@ -166,7 +166,7 @@ export default class ScimHandler {
return null;
}

log.error(`SCIM request failed with statusCode ${ error.statusCode }. ${ error.message || error.toString() }.`);
log.error(`SCIM request failed with status code ${ error.statusCode }. ${ error.message || error.toString() }.`);
throw error;
}

Expand Down
3 changes: 2 additions & 1 deletion test/context/yaml/context.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,8 @@ describe('#YAML context validation', () => {
},
},
],
})
}),
_getRestClient: (path) => ({})
}
}
);
Expand Down
11 changes: 11 additions & 0 deletions test/tools/auth0/handlers/connections.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ describe('#connections handler', () => {
update: () => Promise.resolve([]),
delete: () => Promise.resolve([]),
getAll: () => [],
_getRestClient: (path) => ({}),
},
clients: {
getAll: () => [],
Expand All @@ -117,6 +118,7 @@ describe('#connections handler', () => {
{ strategy: 'github', name: 'github', enabled_clients: [clientId] },
{ strategy: 'auth0', name: 'db-should-be-ignored', enabled_clients: [] },
],
_getRestClient: () => ({}),
},
clients: {
getAll: () => [{ name: 'test client', client_id: clientId }],
Expand Down Expand Up @@ -152,6 +154,7 @@ describe('#connections handler', () => {
},
delete: () => Promise.resolve([]),
getAll: () => [{ name: 'someConnection', id: 'con1', strategy: 'custom' }],
_getRestClient: () => ({}),
},
clients: {
getAll: () => [{ name: 'client1', client_id: 'YwqVtt8W3pw5AuEz3B2Kse9l2Ruy7Tec' }],
Expand Down Expand Up @@ -215,6 +218,7 @@ describe('#connections handler', () => {
},
delete: () => Promise.resolve([]),
getAll: () => [{ name: 'someSamlConnection', id: 'con1', strategy: 'samlp' }],
_getRestClient: () => ({}),
},
clients: {
getAll: () => [
Expand Down Expand Up @@ -300,6 +304,7 @@ describe('#connections handler', () => {
},
delete: () => Promise.resolve([]),
getAll: () => [{ name: 'someSamlConnection', id: 'con1', strategy: 'samlp' }],
_getRestClient: () => ({}),
},
clients: {
getAll: () => [
Expand Down Expand Up @@ -375,6 +380,7 @@ describe('#connections handler', () => {
enabled_clients: ['excluded-one-id'],
},
],
_getRestClient: () => ({}),
},
clients: {
getAll: () => [
Expand Down Expand Up @@ -422,6 +428,7 @@ describe('#connections handler', () => {
return Promise.resolve([]);
},
getAll: () => [{ id: 'con1', name: 'existingConnection', strategy: 'custom' }],
_getRestClient: () => ({}),
},
clients: {
getAll: () => [],
Expand Down Expand Up @@ -455,6 +462,7 @@ describe('#connections handler', () => {
return Promise.resolve([]);
},
getAll: () => [{ id: 'con1', name: 'existingConnection', strategy: 'custom' }],
_getRestClient: () => ({}),
},
clients: {
getAll: () => [],
Expand Down Expand Up @@ -484,6 +492,7 @@ describe('#connections handler', () => {
return Promise.resolve([]);
},
getAll: () => [{ id: 'con1', name: 'existingConnection', strategy: 'custom' }],
_getRestClient: () => ({}),
},
clients: {
getAll: () => [],
Expand Down Expand Up @@ -517,6 +526,7 @@ describe('#connections handler', () => {
return Promise.resolve([]);
},
getAll: () => [{ id: 'con1', name: 'existingConnection', strategy: 'custom' }],
_getRestClient: () => ({}),
},
clients: {
getAll: () => [],
Expand Down Expand Up @@ -554,6 +564,7 @@ describe('#connections handler', () => {
{ id: 'con1', name: 'existing1', strategy: 'custom' },
{ id: 'con2', name: 'existing2', strategy: 'custom' },
],
_getRestClient: () => ({}),
},
clients: {
getAll: () => [],
Expand Down
Loading

0 comments on commit 1792956

Please sign in to comment.