Skip to content

Commit

Permalink
Unit tests for case insensitive header conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
rmsamitha committed Jul 15, 2024
1 parent 91f127a commit b68a518
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* An Utility class to generate dummy policies.
*/
public class TestUtil {
public static final String HEADER_CONDITION_HEADER_NAME = "HEADER1";

/**
* Generate a dummy API Policy object
Expand Down Expand Up @@ -75,6 +76,14 @@ public static ApiPolicy getPolicyAPILevel() {
condition1.setInverted(false);
conditions.add(condition1);

Condition condition2 = new Condition();
condition2.setConditionType("Header");
//set the header name in mixed case to test that execution plans are deployed with lower-case header names
condition2.setName(HEADER_CONDITION_HEADER_NAME);
condition2.setValue("test1");
condition2.setInverted(false);
conditions.add(condition2);

conditionGroup1.setCondition(conditions);

QuotaPolicy defaultLimitCondGroup1 = new QuotaPolicy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ public void testGetThrottlePolicyForAPILevel() throws Exception {

String defaultPolicyString = templateBuilder.getThrottlePolicyForAPILevelDefault(policy);
Assert.assertNotNull(defaultPolicyString);

// Test that execution plans are deployed with lower-case header names even though the header condition of the
// policy had the header name in upper-case (or mix-case)
boolean isPolicyStringContainsLowerCasedHeader =
defaultPolicyString.contains(TestUtil.HEADER_CONDITION_HEADER_NAME.toLowerCase());
Assert.assertTrue(isPolicyStringContainsLowerCasedHeader);
}

@Test
Expand Down

0 comments on commit b68a518

Please sign in to comment.