Fixes tenantId when using the keystone admin extension

This commit is contained in:
Zack Shoylev 2015-11-18 08:55:20 -06:00
parent ab25fc7259
commit 02b79106c3
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{ public class CreateUserOptions implements MapBinder{
@Inject @Inject
private BindToJsonPayload jsonBinder; private BindToJsonPayload jsonBinder;
private String tenant; private String tenant;
private String password; private String password;
private String email; private String email;
@ -75,7 +75,7 @@ public class CreateUserOptions implements MapBinder{
static class ServerRequest { static class ServerRequest {
final String name; final String name;
String tenant; String tenantId;
String password; String password;
String email; String email;
boolean enabled; boolean enabled;
@ -97,7 +97,7 @@ public class CreateUserOptions implements MapBinder{
if (password != null) if (password != null)
user.password = password; user.password = password;
if (tenant != null) if (tenant != null)
user.tenant = tenant; user.tenantId = tenant;
user.enabled = enabled; user.enabled = enabled;
return bindToRequest(request, ImmutableMap.of("user", user)); return bindToRequest(request, ImmutableMap.of("user", user));

View File

@ -48,7 +48,8 @@ public class UserAdminApiMockTest extends BaseOpenStackMockTest<KeystoneApi> {
try { try {
KeystoneApi keystoneApi = api(server.getUrl("/").toString(), "openstack-keystone"); KeystoneApi keystoneApi = api(server.getUrl("/").toString(), "openstack-keystone");
UserAdminApi userAdminApi = keystoneApi.getUserAdminApi().get(); 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); User testUser = userAdminApi.create("jqsmith", "jclouds-password", createUserOptions);
assertNotNull(testUser); assertNotNull(testUser);
@ -61,7 +62,7 @@ public class UserAdminApiMockTest extends BaseOpenStackMockTest<KeystoneApi> {
assertEquals(createUserRequest.getRequestLine(), "POST /users HTTP/1.1"); assertEquals(createUserRequest.getRequestLine(), "POST /users HTTP/1.1");
assertEquals( assertEquals(
new String(createUserRequest.getBody()), 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 { } finally {
server.shutdown(); server.shutdown();
} }