Fixes tenantId when using the keystone admin extension

This commit is contained in:
Zack Shoylev 2015-11-18 08:55:20 -06:00
parent c6f47ca904
commit 72889bbf19
2 changed files with 6 additions and 5 deletions

View File

@ -34,7 +34,7 @@ import com.google.common.collect.ImmutableMap;
public class CreateUserOptions implements MapBinder{
@Inject
private BindToJsonPayload jsonBinder;
private String tenant;
private String password;
private String email;
@ -75,7 +75,7 @@ public class CreateUserOptions implements MapBinder{
static class ServerRequest {
final String name;
String tenant;
String tenantId;
String password;
String email;
boolean enabled;
@ -97,7 +97,7 @@ public class CreateUserOptions implements MapBinder{
if (password != null)
user.password = password;
if (tenant != null)
user.tenant = tenant;
user.tenantId = tenant;
user.enabled = enabled;
return bindToRequest(request, ImmutableMap.of("user", user));

View File

@ -48,7 +48,8 @@ public class UserAdminApiMockTest extends BaseOpenStackMockTest<KeystoneApi> {
try {
KeystoneApi keystoneApi = api(server.getUrl("/").toString(), "openstack-keystone");
UserAdminApi userAdminApi = keystoneApi.getUserAdminApi().get();
CreateUserOptions createUserOptions = CreateUserOptions.Builder.email("john.smith@example.org").enabled(true);
CreateUserOptions createUserOptions = CreateUserOptions.Builder.email("john.smith@example.org").enabled(true)
.tenant("12345");
User testUser = userAdminApi.create("jqsmith", "jclouds-password", createUserOptions);
assertNotNull(testUser);
@ -61,7 +62,7 @@ public class UserAdminApiMockTest extends BaseOpenStackMockTest<KeystoneApi> {
assertEquals(createUserRequest.getRequestLine(), "POST /users HTTP/1.1");
assertEquals(
new String(createUserRequest.getBody()),
"{\"user\":{\"name\":\"jqsmith\",\"password\":\"jclouds-password\",\"email\":\"john.smith@example.org\",\"enabled\":true}}");
"{\"user\":{\"name\":\"jqsmith\",\"tenantId\":\"12345\",\"password\":\"jclouds-password\",\"email\":\"john.smith@example.org\",\"enabled\":true}}");
} finally {
server.shutdown();
}