mirror of
https://github.com/fosrl/pangolin.git
synced 2026-07-09 17:18:31 +00:00
test: add normalized ASN validation coverage
This commit is contained in:
parent
de48a0529e
commit
e5e7b79712
3 changed files with 17 additions and 2 deletions
|
|
@ -245,16 +245,31 @@ function runTests() {
|
|||
null,
|
||||
"Standard ASN should be valid"
|
||||
);
|
||||
assertEquals(
|
||||
getResourceRuleValueValidationError("ASN", " As15169 "),
|
||||
null,
|
||||
"Standard ASN should be valid with mixed case and whitespace"
|
||||
);
|
||||
assertEquals(
|
||||
getResourceRuleValueValidationError("ASN", "ALL"),
|
||||
null,
|
||||
"ALL ASN selector should be valid"
|
||||
);
|
||||
assertEquals(
|
||||
getResourceRuleValueValidationError("ASN", " all "),
|
||||
null,
|
||||
"ALL ASN selector should be valid with mixed case and whitespace"
|
||||
);
|
||||
assertEquals(
|
||||
getResourceRuleValueValidationError("ASN", "AS0"),
|
||||
null,
|
||||
"AS0 alias should be valid"
|
||||
);
|
||||
assertEquals(
|
||||
getResourceRuleValueValidationError("ASN", " as0 "),
|
||||
null,
|
||||
"AS0 alias should be valid with mixed case and whitespace"
|
||||
);
|
||||
assertEquals(
|
||||
getResourceRuleValueValidationError("ASN", "not-an-asn"),
|
||||
"Invalid ASN provided",
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ export function getResourceRuleValueValidationError(
|
|||
: "Invalid country code provided";
|
||||
case "ASN":
|
||||
const normalizedValue = value.trim().toUpperCase();
|
||||
return /^AS\d+$/i.test(normalizedValue) ||
|
||||
return /^AS\d+$/.test(normalizedValue) ||
|
||||
normalizedValue === "ALL" ||
|
||||
normalizedValue === "AS0"
|
||||
? null
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ export function createPolicyRuleValueSchema(t: TranslateFn, match: string) {
|
|||
(value) => {
|
||||
const normalizedValue = value.trim().toUpperCase();
|
||||
return (
|
||||
/^AS\d+$/i.test(normalizedValue) ||
|
||||
/^AS\d+$/.test(normalizedValue) ||
|
||||
normalizedValue === "ALL" ||
|
||||
normalizedValue === "AS0"
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue