mirror of https://github.com/apache/jclouds.git
Use different endpoint for registerUserKeys API call
This commit is contained in:
parent
b6a58941e9
commit
efc1224dae
|
@ -36,6 +36,7 @@ public class CloudStackPropertiesBuilder extends PropertiesBuilder {
|
|||
properties.setProperty(PROPERTY_API_VERSION, "2.2");
|
||||
properties.setProperty("jclouds.ssh.max-retries", "7");
|
||||
properties.setProperty("jclouds.ssh.retry-auth", "true");
|
||||
properties.setProperty("jclouds.cloudstack.integration-api-port", "8096");
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/**
|
||||
* 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.cloudstack.collections;
|
||||
|
||||
import javax.inject.Qualifier;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Change the endpoint as needed for the integration API
|
||||
*
|
||||
* @author Andrei Savu
|
||||
*
|
||||
*/
|
||||
@Retention(value = RetentionPolicy.RUNTIME)
|
||||
@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
|
||||
@Qualifier
|
||||
public @interface Integration {
|
||||
|
||||
}
|
|
@ -19,13 +19,17 @@
|
|||
package org.jclouds.cloudstack.config;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.Singleton;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.inject.name.Named;
|
||||
import org.jclouds.cloudstack.CloudStackAsyncClient;
|
||||
import org.jclouds.cloudstack.CloudStackClient;
|
||||
import org.jclouds.cloudstack.CloudStackDomainAsyncClient;
|
||||
import org.jclouds.cloudstack.CloudStackDomainClient;
|
||||
import org.jclouds.cloudstack.CloudStackGlobalAsyncClient;
|
||||
import org.jclouds.cloudstack.CloudStackGlobalClient;
|
||||
import org.jclouds.cloudstack.collections.Integration;
|
||||
import org.jclouds.cloudstack.features.AccountAsyncClient;
|
||||
import org.jclouds.cloudstack.features.AccountClient;
|
||||
import org.jclouds.cloudstack.features.AddressAsyncClient;
|
||||
|
@ -96,12 +100,15 @@ import org.jclouds.http.annotation.Redirection;
|
|||
import org.jclouds.http.annotation.ServerError;
|
||||
import org.jclouds.json.config.GsonModule.DateAdapter;
|
||||
import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
|
||||
import org.jclouds.location.Provider;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.config.BinderUtils;
|
||||
import org.jclouds.rest.config.RestClientModule;
|
||||
import org.jclouds.rest.internal.RestContextImpl;
|
||||
|
||||
import javax.ws.rs.core.UriBuilder;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -191,4 +198,12 @@ public class CloudStackRestClientModule extends RestClientModule<CloudStackClien
|
|||
bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(CloudStackErrorHandler.class);
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
@Integration
|
||||
protected URI providesIntegrationEndpoint(@Provider URI normal,
|
||||
@Named("jclouds.cloudstack.integration-api-port") int port,
|
||||
com.google.inject.Provider<UriBuilder> uriBuilder) {
|
||||
return uriBuilder.get().uri(normal).port(port).build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,11 +19,13 @@
|
|||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import org.jclouds.cloudstack.collections.Integration;
|
||||
import org.jclouds.cloudstack.domain.ApiKeyPair;
|
||||
import org.jclouds.cloudstack.domain.User;
|
||||
import org.jclouds.cloudstack.filters.QuerySigner;
|
||||
import org.jclouds.cloudstack.options.CreateUserOptions;
|
||||
import org.jclouds.cloudstack.options.UpdateUserOptions;
|
||||
import org.jclouds.rest.annotations.Endpoint;
|
||||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
import org.jclouds.rest.annotations.QueryParams;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
|
@ -65,6 +67,7 @@ public interface GlobalUserAsyncClient extends DomainUserAsyncClient {
|
|||
*/
|
||||
@GET
|
||||
@QueryParams(keys = "comand", values = "registerUserKeys")
|
||||
@Endpoint(Integration.class)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<ApiKeyPair> registerUserKeys(@QueryParam("id") long userId);
|
||||
|
|
|
@ -46,8 +46,6 @@ import static org.testng.Assert.assertNotNull;
|
|||
@Test(groups = "live", singleThreaded = true, testName = "GlobalUserClientLiveTest")
|
||||
public class GlobalUserClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||
|
||||
|
||||
|
||||
public static User createTestUser(CloudStackGlobalClient client, Account account, String prefix) {
|
||||
return client.getUserClient().createUser(prefix + "-user",
|
||||
account.getName(), "dummy2@example.com", "md5-password", "First", "Last");
|
||||
|
@ -72,14 +70,13 @@ public class GlobalUserClientLiveTest extends BaseCloudStackClientLiveTest {
|
|||
assertNotNull(updatedUser);
|
||||
assertEquals(updatedUser.getName(), prefix + "-user-2");
|
||||
|
||||
/*
|
||||
ApiKeyPair apiKeys = globalAdminClient.getUserClient()
|
||||
.registerUserKeys(updatedUser.getId());
|
||||
|
||||
assertNotNull(apiKeys.getApiKey());
|
||||
assertNotNull(apiKeys.getSecretKey());
|
||||
|
||||
checkAuthAsUser(apiKeys); */
|
||||
checkAuthAsUser(apiKeys);
|
||||
|
||||
} finally {
|
||||
if (testUser != null) {
|
||||
|
@ -87,7 +84,6 @@ public class GlobalUserClientLiveTest extends BaseCloudStackClientLiveTest {
|
|||
}
|
||||
globalAdminClient.getAccountClient().deleteAccount(testAccount.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void checkAuthAsUser(ApiKeyPair keyPair) {
|
||||
|
|
Loading…
Reference in New Issue