Skip to content

Commit ff7df80

Browse files
author
Sophia Marie Terry
committed
CLOUDP-328959: Added tests for validating IPA106 valid operationIds
1 parent ae54d57 commit ff7df80

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import testRule from './__helpers__/testRule';
2+
3+
// TODO: add tests for xgen-custom-method extension - CLOUDP-306294
4+
// TOOD: enable tests for invalid methods (after rules are upgraded to warning) - CLOUDP-329722
5+
6+
const componentSchemas = {
7+
schemas: {
8+
Schema: {
9+
type: 'object',
10+
},
11+
},
12+
operationId: 'string',
13+
};
14+
15+
testRule('xgen-IPA-106-valid-operation-id', [
16+
{
17+
name: 'valid methods',
18+
document: {
19+
components: componentSchemas,
20+
paths: {
21+
'/groups/{groupId}/clusters': {
22+
post: {
23+
operationId: 'createGroupCluster',
24+
},
25+
},
26+
},
27+
},
28+
errors: [],
29+
},
30+
// This test will be enable when the xgen-IPA-106-valid-operation-id is set to warning severity - CLOUDP-329722
31+
/* {
32+
name: 'invalid methods',
33+
document: {
34+
components: componentSchemas,
35+
paths: {
36+
'/api/atlas/v2/groups/{groupId}/access': {
37+
post: {
38+
operationId: 'addUserToProject',
39+
},
40+
},
41+
'/api/atlas/v2/groups/{groupId}/invites': {
42+
post: {
43+
operationId: 'createProjectInvitation',
44+
},
45+
},
46+
},
47+
},
48+
errors: [
49+
{
50+
code: 'xgen-IPA-106-valid-operation-id',
51+
message:
52+
'Invalid OperationID. The Operation ID must start with the verb “create” and should be followed by a noun or compound noun. The noun(s) in the Operation ID should be the collection identifiers from the resource identifier in singular form. ',
53+
path: ['paths', '/api/atlas/v2/groups/{groupId}/access', 'post'],
54+
severity: DiagnosticSeverity.Warning,
55+
},
56+
{
57+
code: 'xgen-IPA-106-valid-operation-id',
58+
message:
59+
'Invalid OperationID. The Operation ID must start with the verb “create” and should be followed by a noun or compound noun. The noun(s) in the Operation ID should be the collection identifiers from the resource identifier in singular form. ',
60+
path: ['paths', '/api/atlas/v2/groups/{groupId}/invites', 'post'],
61+
severity: DiagnosticSeverity.Warning,
62+
},
63+
],
64+
}, */
65+
{
66+
name: 'invalid methods with exceptions',
67+
document: {
68+
components: componentSchemas,
69+
paths: {
70+
'/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/index ': {
71+
post: {
72+
operationId: 'createRollingIndex',
73+
'x-xgen-IPA-exception': {
74+
'xgen-IPA-106-valid-operation-id': 'Reason',
75+
},
76+
},
77+
},
78+
},
79+
},
80+
errors: [],
81+
},
82+
]);

0 commit comments

Comments
 (0)