cleaned up test cases and allowed basic auth to be instantiated via new

This commit is contained in:
Adrian Cole 2010-10-01 16:08:15 +01:00
parent 3a09b2ab6b
commit 17e4b779b4
3 changed files with 7 additions and 8 deletions

View File

@ -91,4 +91,5 @@ public class ComputeTestUtils {
} }
} }
} }
} }

View File

@ -43,7 +43,7 @@ public class RunScriptData {
private static String jbossHome = "/usr/local/jboss"; private static String jbossHome = "/usr/local/jboss";
public static String createScriptInstallBase(OperatingSystem os) { public static String installJavaAndCurl(OperatingSystem os) {
if (os == null || OperatingSystemPredicates.supportsApt().apply(os)) if (os == null || OperatingSystemPredicates.supportsApt().apply(os))
return APT_RUN_SCRIPT; return APT_RUN_SCRIPT;
else if (OperatingSystemPredicates.supportsYum().apply(os)) else if (OperatingSystemPredicates.supportsYum().apply(os))
@ -63,7 +63,7 @@ public class RunScriptData {
envVariables, envVariables,
ImmutableList.<Statement> of( ImmutableList.<Statement> of(
new AuthorizeRSAPublicKey(publicKey), new AuthorizeRSAPublicKey(publicKey),
exec(createScriptInstallBase(os)), exec(installJavaAndCurl(os)),
exec("rm -rf /var/cache/apt /usr/lib/vmware-tools"),// jeos hasn't enough room! exec("rm -rf /var/cache/apt /usr/lib/vmware-tools"),// jeos hasn't enough room!
extractTargzIntoDirectory( extractTargzIntoDirectory(
URI.create("http://commondatastorage.googleapis.com/jclouds-repo/jboss-as-distribution-6.0.0.20100911-M5.tar.gz"), URI.create("http://commondatastorage.googleapis.com/jclouds-repo/jboss-as-distribution-6.0.0.20100911-M5.tar.gz"),
@ -92,7 +92,6 @@ public class RunScriptData {
.append( .append(
"echo \"baseurl=http://ec2-us-east-mirror.rightscale.com/epel/5/i386/\" >> /etc/yum.repos.d/CentOS-Base.repo\n")// "echo \"baseurl=http://ec2-us-east-mirror.rightscale.com/epel/5/i386/\" >> /etc/yum.repos.d/CentOS-Base.repo\n")//
.append("echo \"enabled=1\" >> /etc/yum.repos.d/CentOS-Base.repo\n")// .append("echo \"enabled=1\" >> /etc/yum.repos.d/CentOS-Base.repo\n")//
// .append("which unzip ||yum --nogpgcheck -y install unzip\n")//
.append("which curl ||yum --nogpgcheck -y install curl\n")// .append("which curl ||yum --nogpgcheck -y install curl\n")//
.append( .append(
"(which java && java -fullversion 2>&1|egrep -q 1.6 ) || yum --nogpgcheck -y install java-1.6.0-openjdk&&")// "(which java && java -fullversion 2>&1|egrep -q 1.6 ) || yum --nogpgcheck -y install java-1.6.0-openjdk&&")//
@ -101,7 +100,6 @@ public class RunScriptData {
public static final String ZYPPER_RUN_SCRIPT = new StringBuilder()// public static final String ZYPPER_RUN_SCRIPT = new StringBuilder()//
.append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")// .append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")//
// .append("which unzip ||sudo zypper install unzip\n")//
.append("which curl || zypper install curl\n")// .append("which curl || zypper install curl\n")//
.append("(which java && java -fullversion 2>&1|egrep -q 1.6 ) || zypper install java-1.6.0-openjdk\n")// .append("(which java && java -fullversion 2>&1|egrep -q 1.6 ) || zypper install java-1.6.0-openjdk\n")//
.toString(); .toString();

View File

@ -52,8 +52,8 @@ public class BasicAuthentication implements HttpRequestFilter {
private final Set<String> credentialList; private final Set<String> credentialList;
@Inject @Inject
BasicAuthentication(@Named(PROPERTY_IDENTITY) String user, @Named(PROPERTY_CREDENTIAL) String password, Crypto crypto) public BasicAuthentication(@Named(PROPERTY_IDENTITY) String user, @Named(PROPERTY_CREDENTIAL) String password,
throws UnsupportedEncodingException { Crypto crypto) throws UnsupportedEncodingException {
this.credentialList = ImmutableSet.of("Basic " this.credentialList = ImmutableSet.of("Basic "
+ CryptoStreams.base64(String.format("%s:%s", checkNotNull(user, "user"), + CryptoStreams.base64(String.format("%s:%s", checkNotNull(user, "user"),
checkNotNull(password, "password")).getBytes("UTF-8"))); checkNotNull(password, "password")).getBytes("UTF-8")));