Search in sources :

Example 56 with ConditionDto

use of org.wso2.carbon.apimgt.impl.dto.ConditionDto in project carbon-apimgt by wso2.

the class APIUtilTest method testGetConditionDtoListWithHavingMultipleConditionTypes.

@Test
public void testGetConditionDtoListWithHavingMultipleConditionTypes() throws ParseException {
    String base64EncodedString = "W3siaXBzcGVjaWZpYyI6eyJzcGVjaWZpY0lwIjoxNzQzMjcxODksImludmVydCI6ZmFsc2V9LCJoZW" + "FkZXIiOnsiaW52ZXJ0IjpmYWxzZSwidmFsdWVzIjp7ImFiYyI6ImRlZiJ9fSwiand0Y2xhaW1zIjp7ImludmVydCI6ZmFsc2UsI" + "nZhbHVlcyI6eyJhYmMiOiJkZWYifX19XQo=";
    List<ConditionDto> conditionDtoList = APIUtil.extractConditionDto(base64EncodedString);
    Assert.assertEquals(conditionDtoList.size(), 1);
    ConditionDto conditionDto = conditionDtoList.get(0);
    Assert.assertNotNull(conditionDto.getIpCondition());
    Assert.assertNotNull(conditionDto.getHeaderConditions());
    Assert.assertNotNull(conditionDto.getJwtClaimConditions());
    Assert.assertEquals(conditionDto.getHeaderConditions().getValues().size(), 1);
    Assert.assertEquals(conditionDto.getJwtClaimConditions().getValues().size(), 1);
}
Also used : ConditionDto(org.wso2.carbon.apimgt.impl.dto.ConditionDto) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 57 with ConditionDto

use of org.wso2.carbon.apimgt.impl.dto.ConditionDto in project carbon-apimgt by wso2.

the class APIUtilTest method testGetConditionDtoListWithHavingHeaderConditionOnly.

@Test
public void testGetConditionDtoListWithHavingHeaderConditionOnly() throws ParseException {
    String base64EncodedString = "W3siaGVhZGVyIjp7ImludmVydCI6ZmFsc2UsInZhbHVlcyI6eyJhYmMiOiJkZWYifX19XQo=";
    List<ConditionDto> conditionDtoList = APIUtil.extractConditionDto(base64EncodedString);
    Assert.assertEquals(conditionDtoList.size(), 1);
    ConditionDto conditionDto = conditionDtoList.get(0);
    Assert.assertNotNull(conditionDto.getHeaderConditions());
    Assert.assertEquals(conditionDto.getHeaderConditions().getValues().size(), 1);
}
Also used : ConditionDto(org.wso2.carbon.apimgt.impl.dto.ConditionDto) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 58 with ConditionDto

use of org.wso2.carbon.apimgt.impl.dto.ConditionDto in project carbon-apimgt by wso2.

the class APIUtilTest method testGetConditionDtoListWithHavingIPRangeConditionOnly.

@Test
public void testGetConditionDtoListWithHavingIPRangeConditionOnly() throws ParseException {
    String base64EncodedString = "W3siaXByYW5nZSI6eyJzdGFydGluZ0lwIjoxNjg0MzAwOTAsImVuZGluZ0lwIjoxNjg0MzAwOTEsImludmVydCI6dHJ1ZX19XQ==";
    List<ConditionDto> conditionDtoList = APIUtil.extractConditionDto(base64EncodedString);
    Assert.assertEquals(conditionDtoList.size(), 1);
    ConditionDto conditionDto = conditionDtoList.get(0);
    Assert.assertNotNull(conditionDto.getIpRangeCondition());
    Assert.assertTrue(conditionDto.getIpRangeCondition().isInvert());
}
Also used : ConditionDto(org.wso2.carbon.apimgt.impl.dto.ConditionDto) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 59 with ConditionDto

use of org.wso2.carbon.apimgt.impl.dto.ConditionDto in project carbon-apimgt by wso2.

the class APIUtilTest method testGetConditionDtoListWithHavingJWTClaimConditionOnly.

@Test
public void testGetConditionDtoListWithHavingJWTClaimConditionOnly() throws ParseException {
    String base64EncodedString = "W3siand0Y2xhaW1zIjp7ImludmVydCI6ZmFsc2UsInZhbHVlcyI6eyJhYmMiOiJkZWYifX19XQo=";
    List<ConditionDto> conditionDtoList = APIUtil.extractConditionDto(base64EncodedString);
    Assert.assertEquals(conditionDtoList.size(), 1);
    ConditionDto conditionDto = conditionDtoList.get(0);
    Assert.assertNotNull(conditionDto.getJwtClaimConditions());
    Assert.assertEquals(conditionDto.getJwtClaimConditions().getValues().size(), 1);
}
Also used : ConditionDto(org.wso2.carbon.apimgt.impl.dto.ConditionDto) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 60 with ConditionDto

use of org.wso2.carbon.apimgt.impl.dto.ConditionDto in project carbon-apimgt by wso2.

the class APIUtilTest method testGetConditionDtoListWithHavingIPSpecificConditionOnly.

@Test
public void testGetConditionDtoListWithHavingIPSpecificConditionOnly() throws ParseException {
    String base64EncodedString = "W3siaXBzcGVjaWZpYyI6eyJzcGVjaWZpY0lwIjoxNjg0MzAwOTAsImludmVydCI6ZmFsc2V9fV0=";
    List<ConditionDto> conditionDtoList = APIUtil.extractConditionDto(base64EncodedString);
    Assert.assertEquals(conditionDtoList.size(), 1);
    ConditionDto conditionDto = conditionDtoList.get(0);
    Assert.assertNotNull(conditionDto.getIpCondition());
}
Also used : ConditionDto(org.wso2.carbon.apimgt.impl.dto.ConditionDto) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)45 ConditionDto (org.wso2.carbon.apimgt.impl.dto.ConditionDto)40 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)33 MessageContext (org.apache.synapse.MessageContext)32 HashMap (java.util.HashMap)31 List (java.util.List)26 Map (java.util.Map)23 TreeMap (java.util.TreeMap)23 ConditionDTO (org.wso2.carbon.apimgt.api.dto.ConditionDTO)20 AuthenticationContext (org.wso2.carbon.apimgt.gateway.handlers.security.AuthenticationContext)20 ConditionGroupDTO (org.wso2.carbon.apimgt.api.dto.ConditionGroupDTO)19 ThrottleProperties (org.wso2.carbon.apimgt.impl.dto.ThrottleProperties)17 ArrayList (java.util.ArrayList)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)2 HeaderCondition (org.wso2.carbon.apimgt.api.model.policy.HeaderCondition)2 IPCondition (org.wso2.carbon.apimgt.api.model.policy.IPCondition)2 JWTClaimsCondition (org.wso2.carbon.apimgt.api.model.policy.JWTClaimsCondition)2 QueryParameterCondition (org.wso2.carbon.apimgt.api.model.policy.QueryParameterCondition)2 APIPolicy (org.wso2.carbon.apimgt.api.model.subscription.APIPolicy)2