Skip to content

Commit df2c41b

Browse files
author
Sophia Marie Terry
committed
CLOUDP-328960: Fixed tests to match error messages
1 parent e4a662a commit df2c41b

File tree

6 files changed

+15
-16
lines changed

6 files changed

+15
-16
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ testRule('xgen-IPA-104-valid-operation-id', [
3838
{
3939
code: 'xgen-IPA-104-valid-operation-id',
4040
message:
41-
'Invalid OperationID. The Operation ID must start with the verb “get” and should be followed by a noun or compound noun. The noun(s) should be the collection identifiers from the resource identifier in singular form.',
41+
'Invalid OperationID. ',
4242
path: ['paths', '/api/atlas/v2/groups/{groupId}/accessList/{entryValue}/status', 'get'],
4343
severity: DiagnosticSeverity.Warning,
4444
},
4545
{
4646
code: 'xgen-IPA-104-valid-operation-id',
4747
message:
48-
'Invalid OperationID. The Operation ID must start with the verb “get” and should be followed by a noun or compound noun. The noun(s) should be the collection identifiers from the resource identifier in singular form.',
48+
'Invalid OperationID. ',
4949
path: ['paths', '/api/atlas/v2/groups/{groupId}/dataFederation/{tenantName}/limits/{limitName}', 'get'],
5050
severity: DiagnosticSeverity.Warning,
5151
},

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ testRule('xgen-IPA-105-valid-operation-id', [
3838
{
3939
code: 'xgen-IPA-105-valid-operation-id',
4040
message:
41-
'Invalid OperationID. The Operation ID must start with the verb “list” and should be followed by a noun or compound noun. The noun(s) should be the collection identifiers from the resource identifier in singular form, where the last noun is in plural form.',
41+
'Invalid OperationID. ',
4242
path: ['paths', '/api/atlas/v2/groups/{groupId}/databaseUsers/{username}/certs', 'get'],
4343
severity: DiagnosticSeverity.Warning,
4444
},
4545
{
4646
code: 'xgen-IPA-105-valid-operation-id',
4747
message:
48-
'Invalid OperationID. The Operation ID must start with the verb “list” and should be followed by a noun or compound noun. The noun(s) should be the collection identifiers from the resource identifier in singular form, where the last noun is in plural form.',
48+
'Invalid OperationID. ',
4949
path: ['paths', '/api/atlas/v2/orgs/{orgId}/events', 'get'],
5050
severity: DiagnosticSeverity.Warning,
5151
},

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ testRule('xgen-IPA-106-valid-operation-id', [
3838
{
3939
code: 'xgen-IPA-106-valid-operation-id',
4040
message:
41-
'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. ',
41+
'Invalid OperationID. ',
4242
path: ['paths', '/api/atlas/v2/groups/{groupId}/access', 'post'],
4343
severity: DiagnosticSeverity.Warning,
4444
},
4545
{
4646
code: 'xgen-IPA-106-valid-operation-id',
4747
message:
48-
'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. ',
48+
'Invalid OperationID. ',
4949
path: ['paths', '/api/atlas/v2/groups/{groupId}/invites', 'post'],
5050
severity: DiagnosticSeverity.Warning,
5151
},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ testRule('xgen-IPA-107-valid-operation-id', [
4343
{
4444
code: 'xgen-IPA-107-valid-operation-id',
4545
message:
46-
'Invalid OperationID. The Operation ID must start with the verb “update” 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. For singleton resources - the last noun may be in plural form.',
46+
'Invalid OperationID. ',
4747
path: ['paths', '/api/atlas/v2/groups/{groupId}/limits/{limitName}', 'patch'],
4848
severity: DiagnosticSeverity.Warning,
4949
},

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import testRule from './__helpers__/testRule';
2-
import { DiagnosticSeverity } from '@stoplight/types';
32

43
// TODO: add tests for xgen-custom-method extension - CLOUDP-306294
54
// TOOD: enable tests for invalid methods (after rules are upgraded to warning) - CLOUDP-329722
@@ -19,7 +18,7 @@ testRule('xgen-IPA-108-valid-operation-id', [
1918
errors: [],
2019
},
2120
// This test will be enable when the xgen-IPA-108-valid-operation-id is set to warning severity - CLOUDP-329722
22-
{
21+
/* {
2322
name: 'invalid methods',
2423
document: {
2524
paths: {
@@ -49,7 +48,7 @@ testRule('xgen-IPA-108-valid-operation-id', [
4948
severity: DiagnosticSeverity.Warning,
5049
},
5150
],
52-
},
51+
}, */
5352
{
5453
name: 'invalid methods with exceptions',
5554
document: {

tools/spectral/ipa/rulesets/functions/IPA109ValidOperationID.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { isCustomMethodIdentifier, getCustomMethodName, stripCustomMethodName }
44
import { generateOperationID } from './utils/operationIdGeneration.js';
55

66
const RULE_NAME = 'xgen-IPA-109-valid-operation-id';
7-
const ERROR_MESSAGE = 'Invalid Operation ID.';
7+
const ERROR_MESSAGE = 'Invalid OperationID.';
88

99
export default (input, _, { path }) => {
1010
let resourcePath = path[1];
@@ -14,11 +14,6 @@ export default (input, _, { path }) => {
1414
return;
1515
}
1616

17-
if (hasException(input, RULE_NAME)) {
18-
collectException(input, RULE_NAME, path);
19-
return;
20-
}
21-
2217
// TODO detect custom method extension - CLOUDP-306294
2318

2419
let obj;
@@ -28,6 +23,11 @@ export default (input, _, { path }) => {
2823
obj = input.get;
2924
}
3025

26+
if (hasException(obj, RULE_NAME)) {
27+
collectException(obj, RULE_NAME, path);
28+
return;
29+
}
30+
3131
const operationId = obj.operationId;
3232
const expectedOperationID = generateOperationID(methodName, stripCustomMethodName(resourcePath));
3333
if (expectedOperationID !== operationId) {

0 commit comments

Comments
 (0)