Skip to content

Commit

Permalink
Merge pull request #197 from snyk/feat/self-no-tenant
Browse files Browse the repository at this point in the history
feat: allow /self having no tenant
  • Loading branch information
mrded authored Mar 8, 2022
2 parents 27fca6b + 31e7fd1 commit c2044eb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/rulesets/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export const rules = {
url.startsWith("/groups/{group_id}") ||
url === "/orgs" ||
url === "/groups" ||
url === "/current_user"
url === "/self"
)
) {
expect.fail(`expected support for org or group tenant in ${url}`);
Expand Down
46 changes: 23 additions & 23 deletions src/rulesets/tests/__snapshots__/operations.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3485,7 +3485,7 @@ Object {
}
`;

exports[`orgOrGroupTenant path '/current_user' is valid: true 1`] = `
exports[`orgOrGroupTenant path '/self' is valid: true 1`] = `
Object {
"base": Object {
"info": Object {
Expand All @@ -3499,20 +3499,20 @@ Object {
Object {
"added": Object {
"method": "get",
"pathPattern": "/current_user",
"pathPattern": "/self",
},
"changeType": "added",
"location": Object {
"conceptualLocation": Object {
"method": "get",
"path": "/current_user",
"path": "/self",
},
"conceptualPath": Array [
"operations",
"/current_user",
"/self",
"get",
],
"jsonPath": "/paths/~1current_user/get",
"jsonPath": "/paths/~1self/get",
"kind": "operation",
},
},
Expand All @@ -3524,7 +3524,7 @@ Object {
},
"openapi": "3.0.1",
"paths": Object {
"/current_user": Object {
"/self": Object {
"get": Object {
"responses": Object {},
},
Expand All @@ -3536,20 +3536,20 @@ Object {
"change": Object {
"added": Object {
"method": "get",
"pathPattern": "/current_user",
"pathPattern": "/self",
},
"changeType": "added",
"location": Object {
"conceptualLocation": Object {
"method": "get",
"path": "/current_user",
"path": "/self",
},
"conceptualPath": Array [
"operations",
"/current_user",
"/self",
"get",
],
"jsonPath": "/paths/~1current_user/get",
"jsonPath": "/paths/~1self/get",
"kind": "operation",
},
},
Expand All @@ -3559,13 +3559,13 @@ Object {
"isMust": true,
"isShould": false,
"passed": true,
"where": "added operation: GET /current_user",
"where": "added operation: GET /self",
},
],
}
`;

exports[`orgOrGroupTenant path '/current_user/thing' is valid: false 1`] = `
exports[`orgOrGroupTenant path '/self/thing' is valid: false 1`] = `
Object {
"base": Object {
"info": Object {
Expand All @@ -3579,20 +3579,20 @@ Object {
Object {
"added": Object {
"method": "get",
"pathPattern": "/current_user/thing",
"pathPattern": "/self/thing",
},
"changeType": "added",
"location": Object {
"conceptualLocation": Object {
"method": "get",
"path": "/current_user/thing",
"path": "/self/thing",
},
"conceptualPath": Array [
"operations",
"/current_user/thing",
"/self/thing",
"get",
],
"jsonPath": "/paths/~1current_user~1thing/get",
"jsonPath": "/paths/~1self~1thing/get",
"kind": "operation",
},
},
Expand All @@ -3604,7 +3604,7 @@ Object {
},
"openapi": "3.0.1",
"paths": Object {
"/current_user/thing": Object {
"/self/thing": Object {
"get": Object {
"responses": Object {},
},
Expand All @@ -3616,31 +3616,31 @@ Object {
"change": Object {
"added": Object {
"method": "get",
"pathPattern": "/current_user/thing",
"pathPattern": "/self/thing",
},
"changeType": "added",
"location": Object {
"conceptualLocation": Object {
"method": "get",
"path": "/current_user/thing",
"path": "/self/thing",
},
"conceptualPath": Array [
"operations",
"/current_user/thing",
"/self/thing",
"get",
],
"jsonPath": "/paths/~1current_user~1thing/get",
"jsonPath": "/paths/~1self~1thing/get",
"kind": "operation",
},
},
"condition": "have an org or group tenant",
"docsLink": "https://github.com/snyk/sweater-comb/blob/main/docs/standards.md#organization-and-group-tenants-for-resources",
"effectiveOnDate": undefined,
"error": "expected support for org or group tenant in /current_user/thing",
"error": "expected support for org or group tenant in /self/thing",
"isMust": true,
"isShould": false,
"passed": false,
"where": "added operation: GET /current_user/thing",
"where": "added operation: GET /self/thing",
},
],
}
Expand Down
4 changes: 2 additions & 2 deletions src/rulesets/tests/operations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ describe("orgOrGroupTenant", () => {
${true} | ${"/groups"}
${false} | ${"/groups/thing"}
${true} | ${"/groups/{group_id}/thing"}
${true} | ${"/current_user"}
${false} | ${"/current_user/thing"}
${true} | ${"/self"}
${false} | ${"/self/thing"}
`(`path '$path' is valid: $valid`, async ({ valid, path }) => {
const result = await compare(baseForSpecificationTests)
.to((spec) => {
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6662,9 +6662,9 @@ uri-js@^4.2.2:
punycode "^2.1.0"

urijs@^1.19.6:
version "1.19.9"
resolved "https://registry.yarnpkg.com/urijs/-/urijs-1.19.9.tgz#3b15844835de3732866d420768c16f24be7d3e65"
integrity sha512-v0V+v5F3NQFt6TX0GpA2NKyrpythDJI+PHRo66sUIDP/U6cXbm6NqLVcXylQGwiwW5VYNj+OAei3EU0ALj9AWg==
version "1.19.10"
resolved "https://registry.yarnpkg.com/urijs/-/urijs-1.19.10.tgz#8e2fe70a8192845c180f75074884278f1eea26cb"
integrity sha512-EzauQlgKuJgsXOqoMrCiePBf4At5jVqRhXykF3Wfb8ZsOBMxPcfiVBcsHXug4Aepb/ICm2PIgqAUGMelgdrWEg==

urix@^0.1.0:
version "0.1.0"
Expand Down

0 comments on commit c2044eb

Please sign in to comment.