示例#1
0
  public void testListTenants() {
    ServiceApi api =
        requestsSendResponses(
                keystoneAuthWithUsernameAndPasswordAndTenantName,
                responseWithKeystoneAccess,
                authenticatedGET().endpoint(endpoint + "/v2.0/tenants").build(),
                HttpResponse.builder()
                    .statusCode(200)
                    .payload(
                        payloadFromResourceWithContentType("/tenant_list.json", APPLICATION_JSON))
                    .build())
            .getServiceApi();
    Set<? extends Tenant> tenants = api.listTenants();
    assertNotNull(tenants);
    assertFalse(tenants.isEmpty());

    Set<Tenant> expected =
        ImmutableSet.of(
            Tenant.builder()
                .name("demo")
                .id("05d1dc7af71646deba64cfc17b81bec0")
                .enabled(true)
                .build(),
            Tenant.builder()
                .name("admin")
                .id("7aa2e17ec29f44d193c48feaba0852cc")
                .enabled(true)
                .build());

    assertEquals(tenants, expected);
  }
示例#2
0
 @Override
 @SelectJson("access")
 @Consumes(MediaType.APPLICATION_JSON)
 public Access expected() {
   return Access.builder()
       .token(
           Token.builder()
               .expires(
                   new SimpleDateFormatDateService().iso8601DateParse("2012-01-18T21:35:59.050Z"))
               .id("Auth_4f173437e4b013bee56d1007")
               .tenant(
                   Tenant.builder()
                       .id("40806637803162")
                       .name("[email protected]")
                       .build())
               .build())
       .user(
           User.builder()
               .id("36980896575174")
               .name("*****@*****.**")
               .roles(
                   Role.builder()
                       .id("00000000004022")
                       .serviceId("110")
                       .name("Admin")
                       .tenantId("40806637803162")
                       .build(),
                   Role.builder()
                       .id("00000000004024")
                       .serviceId("140")
                       .name("user")
                       .tenantId("40806637803162")
                       .build(),
                   Role.builder().id("00000000004004").serviceId("100").name("domainuser").build(),
                   Role.builder()
                       .id("00000000004016")
                       .serviceId("120")
                       .name("netadmin")
                       .tenantId("40806637803162")
                       .build())
               .build())
       .serviceCatalog(
           Service.builder()
               .name("Object Storage")
               .type("object-store")
               .endpoints(
                   Endpoint.builder()
                       .tenantId("40806637803162")
                       .publicURL(URI.create("https://objects.jclouds.org/v1.0/40806637803162"))
                       .adminURL(URI.create("https://objects.jclouds.org/v1.0/"))
                       .region("region-a.geo-1")
                       .versionId("1.0")
                       .build())
               .build(),
           Service.builder()
               .name("Identity")
               .type("identity")
               .endpoints(
                   Endpoint.builder()
                       .publicURL(URI.create("https://csnode.jclouds.org/v2.0/"))
                       .adminURL(URI.create("https://csnode.jclouds.org:35357/v2.0/"))
                       .region("region-a.geo-1")
                       .versionId("2.0")
                       .build())
               .build(),
           Service.builder()
               .name("Image Management")
               .type("image")
               .endpoints(
                   Endpoint.builder()
                       .tenantId("40806637803162")
                       .publicURL(URI.create("https://glance.jclouds.org:9292/v1.0"))
                       .region("az-1.region-a.geo-1")
                       .versionId("1.0")
                       .build())
               .build(),
           Service.builder()
               .name("Compute")
               .type("compute")
               .endpoints(
                   Endpoint.builder()
                       .tenantId("3456")
                       .publicURL(
                           URI.create(
                               "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456"))
                       .region("az-1.region-a.geo-1")
                       .versionId("1.1")
                       .build(),
                   Endpoint.builder()
                       .tenantId("3456")
                       .publicURL(
                           URI.create(
                               "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456"))
                       .region("az-2.region-a.geo-1")
                       .versionId("1.1")
                       .build(),
                   Endpoint.builder()
                       .tenantId("3456")
                       .publicURL(
                           URI.create(
                               "https://az-3.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456"))
                       .region("az-3.region-a.geo-1")
                       .versionId("1.1")
                       .build())
               .build())
       .build();
 }