Skip to content

Commit

Permalink
Merge pull request #424 from DinoChiesa/peggy-isnot
Browse files Browse the repository at this point in the history
fix: re-order checks for Is and IsNot
  • Loading branch information
ssvaidyanathan authored Feb 27, 2024
2 parents 445c21a + c166d94 commit 2a2bd7b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
16 changes: 8 additions & 8 deletions build/ConditionParser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/peggy/Apigee-Condition.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ op_or = "or"i / "||"
op_accepts_literal
= op_equalsnocase { return "EqualsCaseInsensitive"; }
/ op_startswith {return "StartsWith";}
/ op_equals { return "Equals"; }
/ op_notequals { return "NotEquals"; }
/ op_equals { return "Equals"; }
/ op_greatereq {return "GreaterThanOrEquals";}
/ op_greater {return "GreaterThan";}
/ op_lessereq {return "LesserThanOrEquals";}
Expand All @@ -122,8 +122,8 @@ op_accepts_literal

op_accepts_variable
= op_startswith {return "StartsWith";}
/ op_equals { return "Equals"; }
/ op_notequals { return "NotEquals"; }
/ op_equals { return "Equals"; }
/ op_greatereq {return "GreaterThanOrEquals";}
/ op_greater {return "GreaterThan";}
/ op_lessereq {return "LesserThanOrEquals";}
Expand Down
17 changes: 14 additions & 3 deletions test/specs/ConditionParserTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,22 @@ describe("ConditionParser", function () {
}
});

const validOperators = ["equals", "notquals", "isnot", "is"];
const validOperators = ["equals", "notequals", "isnot", "is"];
validOperators.forEach((goodOp) => {
const badOp = goodOp + "a";
const expr = (op) =>
`request.formparam.grant_type ${op} "authorization_code"`;
it(`accepts ${goodOp} as an operator`, function () {
const c1 = expr(goodOp);
try {
parser.parse(c1);
expect(true);
} catch (_e) {
expect.fail();
}
});
const badOp = `${goodOp}a`;
it(`rejects ${badOp} as an operator`, function () {
const c1 = `request.formparam.grant_type ${badOp} "authorization_code"`;
const c1 = expr(badOp);
try {
parser.parse(c1);
expect.fail();
Expand Down

0 comments on commit 2a2bd7b

Please sign in to comment.