Skip to content

Commit

Permalink
added NetworkSecurityPerimeterConfigurationNameParameter to exclusion…
Browse files Browse the repository at this point in the history
… list
  • Loading branch information
tejaswiMinnu committed Sep 6, 2024
1 parent 9cb4900 commit 5c56ba1
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
7 changes: 6 additions & 1 deletion packages/rulesets/generated/spectral/az-arm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2585,7 +2585,12 @@ const reservedResourceNamesModelAsEnum = (pathItem, _opts, ctx) => {
return errors;
};

const EXCEPTION_LIST = ["resourceGroupName", "privateEndpointConnectionName", "managementGroupName"];
const EXCEPTION_LIST = [
"resourceGroupName",
"privateEndpointConnectionName",
"managementGroupName",
"networkSecurityPerimeterConfigurationName",
];
const resourceNameRestriction = (paths, _opts, ctx) => {
if (paths === null || typeof paths !== "object") {
return [];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
// Check conformance to Azure parameter naming conventions:

//system-defined parameters => needs to be excluded from validation
const EXCEPTION_LIST = ["resourceGroupName", "privateEndpointConnectionName", "managementGroupName"]
const EXCEPTION_LIST = [
"resourceGroupName",
"privateEndpointConnectionName",
"managementGroupName",
"networkSecurityPerimeterConfigurationName",
]
export const resourceNameRestriction = (paths: any, _opts: any, ctx: any) => {
if (paths === null || typeof paths !== "object") {
return []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test("ResourceNameRestriction should find errors on path level", () => {
return linter.run(oasDoc).then((results) => {
expect(results.length).toBe(1)
expect(results[0].path.join(".")).toBe(
"paths./subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/My.NS/foo/{fooName}"
"paths./subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/My.NS/foo/{fooName}",
)
expect(results[0].message).toContain("The resource name parameter 'fooName' should be defined with a 'pattern' restriction.")
})
Expand Down Expand Up @@ -61,7 +61,7 @@ test("ResourceNameRestriction should find errors on operation level", () => {
return linter.run(oasDoc).then((results) => {
expect(results.length).toBe(1)
expect(results[0].path.join(".")).toBe(
"paths./subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/My.NS/foo/{fooName}"
"paths./subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/My.NS/foo/{fooName}",
)
expect(results[0].message).toContain("The resource name parameter 'fooName' should be defined with a 'pattern' restriction.")
})
Expand Down Expand Up @@ -138,6 +138,31 @@ test("ResourceNameRestriction should find no errors for system-defined variables
responses: {},
},
},
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/My.NS/foo/{fooName}/networkSecurityPerimeterConfiguration/{networkSecurityPerimeterConfigurationName}":
{
parameters: [
{
name: "fooName",
in: "path",
required: true,
type: "string",
pattern: "[a-zA-Z_0-9]+",
"x-ms-parameter-location": "method",
},
{
name: "networkSecurityPerimeterConfigurationName",
in: "path",
required: true,
type: "string",
description: "The name of the network security perimeter configuration associated with the Azure resource.",
"x-ms-parameter-location": "method",
},
],
get: {
parameters: [],
responses: {},
},
},
},
}
return linter.run(oasDoc).then((results) => {
Expand Down

0 comments on commit 5c56ba1

Please sign in to comment.