From 00d9edc1e6c1893fd2d3fdcb2600cba2287db36e Mon Sep 17 00:00:00 2001 From: Chris Custine Date: Thu, 31 Jul 2014 01:57:19 -0600 Subject: [PATCH] JCLOUDS-643: Fix Google and OAuth tests --- apis/oauth/pom.xml | 8 +++++++- .../test/java/org/jclouds/oauth/v2/OAuthTestUtils.java | 8 ++++++-- .../jclouds/oauth/v2/internal/BaseOAuthApiLiveTest.java | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/apis/oauth/pom.xml b/apis/oauth/pom.xml index 31d34ac287..a157fde604 100644 --- a/apis/oauth/pom.xml +++ b/apis/oauth/pom.xml @@ -92,6 +92,12 @@ org.apache.maven.plugins maven-surefire-plugin + + default-test + + true + + integration integration-test @@ -105,7 +111,7 @@ ${test.oauth.endpoint} ${test.oauth.api-version} ${test.oauth.build-version} - ${test.jclouds.oauth.signature-or-mac-algorithm>} + ${test.jclouds.oauth.signature-or-mac-algorithm} ${test.jclouds.oauth.audience} ${test.jclouds.oauth.scopes} diff --git a/apis/oauth/src/test/java/org/jclouds/oauth/v2/OAuthTestUtils.java b/apis/oauth/src/test/java/org/jclouds/oauth/v2/OAuthTestUtils.java index 28879a98ce..7e27844e23 100644 --- a/apis/oauth/src/test/java/org/jclouds/oauth/v2/OAuthTestUtils.java +++ b/apis/oauth/src/test/java/org/jclouds/oauth/v2/OAuthTestUtils.java @@ -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 credentialFromFile = null; String testKey = "test." + key; @@ -54,7 +54,11 @@ public class OAuthTestUtils { if (System.getProperties().containsKey(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 { credentialFromFile = Files.toString(new File(val), Charsets.UTF_8); diff --git a/apis/oauth/src/test/java/org/jclouds/oauth/v2/internal/BaseOAuthApiLiveTest.java b/apis/oauth/src/test/java/org/jclouds/oauth/v2/internal/BaseOAuthApiLiveTest.java index ee1149002b..ba1c616bcc 100644 --- a/apis/oauth/src/test/java/org/jclouds/oauth/v2/internal/BaseOAuthApiLiveTest.java +++ b/apis/oauth/src/test/java/org/jclouds/oauth/v2/internal/BaseOAuthApiLiveTest.java @@ -17,7 +17,7 @@ package org.jclouds.oauth.v2.internal; 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.SCOPES; import static org.jclouds.oauth.v2.config.OAuthProperties.SIGNATURE_OR_MAC_ALGORITHM; @@ -40,7 +40,7 @@ public class BaseOAuthApiLiveTest extends BaseApiLiveTest { @Override protected Properties 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, AUDIENCE), "test.jclouds.oauth.audience must be set"); setIfTestSystemPropertyPresent(props, SCOPES);