Skip to content

Commit 4de2ac4

Browse files
committed
make testing optional features (sorting and pagination) configurable
For backward compatibility the tests will be performed if the config option is omitted for the respective feature
1 parent 8472a16 commit 4de2ac4

File tree

3 files changed

+50
-40
lines changed

3 files changed

+50
-40
lines changed

site/.vitepress/theme/components/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
detectSchema: true
22
detectResourceTypes: true
3+
verifyPagination: true
4+
verifySorting: true
35

46
users:
57
enabled: true

src/groups.js

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -102,27 +102,31 @@ function runTests(groupSchema, groupSchemaExtensions = [], configuration) {
102102
assert.strictEqual(response.data.schemas[0], 'urn:ietf:params:scim:api:messages:2.0:Error', 'Error response should contain the correct error schema');
103103
});
104104

105-
test('Paginates groups using startIndex', async (t) => {
106-
const testAxios = getAxiosInstance(configuration, t);
107-
const startIndex = 20;
108-
const count = 5;
109-
const response = await testAxios.get(`/Groups?startIndex=${startIndex}&count=${count}`);
110-
assert.strictEqual(response.status, 200, 'Pagination request should return 200 OK');
111-
assert.strictEqual(response.data.schemas[0], 'urn:ietf:params:scim:api:messages:2.0:ListResponse', 'Response should use the correct SCIM list response schema');
112-
assert.ok(response.data.Resources.length <= count, 'Number of resources should be less than or equal to count');
113-
assert.strictEqual(response.data.startIndex, startIndex, 'startIndex should match the requested startIndex');
114-
});
105+
if (configuration?.verifyPagination !== false) {
106+
test('Paginates groups using startIndex', async (t) => {
107+
const testAxios = getAxiosInstance(configuration, t);
108+
const startIndex = 20;
109+
const count = 5;
110+
const response = await testAxios.get(`/Groups?startIndex=${startIndex}&count=${count}`);
111+
assert.strictEqual(response.status, 200, 'Pagination request should return 200 OK');
112+
assert.strictEqual(response.data.schemas[0], 'urn:ietf:params:scim:api:messages:2.0:ListResponse', 'Response should use the correct SCIM list response schema');
113+
assert.ok(response.data.Resources.length <= count, 'Number of resources should be less than or equal to count');
114+
assert.strictEqual(response.data.startIndex, startIndex, 'startIndex should match the requested startIndex');
115+
});
116+
}
115117

116-
test('Sorts groups by displayName', async (t) => {
117-
const testAxios = getAxiosInstance(configuration, t);
118-
const response = await testAxios.get('/Groups?sortBy=displayName');
119-
assert.strictEqual(response.status, 200, 'Sort request should return 200 OK');
120-
assert.strictEqual(response.data.schemas[0], 'urn:ietf:params:scim:api:messages:2.0:ListResponse', 'Response should use the correct SCIM list response schema');
121-
const groups = response.data.Resources;
122-
for (let i = 1; i < groups.length; i++) {
123-
assert.ok(groups[i - 1].displayName <= groups[i].displayName, 'Groups should be sorted by displayName');
124-
}
125-
});
118+
if (configuration?.verifySorting !== false) {
119+
test('Sorts groups by displayName', async (t) => {
120+
const testAxios = getAxiosInstance(configuration, t);
121+
const response = await testAxios.get('/Groups?sortBy=displayName');
122+
assert.strictEqual(response.status, 200, 'Sort request should return 200 OK');
123+
assert.strictEqual(response.data.schemas[0], 'urn:ietf:params:scim:api:messages:2.0:ListResponse', 'Response should use the correct SCIM list response schema');
124+
const groups = response.data.Resources;
125+
for (let i = 1; i < groups.length; i++) {
126+
assert.ok(groups[i - 1].displayName <= groups[i].displayName, 'Groups should be sorted by displayName');
127+
}
128+
});
129+
}
126130

127131
if (configuration?.groups?.operations?.includes('POST')) {
128132
for (const [index, creation] of (configuration.groups.post_tests || []).entries()) {

src/users.js

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -97,27 +97,31 @@ function runTests(userSchema, userSchemaExtensions = [], configuration) {
9797

9898
});
9999

100-
test('Paginates users using startIndex', async (t) => {
101-
const testAxios = getAxiosInstance(configuration, t);
102-
const startIndex = 20;
103-
const count = 5;
104-
const response = await testAxios.get(`/Users?startIndex=${startIndex}&count=${count}`);
105-
assert.strictEqual(response.status, 200, 'Pagination request should return 200 OK');
106-
assert.strictEqual(response.data.schemas[0], 'urn:ietf:params:scim:api:messages:2.0:ListResponse', 'Response should use the correct SCIM list response schema');
107-
assert.ok(response.data.Resources.length <= count, 'Number of resources should be less than or equal to count');
108-
assert.strictEqual(response.data.startIndex, startIndex, 'startIndex should match the requested startIndex');
109-
});
100+
if (configuration?.verifyPagination !== false) {
101+
test('Paginates users using startIndex', async (t) => {
102+
const testAxios = getAxiosInstance(configuration, t);
103+
const startIndex = 20;
104+
const count = 5;
105+
const response = await testAxios.get(`/Users?startIndex=${startIndex}&count=${count}`);
106+
assert.strictEqual(response.status, 200, 'Pagination request should return 200 OK');
107+
assert.strictEqual(response.data.schemas[0], 'urn:ietf:params:scim:api:messages:2.0:ListResponse', 'Response should use the correct SCIM list response schema');
108+
assert.ok(response.data.Resources.length <= count, 'Number of resources should be less than or equal to count');
109+
assert.strictEqual(response.data.startIndex, startIndex, 'startIndex should match the requested startIndex');
110+
});
111+
}
110112

111-
test('Sorts users by userName', async (t) => {
112-
const testAxios = getAxiosInstance(configuration, t);
113-
const response = await testAxios.get('/Users?sortBy=userName');
114-
assert.strictEqual(response.status, 200, 'Sort request should return 200 OK');
115-
assert.strictEqual(response.data.schemas[0], 'urn:ietf:params:scim:api:messages:2.0:ListResponse', 'Response should use the correct SCIM list response schema');
116-
const users = response.data.Resources;
117-
for (let i = 1; i < users.length; i++) {
118-
assert.ok(users[i - 1].userName <= users[i].userName, 'Users should be sorted by userName');
119-
}
120-
});
113+
if (configuration?.verifySorting !== false) {
114+
test('Sorts users by userName', async (t) => {
115+
const testAxios = getAxiosInstance(configuration, t);
116+
const response = await testAxios.get('/Users?sortBy=userName');
117+
assert.strictEqual(response.status, 200, 'Sort request should return 200 OK');
118+
assert.strictEqual(response.data.schemas[0], 'urn:ietf:params:scim:api:messages:2.0:ListResponse', 'Response should use the correct SCIM list response schema');
119+
const users = response.data.Resources;
120+
for (let i = 1; i < users.length; i++) {
121+
assert.ok(users[i - 1].userName <= users[i].userName, 'Users should be sorted by userName');
122+
}
123+
});
124+
}
121125

122126
test('Retrieves only userName attributes', async (t) => {
123127
const testAxios = getAxiosInstance(configuration, t);

0 commit comments

Comments
 (0)