mirror of https://github.com/apache/jclouds.git
Merge branch 'master' of github.com:jclouds/jclouds into cloudstack-qa
This commit is contained in:
commit
1a9ea265cd
|
@ -25,6 +25,7 @@ import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata;
|
import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata;
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.features.ServiceAsyncClient;
|
||||||
import org.jclouds.openstack.keystone.v2_0.features.TenantAsyncClient;
|
import org.jclouds.openstack.keystone.v2_0.features.TenantAsyncClient;
|
||||||
import org.jclouds.openstack.keystone.v2_0.features.TokenAsyncClient;
|
import org.jclouds.openstack.keystone.v2_0.features.TokenAsyncClient;
|
||||||
import org.jclouds.openstack.keystone.v2_0.features.UserAsyncClient;
|
import org.jclouds.openstack.keystone.v2_0.features.UserAsyncClient;
|
||||||
|
@ -33,6 +34,7 @@ import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
import org.jclouds.rest.annotations.SelectJson;
|
import org.jclouds.rest.annotations.SelectJson;
|
||||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,23 +56,29 @@ public interface KeystoneAsyncClient {
|
||||||
@Path("/v{" + Constants.PROPERTY_API_VERSION + "}/")
|
@Path("/v{" + Constants.PROPERTY_API_VERSION + "}/")
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
ListenableFuture<ApiMetadata> getApiMetadata();
|
ListenableFuture<ApiMetadata> getApiMetadata();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see KeystoneClient#getServiceClient()
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
ServiceAsyncClient getServiceClient();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see KeystoneClient#getTokenClient()
|
* @see KeystoneClient#getTokenClient()
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
TokenAsyncClient getTokenClient();
|
Optional<TokenAsyncClient> getTokenClient();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see KeystoneClient#getUserClient()
|
* @see KeystoneClient#getUserClient()
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
UserAsyncClient getUserClient();
|
Optional<UserAsyncClient> getUserClient();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see KeystoneClient#getTenantClient()
|
* @see KeystoneClient#getTenantClient()
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
TenantAsyncClient getTenantClient();
|
Optional<TenantAsyncClient> getTenantClient();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,11 +22,14 @@ import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata;
|
import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata;
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.features.ServiceClient;
|
||||||
import org.jclouds.openstack.keystone.v2_0.features.TenantClient;
|
import org.jclouds.openstack.keystone.v2_0.features.TenantClient;
|
||||||
import org.jclouds.openstack.keystone.v2_0.features.TokenClient;
|
import org.jclouds.openstack.keystone.v2_0.features.TokenClient;
|
||||||
import org.jclouds.openstack.keystone.v2_0.features.UserClient;
|
import org.jclouds.openstack.keystone.v2_0.features.UserClient;
|
||||||
import org.jclouds.rest.annotations.Delegate;
|
import org.jclouds.rest.annotations.Delegate;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to Openstack keystone resources via their REST API.
|
* Provides access to Openstack keystone resources via their REST API.
|
||||||
* <p/>
|
* <p/>
|
||||||
|
@ -44,23 +47,29 @@ public interface KeystoneClient {
|
||||||
* @return the requested information
|
* @return the requested information
|
||||||
*/
|
*/
|
||||||
ApiMetadata getApiMetadata();
|
ApiMetadata getApiMetadata();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides synchronous access to Token features
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
ServiceClient getServiceClient();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Token features
|
* Provides synchronous access to Token features
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
TokenClient getTokenClient();
|
Optional<TokenClient> getTokenClient();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to User features
|
* Provides synchronous access to User features
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
UserClient getUserClient();
|
Optional<UserClient> getUserClient();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Tenant features
|
* Provides synchronous access to Tenant features
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
TenantClient getTenantClient();
|
Optional<TenantClient> getTenantClient();
|
||||||
}
|
}
|
|
@ -18,27 +18,45 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.keystone.v2_0.config;
|
package org.jclouds.openstack.keystone.v2_0.config;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.http.HttpErrorHandler;
|
import org.jclouds.http.HttpErrorHandler;
|
||||||
import org.jclouds.http.annotation.ClientError;
|
import org.jclouds.http.annotation.ClientError;
|
||||||
import org.jclouds.http.annotation.Redirection;
|
import org.jclouds.http.annotation.Redirection;
|
||||||
import org.jclouds.http.annotation.ServerError;
|
import org.jclouds.http.annotation.ServerError;
|
||||||
import org.jclouds.openstack.keystone.v2_0.KeystoneAsyncClient;
|
import org.jclouds.openstack.keystone.v2_0.KeystoneAsyncClient;
|
||||||
import org.jclouds.openstack.keystone.v2_0.KeystoneClient;
|
import org.jclouds.openstack.keystone.v2_0.KeystoneClient;
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.features.ServiceAsyncClient;
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.features.ServiceClient;
|
||||||
import org.jclouds.openstack.keystone.v2_0.features.TenantAsyncClient;
|
import org.jclouds.openstack.keystone.v2_0.features.TenantAsyncClient;
|
||||||
import org.jclouds.openstack.keystone.v2_0.features.TenantClient;
|
import org.jclouds.openstack.keystone.v2_0.features.TenantClient;
|
||||||
import org.jclouds.openstack.keystone.v2_0.features.TokenAsyncClient;
|
import org.jclouds.openstack.keystone.v2_0.features.TokenAsyncClient;
|
||||||
import org.jclouds.openstack.keystone.v2_0.features.TokenClient;
|
import org.jclouds.openstack.keystone.v2_0.features.TokenClient;
|
||||||
import org.jclouds.openstack.keystone.v2_0.features.UserAsyncClient;
|
import org.jclouds.openstack.keystone.v2_0.features.UserAsyncClient;
|
||||||
import org.jclouds.openstack.keystone.v2_0.features.UserClient;
|
import org.jclouds.openstack.keystone.v2_0.features.UserClient;
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.functions.PresentWhenAdminURLExistsForIdentityService;
|
||||||
import org.jclouds.openstack.keystone.v2_0.handlers.KeystoneErrorHandler;
|
import org.jclouds.openstack.keystone.v2_0.handlers.KeystoneErrorHandler;
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.suppliers.RegionIdToAdminURIFromAccessForTypeAndVersion;
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.suppliers.RegionIdToAdminURISupplier;
|
||||||
|
import org.jclouds.openstack.v2_0.ServiceType;
|
||||||
|
import org.jclouds.openstack.v2_0.services.Identity;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.config.RestClientModule;
|
import org.jclouds.rest.config.RestClientModule;
|
||||||
|
import org.jclouds.rest.functions.ImplicitOptionalConverter;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.base.Suppliers;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
import com.google.inject.util.Modules;
|
import com.google.inject.AbstractModule;
|
||||||
|
import com.google.inject.Provides;
|
||||||
|
import com.google.inject.assistedinject.FactoryModuleBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the Keystone connection.
|
* Configures the Keystone connection.
|
||||||
|
@ -46,17 +64,19 @@ import com.google.inject.util.Modules;
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
*/
|
*/
|
||||||
@ConfiguresRestClient
|
@ConfiguresRestClient
|
||||||
public class KeystoneRestClientModule<S extends KeystoneClient, A extends KeystoneAsyncClient> extends RestClientModule<S, A> {
|
public class KeystoneRestClientModule<S extends KeystoneClient, A extends KeystoneAsyncClient> extends
|
||||||
|
RestClientModule<S, A> {
|
||||||
|
|
||||||
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()
|
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()
|
||||||
.put(TokenClient.class, TokenAsyncClient.class)
|
.put(ServiceClient.class, ServiceAsyncClient.class)
|
||||||
.put(UserClient.class, UserAsyncClient.class)
|
.put(TokenClient.class, TokenAsyncClient.class)
|
||||||
.put(TenantClient.class, TenantAsyncClient.class)
|
.put(UserClient.class, UserAsyncClient.class)
|
||||||
.build();
|
.put(TenantClient.class, TenantAsyncClient.class).build();
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public KeystoneRestClientModule() {
|
public KeystoneRestClientModule() {
|
||||||
super((TypeToken) TypeToken.of(KeystoneClient.class), (TypeToken) TypeToken.of(KeystoneAsyncClient.class), DELEGATE_MAP);
|
super((TypeToken) TypeToken.of(KeystoneClient.class), (TypeToken) TypeToken.of(KeystoneAsyncClient.class),
|
||||||
|
DELEGATE_MAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected KeystoneRestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType,
|
protected KeystoneRestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType,
|
||||||
|
@ -72,10 +92,36 @@ public class KeystoneRestClientModule<S extends KeystoneClient, A extends Keysto
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void installLocations() {
|
protected void installLocations() {
|
||||||
install(new KeystoneAuthenticationModule(Modules.EMPTY_MODULE));
|
install(new KeystoneAuthenticationModule(new KeystoneAdminURLModule()));
|
||||||
super.installLocations();
|
super.installLocations();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class KeystoneAdminURLModule extends AbstractModule {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
bind(ImplicitOptionalConverter.class).to(PresentWhenAdminURLExistsForIdentityService.class);
|
||||||
|
install(new FactoryModuleBuilder().implement(RegionIdToAdminURISupplier.class,
|
||||||
|
RegionIdToAdminURIFromAccessForTypeAndVersion.class).build(RegionIdToAdminURISupplier.Factory.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
// return any identity url.
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
@Identity
|
||||||
|
protected Supplier<URI> provideStorageUrl(RegionIdToAdminURISupplier.Factory factory,
|
||||||
|
@Named(KeystoneProperties.VERSION) String version) {
|
||||||
|
return Suppliers.compose(new Function<Map<String, Supplier<URI>>, URI>() {
|
||||||
|
|
||||||
|
//TODO: throw a nice error when there's nothing here
|
||||||
|
@Override
|
||||||
|
public URI apply(Map<String, Supplier<URI>> input) {
|
||||||
|
return Iterables.getLast(input.values()).get();
|
||||||
|
}
|
||||||
|
}, factory.createForApiTypeAndVersion(ServiceType.IDENTITY, version));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void bindErrorHandlers() {
|
protected void bindErrorHandlers() {
|
||||||
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(KeystoneErrorHandler.class);
|
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(KeystoneErrorHandler.class);
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.openstack.keystone.v2_0.features;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
|
import javax.ws.rs.QueryParam;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
import org.jclouds.Constants;
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
||||||
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
|
import org.jclouds.rest.annotations.SelectJson;
|
||||||
|
import org.jclouds.rest.annotations.SkipEncoding;
|
||||||
|
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||||
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides asynchronous access to Service via their REST API.
|
||||||
|
* <p/>
|
||||||
|
*
|
||||||
|
* @see ServiceClient
|
||||||
|
* @see <a href=
|
||||||
|
* "http://docs.openstack.org/api/openstack-identity-service/2.0/content/Service_API_Client_Operations.html"
|
||||||
|
* />
|
||||||
|
* @author Adam Lowe
|
||||||
|
*/
|
||||||
|
@Path("/v{" + Constants.PROPERTY_API_VERSION + "}")
|
||||||
|
@SkipEncoding( { '/', '=' })
|
||||||
|
public interface ServiceAsyncClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ServiceClient#listTenants()
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@SelectJson("tenants")
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@Path("/tenants")
|
||||||
|
@RequestFilters(AuthenticateRequest.class)
|
||||||
|
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<Set<Tenant>> listTenants();
|
||||||
|
|
||||||
|
/** @see ServiceClient#getTenant(String) */
|
||||||
|
@GET
|
||||||
|
@SelectJson("tenant")
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@Path("/tenants/{tenantId}")
|
||||||
|
@RequestFilters(AuthenticateRequest.class)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<Tenant> getTenant(@PathParam("tenantId") String tenantId);
|
||||||
|
|
||||||
|
/** @see ServiceClient#getTenantByName(String) */
|
||||||
|
@GET
|
||||||
|
@SelectJson("tenant")
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@Path("/tenants")
|
||||||
|
@RequestFilters(AuthenticateRequest.class)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<Tenant> getTenantByName(@QueryParam("name") String tenantName);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.openstack.keystone.v2_0.features;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides synchronous access to the KeyStone Tenant API.
|
||||||
|
* <p/>
|
||||||
|
*
|
||||||
|
* @author Adam Lowe
|
||||||
|
* @see ServiceAsyncClient
|
||||||
|
* @see <a href=
|
||||||
|
* "http://docs.openstack.org/api/openstack-identity-service/2.0/content/Service_API_Client_Operations.html"
|
||||||
|
* />
|
||||||
|
*/
|
||||||
|
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
|
||||||
|
public interface ServiceClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The operation returns a list of tenants which the current token provides access to.
|
||||||
|
*/
|
||||||
|
Set<Tenant> listTenants();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve information about a tenant, by tenant ID
|
||||||
|
*
|
||||||
|
* @return the information about the tenant
|
||||||
|
*/
|
||||||
|
Tenant getTenant(String tenantId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve information about a tenant, by tenant name
|
||||||
|
* <p/>
|
||||||
|
* NOTE: currently not working in openstack ( https://bugs.launchpad.net/keystone/+bug/956687 )
|
||||||
|
*
|
||||||
|
* @return the information about the tenant
|
||||||
|
*/
|
||||||
|
Tenant getTenantByName(String tenantName);
|
||||||
|
}
|
|
@ -27,9 +27,9 @@ import javax.ws.rs.PathParam;
|
||||||
import javax.ws.rs.QueryParam;
|
import javax.ws.rs.QueryParam;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
|
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
|
||||||
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
||||||
|
import org.jclouds.openstack.v2_0.services.Identity;
|
||||||
import org.jclouds.rest.annotations.ExceptionParser;
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
import org.jclouds.rest.annotations.RequestFilters;
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
import org.jclouds.rest.annotations.SelectJson;
|
import org.jclouds.rest.annotations.SelectJson;
|
||||||
|
@ -49,7 +49,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
* />
|
* />
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
*/
|
*/
|
||||||
@Path("/v{" + Constants.PROPERTY_API_VERSION + "}")
|
@org.jclouds.rest.annotations.Endpoint(Identity.class)
|
||||||
@SkipEncoding( { '/', '=' })
|
@SkipEncoding( { '/', '=' })
|
||||||
public interface TenantAsyncClient {
|
public interface TenantAsyncClient {
|
||||||
|
|
||||||
|
|
|
@ -27,11 +27,11 @@ import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.Endpoint;
|
import org.jclouds.openstack.keystone.v2_0.domain.Endpoint;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.Token;
|
import org.jclouds.openstack.keystone.v2_0.domain.Token;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.User;
|
import org.jclouds.openstack.keystone.v2_0.domain.User;
|
||||||
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
||||||
|
import org.jclouds.openstack.v2_0.services.Identity;
|
||||||
import org.jclouds.rest.annotations.ExceptionParser;
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
import org.jclouds.rest.annotations.RequestFilters;
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
import org.jclouds.rest.annotations.SelectJson;
|
import org.jclouds.rest.annotations.SelectJson;
|
||||||
|
@ -52,8 +52,8 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
* />
|
* />
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
*/
|
*/
|
||||||
@Path("/v{" + Constants.PROPERTY_API_VERSION + "}")
|
|
||||||
@SkipEncoding({ '/', '=' })
|
@SkipEncoding({ '/', '=' })
|
||||||
|
@org.jclouds.rest.annotations.Endpoint(Identity.class)
|
||||||
public interface TokenAsyncClient {
|
public interface TokenAsyncClient {
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,10 +27,10 @@ import javax.ws.rs.PathParam;
|
||||||
import javax.ws.rs.QueryParam;
|
import javax.ws.rs.QueryParam;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.Role;
|
import org.jclouds.openstack.keystone.v2_0.domain.Role;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.User;
|
import org.jclouds.openstack.keystone.v2_0.domain.User;
|
||||||
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
||||||
|
import org.jclouds.openstack.v2_0.services.Identity;
|
||||||
import org.jclouds.rest.annotations.ExceptionParser;
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
import org.jclouds.rest.annotations.RequestFilters;
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
import org.jclouds.rest.annotations.SelectJson;
|
import org.jclouds.rest.annotations.SelectJson;
|
||||||
|
@ -50,7 +50,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
* />
|
* />
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
*/
|
*/
|
||||||
@Path("/v{" + Constants.PROPERTY_API_VERSION + "}")
|
@org.jclouds.rest.annotations.Endpoint(Identity.class)
|
||||||
@SkipEncoding({ '/', '=' })
|
@SkipEncoding({ '/', '=' })
|
||||||
public interface UserAsyncClient {
|
public interface UserAsyncClient {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.openstack.keystone.v2_0.functions;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.internal.ClassMethodArgsAndReturnVal;
|
||||||
|
import org.jclouds.rest.functions.ImplicitOptionalConverter;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class PresentWhenAdminURLExistsForIdentityService implements ImplicitOptionalConverter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Object> apply(ClassMethodArgsAndReturnVal input) {
|
||||||
|
//TODO: log and return absent when the admin url for identity service isn't available
|
||||||
|
return Optional.of(input.getReturnVal());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "presentWhenAdminURLExistsForIdentityService()";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.openstack.v2_0.services;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import javax.inject.Qualifier;
|
||||||
|
|
||||||
|
import org.jclouds.openstack.v2_0.ServiceType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identity Service (Keystone)
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
* @see <a href="http://docs.openstack.org/api/openstack-typeentity-service/2.0/content/Identity-Service-Concepts-e1362.html"
|
||||||
|
* />
|
||||||
|
* @see ServiceType#IMAGE
|
||||||
|
*/
|
||||||
|
@Retention(value = RetentionPolicy.RUNTIME)
|
||||||
|
@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
|
||||||
|
@Qualifier
|
||||||
|
public @interface Identity {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,112 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 1.1 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-1.1
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.openstack.keystone.v2_0.features;
|
||||||
|
|
||||||
|
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.assertFalse;
|
||||||
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
import static org.testng.Assert.assertNull;
|
||||||
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.KeystoneClient;
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneRestClientExpectTest;
|
||||||
|
import org.jclouds.rest.AuthorizationException;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests parsing and Guice wiring of ServiceClient
|
||||||
|
*
|
||||||
|
* @author Adam Lowe
|
||||||
|
*/
|
||||||
|
@Test(testName = "ServiceClientExpectTest")
|
||||||
|
public class ServiceClientExpectTest extends BaseKeystoneRestClientExpectTest<KeystoneClient> {
|
||||||
|
|
||||||
|
public void testListTenants() {
|
||||||
|
ServiceClient client = requestsSendResponses(
|
||||||
|
keystoneAuthWithUsernameAndPassword,
|
||||||
|
responseWithKeystoneAccess,
|
||||||
|
standardRequestBuilder(endpoint + "/v2.0/tenants").build(),
|
||||||
|
standardResponseBuilder(200).payload(
|
||||||
|
payloadFromResourceWithContentType("/tenant_list.json", APPLICATION_JSON)).build())
|
||||||
|
.getServiceClient();
|
||||||
|
Set<Tenant> tenants = client.listTenants();
|
||||||
|
assertNotNull(tenants);
|
||||||
|
assertFalse(tenants.isEmpty());
|
||||||
|
|
||||||
|
Set<Tenant> expected = ImmutableSet.of(Tenant.builder().name("demo").id("05d1dc7af71646deba64cfc17b81bec0")
|
||||||
|
.build(), Tenant.builder().name("admin").id("7aa2e17ec29f44d193c48feaba0852cc").build());
|
||||||
|
|
||||||
|
assertEquals(tenants, expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testListTenantsFailNotFound() {
|
||||||
|
ServiceClient client = requestsSendResponses(keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
||||||
|
standardRequestBuilder(endpoint + "/v2.0/tenants").build(), standardResponseBuilder(404).build())
|
||||||
|
.getServiceClient();
|
||||||
|
assertTrue(client.listTenants().isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGetTenant() {
|
||||||
|
ServiceClient client = requestsSendResponses(
|
||||||
|
keystoneAuthWithUsernameAndPassword,
|
||||||
|
responseWithKeystoneAccess,
|
||||||
|
standardRequestBuilder(endpoint + "/v2.0/tenants/013ba41150a14830bec85ffe93353bcc").build(),
|
||||||
|
standardResponseBuilder(200).payload(
|
||||||
|
payloadFromResourceWithContentType("/tenant_details.json", APPLICATION_JSON)).build())
|
||||||
|
.getServiceClient();
|
||||||
|
Tenant tenant = client.getTenant("013ba41150a14830bec85ffe93353bcc");
|
||||||
|
assertNotNull(tenant);
|
||||||
|
assertEquals(tenant, Tenant.builder().id("013ba41150a14830bec85ffe93353bcc").name("admin").build());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expectedExceptions = AuthorizationException.class)
|
||||||
|
public void testListTenantsFailNotAuthorized() {
|
||||||
|
ServiceClient client = requestsSendResponses(keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
||||||
|
standardRequestBuilder(endpoint + "/v2.0/tenants/013ba41150a14830bec85ffe93353bcc").build(),
|
||||||
|
standardResponseBuilder(401).build()).getServiceClient();
|
||||||
|
client.getTenant("013ba41150a14830bec85ffe93353bcc");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGetTenantByName() {
|
||||||
|
ServiceClient client = requestsSendResponses(
|
||||||
|
keystoneAuthWithUsernameAndPassword,
|
||||||
|
responseWithKeystoneAccess,
|
||||||
|
standardRequestBuilder(endpoint + "/v2.0/tenants?name=admin").build(),
|
||||||
|
standardResponseBuilder(200).payload(
|
||||||
|
payloadFromResourceWithContentType("/tenant_details.json", APPLICATION_JSON)).build())
|
||||||
|
.getServiceClient();
|
||||||
|
Tenant tenant = client.getTenantByName("admin");
|
||||||
|
assertNotNull(tenant);
|
||||||
|
assertEquals(tenant, Tenant.builder().id("013ba41150a14830bec85ffe93353bcc").name("admin").build());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGetTenantByNameFailNotFound() {
|
||||||
|
ServiceClient client = requestsSendResponses(keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
||||||
|
standardRequestBuilder(endpoint + "/v2.0/tenants?name=admin").build(),
|
||||||
|
standardResponseBuilder(404).build()).getServiceClient();
|
||||||
|
assertNull(client.getTenantByName("admin"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 1.1 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-1.1
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.openstack.keystone.v2_0.features;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.assertFalse;
|
||||||
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneClientLiveTest;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests ServiceClient
|
||||||
|
*
|
||||||
|
* @author Adam Lowe
|
||||||
|
*/
|
||||||
|
@Test(groups = "live", testName = "ServiceClientLiveTest")
|
||||||
|
public class ServiceClientLiveTest extends BaseKeystoneClientLiveTest {
|
||||||
|
|
||||||
|
public void testTenants() {
|
||||||
|
ServiceClient client = keystoneContext.getApi().getServiceClient();
|
||||||
|
Set<Tenant> result = client.listTenants();
|
||||||
|
assertNotNull(result);
|
||||||
|
assertFalse(result.isEmpty());
|
||||||
|
|
||||||
|
for (Tenant tenant : result) {
|
||||||
|
assertNotNull(tenant.getId());
|
||||||
|
|
||||||
|
Tenant aTenant = client.getTenant(tenant.getId());
|
||||||
|
assertNotNull(aTenant, "get returned null for tenant: " + tenant);
|
||||||
|
|
||||||
|
assertEquals(aTenant, tenant);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testTenantsByName() {
|
||||||
|
|
||||||
|
ServiceClient client = keystoneContext.getApi().getServiceClient();
|
||||||
|
|
||||||
|
for (Tenant tenant : client.listTenants()) {
|
||||||
|
Tenant aTenant = client.getTenantByName(tenant.getName());
|
||||||
|
assertNotNull(aTenant, "get returned null for tenant: " + tenant);
|
||||||
|
|
||||||
|
assertEquals(aTenant, tenant);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -43,6 +43,10 @@ import com.google.common.collect.ImmutableSet;
|
||||||
@Test(testName = "TenantClientExpectTest")
|
@Test(testName = "TenantClientExpectTest")
|
||||||
public class TenantClientExpectTest extends BaseKeystoneRestClientExpectTest<KeystoneClient> {
|
public class TenantClientExpectTest extends BaseKeystoneRestClientExpectTest<KeystoneClient> {
|
||||||
|
|
||||||
|
public TenantClientExpectTest(){
|
||||||
|
endpoint = "https://csnode.jclouds.org:35357";
|
||||||
|
}
|
||||||
|
|
||||||
public void testListTenants() {
|
public void testListTenants() {
|
||||||
TenantClient client = requestsSendResponses(
|
TenantClient client = requestsSendResponses(
|
||||||
keystoneAuthWithUsernameAndPassword,
|
keystoneAuthWithUsernameAndPassword,
|
||||||
|
@ -50,7 +54,7 @@ public class TenantClientExpectTest extends BaseKeystoneRestClientExpectTest<Key
|
||||||
standardRequestBuilder(endpoint + "/v2.0/tenants").build(),
|
standardRequestBuilder(endpoint + "/v2.0/tenants").build(),
|
||||||
standardResponseBuilder(200).payload(
|
standardResponseBuilder(200).payload(
|
||||||
payloadFromResourceWithContentType("/tenant_list.json", APPLICATION_JSON)).build())
|
payloadFromResourceWithContentType("/tenant_list.json", APPLICATION_JSON)).build())
|
||||||
.getTenantClient();
|
.getTenantClient().get();
|
||||||
Set<Tenant> tenants = client.list();
|
Set<Tenant> tenants = client.list();
|
||||||
assertNotNull(tenants);
|
assertNotNull(tenants);
|
||||||
assertFalse(tenants.isEmpty());
|
assertFalse(tenants.isEmpty());
|
||||||
|
@ -64,7 +68,7 @@ public class TenantClientExpectTest extends BaseKeystoneRestClientExpectTest<Key
|
||||||
public void testListTenantsFailNotFound() {
|
public void testListTenantsFailNotFound() {
|
||||||
TenantClient client = requestsSendResponses(keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
TenantClient client = requestsSendResponses(keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
||||||
standardRequestBuilder(endpoint + "/v2.0/tenants").build(), standardResponseBuilder(404).build())
|
standardRequestBuilder(endpoint + "/v2.0/tenants").build(), standardResponseBuilder(404).build())
|
||||||
.getTenantClient();
|
.getTenantClient().get();
|
||||||
assertTrue(client.list().isEmpty());
|
assertTrue(client.list().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +79,7 @@ public class TenantClientExpectTest extends BaseKeystoneRestClientExpectTest<Key
|
||||||
standardRequestBuilder(endpoint + "/v2.0/tenants/013ba41150a14830bec85ffe93353bcc").build(),
|
standardRequestBuilder(endpoint + "/v2.0/tenants/013ba41150a14830bec85ffe93353bcc").build(),
|
||||||
standardResponseBuilder(200).payload(
|
standardResponseBuilder(200).payload(
|
||||||
payloadFromResourceWithContentType("/tenant_details.json", APPLICATION_JSON)).build())
|
payloadFromResourceWithContentType("/tenant_details.json", APPLICATION_JSON)).build())
|
||||||
.getTenantClient();
|
.getTenantClient().get();
|
||||||
Tenant tenant = client.get("013ba41150a14830bec85ffe93353bcc");
|
Tenant tenant = client.get("013ba41150a14830bec85ffe93353bcc");
|
||||||
assertNotNull(tenant);
|
assertNotNull(tenant);
|
||||||
assertEquals(tenant, Tenant.builder().id("013ba41150a14830bec85ffe93353bcc").name("admin").build());
|
assertEquals(tenant, Tenant.builder().id("013ba41150a14830bec85ffe93353bcc").name("admin").build());
|
||||||
|
@ -85,7 +89,7 @@ public class TenantClientExpectTest extends BaseKeystoneRestClientExpectTest<Key
|
||||||
public void testListTenantsFailNotAuthorized() {
|
public void testListTenantsFailNotAuthorized() {
|
||||||
TenantClient client = requestsSendResponses(keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
TenantClient client = requestsSendResponses(keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
||||||
standardRequestBuilder(endpoint + "/v2.0/tenants/013ba41150a14830bec85ffe93353bcc").build(),
|
standardRequestBuilder(endpoint + "/v2.0/tenants/013ba41150a14830bec85ffe93353bcc").build(),
|
||||||
standardResponseBuilder(401).build()).getTenantClient();
|
standardResponseBuilder(401).build()).getTenantClient().get();
|
||||||
client.get("013ba41150a14830bec85ffe93353bcc");
|
client.get("013ba41150a14830bec85ffe93353bcc");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +100,7 @@ public class TenantClientExpectTest extends BaseKeystoneRestClientExpectTest<Key
|
||||||
standardRequestBuilder(endpoint + "/v2.0/tenants?name=admin").build(),
|
standardRequestBuilder(endpoint + "/v2.0/tenants?name=admin").build(),
|
||||||
standardResponseBuilder(200).payload(
|
standardResponseBuilder(200).payload(
|
||||||
payloadFromResourceWithContentType("/tenant_details.json", APPLICATION_JSON)).build())
|
payloadFromResourceWithContentType("/tenant_details.json", APPLICATION_JSON)).build())
|
||||||
.getTenantClient();
|
.getTenantClient().get();
|
||||||
Tenant tenant = client.getByName("admin");
|
Tenant tenant = client.getByName("admin");
|
||||||
assertNotNull(tenant);
|
assertNotNull(tenant);
|
||||||
assertEquals(tenant, Tenant.builder().id("013ba41150a14830bec85ffe93353bcc").name("admin").build());
|
assertEquals(tenant, Tenant.builder().id("013ba41150a14830bec85ffe93353bcc").name("admin").build());
|
||||||
|
@ -105,7 +109,7 @@ public class TenantClientExpectTest extends BaseKeystoneRestClientExpectTest<Key
|
||||||
public void testGetTenantByNameFailNotFound() {
|
public void testGetTenantByNameFailNotFound() {
|
||||||
TenantClient client = requestsSendResponses(keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
TenantClient client = requestsSendResponses(keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
||||||
standardRequestBuilder(endpoint + "/v2.0/tenants?name=admin").build(),
|
standardRequestBuilder(endpoint + "/v2.0/tenants?name=admin").build(),
|
||||||
standardResponseBuilder(404).build()).getTenantClient();
|
standardResponseBuilder(404).build()).getTenantClient().get();
|
||||||
assertNull(client.getByName("admin"));
|
assertNull(client.getByName("admin"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ import org.testng.annotations.Test;
|
||||||
public class TenantClientLiveTest extends BaseKeystoneClientLiveTest {
|
public class TenantClientLiveTest extends BaseKeystoneClientLiveTest {
|
||||||
|
|
||||||
public void testTenants() {
|
public void testTenants() {
|
||||||
TenantClient client = keystoneContext.getApi().getTenantClient();
|
TenantClient client = keystoneContext.getApi().getTenantClient().get();
|
||||||
Set<Tenant> result = client.list();
|
Set<Tenant> result = client.list();
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
assertFalse(result.isEmpty());
|
assertFalse(result.isEmpty());
|
||||||
|
@ -54,7 +54,7 @@ public class TenantClientLiveTest extends BaseKeystoneClientLiveTest {
|
||||||
|
|
||||||
public void testTenantsByName() {
|
public void testTenantsByName() {
|
||||||
|
|
||||||
TenantClient client = keystoneContext.getApi().getTenantClient();
|
TenantClient client = keystoneContext.getApi().getTenantClient().get();
|
||||||
|
|
||||||
for (Tenant tenant : client.list()) {
|
for (Tenant tenant : client.list()) {
|
||||||
Tenant aTenant = client.getByName(tenant.getName());
|
Tenant aTenant = client.getByName(tenant.getName());
|
||||||
|
|
|
@ -50,6 +50,11 @@ import com.google.common.collect.ImmutableSet;
|
||||||
*/
|
*/
|
||||||
@Test(testName = "TokenClientExpectTest")
|
@Test(testName = "TokenClientExpectTest")
|
||||||
public class TokenClientExpectTest extends BaseKeystoneRestClientExpectTest<KeystoneClient> {
|
public class TokenClientExpectTest extends BaseKeystoneRestClientExpectTest<KeystoneClient> {
|
||||||
|
|
||||||
|
public TokenClientExpectTest(){
|
||||||
|
endpoint = "https://csnode.jclouds.org:35357";
|
||||||
|
}
|
||||||
|
|
||||||
private DateService dateService = new SimpleDateFormatDateService();
|
private DateService dateService = new SimpleDateFormatDateService();
|
||||||
|
|
||||||
public void testGetToken() {
|
public void testGetToken() {
|
||||||
|
@ -57,7 +62,7 @@ public class TokenClientExpectTest extends BaseKeystoneRestClientExpectTest<Keys
|
||||||
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
||||||
standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").build(),
|
standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").build(),
|
||||||
standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/token_details.json", APPLICATION_JSON)).build())
|
standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/token_details.json", APPLICATION_JSON)).build())
|
||||||
.getTokenClient();
|
.getTokenClient().get();
|
||||||
Token token = client.get("sometokenorother");
|
Token token = client.get("sometokenorother");
|
||||||
assertNotNull(token);
|
assertNotNull(token);
|
||||||
assertEquals(token,
|
assertEquals(token,
|
||||||
|
@ -70,7 +75,7 @@ public class TokenClientExpectTest extends BaseKeystoneRestClientExpectTest<Keys
|
||||||
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
||||||
standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").build(),
|
standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").build(),
|
||||||
standardResponseBuilder(404).build())
|
standardResponseBuilder(404).build())
|
||||||
.getTokenClient();
|
.getTokenClient().get();
|
||||||
assertNull(client.get("sometokenorother"));
|
assertNull(client.get("sometokenorother"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +84,7 @@ public class TokenClientExpectTest extends BaseKeystoneRestClientExpectTest<Keys
|
||||||
TokenClient client = requestsSendResponses(
|
TokenClient client = requestsSendResponses(
|
||||||
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
||||||
standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").build(),
|
standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").build(),
|
||||||
standardResponseBuilder(500).build()).getTokenClient();
|
standardResponseBuilder(500).build()).getTokenClient().get();
|
||||||
client.get("sometokenorother");
|
client.get("sometokenorother");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +93,7 @@ public class TokenClientExpectTest extends BaseKeystoneRestClientExpectTest<Keys
|
||||||
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
||||||
standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").build(),
|
standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").build(),
|
||||||
standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/token_details.json", APPLICATION_JSON)).build())
|
standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/token_details.json", APPLICATION_JSON)).build())
|
||||||
.getTokenClient();
|
.getTokenClient().get();
|
||||||
User user = client.getUserOfToken("sometokenorother");
|
User user = client.getUserOfToken("sometokenorother");
|
||||||
assertNotNull(user);
|
assertNotNull(user);
|
||||||
assertEquals(user, User.builder().id("2b9b606181634ae9ac86fd95a8bc2cde").name("admin")
|
assertEquals(user, User.builder().id("2b9b606181634ae9ac86fd95a8bc2cde").name("admin")
|
||||||
|
@ -100,7 +105,7 @@ public class TokenClientExpectTest extends BaseKeystoneRestClientExpectTest<Keys
|
||||||
TokenClient client = requestsSendResponses(
|
TokenClient client = requestsSendResponses(
|
||||||
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
||||||
standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").build(),
|
standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").build(),
|
||||||
standardResponseBuilder(404).build()).getTokenClient();
|
standardResponseBuilder(404).build()).getTokenClient().get();
|
||||||
assertNull(client.getUserOfToken("sometokenorother"));
|
assertNull(client.getUserOfToken("sometokenorother"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +115,7 @@ public class TokenClientExpectTest extends BaseKeystoneRestClientExpectTest<Keys
|
||||||
standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").method("HEAD")
|
standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").method("HEAD")
|
||||||
.headers(ImmutableMultimap.of("X-Auth-Token", authToken)).build(),
|
.headers(ImmutableMultimap.of("X-Auth-Token", authToken)).build(),
|
||||||
standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/token_details.json", APPLICATION_JSON)).build())
|
standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/token_details.json", APPLICATION_JSON)).build())
|
||||||
.getTokenClient();
|
.getTokenClient().get();
|
||||||
assertTrue(client.isValid("sometokenorother"));
|
assertTrue(client.isValid("sometokenorother"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +124,7 @@ public class TokenClientExpectTest extends BaseKeystoneRestClientExpectTest<Keys
|
||||||
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
||||||
standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").method("HEAD")
|
standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").method("HEAD")
|
||||||
.headers(ImmutableMultimap.of("X-Auth-Token", authToken)).build(),
|
.headers(ImmutableMultimap.of("X-Auth-Token", authToken)).build(),
|
||||||
standardResponseBuilder(404).build()).getTokenClient();
|
standardResponseBuilder(404).build()).getTokenClient().get();
|
||||||
assertFalse(client.isValid("sometokenorother"));
|
assertFalse(client.isValid("sometokenorother"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +134,7 @@ public class TokenClientExpectTest extends BaseKeystoneRestClientExpectTest<Keys
|
||||||
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
||||||
standardRequestBuilder(endpoint + "/v2.0/tokens/XXXXXX/endpoints").build(),
|
standardRequestBuilder(endpoint + "/v2.0/tokens/XXXXXX/endpoints").build(),
|
||||||
standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/user_endpoints.json", APPLICATION_JSON)).build())
|
standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/user_endpoints.json", APPLICATION_JSON)).build())
|
||||||
.getTokenClient();
|
.getTokenClient().get();
|
||||||
Set<Endpoint> endpoints = client.listEndpointsForToken("XXXXXX");
|
Set<Endpoint> endpoints = client.listEndpointsForToken("XXXXXX");
|
||||||
|
|
||||||
assertEquals(endpoints, ImmutableSet.of(
|
assertEquals(endpoints, ImmutableSet.of(
|
||||||
|
@ -145,7 +150,7 @@ public class TokenClientExpectTest extends BaseKeystoneRestClientExpectTest<Keys
|
||||||
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
||||||
standardRequestBuilder(endpoint + "/v2.0/tokens/XXXXXX/endpoints").build(),
|
standardRequestBuilder(endpoint + "/v2.0/tokens/XXXXXX/endpoints").build(),
|
||||||
standardResponseBuilder(404).build())
|
standardResponseBuilder(404).build())
|
||||||
.getTokenClient();
|
.getTokenClient().get();
|
||||||
assertTrue(client.listEndpointsForToken("XXXXXX").isEmpty());
|
assertTrue(client.listEndpointsForToken("XXXXXX").isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class TokenClientLiveTest extends BaseKeystoneClientLiveTest {
|
||||||
|
|
||||||
public void testToken() {
|
public void testToken() {
|
||||||
|
|
||||||
TokenClient client = keystoneContext.getApi().getTokenClient();
|
TokenClient client = keystoneContext.getApi().getTokenClient().get();
|
||||||
assertTrue(client.isValid(token));
|
assertTrue(client.isValid(token));
|
||||||
Token result = client.get(token);
|
Token result = client.get(token);
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
|
@ -74,7 +74,7 @@ public class TokenClientLiveTest extends BaseKeystoneClientLiveTest {
|
||||||
|
|
||||||
public void testInvalidToken() {
|
public void testInvalidToken() {
|
||||||
|
|
||||||
TokenClient client = keystoneContext.getApi().getTokenClient();
|
TokenClient client = keystoneContext.getApi().getTokenClient().get();
|
||||||
assertFalse(client.isValid("thisisnotarealtoken!"));
|
assertFalse(client.isValid("thisisnotarealtoken!"));
|
||||||
assertNull(client.get("thisisnotarealtoken!"));
|
assertNull(client.get("thisisnotarealtoken!"));
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class TokenClientLiveTest extends BaseKeystoneClientLiveTest {
|
||||||
|
|
||||||
public void testTokenEndpoints() {
|
public void testTokenEndpoints() {
|
||||||
|
|
||||||
TokenClient client = keystoneContext.getApi().getTokenClient();
|
TokenClient client = keystoneContext.getApi().getTokenClient().get();
|
||||||
Set<Endpoint> endpoints = client.listEndpointsForToken(token);
|
Set<Endpoint> endpoints = client.listEndpointsForToken(token);
|
||||||
assertNotNull(endpoints);
|
assertNotNull(endpoints);
|
||||||
assertFalse(endpoints.isEmpty());
|
assertFalse(endpoints.isEmpty());
|
||||||
|
@ -91,7 +91,7 @@ public class TokenClientLiveTest extends BaseKeystoneClientLiveTest {
|
||||||
|
|
||||||
public void testInvalidTokenEndpoints() {
|
public void testInvalidTokenEndpoints() {
|
||||||
|
|
||||||
TokenClient client = keystoneContext.getApi().getTokenClient();
|
TokenClient client = keystoneContext.getApi().getTokenClient().get();
|
||||||
assertTrue(client.listEndpointsForToken("thisisnotarealtoken!").isEmpty());
|
assertTrue(client.listEndpointsForToken("thisisnotarealtoken!").isEmpty());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,13 +44,17 @@ import com.google.common.collect.ImmutableSet;
|
||||||
*/
|
*/
|
||||||
@Test(testName = "UserClientExpectTest")
|
@Test(testName = "UserClientExpectTest")
|
||||||
public class UserClientExpectTest extends BaseKeystoneRestClientExpectTest<KeystoneClient> {
|
public class UserClientExpectTest extends BaseKeystoneRestClientExpectTest<KeystoneClient> {
|
||||||
|
|
||||||
|
public UserClientExpectTest(){
|
||||||
|
endpoint = "https://csnode.jclouds.org:35357";
|
||||||
|
}
|
||||||
|
|
||||||
public void testListUsers() {
|
public void testListUsers() {
|
||||||
UserClient client = requestsSendResponses(
|
UserClient client = requestsSendResponses(
|
||||||
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
||||||
standardRequestBuilder(endpoint + "/v2.0/users").build(),
|
standardRequestBuilder(endpoint + "/v2.0/users").build(),
|
||||||
standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/user_list.json", APPLICATION_JSON)).build())
|
standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/user_list.json", APPLICATION_JSON)).build())
|
||||||
.getUserClient();
|
.getUserClient().get();
|
||||||
Set<User> users = client.list();
|
Set<User> users = client.list();
|
||||||
assertNotNull(users);
|
assertNotNull(users);
|
||||||
assertFalse(users.isEmpty());
|
assertFalse(users.isEmpty());
|
||||||
|
@ -70,7 +74,7 @@ public class UserClientExpectTest extends BaseKeystoneRestClientExpectTest<Keyst
|
||||||
UserClient client = requestsSendResponses(
|
UserClient client = requestsSendResponses(
|
||||||
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
||||||
standardRequestBuilder(endpoint + "/v2.0/users").build(),
|
standardRequestBuilder(endpoint + "/v2.0/users").build(),
|
||||||
standardResponseBuilder(401).build()).getUserClient();
|
standardResponseBuilder(401).build()).getUserClient().get();
|
||||||
client.list();
|
client.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +83,7 @@ public class UserClientExpectTest extends BaseKeystoneRestClientExpectTest<Keyst
|
||||||
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
||||||
standardRequestBuilder(endpoint + "/v2.0/users/e021dfd758eb44a89f1c57c8ef3be8e2").build(),
|
standardRequestBuilder(endpoint + "/v2.0/users/e021dfd758eb44a89f1c57c8ef3be8e2").build(),
|
||||||
standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/user_details.json", APPLICATION_JSON)).build())
|
standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/user_details.json", APPLICATION_JSON)).build())
|
||||||
.getUserClient();
|
.getUserClient().get();
|
||||||
User user = client.get("e021dfd758eb44a89f1c57c8ef3be8e2");
|
User user = client.get("e021dfd758eb44a89f1c57c8ef3be8e2");
|
||||||
assertNotNull(user);
|
assertNotNull(user);
|
||||||
assertEquals(user, User.builder().name("nova").id("e021dfd758eb44a89f1c57c8ef3be8e2").build());
|
assertEquals(user, User.builder().name("nova").id("e021dfd758eb44a89f1c57c8ef3be8e2").build());
|
||||||
|
@ -89,7 +93,7 @@ public class UserClientExpectTest extends BaseKeystoneRestClientExpectTest<Keyst
|
||||||
UserClient client = requestsSendResponses(
|
UserClient client = requestsSendResponses(
|
||||||
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
||||||
standardRequestBuilder(endpoint + "/v2.0/users/f021dfd758eb44a89f1c57c8ef3be8e2").build(),
|
standardRequestBuilder(endpoint + "/v2.0/users/f021dfd758eb44a89f1c57c8ef3be8e2").build(),
|
||||||
standardResponseBuilder(404).build()).getUserClient();
|
standardResponseBuilder(404).build()).getUserClient().get();
|
||||||
assertNull(client.get("f021dfd758eb44a89f1c57c8ef3be8e2"));
|
assertNull(client.get("f021dfd758eb44a89f1c57c8ef3be8e2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +102,7 @@ public class UserClientExpectTest extends BaseKeystoneRestClientExpectTest<Keyst
|
||||||
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
||||||
standardRequestBuilder(endpoint + "/v2.0/users?name=nova").build(),
|
standardRequestBuilder(endpoint + "/v2.0/users?name=nova").build(),
|
||||||
standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/user_details.json", APPLICATION_JSON)).build())
|
standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/user_details.json", APPLICATION_JSON)).build())
|
||||||
.getUserClient();
|
.getUserClient().get();
|
||||||
User user = client.getByName("nova");
|
User user = client.getByName("nova");
|
||||||
assertNotNull(user);
|
assertNotNull(user);
|
||||||
assertEquals(user, User.builder().name("nova").id("e021dfd758eb44a89f1c57c8ef3be8e2").build());
|
assertEquals(user, User.builder().name("nova").id("e021dfd758eb44a89f1c57c8ef3be8e2").build());
|
||||||
|
@ -108,7 +112,7 @@ public class UserClientExpectTest extends BaseKeystoneRestClientExpectTest<Keyst
|
||||||
UserClient client = requestsSendResponses(
|
UserClient client = requestsSendResponses(
|
||||||
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
||||||
standardRequestBuilder(endpoint + "/v2.0/users?name=fred").build(),
|
standardRequestBuilder(endpoint + "/v2.0/users?name=fred").build(),
|
||||||
standardResponseBuilder(404).build()).getUserClient();
|
standardResponseBuilder(404).build()).getUserClient().get();
|
||||||
assertNull(client.getByName("fred"));
|
assertNull(client.getByName("fred"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +121,7 @@ public class UserClientExpectTest extends BaseKeystoneRestClientExpectTest<Keyst
|
||||||
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
||||||
standardRequestBuilder(endpoint + "/v2.0/users/3f6c1c9ba993495ead7d2eb2192e284f/roles").build(),
|
standardRequestBuilder(endpoint + "/v2.0/users/3f6c1c9ba993495ead7d2eb2192e284f/roles").build(),
|
||||||
standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/user_role_list.json", APPLICATION_JSON)).build())
|
standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/user_role_list.json", APPLICATION_JSON)).build())
|
||||||
.getUserClient();
|
.getUserClient().get();
|
||||||
Set<Role> roles = client.listRolesOfUser("3f6c1c9ba993495ead7d2eb2192e284f");
|
Set<Role> roles = client.listRolesOfUser("3f6c1c9ba993495ead7d2eb2192e284f");
|
||||||
assertNotNull(roles);
|
assertNotNull(roles);
|
||||||
assertFalse(roles.isEmpty());
|
assertFalse(roles.isEmpty());
|
||||||
|
@ -130,7 +134,7 @@ public class UserClientExpectTest extends BaseKeystoneRestClientExpectTest<Keyst
|
||||||
UserClient client = requestsSendResponses(
|
UserClient client = requestsSendResponses(
|
||||||
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
||||||
standardRequestBuilder(endpoint + "/v2.0/users/4f6c1c9ba993495ead7d2eb2192e284f/roles").build(),
|
standardRequestBuilder(endpoint + "/v2.0/users/4f6c1c9ba993495ead7d2eb2192e284f/roles").build(),
|
||||||
standardResponseBuilder(404).build()).getUserClient();
|
standardResponseBuilder(404).build()).getUserClient().get();
|
||||||
assertTrue(client.listRolesOfUser("4f6c1c9ba993495ead7d2eb2192e284f").isEmpty());
|
assertTrue(client.listRolesOfUser("4f6c1c9ba993495ead7d2eb2192e284f").isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +143,7 @@ public class UserClientExpectTest extends BaseKeystoneRestClientExpectTest<Keyst
|
||||||
UserClient client = requestsSendResponses(
|
UserClient client = requestsSendResponses(
|
||||||
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
||||||
standardRequestBuilder(endpoint + "/v2.0/users/5f6c1c9ba993495ead7d2eb2192e284f/roles").build(),
|
standardRequestBuilder(endpoint + "/v2.0/users/5f6c1c9ba993495ead7d2eb2192e284f/roles").build(),
|
||||||
standardResponseBuilder(501).build()).getUserClient();
|
standardResponseBuilder(501).build()).getUserClient().get();
|
||||||
assertTrue(client.listRolesOfUser("5f6c1c9ba993495ead7d2eb2192e284f").isEmpty());
|
assertTrue(client.listRolesOfUser("5f6c1c9ba993495ead7d2eb2192e284f").isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +152,7 @@ public class UserClientExpectTest extends BaseKeystoneRestClientExpectTest<Keyst
|
||||||
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
||||||
standardRequestBuilder(endpoint + "/v2.0/users/3f6c1c9ba993495ead7d2eb2192e284f/roles").build(),
|
standardRequestBuilder(endpoint + "/v2.0/users/3f6c1c9ba993495ead7d2eb2192e284f/roles").build(),
|
||||||
standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/user_tenant_role_list.json", APPLICATION_JSON)).build())
|
standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/user_tenant_role_list.json", APPLICATION_JSON)).build())
|
||||||
.getUserClient();
|
.getUserClient().get();
|
||||||
Set<Role> roles = client.listRolesOfUser("3f6c1c9ba993495ead7d2eb2192e284f");
|
Set<Role> roles = client.listRolesOfUser("3f6c1c9ba993495ead7d2eb2192e284f");
|
||||||
assertNotNull(roles);
|
assertNotNull(roles);
|
||||||
assertFalse(roles.isEmpty());
|
assertFalse(roles.isEmpty());
|
||||||
|
@ -162,7 +166,7 @@ public class UserClientExpectTest extends BaseKeystoneRestClientExpectTest<Keyst
|
||||||
UserClient client = requestsSendResponses(
|
UserClient client = requestsSendResponses(
|
||||||
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
|
||||||
standardRequestBuilder(endpoint + "/v2.0/users/3f6c1c9ba993495ead7d2eb2192e284f/roles").build(),
|
standardRequestBuilder(endpoint + "/v2.0/users/3f6c1c9ba993495ead7d2eb2192e284f/roles").build(),
|
||||||
standardResponseBuilder(404).build()).getUserClient();
|
standardResponseBuilder(404).build()).getUserClient().get();
|
||||||
assertTrue(client.listRolesOfUser("3f6c1c9ba993495ead7d2eb2192e284f").isEmpty());
|
assertTrue(client.listRolesOfUser("3f6c1c9ba993495ead7d2eb2192e284f").isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class UserClientLiveTest extends BaseKeystoneClientLiveTest {
|
||||||
|
|
||||||
public void testUsers() {
|
public void testUsers() {
|
||||||
|
|
||||||
UserClient client = keystoneContext.getApi().getUserClient();
|
UserClient client = keystoneContext.getApi().getUserClient().get();
|
||||||
Set<User> users = client.list();
|
Set<User> users = client.list();
|
||||||
assertNotNull(users);
|
assertNotNull(users);
|
||||||
assertFalse(users.isEmpty());
|
assertFalse(users.isEmpty());
|
||||||
|
@ -53,9 +53,9 @@ public class UserClientLiveTest extends BaseKeystoneClientLiveTest {
|
||||||
|
|
||||||
public void testUserRolesOnTenant() {
|
public void testUserRolesOnTenant() {
|
||||||
|
|
||||||
UserClient client = keystoneContext.getApi().getUserClient();
|
UserClient client = keystoneContext.getApi().getUserClient().get();
|
||||||
Set<User> users = client.list();
|
Set<User> users = client.list();
|
||||||
Set<Tenant> tenants = keystoneContext.getApi().getTenantClient().list();
|
Set<Tenant> tenants = keystoneContext.getApi().getTenantClient().get().list();
|
||||||
|
|
||||||
for (User user : users) {
|
for (User user : users) {
|
||||||
for (Tenant tenant : tenants) {
|
for (Tenant tenant : tenants) {
|
||||||
|
@ -70,7 +70,7 @@ public class UserClientLiveTest extends BaseKeystoneClientLiveTest {
|
||||||
|
|
||||||
public void testListRolesOfUser() {
|
public void testListRolesOfUser() {
|
||||||
|
|
||||||
UserClient client = keystoneContext.getApi().getUserClient();
|
UserClient client = keystoneContext.getApi().getUserClient().get();
|
||||||
for (User user : client.list()) {
|
for (User user : client.list()) {
|
||||||
Set<Role> roles = client.listRolesOfUser(user.getId());
|
Set<Role> roles = client.listRolesOfUser(user.getId());
|
||||||
for (Role role : roles) {
|
for (Role role : roles) {
|
||||||
|
@ -82,7 +82,7 @@ public class UserClientLiveTest extends BaseKeystoneClientLiveTest {
|
||||||
|
|
||||||
public void testUsersByName() {
|
public void testUsersByName() {
|
||||||
|
|
||||||
UserClient client = keystoneContext.getApi().getUserClient();
|
UserClient client = keystoneContext.getApi().getUserClient().get();
|
||||||
for (User user : client.list()) {
|
for (User user : client.list()) {
|
||||||
User aUser = client.getByName(user.getName());
|
User aUser = client.getByName(user.getName());
|
||||||
assertEquals(aUser, user);
|
assertEquals(aUser, user);
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 1.1 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-1.1
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.cloudidentity.v2_0.features;
|
||||||
|
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.features.ServiceClientLiveTest;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "live", testName = "CloudIdentityServiceClientLiveTest", singleThreaded = true)
|
||||||
|
public class CloudIdentityServiceClientLiveTest extends ServiceClientLiveTest {
|
||||||
|
public CloudIdentityServiceClientLiveTest() {
|
||||||
|
provider = "cloudidentity";
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue