Search in sources :

Example 26 with PolicyBean

use of io.apiman.manager.api.beans.policies.PolicyBean in project apiman by apiman.

the class PolicyTemplateUtilTest method testGeneratePolicyDescription_novars.

/**
 * Test method for {@link io.apiman.manager.api.core.util.PolicyTemplateUtil#generatePolicyDescription(io.apiman.manager.api.beans.policies.PolicyBean)}.
 * @throws Exception any exception
 */
@Test
public void testGeneratePolicyDescription_novars() throws Exception {
    PolicyBean policy = new PolicyBean();
    PolicyDefinitionBean def = new PolicyDefinitionBean();
    // $NON-NLS-1$
    def.setId("novars");
    PolicyDefinitionTemplateBean template = new PolicyDefinitionTemplateBean();
    // $NON-NLS-1$
    template.setTemplate("Hello World");
    def.getTemplates().add(template);
    policy.setDefinition(def);
    // $NON-NLS-1$
    policy.setConfiguration("{}");
    PolicyTemplateUtil.generatePolicyDescription(policy);
    // $NON-NLS-1$
    Assert.assertEquals("Hello World", policy.getDescription());
}
Also used : PolicyDefinitionTemplateBean(io.apiman.manager.api.beans.policies.PolicyDefinitionTemplateBean) PolicyDefinitionBean(io.apiman.manager.api.beans.policies.PolicyDefinitionBean) PolicyBean(io.apiman.manager.api.beans.policies.PolicyBean) Test(org.junit.Test)

Example 27 with PolicyBean

use of io.apiman.manager.api.beans.policies.PolicyBean in project apiman by apiman.

the class PolicyTemplateUtilTest method testGeneratePolicyDescription_blacklist.

/**
 * Test method for {@link io.apiman.manager.api.core.util.PolicyTemplateUtil#generatePolicyDescription(io.apiman.manager.api.beans.policies.PolicyBean)}.
 * @throws Exception any exception
 */
@Test
public void testGeneratePolicyDescription_blacklist() throws Exception {
    PolicyBean policy = new PolicyBean();
    PolicyDefinitionBean def = new PolicyDefinitionBean();
    // $NON-NLS-1$
    def.setId("blacklist");
    PolicyDefinitionTemplateBean template = new PolicyDefinitionTemplateBean();
    // $NON-NLS-1$
    template.setTemplate("Requests that originate from the set of @{ipList.size()} configured IP address(es) will be denied access to the managed API.");
    def.getTemplates().add(template);
    policy.setDefinition(def);
    // $NON-NLS-1$
    policy.setConfiguration("{ \"ipList\" : [ \"127.0.0.1\", \"192.168.1.10\" ] }");
    PolicyTemplateUtil.generatePolicyDescription(policy);
    // $NON-NLS-1$
    Assert.assertEquals("Requests that originate from the set of 2 configured IP address(es) will be denied access to the managed API.", policy.getDescription());
}
Also used : PolicyDefinitionTemplateBean(io.apiman.manager.api.beans.policies.PolicyDefinitionTemplateBean) PolicyDefinitionBean(io.apiman.manager.api.beans.policies.PolicyDefinitionBean) PolicyBean(io.apiman.manager.api.beans.policies.PolicyBean) Test(org.junit.Test)

Example 28 with PolicyBean

use of io.apiman.manager.api.beans.policies.PolicyBean in project apiman by apiman.

the class PolicyTemplateUtilTest method testGeneratePolicyDescription_nested2.

/**
 * Test method for {@link io.apiman.manager.api.core.util.PolicyTemplateUtil#generatePolicyDescription(io.apiman.manager.api.beans.policies.PolicyBean)}.
 * @throws Exception any exception
 */
@Test
public void testGeneratePolicyDescription_nested2() throws Exception {
    PolicyBean policy = new PolicyBean();
    PolicyDefinitionBean def = new PolicyDefinitionBean();
    // $NON-NLS-1$
    def.setId("nested2");
    PolicyDefinitionTemplateBean template = new PolicyDefinitionTemplateBean();
    // $NON-NLS-1$
    template.setTemplate("@{messages.index[0].value} @{messages.index[1].value}");
    def.getTemplates().add(template);
    policy.setDefinition(def);
    // $NON-NLS-1$
    policy.setConfiguration("{ \"messages\" : { \"index\" : [ { \"id\" : \"first\", \"value\" : \"Hello\" }, { \"id\" : \"second\", \"value\" : \"World\" } ] } }");
    PolicyTemplateUtil.generatePolicyDescription(policy);
    // $NON-NLS-1$
    Assert.assertEquals("Hello World", policy.getDescription());
}
Also used : PolicyDefinitionTemplateBean(io.apiman.manager.api.beans.policies.PolicyDefinitionTemplateBean) PolicyDefinitionBean(io.apiman.manager.api.beans.policies.PolicyDefinitionBean) PolicyBean(io.apiman.manager.api.beans.policies.PolicyBean) Test(org.junit.Test)

Example 29 with PolicyBean

