Package org.jclouds.net.domain

Examples of org.jclouds.net.domain.IpPermission


                                                         emptyStringSet(),
                                                         origGroup);

      assertEquals(1, newGroup.getIpPermissions().size());

      IpPermission newPerm = Iterables.getOnlyElement(newGroup.getIpPermissions());

      assertNotNull(newPerm);
      assertEquals(IpProtocol.TCP, newPerm.getIpProtocol());
      assertEquals(22, newPerm.getFromPort());
      assertEquals(40, newPerm.getToPort());
      assertEquals(1, newPerm.getCidrBlocks().size());
      assertTrue(newPerm.getCidrBlocks().contains("0.0.0.0/0"));
   }
View Full Code Here


      builder.ipProtocol(IpProtocol.TCP);
      builder.fromPort(22);
      builder.toPort(40);
      builder.tenantIdGroupNamePair("993194456877", "jclouds#some-group");

      IpPermission perm = builder.build();

      SecurityGroupExtension extension = requestsSendResponses(requestResponseMap.build()).getSecurityGroupExtension().get();

      SecurityGroupBuilder groupBuilder = new SecurityGroupBuilder();
      groupBuilder.id("jclouds#some-group");
      groupBuilder.providerId("sg-3c6ef654");
      groupBuilder.name("jclouds#some-group");
      groupBuilder.location(new LocationBuilder()
                            .scope(LocationScope.REGION)
                            .id(region)
                            .description("region")
                            .build());
      groupBuilder.ownerId("993194456877");
     
      SecurityGroup origGroup = groupBuilder.build();

      SecurityGroup newGroup = extension.addIpPermission(perm, origGroup);

      assertEquals(1, newGroup.getIpPermissions().size());

      IpPermission newPerm = Iterables.getOnlyElement(newGroup.getIpPermissions());

      assertNotNull(newPerm);
      assertEquals(IpProtocol.TCP, newPerm.getIpProtocol());
      assertEquals(22, newPerm.getFromPort());
      assertEquals(40, newPerm.getToPort());
      assertEquals(0, newPerm.getCidrBlocks().size());
      assertEquals(1, newPerm.getTenantIdGroupNamePairs().size());
      assertTrue(newPerm.getTenantIdGroupNamePairs().keySet().contains(origGroup.getOwnerId()));
      assertTrue(newPerm.getTenantIdGroupNamePairs().values().contains(origGroup.getName()));
   }
View Full Code Here

                                                         emptyStringSet(),
                                                         origGroup);

      assertEquals(1, newGroup.getIpPermissions().size());

      IpPermission newPerm = Iterables.getOnlyElement(newGroup.getIpPermissions());

      assertNotNull(newPerm);
      assertEquals(IpProtocol.TCP, newPerm.getIpProtocol());
      assertEquals(22, newPerm.getFromPort());
      assertEquals(40, newPerm.getToPort());
      assertEquals(0, newPerm.getCidrBlocks().size());
      assertEquals(1, newPerm.getTenantIdGroupNamePairs().size());
      assertTrue(newPerm.getTenantIdGroupNamePairs().keySet().contains(origGroup.getOwnerId()));
      assertTrue(newPerm.getTenantIdGroupNamePairs().values().contains(origGroup.getName()));
   }
View Full Code Here

      assertTrue(optGroup.isPresent());

      SecurityGroup group = optGroup.get();

      IpPermission portRangeIpPermission = createPortRangePermission();
      IpPermission singlePortIpPermission = createSinglePortPermission();

      Set<IpPermission> expectedPermissions = ImmutableSet.of(portRangeIpPermission, singlePortIpPermission);

      SecurityGroup onePermissionAdded = securityGroupExtension.get().addIpPermission(portRangeIpPermission, group);
      SecurityGroup twoPermissionsAdded = securityGroupExtension.get().addIpPermission(singlePortIpPermission,
View Full Code Here

      assertTrue(optGroup.isPresent());

      SecurityGroup group = optGroup.get();

      IpPermission portRangeIpPermission = createPortRangePermission();
      IpPermission singlePortIpPermission = createSinglePortPermission();

      SecurityGroup newGroup = securityGroupExtension.get().removeIpPermission(portRangeIpPermission, group);
      SecurityGroup emptyGroup = securityGroupExtension.get().removeIpPermission(singlePortIpPermission, newGroup);

      assertEquals(Iterables.size(emptyGroup.getIpPermissions()), 0, "Group should have no permissions, but has "
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

      Optional<SecurityGroup> optGroup = getGroup(securityGroupExtension.get());
      assertTrue(optGroup.isPresent());
      SecurityGroup group = optGroup.get();

      IpPermission cidrExclusionPermission = createCidrExclusionPermission();
      Set<IpPermission> expectedPermissions = ImmutableSet.of(cidrExclusionPermission);

      SecurityGroup securityGroupWithExclusion = securityGroupExtension.get().addIpPermission(cidrExclusionPermission, group);

      assertTrue(securityGroupWithExclusion.getIpPermissions().containsAll(expectedPermissions));
View Full Code Here

      Optional<SecurityGroup> optGroup = getGroup(securityGroupExtension.get());
      assertTrue(optGroup.isPresent());
      SecurityGroup group = optGroup.get();

      IpPermission cidrExclusionPermission = createCidrExclusionPermission();

      SecurityGroup emptyGroup = securityGroupExtension.get().removeIpPermission(cidrExclusionPermission, group);

      assertFalse(emptyGroup.getIpPermissions().contains(cidrExclusionPermission));
   }
View Full Code Here

      }
      if (!Iterables.isEmpty(groupIds)) {
         ipBuilder.groupIds(groupIds);
      }

      IpPermission perm = ipBuilder.build();

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

      builder.ipPermission(perm);
View Full Code Here

      }
      if (!Iterables.isEmpty(groupIds)) {
         ipBuilder.groupIds(groupIds);
      }

      IpPermission perm = ipBuilder.build();

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

      builder.ipPermissions();
View Full Code Here

TOP

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

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.