Package org.jclouds.net.domain

Examples of org.jclouds.net.domain.IpPermission$Builder


      builder.ipProtocol(IpProtocol.TCP);
      builder.fromPort(10);
      builder.toPort(20);
      builder.cidrBlock("0.0.0.0/0");

      IpPermission perm = builder.build();

      SecurityGroup newGroup = securityGroupExtension.get().addIpPermission(perm, group);

      assertEquals(Iterables.getOnlyElement(newGroup.getIpPermissions()), perm,
              "Expecting IpPermission " + perm + " but group was " + newGroup);
View Full Code Here


      builder.ipProtocol(IpProtocol.TCP);
      builder.fromPort(10);
      builder.toPort(20);
      builder.cidrBlock("0.0.0.0/0");

      IpPermission perm = builder.build();

      SecurityGroup newGroup = securityGroupExtension.get().removeIpPermission(perm, group);

      assertEquals(Iterables.size(newGroup.getIpPermissions()), 0,
              "Group should have no permissions, but has " + Iterables.size(newGroup.getIpPermissions()));
View Full Code Here

      builder.ipProtocol(IpProtocol.TCP);
      builder.fromPort(50);
      builder.toPort(60);
      builder.cidrBlock("0.0.0.0/0");

      IpPermission perm = builder.build();

      SecurityGroup newGroup = securityGroupExtension.get().addIpPermission(IpProtocol.TCP,
                                                                            50,
                                                                            60,
                                                                            emptyMultimap(),
                                                                            ImmutableSet.of("0.0.0.0/0"),
                                                                            emptyStringSet(),
                                                                            group);

      assertTrue(newGroup.getIpPermissions().contains(perm));

      if (securityGroupExtension.get().supportsGroupIds()) {
         IpPermission.Builder secondBuilder = IpPermission.builder();
        
         int fromPort;
         int toPort;

         if (securityGroupExtension.get().supportsPortRangesForGroups()) {
            fromPort = 70;
            toPort = 80;
         } else {
            fromPort = 1;
            toPort = 65535;
         }
         secondBuilder.ipProtocol(IpProtocol.TCP);
         secondBuilder.fromPort(fromPort);
         secondBuilder.toPort(toPort);
         secondBuilder.groupId(group.getId());
        
         IpPermission secondPerm = secondBuilder.build();
        
         SecurityGroup secondNewGroup = securityGroupExtension.get().addIpPermission(IpProtocol.TCP,
                                                                                     fromPort,
                                                                                     toPort,
                                                                                     emptyMultimap(),
                                                                                     emptyStringSet(),
                                                                                     ImmutableSet.of(group.getId()),
                                                                                     newGroup);

         assertTrue(secondNewGroup.getIpPermissions().contains(secondPerm), "permissions for second group should contain "
                 + secondPerm + " but do not: " + secondNewGroup.getIpPermissions());
      }

      if (securityGroupExtension.get().supportsTenantIdGroupNamePairs()
              || securityGroupExtension.get().supportsTenantIdGroupIdPairs()) {
         IpPermission.Builder thirdBuilder = IpPermission.builder();

         int fromPort;
         int toPort;

         if (securityGroupExtension.get().supportsPortRangesForGroups()) {
            fromPort = 90;
            toPort = 100;
         } else {
            fromPort = 1;
            toPort = 65535;
         }
         thirdBuilder.ipProtocol(IpProtocol.TCP);
         thirdBuilder.fromPort(fromPort);
         thirdBuilder.toPort(toPort);
         if (securityGroupExtension.get().supportsTenantIdGroupIdPairs()) {
            thirdBuilder.tenantIdGroupNamePair(group.getOwnerId(), group.getProviderId());
         } else if (securityGroupExtension.get().supportsTenantIdGroupNamePairs()) {
            thirdBuilder.tenantIdGroupNamePair(group.getOwnerId(), group.getName());
         }

         IpPermission thirdPerm = thirdBuilder.build();

         SecurityGroup thirdNewGroup = securityGroupExtension.get().addIpPermission(IpProtocol.TCP,
                                                                                    fromPort,
                                                                                    toPort,
                                                                                    thirdPerm.getTenantIdGroupNamePairs(),
                                                                                    emptyStringSet(),
                                                                                    emptyStringSet(),
                                                                                    newGroup);

         assertTrue(thirdNewGroup.getIpPermissions().contains(thirdPerm));
View Full Code Here

              "Firewall " + getFwForTestSourceTags() + " should NOT contain the source range '0.0.0.0/0'.");
   }

   @Test
   public void testEqualsIpPermission() {
      IpPermission perm = IpPermission.builder().groupId("tag-1")
              .fromPort(1).toPort(10).ipProtocol(IpProtocol.TCP).build();

      assertTrue(equalsIpPermission(perm).apply(getFwForTestSourceTagsExact()),
              "Firewall " + getFwForTestSourceTagsExact() + " should match IpPermission " + perm + " but does not.");
   }
