mirror of https://github.com/apache/jclouds.git
fixed stub to work with override credential template options
This commit is contained in:
parent
a6da180f61
commit
d86fa45fb6
|
@ -99,7 +99,14 @@ public class StubComputeServiceAdapter implements JCloudsNativeComputeServiceAda
|
||||||
builder.state(NodeState.PENDING);
|
builder.state(NodeState.PENDING);
|
||||||
builder.publicAddresses(ImmutableSet.<String> of(publicIpPrefix + id));
|
builder.publicAddresses(ImmutableSet.<String> of(publicIpPrefix + id));
|
||||||
builder.privateAddresses(ImmutableSet.<String> of(privateIpPrefix + id));
|
builder.privateAddresses(ImmutableSet.<String> of(privateIpPrefix + id));
|
||||||
builder.credentials(new Credentials("root", passwordPrefix + id));
|
Credentials creds = template.getOptions().getOverridingCredentials();
|
||||||
|
if (creds == null)
|
||||||
|
creds = new Credentials(null, null);
|
||||||
|
if (creds.identity == null)
|
||||||
|
creds = creds.toBuilder().identity("root").build();
|
||||||
|
if (creds.credential == null)
|
||||||
|
creds = creds.toBuilder().credential(passwordPrefix + id).build();
|
||||||
|
builder.credentials(creds);
|
||||||
NodeMetadata node = builder.build();
|
NodeMetadata node = builder.build();
|
||||||
credentialStore.put("node#" + node.getId(), node.getCredentials());
|
credentialStore.put("node#" + node.getId(), node.getCredentials());
|
||||||
nodes.put(node.getId(), node);
|
nodes.put(node.getId(), node);
|
||||||
|
|
|
@ -137,12 +137,11 @@ list, Alan Dipert and MeikelBrandmeyer."
|
||||||
node (create-node service "something" template)]
|
node (create-node service "something" template)]
|
||||||
(is (= (-> node bean :credentials f)
|
(is (= (-> node bean :credentials f)
|
||||||
(f credentials)))
|
(f credentials)))
|
||||||
(let [credentials (org.jclouds.domain.Credentials. "user" "pwd")
|
(let [identity "fred"
|
||||||
f #(.identity %)
|
f #(.identity %)
|
||||||
template (build-template service {:override-login-user-with "fred"})
|
template (build-template service {:override-login-user-with identity})
|
||||||
node (create-node service "something" template)]
|
node (create-node service "something" template)]
|
||||||
(is (= (-> node bean :credentials f)
|
(is (= (-> node bean :credentials f) identity)))
|
||||||
(f credentials))))
|
|
||||||
(let [credential "fred"
|
(let [credential "fred"
|
||||||
f #(.credential %)
|
f #(.credential %)
|
||||||
template (build-template
|
template (build-template
|
||||||
|
|
Loading…
Reference in New Issue