Examples of IngressRule


Examples of org.jclouds.cloudstack.domain.IngressRule

            return input.getId() == group.getId();
         }

      });

      IngressRule ICMPPingRule = Iterables.find(group.getIngressRules(), new Predicate<IngressRule>() {

         @Override
         public boolean apply(IngressRule input) {
            return "icmp".equals(input.getProtocol());
         }

      });

      assert ICMPPingRule.getId() != null : ICMPPingRule;
      assert "icmp".equals(ICMPPingRule.getProtocol()) : ICMPPingRule;
      assert ICMPPingRule.getStartPort() == -1 : ICMPPingRule;
      assert ICMPPingRule.getEndPort() == -1 : ICMPPingRule;
      assert ICMPPingRule.getICMPCode() == 0 : ICMPPingRule;
      assert ICMPPingRule.getICMPType() == 8 : ICMPPingRule;
      assert ICMPPingRule.getAccount() == null : ICMPPingRule;
      assert ICMPPingRule.getSecurityGroupName() == null : ICMPPingRule;
      assert cidr.equals(ICMPPingRule.getCIDR()) : ICMPPingRule;

      IngressRule SSHRule = Iterables.find(group.getIngressRules(), new Predicate<IngressRule>() {

         @Override
         public boolean apply(IngressRule input) {
            return "tcp".equals(input.getProtocol());
         }

      });

      assert SSHRule.getId() != null : SSHRule;
      assert "tcp".equals(SSHRule.getProtocol()) : SSHRule;
      assert SSHRule.getStartPort() == 22 : SSHRule;
      assert SSHRule.getEndPort() == 22 : SSHRule;
      assert SSHRule.getICMPCode() == -1 : SSHRule;
      assert SSHRule.getICMPType() == -1 : SSHRule;
      assert SSHRule.getAccount() == null : SSHRule;
      assert SSHRule.getSecurityGroupName() == null : SSHRule;
      assert cidr.equals(SSHRule.getCIDR()) : SSHRule;

   }
View Full Code Here

Examples of org.jclouds.cloudstack.domain.IngressRule

            return input.getId() == group.getId();
         }

      });

      IngressRule ICMPPingRule = Iterables.find(group.getIngressRules(), new Predicate<IngressRule>() {

         @Override
         public boolean apply(IngressRule input) {
            return "icmp".equals(input.getProtocol());
         }

      });

      assert ICMPPingRule.getId() != null : ICMPPingRule;
      assert "icmp".equals(ICMPPingRule.getProtocol()) : ICMPPingRule;
      assert ICMPPingRule.getStartPort() == -1 : ICMPPingRule;
      assert ICMPPingRule.getEndPort() == -1 : ICMPPingRule;
      assert ICMPPingRule.getICMPCode() == 0 : ICMPPingRule;
      assert ICMPPingRule.getICMPType() == 8 : ICMPPingRule;
      assert ICMPPingRule.getAccount() == null : ICMPPingRule;
      assert ICMPPingRule.getSecurityGroupName() == null : ICMPPingRule;
      assert cidr.equals(ICMPPingRule.getCIDR()) : ICMPPingRule;

      IngressRule SSHRule = Iterables.find(group.getIngressRules(), new Predicate<IngressRule>() {

         @Override
         public boolean apply(IngressRule input) {
            return "tcp".equals(input.getProtocol());
         }

      });

      assert SSHRule.getId() != null : SSHRule;
      assert "tcp".equals(SSHRule.getProtocol()) : SSHRule;
      assert SSHRule.getStartPort() == 22 : SSHRule;
      assert SSHRule.getEndPort() == 22 : SSHRule;
      assert SSHRule.getICMPCode() == -1 : SSHRule;
      assert SSHRule.getICMPType() == -1 : SSHRule;
      assert SSHRule.getAccount() == null : SSHRule;
      assert SSHRule.getSecurityGroupName() == null : SSHRule;
      assert cidr.equals(SSHRule.getCIDR()) : SSHRule;

   }
View Full Code Here

Examples of org.jclouds.cloudstack.domain.IngressRule

public class ConversionsTest {

