Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ref links & update tests #20

Merged
merged 6 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion functions/acceptableAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function (input) {
if (invalidScheme) {
return [
{
message: 'My API authenticates requests using access tokens; NOT username/passwords. (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'My API authenticates requests using access tokens; NOT username/passwords.',
},
];
}
Expand Down
6 changes: 3 additions & 3 deletions functions/acceptableAuth.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('acceptableAuth', () => {

expect(res).toEqual([
{
message: 'My API authenticates requests using access tokens; NOT username/passwords. (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'My API authenticates requests using access tokens; NOT username/passwords.',
},
]);
});
Expand All @@ -68,7 +68,7 @@ describe('acceptableAuth', () => {

expect(res).toEqual([
{
message: 'My API authenticates requests using access tokens; NOT username/passwords. (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'My API authenticates requests using access tokens; NOT username/passwords.',
},
]);
});
Expand All @@ -79,7 +79,7 @@ describe('acceptableAuth', () => {

expect(res).toEqual([
{
message: 'My API authenticates requests using access tokens; NOT username/passwords. (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'My API authenticates requests using access tokens; NOT username/passwords.',
},
]);
});
Expand Down
4 changes: 2 additions & 2 deletions functions/checkForMaxParameterLinkHeaderLikely.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ const path = [
'/test',
];
const maxQueryMessage = {
message: 'When returning a paginated collection, include a "max" query parameter (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'When returning a paginated collection, include a "max" query parameter',
path: [...path],
};
const linkHeaderMessage = {
message: 'When returning a paginated collection, include a "Link" header in the response (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'When returning a paginated collection, include a "Link" header in the response',
path: [
...path,
'responses',
Expand Down
6 changes: 3 additions & 3 deletions functions/checkForMaxParameterLinkHeaderPossible.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ const path = [
'/test',
];
const maxQueryMessage = {
message: 'When returning a paginated collection, include a "max" query parameter (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'When returning a paginated collection, include a "max" query parameter',
path: [...path],
};
const offsetQueryMessage = {
message: 'When supporting offset-based pagination, operations include a "offset" query parameter (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'When supporting offset-based pagination, operations include a "offset" query parameter',
path: [...path],
};
const linkHeaderMessage = {
message: 'When returning a paginated collection, include a "Link" header in the response (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'When returning a paginated collection, include a "Link" header in the response',
path: [
...path,
'responses',
Expand Down
4 changes: 2 additions & 2 deletions functions/checkPathBasedVersioning.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function (input, opts) {
if (!(defaultVersioning || paths || onlyMajor)) {
return [
{
message: 'API uses path-based versioning. (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'API uses path-based versioning.',
},
];
}
Expand All @@ -60,7 +60,7 @@ export default function (input, opts) {
if ((defaultVersioning || paths) && onlyMajor) {
return [
{
message: 'API shows only major version numbers on the path; not the revision numbers. (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'API shows only major version numbers on the path; not the revision numbers.',
},
];
}
Expand Down
4 changes: 2 additions & 2 deletions functions/checkPathBasedVersioning.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*/

import checkPathBasedVersioning from './checkPathBasedVersioning.js';
const hasVersionErrorMsg = 'API uses path-based versioning. (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)';
const onlyMajorErrorMsg = 'API shows only major version numbers on the path; not the revision numbers. (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)';
const hasVersionErrorMsg = 'API uses path-based versioning.';
const onlyMajorErrorMsg = 'API shows only major version numbers on the path; not the revision numbers.';

describe('checkPathBasedVersioning', () => {
test('should check version in servers - oas3', () => {
Expand Down
6 changes: 3 additions & 3 deletions functions/checkRFC5322RegexCompliance.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function (input) {
if (!regex.exec(sample)) {
return [
{
message: `The regex pattern used does not pass basic linting sample checks - should have matched case ${ sample } (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)`,
message: `The regex pattern used does not pass basic linting sample checks - should have matched case ${ sample }`,
},
];
}
Expand All @@ -54,15 +54,15 @@ export default function (input) {
if (regex.exec(sample)) {
return [
{
message: `The regex pattern used does not pass basic linting sample checks - should not have matched case ${ sample } (${ msg }) (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)`,
message: `The regex pattern used does not pass basic linting sample checks - should not have matched case ${ sample } (${ msg })`,
},
];
}
}
} catch (err) {
return [
{
message: 'Failed to parse regex (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'Failed to parse regex',
},
];
}
Expand Down
2 changes: 1 addition & 1 deletion functions/checkRFC5322RegexCompliance.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('checkRFC5322RegexCompliance', () => {

expect(res).toEqual([
{
message: 'The regex pattern used does not pass basic linting sample checks - should not have matched case Thu 8 Apr 2021 19:06:27 GMT (Comma required after Day of Week) (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'The regex pattern used does not pass basic linting sample checks - should not have matched case Thu 8 Apr 2021 19:06:27 GMT (Comma required after Day of Week)',
},
]);
});
Expand Down
2 changes: 1 addition & 1 deletion functions/correctResponseRange.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function (input, opts) {
if (errStatusCodes.length) {
return [
{
message: `Status Code(s) [${ errStatusCodes.toString() }] must be in the ${ rangeString } ranges: (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)`,
message: `Status Code(s) [${ errStatusCodes.toString() }] must be in the ${ rangeString } ranges`,
},
];
}
Expand Down
2 changes: 1 addition & 1 deletion functions/correctResponseRange.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('correctResponseRange', () => {

expect(res).toEqual([
{
message: 'Status Code(s) [99,100,782] must be in the 2xx/3xx/4xx/5xx ranges: (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'Status Code(s) [99,100,782] must be in the 2xx/3xx/4xx/5xx ranges',
},
]);
});
Expand Down
2 changes: 1 addition & 1 deletion functions/hasErrorMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function (input, opts, context) {
if (!errorMessage) {
return [
{
message: 'Error representations include a useful human-readable message. (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'Error representations include a useful human-readable message.',
},
];
}
Expand Down
2 changes: 1 addition & 1 deletion functions/hasErrorMessage.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe('hasErrorMessage', () => {

expect(res).toEqual([
{
message: 'Error representations include a useful human-readable message. (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'Error representations include a useful human-readable message.',
},
]);
});
Expand Down
2 changes: 1 addition & 1 deletion functions/hasRecommendedStatusCodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default function (input, opts) {
if (!acceptableCodes.includes(`${ input }`)) {
return [
{
message: `${ input } is not an acceptable response code for ${ method.toUpperCase() }. My API responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx ranges (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)`,
message: `${ input } is not an acceptable response code for ${ method.toUpperCase() }. My API responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx ranges`,
},
];
}
Expand Down
12 changes: 6 additions & 6 deletions functions/hasRecommendedStatusCodes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('hasRecommendedStatusCodes', () => {
for (const res of badCodes) {
expect(hasRecommendedStatusCodes(res, { method: 'get' })).toEqual([
{
message: `${ res } is not an acceptable response code for GET. My API responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx ranges (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)`,
message: `${ res } is not an acceptable response code for GET. My API responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx ranges`,
},
]);
}
Expand All @@ -96,7 +96,7 @@ describe('hasRecommendedStatusCodes', () => {
for (const res of badCodes) {
expect(hasRecommendedStatusCodes(res, { method: 'get' })).toEqual([
{
message: `${ res } is not an acceptable response code for GET. My API responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx ranges (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)`,
message: `${ res } is not an acceptable response code for GET. My API responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx ranges`,
},
]);
}
Expand All @@ -116,7 +116,7 @@ describe('hasRecommendedStatusCodes', () => {
for (const res of badCodes) {
expect(hasRecommendedStatusCodes(res, { method: 'post' })).toEqual([
{
message: `${ res } is not an acceptable response code for POST. My API responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx ranges (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)`,
message: `${ res } is not an acceptable response code for POST. My API responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx ranges`,
},
]);
}
Expand All @@ -136,7 +136,7 @@ describe('hasRecommendedStatusCodes', () => {
for (const res of badCodes) {
expect(hasRecommendedStatusCodes(res, { method: 'put' })).toEqual([
{
message: `${ res } is not an acceptable response code for PUT. My API responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx ranges (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)`,
message: `${ res } is not an acceptable response code for PUT. My API responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx ranges`,
},
]);
}
Expand All @@ -159,7 +159,7 @@ describe('hasRecommendedStatusCodes', () => {
for (const res of badCodes) {
expect(hasRecommendedStatusCodes(res, { method: 'patch' })).toEqual([
{
message: `${ res } is not an acceptable response code for PATCH. My API responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx ranges (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)`,
message: `${ res } is not an acceptable response code for PATCH. My API responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx ranges`,
},
]);
}
Expand All @@ -182,7 +182,7 @@ describe('hasRecommendedStatusCodes', () => {
for (const res of badCodes) {
expect(hasRecommendedStatusCodes(res, { method: 'delete' })).toEqual([
{
message: `${ res } is not an acceptable response code for DELETE. My API responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx ranges (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)`,
message: `${ res } is not an acceptable response code for DELETE. My API responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx ranges`,
},
]);
}
Expand Down
2 changes: 1 addition & 1 deletion functions/noCrudVerbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function (input) {
if (foundVerb) {
return [
{
message: 'Standard CRUD lifecycle operations map to HTTP verbs; Functional resources are used when non-standard CRUD are needed (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'Standard CRUD lifecycle operations map to HTTP verbs; Functional resources are used when non-standard CRUD are needed',
},
];
}
Expand Down
2 changes: 1 addition & 1 deletion functions/resourcePasCamelCase.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default function (input, opts) {
if (_node && !isPascalOrCamelCase(_node)) {
// user will have to iteratively resolve issues in the same string
result.push({
message: `${ _node } must be PasCamelCase: (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)`,
message: `${ _node } must be PasCamelCase`,
});
}
}
Expand Down
14 changes: 7 additions & 7 deletions functions/resourcePasCamelCase.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,28 +69,28 @@ describe('resourcePasCamelCase', () => {

expect(res).toEqual([
{
message: '30DaysCount must be PasCamelCase: (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: '30DaysCount must be PasCamelCase',
},
]);

res = resourcePasCamelCase('30LessThan60DaysCount');
expect(res).toEqual([
{
message: '30LessThan60DaysCount must be PasCamelCase: (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: '30LessThan60DaysCount must be PasCamelCase',
},
]);

res = resourcePasCamelCase('60LessThan90DaysCount');
expect(res).toEqual([
{
message: '60LessThan90DaysCount must be PasCamelCase: (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: '60LessThan90DaysCount must be PasCamelCase',
},
]);

res = resourcePasCamelCase('90DaysCount');
expect(res).toEqual([
{
message: '90DaysCount must be PasCamelCase: (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: '90DaysCount must be PasCamelCase',
},
]);
});
Expand All @@ -100,21 +100,21 @@ describe('resourcePasCamelCase', () => {

expect(res).toEqual([
{
message: 'THISISALLCAPS must be PasCamelCase: (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'THISISALLCAPS must be PasCamelCase',
},
]);

res = resourcePasCamelCase('this_is_snake_case');
expect(res).toEqual([
{
message: 'this_is_snake_case must be PasCamelCase: (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'this_is_snake_case must be PasCamelCase',
},
]);

res = resourcePasCamelCase('THISHastoBePasCamelCase?!1');
expect(res).toEqual([
{
message: 'THISHastoBePasCamelCase?!1 must be PasCamelCase: (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'THISHastoBePasCamelCase?!1 must be PasCamelCase',
},
]);
});
Expand Down
10 changes: 5 additions & 5 deletions test/authenticate-requests.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe(ruleName, () => {
expect(res).toEqual([
{
code: ruleName,
message: 'API.REST.SECURITY.03: My API authenticates and authorizes all requests (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'API.REST.SECURITY.03: My API authenticates and authorizes all requests; "get.security" property must be truthy',
path: [
'paths',
'/test',
Expand All @@ -58,7 +58,7 @@ describe(ruleName, () => {
},
{
code: ruleName,
message: 'API.REST.SECURITY.03: My API authenticates and authorizes all requests (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'API.REST.SECURITY.03: My API authenticates and authorizes all requests; "post.security" property must be truthy',
path: [
'paths',
'/test',
Expand All @@ -78,7 +78,7 @@ describe(ruleName, () => {
},
{
code: ruleName,
message: 'API.REST.SECURITY.03: My API authenticates and authorizes all requests (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'API.REST.SECURITY.03: My API authenticates and authorizes all requests; "put.security" property must be truthy',
path: [
'paths',
'/test',
Expand All @@ -98,7 +98,7 @@ describe(ruleName, () => {
},
{
code: ruleName,
message: 'API.REST.SECURITY.03: My API authenticates and authorizes all requests (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'API.REST.SECURITY.03: My API authenticates and authorizes all requests; "delete.security" property must be truthy',
path: [
'paths',
'/test',
Expand All @@ -118,7 +118,7 @@ describe(ruleName, () => {
},
{
code: ruleName,
message: 'API.REST.SECURITY.03: My API authenticates and authorizes all requests (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'API.REST.SECURITY.03: My API authenticates and authorizes all requests; "options.security" property must be truthy',
path: [
'paths',
'/test',
Expand Down
6 changes: 3 additions & 3 deletions test/date-response-header-format-pattern-requirement.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe(ruleName, () => {
expect(res).toEqual([
{
code: ruleName,
message: 'All \'Date\' response headers should use a custom pattern match for RFC 5322. date-time or other given formats should not be used (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'All responses include a \'Date\' header in the GMT timezone and RFC 5322 format.; "schema.pattern" property must be truthy',
path: [
'paths',
'/test',
Expand All @@ -61,7 +61,7 @@ describe(ruleName, () => {
},
{
code: ruleName,
message: 'All \'Date\' response headers should use a custom pattern match for RFC 5322. date-time or other given formats should not be used (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'All responses include a \'Date\' header in the GMT timezone and RFC 5322 format.; "format" property must be falsy',
path: [
'paths',
'/test',
Expand All @@ -87,7 +87,7 @@ describe(ruleName, () => {
},
{
code: ruleName,
message: 'All \'Date\' response headers should use a custom pattern match for RFC 5322. date-time or other given formats should not be used (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'All responses include a \'Date\' header in the GMT timezone and RFC 5322 format.; "schema.pattern" property must be truthy',
path: [
'paths',
'/anotherTest',
Expand Down
2 changes: 1 addition & 1 deletion test/date-response-header-regex-check.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe(ruleName, () => {
expect(res).toEqual([
{
code: ruleName,
message: 'The regex pattern used does not pass basic linting sample checks - should not have matched case Thu 8 Apr 2021 19:06:27 GMT (Comma required after Day of Week) (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'All responses include a \'Date\' header in the GMT timezone and RFC 5322 format.; The regex pattern used does not pass basic linting sample checks - should not have matched case Thu 8 Apr 2021 19:06:27 GMT (Comma required after Day of Week)',
path: [
'paths',
'/test',
Expand Down
Loading