ensure identity/credential properties are not needed when using credential supplier

This commit is contained in:
adriancole 2013-01-21 10:02:46 -08:00
parent ad70dae25c
commit 847561ee00
2 changed files with 12 additions and 16 deletions

View File

@ -297,11 +297,17 @@ public class ContextBuilder {
Properties unexpanded = currentStateToUnexpandedProperties(); Properties unexpanded = currentStateToUnexpandedProperties();
ImmutableSet<String> keysToResolve = ImmutableSet.of(PROPERTY_ENDPOINT, PROPERTY_IDENTITY, PROPERTY_CREDENTIAL, Set<String> keysToResolve = ImmutableSet.of(PROPERTY_IDENTITY, PROPERTY_CREDENTIAL, PROPERTY_ENDPOINT,
PROPERTY_API, PROPERTY_API_VERSION, PROPERTY_BUILD_VERSION); PROPERTY_API, PROPERTY_API_VERSION, PROPERTY_BUILD_VERSION);
ImmutableSet<String> optionalKeys = apiMetadata.getCredentialName().isPresent() ? ImmutableSet.<String> of() Set<String> optionalKeys;
: ImmutableSet.of(PROPERTY_CREDENTIAL); if (credentialsSupplierOption.isPresent()) {
optionalKeys = ImmutableSet.of(PROPERTY_IDENTITY, PROPERTY_CREDENTIAL);
} else if (!apiMetadata.getCredentialName().isPresent()) {
optionalKeys = ImmutableSet.of(PROPERTY_CREDENTIAL);
} else {
optionalKeys = ImmutableSet.of();
}
Properties resolved = resolveProperties(unexpanded, providerId, keysToResolve, optionalKeys); Properties resolved = resolveProperties(unexpanded, providerId, keysToResolve, optionalKeys);

View File

@ -64,10 +64,7 @@ public class ContextBuilderTest {
@ConfiguresHttpCommandExecutorService @ConfiguresHttpCommandExecutorService
static class HttpModule extends AbstractModule { static class HttpModule extends AbstractModule {
@Override
protected void configure() { protected void configure() {
} }
} }
@ -124,9 +121,6 @@ public class ContextBuilderTest {
@Test @Test
public void testProviderMetadataWithCredentialsSetSupplier() { public void testProviderMetadataWithCredentialsSetSupplier() {
Properties overrides = new Properties();
overrides.setProperty(Constants.PROPERTY_IDENTITY, "foo");
overrides.setProperty(Constants.PROPERTY_CREDENTIAL, "BAR");
ContextBuilder withCredsSupplier = testContextBuilder().credentialsSupplier( ContextBuilder withCredsSupplier = testContextBuilder().credentialsSupplier(
ofInstance(new Credentials("foo", "BAR"))); ofInstance(new Credentials("foo", "BAR")));
Credentials creds = withCredsSupplier.buildInjector() Credentials creds = withCredsSupplier.buildInjector()
@ -239,14 +233,10 @@ public class ContextBuilderTest {
public void testBuilder() { public void testBuilder() {
Module module1 = new AbstractModule() { Module module1 = new AbstractModule() {
@Override
protected void configure() { protected void configure() {
} }
}; };
Module module2 = new AbstractModule() { Module module2 = new AbstractModule() {
@Override
protected void configure() { protected void configure() {
} }
}; };