Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
},
"testPathIgnorePatterns": [
"__helpers__",
"metrics/data",
"IPA\\d+ValidOperationID\\.test\\.js$"
"metrics/data"
]
},
"dependencies": {
Expand Down
43 changes: 27 additions & 16 deletions tools/spectral/ipa/__tests__/IPA104ValidOperationID.test.js
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some test cases for:

  • Valid/invalid op ID overrides for the different methods
  • Usage of the verb override in standard and legacy custom methods

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added, TY - anything missing ?

Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import testRule from './__helpers__/testRule';

// TODO: add tests for xgen-custom-method extension - CLOUDP-306294
// TOOD: enable tests for invalid methods (after rules are upgraded to warning) - CLOUDP-329722
import { DiagnosticSeverity } from '@stoplight/types';

testRule('xgen-IPA-104-valid-operation-id', [
{
Expand All @@ -17,40 +15,53 @@ testRule('xgen-IPA-104-valid-operation-id', [
},
errors: [],
},
// This test will be enable when the xgen-IPA-104-valid-operation-id is set to warning severity - CLOUDP-329722
/* {
name: 'invalid methods',
{
name: 'invalid methods with short opIDs',
document: {
paths: {
'/api/atlas/v2/groups/{groupId}/accessList/{entryValue}/status': {
'/api/atlas/v2/groups/{groupId}/accessList/{entryValue}': {
get: {
operationId: 'getProjectIpAccessListStatus',
operationId: 'getProjectIpList',
},
},
'/api/atlas/v2/groups/{groupId}/dataFederation/{tenantName}/limits/{limitName}': {
},
},
errors: [
{
code: 'xgen-IPA-104-valid-operation-id',
message: 'Invalid OperationID. ',
path: ['paths', '/api/atlas/v2/groups/{groupId}/accessList/{entryValue}', 'get', 'operationId'],
severity: DiagnosticSeverity.Warning,
},
],
},
{
name: 'invalid methods with long opIDs',
document: {
paths: {
'/api/atlas/v2/groups/{groupId}/alerts/{alertId}/alertConfigs': {
get: {
operationId: 'returnFederatedDatabaseQueryLimit',
operationId: 'listAlertConfigurationsByAlertId',
},
},
},
},
errors: [
{
code: 'xgen-IPA-104-valid-operation-id',
message:
'Invalid OperationID. ',
path: ['paths', '/api/atlas/v2/groups/{groupId}/accessList/{entryValue}/status', 'get'],
message: 'Invalid OperationID. ',
path: ['paths', '/api/atlas/v2/groups/{groupId}/alerts/{alertId}/alertConfigs', 'get', 'operationId'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-104-valid-operation-id',
message:
'Invalid OperationID. ',
path: ['paths', '/api/atlas/v2/groups/{groupId}/dataFederation/{tenantName}/limits/{limitName}', 'get'],
"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. ",
path: ['paths', '/api/atlas/v2/groups/{groupId}/alerts/{alertId}/alertConfigs', 'get', 'operationId'],
severity: DiagnosticSeverity.Warning,
},
],
}, */
},
{
name: 'invalid methods with exceptions',
document: {
Expand Down
43 changes: 27 additions & 16 deletions tools/spectral/ipa/__tests__/IPA105ValidOperationID.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import testRule from './__helpers__/testRule';

// TODO: add tests for xgen-custom-method extension - CLOUDP-306294
// TOOD: enable tests for invalid methods (after rules are upgraded to warning) - CLOUDP-329722
import { DiagnosticSeverity } from '@stoplight/types';

testRule('xgen-IPA-105-valid-operation-id', [
{
Expand All @@ -17,40 +15,53 @@ testRule('xgen-IPA-105-valid-operation-id', [
},
errors: [],
},
// This test will be enable when the xgen-IPA-105-valid-operation-id is set to warning severity - CLOUDP-329722
/* {
name: 'invalid methods',
{
name: 'invalid methods with short opIDs',
document: {
paths: {
'/api/atlas/v2/orgs/{orgId}/teams/{teamId}/users': {
'/api/atlas/v2/unauth/openapi/versions': {
get: {
operationId: 'listTeamUsers',
operationId: 'getApiVersions',
},
},
'/api/atlas/v2/orgs/{orgId}/events': {
},
},
errors: [
{
code: 'xgen-IPA-105-valid-operation-id',
message: 'Invalid OperationID. ',
path: ['paths', '/api/atlas/v2/unauth/openapi/versions', 'get', 'operationId'],
severity: DiagnosticSeverity.Warning,
},
],
},
{
name: 'invalid methods with too long opIDs',
document: {
paths: {
'/api/atlas/v2/unauth/controlPlaneIPAddresses': {
get: {
operationId: 'listOrganizationEvents',
operationId: 'returnAllControlPlaneIpAddresses',
},
},
},
},
errors: [
{
code: 'xgen-IPA-105-valid-operation-id',
message:
'Invalid OperationID. ',
path: ['paths', '/api/atlas/v2/groups/{groupId}/databaseUsers/{username}/certs', 'get'],
message: 'Invalid OperationID. ',
path: ['paths', '/api/atlas/v2/unauth/controlPlaneIPAddresses', 'get', 'operationId'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-105-valid-operation-id',
message:
'Invalid OperationID. ',
path: ['paths', '/api/atlas/v2/orgs/{orgId}/events', 'get'],
"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. ",
path: ['paths', '/api/atlas/v2/unauth/controlPlaneIPAddresses', 'get', 'operationId'],
severity: DiagnosticSeverity.Warning,
},
],
}, */
},
{
name: 'invalid methods with exceptions',
document: {
Expand Down
46 changes: 35 additions & 11 deletions tools/spectral/ipa/__tests__/IPA106ValidOperationID.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import testRule from './__helpers__/testRule';

// TODO: add tests for xgen-custom-method extension - CLOUDP-306294
// TOOD: enable tests for invalid methods (after rules are upgraded to warning) - CLOUDP-329722
import { DiagnosticSeverity } from '@stoplight/types';

testRule('xgen-IPA-106-valid-operation-id', [
{
Expand All @@ -17,9 +15,8 @@ testRule('xgen-IPA-106-valid-operation-id', [
},
errors: [],
},
// This test will be enable when the xgen-IPA-106-valid-operation-id is set to warning severity - CLOUDP-329722
/* {
name: 'invalid methods',
{
name: 'invalid methods with short opIds',
document: {
paths: {
'/api/atlas/v2/groups/{groupId}/access': {
Expand All @@ -38,19 +35,46 @@ testRule('xgen-IPA-106-valid-operation-id', [
{
code: 'xgen-IPA-106-valid-operation-id',
message:
'Invalid OperationID. ',
path: ['paths', '/api/atlas/v2/groups/{groupId}/access', 'post'],
"Invalid OperationID. Found 'addUserToProject', expected 'createGroupAccess'. https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-106-valid-operation-id",
path: ['paths', '/api/atlas/v2/groups/{groupId}/access', 'post', 'operationId'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-106-valid-operation-id',
message:
'Invalid OperationID. ',
path: ['paths', '/api/atlas/v2/groups/{groupId}/invites', 'post'],
"Invalid OperationID. Found 'createProjectInvitation', expected 'createGroupInvite'. https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-106-valid-operation-id",
path: ['paths', '/api/atlas/v2/groups/{groupId}/invites', 'post', 'operationId'],
severity: DiagnosticSeverity.Warning,
},
],
}, */
},
{
name: 'invalid methods with too long opIDs',
document: {
paths: {
'/api/atlas/v2/orgs/{orgId}/serviceAccounts/{clientId}/accessList': {
post: {
operationId: 'createServiceAccountAccessList',
},
},
},
},
errors: [
{
code: 'xgen-IPA-106-valid-operation-id',
message: 'Invalid OperationID. ',
path: ['paths', '/api/atlas/v2/orgs/{orgId}/serviceAccounts/{clientId}/accessList', 'post', 'operationId'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-106-valid-operation-id',
message:
"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. ",
path: ['paths', '/api/atlas/v2/orgs/{orgId}/serviceAccounts/{clientId}/accessList', 'post', 'operationId'],
severity: DiagnosticSeverity.Warning,
},
],
},
{
name: 'invalid methods with exceptions',
document: {
Expand Down
46 changes: 34 additions & 12 deletions tools/spectral/ipa/__tests__/IPA107ValidOperationID.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import testRule from './__helpers__/testRule';

// TODO: add tests for xgen-custom-method extension - CLOUDP-306294
// TOOD: enable tests for invalid methods (after rules are upgraded to warning) - CLOUDP-329722
import { DiagnosticSeverity } from '@stoplight/types';

testRule('xgen-IPA-107-valid-operation-id', [
{
Expand All @@ -22,9 +20,8 @@ testRule('xgen-IPA-107-valid-operation-id', [
},
errors: [],
},
// This test will be enable when the xgen-IPA-107-valid-operation-id is set to warning severity - CLOUDP-329722
/* {
name: 'invalid methods',
{
name: 'invalid methods with short opIds',
document: {
paths: {
'/api/atlas/v2/groups/{groupId}/limits/{limitName}': {
Expand All @@ -42,20 +39,45 @@ testRule('xgen-IPA-107-valid-operation-id', [
errors: [
{
code: 'xgen-IPA-107-valid-operation-id',
message:
'Invalid OperationID. ',
path: ['paths', '/api/atlas/v2/groups/{groupId}/limits/{limitName}', 'patch'],
message: 'Invalid OperationID. ',
path: ['paths', '/api/atlas/v2/groups/{groupId}/limits/{limitName}', 'patch', 'operationId'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-107-valid-operation-id',
message: 'Invalid OperationID. ',
path: ['paths', '/api/atlas/v2/groups/{groupId}/settings', 'put', 'operationId'],
severity: DiagnosticSeverity.Warning,
},
],
},
{
name: 'invalid methods with too long opIDs',
document: {
paths: {
'/api/atlas/v2/groups/{groupId}/pushBasedLogExport': {
patch: {
operationId: 'updatePushBasedLogConfiguration',
},
},
},
},
errors: [
{
code: 'xgen-IPA-107-valid-operation-id',
message: 'Invalid OperationID. ',
path: ['paths', '/api/atlas/v2/groups/{groupId}/pushBasedLogExport', 'patch', 'operationId'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-107-valid-operation-id',
message:
'Invalid OperationID. ',
path: ['paths', '/api/atlas/v2/groups/{groupId}/settings', 'put'],
"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. ",
path: ['paths', '/api/atlas/v2/groups/{groupId}/pushBasedLogExport', 'patch', 'operationId'],
severity: DiagnosticSeverity.Warning,
},
],
}, */
},
{
name: 'invalid methods with exceptions',
document: {
Expand Down
52 changes: 43 additions & 9 deletions tools/spectral/ipa/__tests__/IPA108ValidOperationID.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import testRule from './__helpers__/testRule';

// TODO: add tests for xgen-custom-method extension - CLOUDP-306294
// TOOD: enable tests for invalid methods (after rules are upgraded to warning) - CLOUDP-329722
import { DiagnosticSeverity } from '@stoplight/types';

testRule('xgen-IPA-108-valid-operation-id', [
{
Expand All @@ -17,9 +15,8 @@ testRule('xgen-IPA-108-valid-operation-id', [
},
errors: [],
},
// This test will be enable when the xgen-IPA-108-valid-operation-id is set to warning severity - CLOUDP-329722
/* {
name: 'invalid methods',
{
name: 'invalid methods with short opIDs',
document: {
paths: {
'/api/atlas/v2/groups/{groupId}/apiKeys/{apiUserId}': {
Expand All @@ -38,17 +35,54 @@ testRule('xgen-IPA-108-valid-operation-id', [
{
code: 'xgen-IPA-108-valid-operation-id',
message: 'Invalid OperationID. ',
path: ['paths', '/api/atlas/v2/groups/{groupId}/apiKeys/{apiUserId}', 'delete'],
path: ['paths', '/api/atlas/v2/groups/{groupId}/apiKeys/{apiUserId}', 'delete', 'operationId'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-108-valid-operation-id',
message: 'Invalid OperationID. ',
path: ['paths', '/api/atlas/v2/groups/{groupId}', 'delete'],
path: ['paths', '/api/atlas/v2/groups/{groupId}', 'delete', 'operationId'],
severity: DiagnosticSeverity.Warning,
},
],
}, */
},
{
name: 'invalid methods with too long opIDs',
document: {
paths: {
'/api/atlas/v2/groups/{groupId}/dataFederation/{tenantName}/limits/{limitName}': {
delete: {
operationId: 'deleteOneDataFederationInstanceQueryLimit',
},
},
},
},
errors: [
{
code: 'xgen-IPA-108-valid-operation-id',
message: 'Invalid OperationID. ',
path: [
'paths',
'/api/atlas/v2/groups/{groupId}/dataFederation/{tenantName}/limits/{limitName}',
'delete',
'operationId',
],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-108-valid-operation-id',
message:
"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. ",
path: [
'paths',
'/api/atlas/v2/groups/{groupId}/dataFederation/{tenantName}/limits/{limitName}',
'delete',
'operationId',
],
severity: DiagnosticSeverity.Warning,
},
],
},
{
name: 'invalid methods with exceptions',
document: {
Expand Down
Loading
Loading