    @Test
    public void testConvertIngressRuleToRuleICMP() throws Exception {
        final IngressRule ingressRule = IngressRule.builder()
            .id("rule1")
            .protocol("icmp")
            .ICMPCode(SecurityGroups.DEFAULT_ICMP_CODE)
            .ICMPType(SecurityGroups.DEFAULT_ICMP_TYPE)
            .CIDR("10.0.0.0/24")
            .build();

        Rule rule = ConvertIngressRuleToRule.FUNCTION.apply(ingressRule);
        assertThat(rule.getProtocol()).isEqualTo(Protocol.ICMP);
        assertThat(rule.getCidr()).isEqualTo(ingressRule.getCIDR());
    }
View Full Code Here

Examples of org.jclouds.cloudstack.domain.IngressRule

        assertThat(rule.getCidr()).isEqualTo(ingressRule.getCIDR());
    }

    @Test
    public void testConvertSinglePortRangeIngressRuleToRule() throws Exception {
        final IngressRule ingressRule = IngressRule.builder()
            .id("rule1")
            .protocol("tcp")
            .startPort(22)
            .endPort(22)
            .CIDR("0.0.0.1/24")
            .build();

        Rule rule = ConvertIngressRuleToRule.FUNCTION.apply(ingressRule);
        assertThat(rule.getProtocol()).isEqualTo(Protocol.TCP);
        assertThat(rule.getCidr()).isEqualTo(ingressRule.getCIDR());
        assertThat(rule.getPorts().lowerEndpoint()).isEqualTo(ingressRule.getStartPort());
        assertThat(rule.getPorts().upperEndpoint()).isEqualTo(ingressRule.getEndPort());
    }
View Full Code Here

Examples of org.jclouds.cloudstack.domain.IngressRule

   private static final IngressRuleToIpPermission ruleConverter = new IngressRuleToIpPermission();
  
   @Test
   public void testApply() {
      IngressRule ruleToConvert = IngressRule.builder()
         .id("some-id")
         .account("some-account")
         .securityGroupName("some-group-name")
         .protocol(IpProtocol.TCP.toString())
         .startPort(10)
View Full Code Here

Examples of org.jclouds.cloudstack.domain.IngressRule

*/
public class IngressRuleToIpPermissionTest {

   @Test
   public void testApplyWithTCP() {
      IngressRule ruleToConvert = IngressRule.builder()
         .id("some-id")
         .account("some-account")
         .securityGroupName("some-group-name")
         .protocol(IpProtocol.TCP.toString())
         .startPort(10)
         .endPort(20)
         .CIDR("0.0.0.0/0")
         .build();

      IngressRuleToIpPermission converter = new IngressRuleToIpPermission();

      IpPermission convertedPerm = converter.apply(ruleToConvert);

      assertEquals(convertedPerm.getIpProtocol(), IpProtocol.fromValue(ruleToConvert.getProtocol()));
      assertEquals(convertedPerm.getFromPort(), ruleToConvert.getStartPort());
      assertEquals(convertedPerm.getToPort(), ruleToConvert.getEndPort());
      assertEquals(convertedPerm.getCidrBlocks(), ImmutableSet.of("0.0.0.0/0"));
      assertTrue(convertedPerm.getTenantIdGroupNamePairs().size() == 1);
      assertTrue(convertedPerm.getGroupIds().size() == 0);
   }
View Full Code Here

Examples of org.jclouds.cloudstack.domain.IngressRule

            return input.getId() == group.getId();
         }

      });

      IngressRule ICMPPingRule = Iterables.find(group.getIngressRules(), new Predicate<IngressRule>() {

         @Override
         public boolean apply(IngressRule input) {
            return "icmp".equals(input.getProtocol());
         }

      });

      assert ICMPPingRule.getId() != null : ICMPPingRule;
      assert "icmp".equals(ICMPPingRule.getProtocol()) : ICMPPingRule;
      assert ICMPPingRule.getStartPort() == -1 : ICMPPingRule;
      assert ICMPPingRule.getEndPort() == -1 : ICMPPingRule;
      assert ICMPPingRule.getICMPCode() == 0 : ICMPPingRule;
      assert ICMPPingRule.getICMPType() == 8 : ICMPPingRule;
      assert ICMPPingRule.getAccount() == null : ICMPPingRule;
      assert ICMPPingRule.getSecurityGroupName() == null : ICMPPingRule;
      assert cidr.equals(ICMPPingRule.getCIDR()) : ICMPPingRule;

      IngressRule SSHRule = Iterables.find(group.getIngressRules(), new Predicate<IngressRule>() {

         @Override
         public boolean apply(IngressRule input) {
            return "tcp".equals(input.getProtocol());
         }

      });

      assert SSHRule.getId() != null : SSHRule;
      assert "tcp".equals(SSHRule.getProtocol()) : SSHRule;
      assert SSHRule.getStartPort() == 22 : SSHRule;
      assert SSHRule.getEndPort() == 22 : SSHRule;
      assert SSHRule.getICMPCode() == -1 : SSHRule;
      assert SSHRule.getICMPType() == -1 : SSHRule;
      assert SSHRule.getAccount() == null : SSHRule;
      assert SSHRule.getSecurityGroupName() == null : SSHRule;
      assert cidr.equals(SSHRule.getCIDR()) : SSHRule;

   }
