mirror of https://github.com/apache/jclouds.git
JCLOUDS-643: Fix Google and OAuth tests
This commit is contained in:
parent
5c1e36e5d1
commit
00d9edc1e6
|
@ -92,6 +92,12 @@
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<executions>
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>default-test</id>
|
||||||
|
<configuration>
|
||||||
|
<skipTests>true</skipTests>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
<execution>
|
<execution>
|
||||||
<id>integration</id>
|
<id>integration</id>
|
||||||
<phase>integration-test</phase>
|
<phase>integration-test</phase>
|
||||||
|
@ -105,7 +111,7 @@
|
||||||
<test.oauth.endpoint>${test.oauth.endpoint}</test.oauth.endpoint>
|
<test.oauth.endpoint>${test.oauth.endpoint}</test.oauth.endpoint>
|
||||||
<test.oauth.api-version>${test.oauth.api-version}</test.oauth.api-version>
|
<test.oauth.api-version>${test.oauth.api-version}</test.oauth.api-version>
|
||||||
<test.oauth.build-version>${test.oauth.build-version}</test.oauth.build-version>
|
<test.oauth.build-version>${test.oauth.build-version}</test.oauth.build-version>
|
||||||
<test.jclouds.oauth.signature-or-mac-algorithm>${test.jclouds.oauth.signature-or-mac-algorithm>}</test.jclouds.oauth.signature-or-mac-algorithm>
|
<test.jclouds.oauth.signature-or-mac-algorithm>${test.jclouds.oauth.signature-or-mac-algorithm}</test.jclouds.oauth.signature-or-mac-algorithm>
|
||||||
<test.jclouds.oauth.audience>${test.jclouds.oauth.audience}</test.jclouds.oauth.audience>
|
<test.jclouds.oauth.audience>${test.jclouds.oauth.audience}</test.jclouds.oauth.audience>
|
||||||
<test.jclouds.oauth.scopes>${test.jclouds.oauth.scopes}</test.jclouds.oauth.scopes>
|
<test.jclouds.oauth.scopes>${test.jclouds.oauth.scopes}</test.jclouds.oauth.scopes>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class OAuthTestUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String setCredentialFromPemFile(Properties overrides, String key) {
|
public static String setCredential(Properties overrides, String key) {
|
||||||
String val = null;
|
String val = null;
|
||||||
String credentialFromFile = null;
|
String credentialFromFile = null;
|
||||||
String testKey = "test." + key;
|
String testKey = "test." + key;
|
||||||
|
@ -54,7 +54,11 @@ public class OAuthTestUtils {
|
||||||
if (System.getProperties().containsKey(testKey)) {
|
if (System.getProperties().containsKey(testKey)) {
|
||||||
val = System.getProperty(testKey);
|
val = System.getProperty(testKey);
|
||||||
}
|
}
|
||||||
checkNotNull(val, String.format("the property %s must be set (pem private key path)", testKey));
|
checkNotNull(val, String.format("the property %s must be set (pem private key file path or private key as a string)", testKey));
|
||||||
|
|
||||||
|
if (val.startsWith("-----BEGIN")) {
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
credentialFromFile = Files.toString(new File(val), Charsets.UTF_8);
|
credentialFromFile = Files.toString(new File(val), Charsets.UTF_8);
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
package org.jclouds.oauth.v2.internal;
|
package org.jclouds.oauth.v2.internal;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.oauth.v2.OAuthTestUtils.setCredentialFromPemFile;
|
import static org.jclouds.oauth.v2.OAuthTestUtils.setCredential;
|
||||||
import static org.jclouds.oauth.v2.config.OAuthProperties.AUDIENCE;
|
import static org.jclouds.oauth.v2.config.OAuthProperties.AUDIENCE;
|
||||||
import static org.jclouds.oauth.v2.config.OAuthProperties.SCOPES;
|
import static org.jclouds.oauth.v2.config.OAuthProperties.SCOPES;
|
||||||
import static org.jclouds.oauth.v2.config.OAuthProperties.SIGNATURE_OR_MAC_ALGORITHM;
|
import static org.jclouds.oauth.v2.config.OAuthProperties.SIGNATURE_OR_MAC_ALGORITHM;
|
||||||
|
@ -40,7 +40,7 @@ public class BaseOAuthApiLiveTest extends BaseApiLiveTest<OAuthApi> {
|
||||||
@Override
|
@Override
|
||||||
protected Properties setupProperties() {
|
protected Properties setupProperties() {
|
||||||
Properties props = super.setupProperties();
|
Properties props = super.setupProperties();
|
||||||
setCredentialFromPemFile(props, "oauth.credential");
|
setCredential(props, "oauth.credential");
|
||||||
checkNotNull(setIfTestSystemPropertyPresent(props, "oauth.endpoint"), "test.oauth.endpoint must be set");
|
checkNotNull(setIfTestSystemPropertyPresent(props, "oauth.endpoint"), "test.oauth.endpoint must be set");
|
||||||
checkNotNull(setIfTestSystemPropertyPresent(props, AUDIENCE), "test.jclouds.oauth.audience must be set");
|
checkNotNull(setIfTestSystemPropertyPresent(props, AUDIENCE), "test.jclouds.oauth.audience must be set");
|
||||||
setIfTestSystemPropertyPresent(props, SCOPES);
|
setIfTestSystemPropertyPresent(props, SCOPES);
|
||||||
|
|
Loading…
Reference in New Issue