Skip to content

Commit ff4dcb2

Browse files
Merge pull request #20 from Tlepel/user-and-groups-schema-and-resource
only test user and group schema and resourcetype when they are enabled through the config
2 parents 0dd939a + 00620a9 commit ff4dcb2

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

src/resourcetypes.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,23 @@ function runTests(configuration) {
99
const response = await axios.get('/ResourceTypes');
1010
assert.strictEqual(response.status, 200, 'ResourceTypes endpoint should return status code 200');
1111
assert.strictEqual(response.data.schemas[0], 'urn:ietf:params:scim:api:messages:2.0:ListResponse', 'Response should have the correct ListResponse schema');
12-
12+
1313
const resources = response.data.Resources;
1414
assert.ok(Array.isArray(resources), 'Resources should be an array');
15-
16-
// Check for User and Group resource types
17-
const userResourceType = resources.find(r => r.id === 'User');
18-
const groupResourceType = resources.find(r => r.id === 'Group');
19-
20-
assert.ok(userResourceType, 'User resource type should exist');
21-
assert.ok(groupResourceType, 'Group resource type should exist');
22-
23-
// Verify essential properties
24-
assert.ok(userResourceType.schema, 'User resource type should have a schema');
25-
assert.ok(groupResourceType.schema, 'Group resource type should have a schema');
15+
16+
if (configuration?.users?.enabled) {
17+
// Check for User resource type and verify essential properties
18+
const userResourceType = resources.find(r => r.id === 'User');
19+
assert.ok(userResourceType, 'User resource type should exist');
20+
assert.ok(userResourceType.schema, 'User resource type should have a schema');
21+
}
22+
23+
if (configuration?.groups?.enabled) {
24+
// Check for Group resource type and verify essential properties
25+
const groupResourceType = resources.find(r => r.id === 'Group');
26+
assert.ok(groupResourceType, 'Group resource type should exist');
27+
assert.ok(groupResourceType.schema, 'Group resource type should have a schema');
28+
}
2629
});
2730
});
2831
}

src/schemas.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,19 @@ export function runTests(configuration) {
1414
const resources = response.data.Resources;
1515
assert.ok(Array.isArray(resources), 'Schemas should be an array');
1616

17-
// Check for core schema definitions
18-
const userSchema = resources.find(s => s.id === 'urn:ietf:params:scim:schemas:core:2.0:User');
19-
const groupSchema = resources.find(s => s.id === 'urn:ietf:params:scim:schemas:core:2.0:Group');
17+
if (configuration?.users?.enabled) {
18+
// Check for User schema and verify that it has attributes
19+
const userSchema = resources.find(s => s.id === 'urn:ietf:params:scim:schemas:core:2.0:User');
20+
assert.ok(userSchema, 'User schema should exist');
21+
assert.ok(Array.isArray(userSchema.attributes), 'User schema should have attributes');
22+
}
2023

21-
assert.ok(userSchema, 'User schema should exist');
22-
assert.ok(groupSchema, 'Group schema should exist');
23-
24-
// Verify attributes
25-
assert.ok(Array.isArray(userSchema.attributes), 'User schema should have attributes');
26-
assert.ok(Array.isArray(groupSchema.attributes), 'Group schema should have attributes');
24+
if (configuration?.groups?.enabled) {
25+
// Check for Group schema and verify that it has attributes
26+
const groupSchema = resources.find(s => s.id === 'urn:ietf:params:scim:schemas:core:2.0:Group');
27+
assert.ok(groupSchema, 'Group schema should exist');
28+
assert.ok(Array.isArray(groupSchema.attributes), 'Group schema should have attributes');
29+
}
2730
});
2831

2932
});

0 commit comments

Comments
 (0)