Skip to content

Commit 5c5b0d5

Browse files
author
Sophia Marie Terry
committed
Update and enable tests
1 parent ca3f232 commit 5c5b0d5

File tree

5 files changed

+138
-24
lines changed

5 files changed

+138
-24
lines changed

tools/spectral/ipa/__tests__/IPA105ValidOperationID.test.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import testRule from './__helpers__/testRule';
22
import { DiagnosticSeverity } from '@stoplight/types';
33

4-
// TODO: add tests for xgen-custom-method extension - CLOUDP-306294
5-
64
testRule('xgen-IPA-105-valid-operation-id', [
75
{
86
name: 'valid methods',
@@ -17,6 +15,26 @@ testRule('xgen-IPA-105-valid-operation-id', [
1715
},
1816
errors: [],
1917
},
18+
{
19+
name: 'invalid methods with short opIDs',
20+
document: {
21+
paths: {
22+
'/api/atlas/v2/unauth/openapi/versions': {
23+
get: {
24+
operationId: 'getApiVersions',
25+
},
26+
},
27+
},
28+
},
29+
errors: [
30+
{
31+
code: 'xgen-IPA-105-valid-operation-id',
32+
message: 'Invalid OperationID. ',
33+
path: ['paths', '/api/atlas/v2/unauth/openapi/versions', 'get', 'operationId'],
34+
severity: DiagnosticSeverity.Warning,
35+
},
36+
],
37+
},
2038
{
2139
name: 'invalid methods with too long opIDs',
2240
document: {
@@ -38,7 +56,7 @@ testRule('xgen-IPA-105-valid-operation-id', [
3856
{
3957
code: 'xgen-IPA-105-valid-operation-id',
4058
message:
41-
"The Operation ID is longer than 4 words. Please add an 'x-xgen-operation-id-override' extension to the operation with a shorter operation ID. For example: 'listPlaneIPAddresses'. https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-105-valid-operation-id",
59+
"The Operation ID is longer than 4 words. Please add an 'x-xgen-operation-id-override' extension to the operation with a shorter operation ID. ",
4260
path: ['paths', '/api/atlas/v2/unauth/controlPlaneIPAddresses', 'get', 'operationId'],
4361
severity: DiagnosticSeverity.Warning,
4462
},

tools/spectral/ipa/__tests__/IPA106ValidOperationID.test.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import testRule from './__helpers__/testRule';
22
import { DiagnosticSeverity } from '@stoplight/types';
33

4-
// TODO: add tests for xgen-custom-method extension - CLOUDP-306294
5-
64
testRule('xgen-IPA-106-valid-operation-id', [
75
{
86
name: 'valid methods',
@@ -18,7 +16,7 @@ testRule('xgen-IPA-106-valid-operation-id', [
1816
errors: [],
1917
},
2018
{
21-
name: 'invalid methods',
19+
name: 'invalid methods with short opIds',
2220
document: {
2321
paths: {
2422
'/api/atlas/v2/groups/{groupId}/access': {
@@ -50,6 +48,33 @@ testRule('xgen-IPA-106-valid-operation-id', [
5048
},
5149
],
5250
},
51+
{
52+
name: 'invalid methods with too long opIDs',
53+
document: {
54+
paths: {
55+
'/api/atlas/v2/orgs/{orgId}/serviceAccounts/{clientId}/accessList': {
56+
post: {
57+
operationId: 'createServiceAccountAccessList',
58+
},
59+
},
60+
},
61+
},
62+
errors: [
63+
{
64+
code: 'xgen-IPA-106-valid-operation-id',
65+
message: 'Invalid OperationID. ',
66+
path: ['paths', '/api/atlas/v2/orgs/{orgId}/serviceAccounts/{clientId}/accessList', 'post', 'operationId'],
67+
severity: DiagnosticSeverity.Warning,
68+
},
69+
{
70+
code: 'xgen-IPA-106-valid-operation-id',
71+
message:
72+
"The Operation ID is longer than 4 words. Please add an 'x-xgen-operation-id-override' extension to the operation with a shorter operation ID. ",
73+
path: ['paths', '/api/atlas/v2/orgs/{orgId}/serviceAccounts/{clientId}/accessList', 'post', 'operationId'],
74+
severity: DiagnosticSeverity.Warning,
75+
},
76+
],
77+
},
5378
{
5479
name: 'invalid methods with exceptions',
5580
document: {

tools/spectral/ipa/__tests__/IPA107ValidOperationID.test.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import testRule from './__helpers__/testRule';
22
import { DiagnosticSeverity } from '@stoplight/types';
33

4-
// TODO: add tests for xgen-custom-method extension - CLOUDP-306294
5-
64
testRule('xgen-IPA-107-valid-operation-id', [
75
{
86
name: 'valid methods',
@@ -23,7 +21,7 @@ testRule('xgen-IPA-107-valid-operation-id', [
2321
errors: [],
2422
},
2523
{
26-
name: 'invalid methods',
24+
name: 'invalid methods with short opIds',
2725
document: {
2826
paths: {
2927
'/api/atlas/v2/groups/{groupId}/limits/{limitName}': {
@@ -53,6 +51,33 @@ testRule('xgen-IPA-107-valid-operation-id', [
5351
},
5452
],
5553
},
54+
{
55+
name: 'invalid methods with too long opIDs',
56+
document: {
57+
paths: {
58+
'/api/atlas/v2/groups/{groupId}/pushBasedLogExport': {
59+
patch: {
60+
operationId: 'updatePushBasedLogConfiguration',
61+
},
62+
},
63+
},
64+
},
65+
errors: [
66+
{
67+
code: 'xgen-IPA-107-valid-operation-id',
68+
message: 'Invalid OperationID. ',
69+
path: ['paths', '/api/atlas/v2/groups/{groupId}/pushBasedLogExport', 'patch', 'operationId'],
70+
severity: DiagnosticSeverity.Warning,
71+
},
72+
{
73+
code: 'xgen-IPA-107-valid-operation-id',
74+
message:
75+
"The Operation ID is longer than 4 words. Please add an 'x-xgen-operation-id-override' extension to the operation with a shorter operation ID. ",
76+
path: ['paths', '/api/atlas/v2/groups/{groupId}/pushBasedLogExport', 'patch', 'operationId'],
77+
severity: DiagnosticSeverity.Warning,
78+
},
79+
],
80+
},
5681
{
5782
name: 'invalid methods with exceptions',
5883
document: {

tools/spectral/ipa/__tests__/IPA108ValidOperationID.test.js

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import testRule from './__helpers__/testRule';
22
import { DiagnosticSeverity } from '@stoplight/types';
33

4-
// TODO: add tests for xgen-custom-method extension - CLOUDP-306294
5-
64
testRule('xgen-IPA-108-valid-operation-id', [
75
{
86
name: 'valid methods',
@@ -18,7 +16,7 @@ testRule('xgen-IPA-108-valid-operation-id', [
1816
errors: [],
1917
},
2018
{
21-
name: 'invalid methods',
19+
name: 'invalid methods with short opIDs',
2220
document: {
2321
paths: {
2422
'/api/atlas/v2/groups/{groupId}/apiKeys/{apiUserId}': {
@@ -48,6 +46,43 @@ testRule('xgen-IPA-108-valid-operation-id', [
4846
},
4947
],
5048
},
49+
{
50+
name: 'invalid methods with too long opIDs',
51+
document: {
52+
paths: {
53+
'/api/atlas/v2/groups/{groupId}/dataFederation/{tenantName}/limits/{limitName}': {
54+
delete: {
55+
operationId: 'deleteOneDataFederationInstanceQueryLimit',
56+
},
57+
},
58+
},
59+
},
60+
errors: [
61+
{
62+
code: 'xgen-IPA-108-valid-operation-id',
63+
message: 'Invalid OperationID. ',
64+
path: [
65+
'paths',
66+
'/api/atlas/v2/groups/{groupId}/dataFederation/{tenantName}/limits/{limitName}',
67+
'delete',
68+
'operationId',
69+
],
70+
severity: DiagnosticSeverity.Warning,
71+
},
72+
{
73+
code: 'xgen-IPA-108-valid-operation-id',
74+
message:
75+
"The Operation ID is longer than 4 words. Please add an 'x-xgen-operation-id-override' extension to the operation with a shorter operation ID. ",
76+
path: [
77+
'paths',
78+
'/api/atlas/v2/groups/{groupId}/dataFederation/{tenantName}/limits/{limitName}',
79+
'delete',
80+
'operationId',
81+
],
82+
severity: DiagnosticSeverity.Warning,
83+
},
84+
],
85+
},
5186
{
5287
name: 'invalid methods with exceptions',
5388
document: {

tools/spectral/ipa/__tests__/IPA109ValidOperationID.test.js

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
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
2+
import { DiagnosticSeverity } from '@stoplight/types';
53

64
testRule('xgen-IPA-109-valid-operation-id', [
75
{
@@ -22,16 +20,30 @@ testRule('xgen-IPA-109-valid-operation-id', [
2220
},
2321
errors: [],
2422
},
25-
// This test will be enable when the xgen-IPA-109-valid-operation-id is set to warning severity - CLOUDP-329722
26-
/* {
27-
name: 'invalid methods',
23+
{
24+
name: 'invalid methods with short opIds',
2825
document: {
2926
paths: {
3027
'/api/atlas/v2/groups/{groupId}/clusters:search': {
3128
post: {
3229
operationId: 'searchClusters',
3330
},
3431
},
32+
},
33+
},
34+
errors: [
35+
{
36+
code: 'xgen-IPA-109-valid-operation-id',
37+
message: 'Invalid OperationID. ',
38+
path: ['paths', '/api/atlas/v2/groups/{groupId}/clusters:search', 'post', 'operationId'],
39+
severity: DiagnosticSeverity.Warning,
40+
},
41+
],
42+
},
43+
{
44+
name: 'invalid methods with too long opIDs',
45+
document: {
46+
paths: {
3547
'/api/atlas/v2/groups/{groupId}:migrate': {
3648
post: {
3749
operationId: 'migrateProjectToAnotherOrg',
@@ -42,20 +54,19 @@ testRule('xgen-IPA-109-valid-operation-id', [
4254
errors: [
4355
{
4456
code: 'xgen-IPA-109-valid-operation-id',
45-
message:
46-
'Invalid OperationID. ',
47-
path: ['paths', '/api/atlas/v2/groups/{groupId}/clusters:search'],
57+
message: 'Invalid OperationID. ',
58+
path: ['paths', '/api/atlas/v2/groups/{groupId}:migrate', 'post', 'operationId'],
4859
severity: DiagnosticSeverity.Warning,
4960
},
5061
{
5162
code: 'xgen-IPA-109-valid-operation-id',
5263
message:
53-
'Invalid OperationID. ',
54-
path: ['paths', '/api/atlas/v2/groups/{groupId}:migrate'],
64+
"The Operation ID is longer than 4 words. Please add an 'x-xgen-operation-id-override' extension to the operation with a shorter operation ID. ",
65+
path: ['paths', '/api/atlas/v2/groups/{groupId}:migrate', 'post', 'operationId'],
5566
severity: DiagnosticSeverity.Warning,
5667
},
5768
],
58-
}, */
69+
},
5970
{
6071
name: 'invalid methods with exceptions',
6172
document: {

0 commit comments

Comments
 (0)