View Full Code Here

              "Firewall " + getFwForTestSourceTagsExact() + " should match IpPermission " + perm + " but does not.");
   }

   @Test
   public void testEqualsIpPermissionFails() {
      IpPermission perm = IpPermission.builder().groupId("tag-1")
              .fromPort(1).toPort(10).ipProtocol(IpProtocol.TCP).build();

      assertFalse(equalsIpPermission(perm).apply(getFwForTestSourceTags()),
              "Firewall " + getFwForTestSourceTags() + " should not match IpPermission " + perm + " but does.");
   }
View Full Code Here

              "Firewall " + getFwForTestSourceTags() + " should not match IpPermission " + perm + " but does.");
   }

   @Test
   public void testProvidesIpPermission() {
      IpPermission perm = IpPermission.builder().groupId("tag-1")
              .fromPort(1).toPort(10).ipProtocol(IpProtocol.TCP).build();

      assertTrue(providesIpPermission(perm).apply(getFwForTestSourceTagsExact()),
              "Firewall " + getFwForTestSourceTagsExact() + " should provide IpPermission " + perm + " but does not.");
View Full Code Here

              "Firewall " + getFwForTestSourceTags() + " should inexactly provide IpPermission " + perm + " but does not.");
   }

   @Test
   public void testProvidesIpPermissionFails() {
      IpPermission perm = IpPermission.builder().groupId("tag-1")
              .fromPort(1).toPort(10).ipProtocol(IpProtocol.TCP).build();

      assertFalse(providesIpPermission(perm).apply(fwForTest()),
              "Firewall " + fwForTest() + " should not provide IpPermission " + perm + " but does.");
   }
View Full Code Here

      InputStream is = getClass().getResourceAsStream("/describe_securitygroups.xml");

      Set<SecurityGroup> expected = ImmutableSet.of(
            new SecurityGroup(defaultRegion, "sg-3c6ef654", "WebServers", "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "Web Servers",
                  ImmutableSet.of(new IpPermission(IpProtocol.TCP, 80, 80, ImmutableMultimap.<String, String> of(),
                        ImmutableSet.<String> of(), ImmutableSet.of("0.0.0.0/0")))),
            new SecurityGroup(defaultRegion, "sg-867309ab", "RangedPortsBySource", "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "Group A",
                  ImmutableSet.of(new IpPermission(IpProtocol.TCP, 6000, 7000, ImmutableMultimap
                        .<String, String> of(), ImmutableSet.<String> of(), ImmutableSet.<String> of()))));

      DescribeSecurityGroupsResponseHandler handler = injector.getInstance(DescribeSecurityGroupsResponseHandler.class);
      addDefaultRegionToHandler(handler);
      Set<SecurityGroup> result = factory.create(handler).parse(is);
View Full Code Here

      userIdGroupPairs.put("UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "jclouds#cluster#world");

      Set<SecurityGroup> expected = ImmutableSet.of(
            new SecurityGroup(defaultRegion, "sg-3c6ef654", "jclouds#cluster#world", "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "Cluster",
                  ImmutableSet.of(
                        new IpPermission(IpProtocol.TCP, 22, 22, ImmutableMultimap.<String, String> of(),
                              ImmutableSet.<String> of(), ImmutableSet.of("0.0.0.0/0")),
                        new IpPermission(IpProtocol.ALL, -1, -1, userIdGroupPairs,
                              ImmutableSet.<String> of(), ImmutableSet.<String> of()))));

      DescribeSecurityGroupsResponseHandler handler = injector.getInstance(DescribeSecurityGroupsResponseHandler.class);
      addDefaultRegionToHandler(handler);
      Set<SecurityGroup> result = factory.create(handler).parse(is);
View Full Code Here

      }
      if (Iterables.size(groupIds) > 0) {
         ipBuilder.groupIds(groupIds);
      }

      IpPermission perm = ipBuilder.build();

      SecurityGroupBuilder builder = SecurityGroupBuilder.fromSecurityGroup(checkNotNull(group, "group"));

      builder.ipPermission(perm);
View Full Code Here

TOP

Related Classes of org.jclouds.net.domain.IpPermission$Builder

Copyright © 2018 www.massapicom. 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.