Skip to content

Commit 5b05efc

Browse files
Merge branch 'main' into CLOUDP-287245
2 parents 74cc372 + c29cfec commit 5b05efc

17 files changed

+336
-24
lines changed

.github/workflows/code-health-tools.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Checkout CLI
2020
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
2121
- name: Install Go
22-
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed
22+
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a
2323
with:
2424
go-version-file: 'tools/cli/go.mod'
2525
- name: Build CLI
@@ -40,7 +40,7 @@ jobs:
4040
- name: Checkout
4141
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
4242
- name: Install Go
43-
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed
43+
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a
4444
with:
4545
go-version-file: 'tools/cli/go.mod'
4646
- name: Run unit tests
@@ -88,7 +88,7 @@ jobs:
8888
run: |
8989
npm run lint-js
9090
- name: Install Go
91-
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed
91+
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a
9292
with:
9393
go-version-file: 'tools/cli/go.mod'
9494
cache: false # see https://github.com/golangci/golangci-lint-action/issues/807
@@ -118,7 +118,7 @@ jobs:
118118
- name: Checkout
119119
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
120120
- name: Install Go
121-
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed
121+
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a
122122
with:
123123
go-version-file: 'tools/cli/go.mod'
124124
- name: Run e2e tests

.github/workflows/release-cli.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
with:
6161
ref: ${{ inputs.version_number }}
6262
- name: Set up Go
63-
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed
63+
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a
6464
with:
6565
go-version-file: 'tools/cli/go.mod'
6666
- name: Run GoReleaser

.github/workflows/required-spec-validations.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
SPECTRAL_VERSION: ${{ inputs.spectral_version }}
4343
run: npx -- @stoplight/spectral-cli@"${SPECTRAL_VERSION}" lint openapi-foas.yaml --ruleset=tools/spectral/.spectral.yaml
4444
- name: Install Go
45-
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed
45+
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a
4646
with:
4747
go-version-file: 'tools/cli/go.mod'
4848
cache-dependency-path: "tools/cli/go.sum"