use of io.apiman.manager.api.beans.policies.PolicyBean in project apiman by apiman.

the class PolicyTemplateUtilTest method testGeneratePolicyDescription_nested.

/**
 * Test method for {@link io.apiman.manager.api.core.util.PolicyTemplateUtil#generatePolicyDescription(io.apiman.manager.api.beans.policies.PolicyBean)}.
 * @throws Exception any exception
 */
@Test
public void testGeneratePolicyDescription_nested() throws Exception {
    PolicyBean policy = new PolicyBean();
    PolicyDefinitionBean def = new PolicyDefinitionBean();
    // $NON-NLS-1$
    def.setId("nested");
    PolicyDefinitionTemplateBean template = new PolicyDefinitionTemplateBean();
    // $NON-NLS-1$
    template.setTemplate("@{messages.messageOne}");
    def.getTemplates().add(template);
    policy.setDefinition(def);
    // $NON-NLS-1$
    policy.setConfiguration("{ \"messages\" : { \"messageOne\" : \"Hello World\" } }");
    PolicyTemplateUtil.generatePolicyDescription(policy);
    // $NON-NLS-1$
    Assert.assertEquals("Hello World", policy.getDescription());
}
Also used : PolicyDefinitionTemplateBean(io.apiman.manager.api.beans.policies.PolicyDefinitionTemplateBean) PolicyDefinitionBean(io.apiman.manager.api.beans.policies.PolicyDefinitionBean) PolicyBean(io.apiman.manager.api.beans.policies.PolicyBean) Test(org.junit.Test)

Example 30 with PolicyBean

use of io.apiman.manager.api.beans.policies.PolicyBean in project apiman by apiman.

the class PolicyTemplateUtilTest method testGeneratePolicyDescription_missingvar.

/**
 * Test method for {@link io.apiman.manager.api.core.util.PolicyTemplateUtil#generatePolicyDescription(io.apiman.manager.api.beans.policies.PolicyBean)}.
 * @throws Exception any exception
 */
@Test
public void testGeneratePolicyDescription_missingvar() throws Exception {
    PolicyBean policy = new PolicyBean();
    PolicyDefinitionBean def = new PolicyDefinitionBean();
    // $NON-NLS-1$
    def.setId("missingvar");
    PolicyDefinitionTemplateBean template = new PolicyDefinitionTemplateBean();
    // $NON-NLS-1$
    template.setTemplate("Template includes a missing var: @{missingVar}");
    def.getTemplates().add(template);
    policy.setDefinition(def);
    // $NON-NLS-1$
    policy.setConfiguration("{}");
    PolicyTemplateUtil.generatePolicyDescription(policy);
    // $NON-NLS-1$
    Assert.assertEquals("Template includes a missing var: null", policy.getDescription());
}
Also used : PolicyDefinitionTemplateBean(io.apiman.manager.api.beans.policies.PolicyDefinitionTemplateBean) PolicyDefinitionBean(io.apiman.manager.api.beans.policies.PolicyDefinitionBean) PolicyBean(io.apiman.manager.api.beans.policies.PolicyBean) Test(org.junit.Test)

Aggregations

PolicyBean (io.apiman.manager.api.beans.policies.PolicyBean)64 NewPolicyBean (io.apiman.manager.api.beans.policies.NewPolicyBean)31 StorageException (io.apiman.manager.api.core.exceptions.StorageException)30 UpdatePolicyBean (io.apiman.manager.api.beans.policies.UpdatePolicyBean)29 NotAuthorizedException (io.apiman.manager.api.rest.exceptions.NotAuthorizedException)22 Date (java.util.Date)22 OrganizationNotFoundException (io.apiman.manager.api.rest.exceptions.OrganizationNotFoundException)19 SystemErrorException (io.apiman.manager.api.rest.exceptions.SystemErrorException)19 GatewayAuthenticationException (io.apiman.manager.api.gateway.GatewayAuthenticationException)18 ApiNotFoundException (io.apiman.manager.api.rest.exceptions.ApiNotFoundException)18 ApiVersionNotFoundException (io.apiman.manager.api.rest.exceptions.ApiVersionNotFoundException)18 ClientVersionNotFoundException (io.apiman.manager.api.rest.exceptions.ClientVersionNotFoundException)18 GatewayNotFoundException (io.apiman.manager.api.rest.exceptions.GatewayNotFoundException)18 PlanNotFoundException (io.apiman.manager.api.rest.exceptions.PlanNotFoundException)18 PlanVersionNotFoundException (io.apiman.manager.api.rest.exceptions.PlanVersionNotFoundException)18 AbstractRestException (io.apiman.manager.api.rest.exceptions.AbstractRestException)17 ClientNotFoundException (io.apiman.manager.api.rest.exceptions.ClientNotFoundException)17 InvalidClientStatusException (io.apiman.manager.api.rest.exceptions.InvalidClientStatusException)17 InvalidNameException (io.apiman.manager.api.rest.exceptions.InvalidNameException)17 InvalidVersionException (io.apiman.manager.api.rest.exceptions.InvalidVersionException)17