Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 5 additions & 5 deletions tools/spectral/ipa/__tests__/IPA104ValidOperationID.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ testRule('xgen-IPA-104-valid-operation-id', [
code: 'xgen-IPA-104-valid-operation-id',
message: "Invalid OperationID. Found 'getProjectIpList', expected 'getGroupAccessList'. ",
path: ['paths', '/api/atlas/v2/groups/{groupId}/accessList/{entryValue}', 'get', 'operationId'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand All @@ -52,14 +52,14 @@ testRule('xgen-IPA-104-valid-operation-id', [
message:
"Invalid OperationID. Found 'listAlertConfigurationsByAlertId', expected 'getGroupAlertAlertConfigs'. ",
path: ['paths', '/api/atlas/v2/groups/{groupId}/alerts/{alertId}/alertConfigs', 'get', 'operationId'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-104-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}/alerts/{alertId}/alertConfigs', 'get', 'operationId'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand Down Expand Up @@ -109,7 +109,7 @@ testRule('xgen-IPA-104-valid-operation-id', [
'get',
'x-xgen-operation-id-override',
],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-104-valid-operation-id',
Expand All @@ -120,7 +120,7 @@ testRule('xgen-IPA-104-valid-operation-id', [
'get',
'x-xgen-operation-id-override',
],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand Down
10 changes: 5 additions & 5 deletions tools/spectral/ipa/__tests__/IPA105ValidOperationID.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ testRule('xgen-IPA-105-valid-operation-id', [
code: 'xgen-IPA-105-valid-operation-id',
message: "Invalid OperationID. Found 'getApiVersions', expected 'listOpenapiVersions'. ",
path: ['paths', '/api/atlas/v2/unauth/openapi/versions', 'get', 'operationId'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand All @@ -52,14 +52,14 @@ testRule('xgen-IPA-105-valid-operation-id', [
message:
"Invalid OperationID. Found 'returnAllControlPlaneIpAddresses', expected 'listControlPlaneIpAddresses'. ",
path: ['paths', '/api/atlas/v2/unauth/controlPlaneIPAddresses', 'get', 'operationId'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-105-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/unauth/controlPlaneIPAddresses', 'get', 'operationId'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand Down Expand Up @@ -101,13 +101,13 @@ testRule('xgen-IPA-105-valid-operation-id', [
message:
"The operation ID override must only contain nouns from the operation ID 'listGroupBackupExportBuckets'. ",
path: ['paths', '/api/atlas/v2/groups/{groupId}/backup/exportBuckets', 'get', 'x-xgen-operation-id-override'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-105-valid-operation-id',
message: "The operation ID override must end with the noun 'Buckets'. ",
path: ['paths', '/api/atlas/v2/groups/{groupId}/backup/exportBuckets', 'get', 'x-xgen-operation-id-override'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand Down
19 changes: 11 additions & 8 deletions tools/spectral/ipa/__tests__/IPA106ValidOperationID.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ testRule('xgen-IPA-106-valid-operation-id', [
code: 'xgen-IPA-106-valid-operation-id',
message: "Invalid OperationID. Found 'addUserToProject', expected 'createGroupAccess'. ",
path: ['paths', '/api/atlas/v2/groups/{groupId}/access', 'post', 'operationId'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-106-valid-operation-id',
message: "Invalid OperationID. Found 'createProjectInvitation', expected 'createGroupInvite'. ",
path: ['paths', '/api/atlas/v2/groups/{groupId}/invites', 'post', 'operationId'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand All @@ -63,14 +63,14 @@ testRule('xgen-IPA-106-valid-operation-id', [
message:
"Invalid OperationID. Found 'createServiceAccountAccessList', expected 'createOrgServiceAccountAccessList'. ",
path: ['paths', '/api/atlas/v2/orgs/{orgId}/serviceAccounts/{clientId}/accessList', 'post', 'operationId'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
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,
severity: DiagnosticSeverity.Error,
},
],
},
Expand Down Expand Up @@ -110,7 +110,7 @@ testRule('xgen-IPA-106-valid-operation-id', [
'post',
'x-xgen-operation-id-override',
],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-106-valid-operation-id',
Expand All @@ -122,7 +122,7 @@ testRule('xgen-IPA-106-valid-operation-id', [
'post',
'x-xgen-operation-id-override',
],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-106-valid-operation-id',
Expand All @@ -133,7 +133,7 @@ testRule('xgen-IPA-106-valid-operation-id', [
'post',
'x-xgen-operation-id-override',
],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand All @@ -144,7 +144,10 @@ testRule('xgen-IPA-106-valid-operation-id', [
'/api/atlas/v2/groups/{groupId}/serverless': {
post: {
operationId: 'createGroupServerlessInstance',
'x-xgen-method-verb-override': { verb: 'createInstance', customMethod: false },
'x-xgen-method-verb-override': {
verb: 'createInstance',
customMethod: false,
},
'x-xgen-operation-id-override': 'createServerlessInstance',
},
},
Expand Down
17 changes: 10 additions & 7 deletions tools/spectral/ipa/__tests__/IPA107ValidOperationID.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ testRule('xgen-IPA-107-valid-operation-id', [
code: 'xgen-IPA-107-valid-operation-id',
message: "Invalid OperationID. Found 'setProjectLimit', expected 'updateGroupLimit'. ",
path: ['paths', '/api/atlas/v2/groups/{groupId}/limits/{limitName}', 'patch', 'operationId'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-107-valid-operation-id',
message: "Invalid OperationID. Found 'updateProjectSettings', expected 'updateGroupSettings'. ",
path: ['paths', '/api/atlas/v2/groups/{groupId}/settings', 'put', 'operationId'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand All @@ -68,14 +68,14 @@ testRule('xgen-IPA-107-valid-operation-id', [
message:
"Invalid OperationID. Found 'updatePushBasedLogConfiguration', expected 'updateGroupPushBasedLogExport'. ",
path: ['paths', '/api/atlas/v2/groups/{groupId}/pushBasedLogExport', 'patch', 'operationId'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-107-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}/pushBasedLogExport', 'patch', 'operationId'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand Down Expand Up @@ -116,7 +116,7 @@ testRule('xgen-IPA-107-valid-operation-id', [
'patch',
'x-xgen-operation-id-override',
],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-107-valid-operation-id',
Expand All @@ -127,7 +127,7 @@ testRule('xgen-IPA-107-valid-operation-id', [
'patch',
'x-xgen-operation-id-override',
],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand All @@ -138,7 +138,10 @@ testRule('xgen-IPA-107-valid-operation-id', [
'/api/atlas/v2/groups/{groupId}/serverless': {
patch: {
operationId: 'updateGroupServerlessInstance',
'x-xgen-method-verb-override': { verb: 'updateInstance', customMethod: false },
'x-xgen-method-verb-override': {
verb: 'updateInstance',
customMethod: false,
},
'x-xgen-operation-id-override': 'updateServerlessInstance',
},
},
Expand Down
17 changes: 10 additions & 7 deletions tools/spectral/ipa/__tests__/IPA108ValidOperationID.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ testRule('xgen-IPA-108-valid-operation-id', [
code: 'xgen-IPA-108-valid-operation-id',
message: "Invalid OperationID. Found 'removeProjectApiKey', expected 'deleteGroupApiKey'. ",
path: ['paths', '/api/atlas/v2/groups/{groupId}/apiKeys/{apiUserId}', 'delete', 'operationId'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-108-valid-operation-id',
message: "Invalid OperationID. Found 'deleteProject', expected 'deleteGroup'. ",
path: ['paths', '/api/atlas/v2/groups/{groupId}', 'delete', 'operationId'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand All @@ -68,7 +68,7 @@ testRule('xgen-IPA-108-valid-operation-id', [
'delete',
'operationId',
],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-108-valid-operation-id',
Expand All @@ -80,7 +80,7 @@ testRule('xgen-IPA-108-valid-operation-id', [
'delete',
'operationId',
],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand Down Expand Up @@ -121,7 +121,7 @@ testRule('xgen-IPA-108-valid-operation-id', [
'delete',
'x-xgen-operation-id-override',
],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-108-valid-operation-id',
Expand All @@ -132,7 +132,7 @@ testRule('xgen-IPA-108-valid-operation-id', [
'delete',
'x-xgen-operation-id-override',
],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand All @@ -143,7 +143,10 @@ testRule('xgen-IPA-108-valid-operation-id', [
'/api/atlas/v2/groups/{groupId}/serverless': {
delete: {
operationId: 'deleteGroupServerlessInstance',
'x-xgen-method-verb-override': { verb: 'deleteInstance', customMethod: false },
'x-xgen-method-verb-override': {
verb: 'deleteInstance',
customMethod: false,
},
'x-xgen-operation-id-override': 'deleteServerlessInstance',
},
},
Expand Down
10 changes: 5 additions & 5 deletions tools/spectral/ipa/__tests__/IPA109ValidOperationID.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ testRule('xgen-IPA-109-valid-operation-id', [
code: 'xgen-IPA-109-valid-operation-id',
message: "Invalid OperationID. Found 'searchClusters', expected 'searchGroupClusters'. ",
path: ['paths', '/api/atlas/v2/groups/{groupId}/clusters:search', 'post', 'operationId'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand All @@ -56,14 +56,14 @@ testRule('xgen-IPA-109-valid-operation-id', [
code: 'xgen-IPA-109-valid-operation-id',
message: "Invalid OperationID. Found 'migrateProjectToAnotherOrg', expected 'migrateGroup'. ",
path: ['paths', '/api/atlas/v2/groups/{groupId}:migrate', 'post', 'operationId'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-109-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}:migrate', 'post', 'operationId'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand Down Expand Up @@ -118,7 +118,7 @@ testRule('xgen-IPA-109-valid-operation-id', [
'delete',
'x-xgen-operation-id-override',
],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-109-valid-operation-id',
Expand All @@ -129,7 +129,7 @@ testRule('xgen-IPA-109-valid-operation-id', [
'delete',
'x-xgen-operation-id-override',
],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
{
"componentId": "paths./api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}.get",
"ruleName": "xgen-IPA-104-valid-operation-id"
}],
},
{
"componentId": "paths./api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}.get",
"ruleName": "xgen-IPA-104-valid-operation-id-warn"
}
],
"adoptions": [
{
"componentId": "paths./api/atlas/v2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1752,6 +1752,16 @@
"component_id": "paths./api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}.get",
"ipa_rule": "xgen-IPA-104-valid-operation-id",
"ipa": "IPA-104",
"severity_level": "error",
"adoption_status": "violated",
"exception_reason": null,
"owner_team": null,
"timestamp": "2025-01-21T16:45:11.681Z"
},
{
"component_id": "paths./api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}.get",
"ipa_rule": "xgen-IPA-104-valid-operation-id-warn",
"ipa": "IPA-104",
"severity_level": "warn",
"adoption_status": "violated",
"exception_reason": null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,24 @@
extends:
- ../../../rulesets/IPA-104.yaml

functionsDir: '../../../rulesets/functions'

functions:
- IPA104ValidOperationID

aliases:
GetOperationObject:
- '$.paths[*].get'

rules:
xgen-IPA-104-valid-operation-id-warn:
description: Test rule as warning for testing purposes
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added this rule as warning level just for testing purposes in the metrics collection test. This spectral file is only used for the test

message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-104-valid-operation-id'
severity: warn
given: '#GetOperationObject'
then:
function: 'IPA104ValidOperationID'
functionOptions:
methodName: 'get'
ignoreSingularizationList:
- 'Fts'
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('tools/spectral/ipa/metrics/metricCollection.js runMetricCollectionJob'
expect(results.warnings.count).toEqual(1);
const violations = [
{
code: 'xgen-IPA-104-valid-operation-id',
code: 'xgen-IPA-104-valid-operation-id-warn',
},
];
expect(results.warnings.violations).toEqual(violations);
Expand Down
Loading
Loading