changelog/internal/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"runDate": "2024-12-17",
2+
"runDate": "2024-12-18",
33
"specRevision": "7f87fecf3b0ec832d2e6878e487c431a24d67c24",
44
"specRevisionShort": "7f87fecf3b0",
55
"versions": [

package-lock.json

Lines changed: 9 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"@babel/preset-env": "^7.26.0",
2929
"@eslint/js": "^9.16.0",
3030
"@jest/globals": "^29.7.0",
31-
"eslint": "^9.16.0",
31+
"eslint": "^9.17.0",
3232
"globals": "^15.13.0",
3333
"jest": "^29.7.0",
3434
"prettier": "3.4.2"

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,26 @@ testRule('xgen-IPA-102-path-alternate-resource-name-path-param', [
134134
},
135135
],
136136
},
137+
{
138+
name: 'invalid paths with exceptions',
139+
document: {
140+
paths: {
141+
'/api/atlas/v2/unauth/resourceName1/resourceName2': {
142+
'x-xgen-IPA-exception': {
143+
'xgen-IPA-102-path-alternate-resource-name-path-param': {
144+
reason: 'test',
145+
},
146+
},
147+
},
148+
'/api/atlas/v2/resourceName/{pathParam1}/{pathParam2}': {
149+
'x-xgen-IPA-exception': {
150+
'xgen-IPA-102-path-alternate-resource-name-path-param': {
151+
reason: 'test',
152+
},
153+
},
154+
},
155+
},
156+
},
157+
errors: [],
158+
},
137159
]);

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,25 @@ testRule('xgen-IPA-104-resource-has-GET', [
125125
},
126126
],
127127
},
128+
{
129+
name: 'invalid method with exception',
130+
document: {
131+
paths: {
132+
'/standard': {
133+
post: {},
134+
get: {},
135+
'x-xgen-IPA-exception': {
136+
'xgen-IPA-104-resource-has-GET': {
137+
reason: 'test',
138+
},
139+
},
140+
},
141+
'/standard/{exampleId}': {
142+
patch: {},
143+
delete: {},
144+
},
145+
},
146+
},
147+
errors: [],
148+
},
128149
]);
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import testRule from './__helpers__/testRule';
2+
import { DiagnosticSeverity } from '@stoplight/types';
3+
4+
testRule('xgen-IPA-005-exception-extension-format', [
5+
{
6+
name: 'valid exceptions',
7+
document: {
8+
paths: {
9+
'/path': {
10+
'x-xgen-IPA-exception': {
11+
'xgen-IPA-100-rule-name': {
12+
reason: 'Exception',
13+
},
14+
},
15+
},
16+
'/nested': {
17+
post: {
18+
'x-xgen-IPA-exception': {
19+
'xgen-IPA-100-rule-name': {
20+
reason: 'Exception',
21+
},
22+
},
23+
},
24+
},
25+
},
26+
},
27+
errors: [],
28+
},
29+
{
30+
name: 'invalid exceptions',
31+
document: {
32+
paths: {
33+
'/path1': {
34+
'x-xgen-IPA-exception': 'Exception',
35+
},
36+
'/path2': {
37+
'x-xgen-IPA-exception': {
38+
'xgen-IPA-100-rule-name': 'Exception',
39+
},
40+
},
41+
'/path3': {
42+
'x-xgen-IPA-exception': {
43+
'xgen-IPA-100-rule-name': {
44+
reason: '',
45+
},
46+
},
47+
},
48+
'/path4': {
49+
'x-xgen-IPA-exception': {
50+
'invalid-rule-name': {
51+
reason: 'Exception',
52+
},
53+
},
54+
},
55+
'/path5': {
56+
'x-xgen-IPA-exception': {
57+
'xgen-IPA-100-rule-name': {
58+
wrongKey: 'Exception',
59+
},
60+
},
61+
},
62+
'/path6': {
63+
'x-xgen-IPA-exception': {
64+
'xgen-IPA-100-rule-name': {
65+
reason: 'Exception',
66+
excessKey: 'Exception',
67+
},
68+
},
69+
},
70+
'/path7': {
71+
'x-xgen-IPA-exception': {
72+
'xgen-IPA-100-rule-name': {},
73+
},
74+
},
75+
},
76+
},
77+
errors: [
78+
{
79+
code: 'xgen-IPA-005-exception-extension-format',
80+
message: 'IPA exceptions must have a valid rule name and a reason. http://go/ipa/5',
81+
path: ['paths', '/path1', 'x-xgen-IPA-exception'],
82+
severity: DiagnosticSeverity.Warning,
83+
},
84+
{
85+
code: 'xgen-IPA-005-exception-extension-format',
86+
message: 'IPA exceptions must have a valid rule name and a reason. http://go/ipa/5',
87+
path: ['paths', '/path2', 'x-xgen-IPA-exception', 'xgen-IPA-100-rule-name'],
88+
severity: DiagnosticSeverity.Warning,
89+
},
90+
{
91+
code: 'xgen-IPA-005-exception-extension-format',
92+
message: 'IPA exceptions must have a valid rule name and a reason. http://go/ipa/5',
93+
path: ['paths', '/path3', 'x-xgen-IPA-exception', 'xgen-IPA-100-rule-name'],
94+
severity: DiagnosticSeverity.Warning,
95+
},
96+
{
97+
code: 'xgen-IPA-005-exception-extension-format',
98+
message: 'IPA exceptions must have a valid rule name and a reason. http://go/ipa/5',
99+
path: ['paths', '/path4', 'x-xgen-IPA-exception', 'invalid-rule-name'],
100+
severity: DiagnosticSeverity.Warning,
101+
},
102+
{
103+
code: 'xgen-IPA-005-exception-extension-format',
104+
message: 'IPA exceptions must have a valid rule name and a reason. http://go/ipa/5',
105+
path: ['paths', '/path5', 'x-xgen-IPA-exception', 'xgen-IPA-100-rule-name'],
106+
severity: DiagnosticSeverity.Warning,
107+
},
108+
{
109+
code: 'xgen-IPA-005-exception-extension-format',
110+
message: 'IPA exceptions must have a valid rule name and a reason. http://go/ipa/5',
111+
path: ['paths', '/path6', 'x-xgen-IPA-exception', 'xgen-IPA-100-rule-name'],
112+
severity: DiagnosticSeverity.Warning,
113+
},
114+
{
115+
code: 'xgen-IPA-005-exception-extension-format',
116+
message: 'IPA exceptions must have a valid rule name and a reason. http://go/ipa/5',
117+
path: ['paths', '/path7', 'x-xgen-IPA-exception', 'xgen-IPA-100-rule-name'],
118+
severity: DiagnosticSeverity.Warning,
119+
},
120+
],
121+
},
122+
]);
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import { describe, expect, it } from '@jest/globals';
2+
import { hasException } from '../../rulesets/functions/utils/exceptions';
3+
4+
const TEST_RULE_NAME_100 = 'xgen-IPA-100';
5+
6+
const objectWithIpa100Exception = {
7+
'x-xgen-IPA-exception': {
8+
'xgen-IPA-100': {
9+
reason: 'test',
10+
},
11+
},
12+
};
13+
14+
const objectWithNestedIpa100Exception = {
15+
get: {
16+
'x-xgen-IPA-exception': {
17+
'xgen-IPA-100': {
18+
reason: 'test',
19+
},
20+
},
21+
},
22+
};
23+
24+
const objectWithIpa100ExceptionAndOwnerExtension = {
25+
'x-xgen-IPA-exception': {
26+
'xgen-IPA-100': {
27+
reason: 'test',
28+
},
29+
},
30+
'x-xgen-owner-team': 'apix',
31+
};
32+
33+
const objectWithIpa101Exception = {
34+
'x-xgen-IPA-exception': {
35+
'xgen-IPA-101': {
36+
reason: 'test',
37+
},
38+
},
39+
};
40+
41+
const objectWithIpa100And101Exception = {
42+
'x-xgen-IPA-exception': {
43+
'xgen-IPA-101': {
44+
reason: 'test',
45+
},
46+
'xgen-IPA-100': {
47+
reason: 'test',
48+
},
49+
},
50+
};
51+
52+
describe('tools/spectral/ipa/rulesets/functions/utils/exceptions.js', () => {
53+
describe('hasException', () => {
54+
it('returns true if object has exception matching the rule name', () => {
55+
expect(hasException(objectWithIpa100Exception, TEST_RULE_NAME_100)).toBe(true);
56+
expect(hasException(objectWithIpa100ExceptionAndOwnerExtension, TEST_RULE_NAME_100)).toBe(true);
57+
expect(hasException(objectWithIpa100And101Exception, TEST_RULE_NAME_100)).toBe(true);
58+
});
59+
it('returns false if object does not have exception matching the rule name', () => {
60+
expect(hasException({}, TEST_RULE_NAME_100)).toBe(false);
61+
expect(hasException(objectWithIpa101Exception, TEST_RULE_NAME_100)).toBe(false);
62+
});
63+
it('returns false if object has nested exception matching the rule name', () => {
64+
expect(hasException(objectWithNestedIpa100Exception, TEST_RULE_NAME_100)).toBe(false);
65+
});
66+
});
67+
});

0 commit comments

Comments
 (0)