View Full Code Here

Examples of org.jclouds.cloudstack.domain.IngressRule

            return input.getId() == group.getId();
         }

      });

      IngressRule ICMPPingRule = Iterables.find(group.getIngressRules(), new Predicate<IngressRule>() {

         @Override
         public boolean apply(IngressRule input) {
            return "icmp".equals(input.getProtocol());
         }

      });

      assert ICMPPingRule.getId() != null : ICMPPingRule;
      assert "icmp".equals(ICMPPingRule.getProtocol()) : ICMPPingRule;
      assert ICMPPingRule.getStartPort() == -1 : ICMPPingRule;
      assert ICMPPingRule.getEndPort() == -1 : ICMPPingRule;
      assert ICMPPingRule.getICMPCode() == 0 : ICMPPingRule;
      assert ICMPPingRule.getICMPType() == 8 : ICMPPingRule;
      assert ICMPPingRule.getAccount() == null : ICMPPingRule;
      assert ICMPPingRule.getSecurityGroupName() == null : ICMPPingRule;
      assert cidr.equals(ICMPPingRule.getCIDR()) : ICMPPingRule;

      IngressRule SSHRule = Iterables.find(group.getIngressRules(), new Predicate<IngressRule>() {

         @Override
         public boolean apply(IngressRule input) {
            return "tcp".equals(input.getProtocol());
         }

      });

      assert SSHRule.getId() != null : SSHRule;
      assert "tcp".equals(SSHRule.getProtocol()) : SSHRule;
      assert SSHRule.getStartPort() == 22 : SSHRule;
      assert SSHRule.getEndPort() == 22 : SSHRule;
      assert SSHRule.getICMPCode() == -1 : SSHRule;
      assert SSHRule.getICMPType() == -1 : SSHRule;
      assert SSHRule.getAccount() == null : SSHRule;
      assert SSHRule.getSecurityGroupName() == null : SSHRule;
      assert cidr.equals(SSHRule.getCIDR()) : SSHRule;

   }
View Full Code Here

Examples of org.jclouds.cloudstack.domain.IngressRule

   private static final IngressRuleToIpPermission ruleConverter = new IngressRuleToIpPermission();
  
   @Test
   public void testApply() {
      IngressRule ruleToConvert = IngressRule.builder()
         .id("some-id")
         .account("some-account")
         .securityGroupName("some-group-name")
         .protocol(IpProtocol.TCP.toString())
         .startPort(10)
View Full Code Here

Examples of org.jclouds.cloudstack.domain.IngressRule

*/
public class IngressRuleToIpPermissionTest {

   @Test
   public void testApplyWithTCP() {
      IngressRule ruleToConvert = IngressRule.builder()
         .id("some-id")
         .account("some-account")
         .securityGroupName("some-group-name")
         .protocol(IpProtocol.TCP.toString())
         .startPort(10)
         .endPort(20)
         .CIDR("0.0.0.0/0")
         .build();

      IngressRuleToIpPermission converter = new IngressRuleToIpPermission();

      IpPermission convertedPerm = converter.apply(ruleToConvert);

      assertEquals(convertedPerm.getIpProtocol(), IpProtocol.fromValue(ruleToConvert.getProtocol()));
      assertEquals(convertedPerm.getFromPort(), ruleToConvert.getStartPort());
      assertEquals(convertedPerm.getToPort(), ruleToConvert.getEndPort());
      assertEquals(convertedPerm.getCidrBlocks(), ImmutableSet.of("0.0.0.0/0"));
      assertEquals(convertedPerm.getTenantIdGroupNamePairs().size(), 1);
      assertEquals(convertedPerm.getGroupIds().size(), 0);
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.