Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ private IdentityProviderConfig(
this.apiURL = apiURL;
this.defaultLoginRedirectURL = defaultLoginRedirectURL;
this.defaultLinkRedirectURL = defaultLinkRedirectURL;
this.customConfig = Collections.unmodifiableMap(customConfig);
this.envLoginRedirectURL = Collections.unmodifiableMap(envLoginRedirectURL);
this.envLinkRedirectURL = Collections.unmodifiableMap(envLinkRedirectURL);
this.customConfig = Collections.unmodifiableMap(new HashMap<>(customConfig));
this.envLoginRedirectURL = Collections.unmodifiableMap(new HashMap<>(envLoginRedirectURL));
this.envLinkRedirectURL = Collections.unmodifiableMap(new HashMap<>(envLinkRedirectURL));
}

/** Get the class name of the identity provider factory for this configuration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void goodInput() throws Exception {
new URL("http://api.com"),
"foo",
"bar",
new URL("https://loginredirect.com"),
new URL("https://fakeloginredirect.com"),
new URL("https://linkredirect.com"))
.withCustomConfiguration("foo", "bar")
.withCustomConfiguration("baz", "bat")
Expand All @@ -61,7 +61,7 @@ public void goodInput() throws Exception {
assertThat("incorrect link redirect URL", c.getLinkRedirectURL("env2"),
is(new URL("https://linkredirect2.com")));
assertThat("incorrect login redirect URL", c.getLoginRedirectURL(),
is(new URL("https://loginredirect.com")));
is(new URL("https://fakeloginredirect.com")));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should use a fake KBase subdomain for stable not-hanging not-existingness?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this happens so rarely it's not really worth worrying about

assertThat("incorrect login redirect URL", c.getLoginRedirectURL("env1"),
is(new URL("https://loginredirect1.com")));
assertThat("incorrect login redirect URL", c.getLoginRedirectURL("env2"),
Expand Down Expand Up @@ -265,7 +265,7 @@ private void failAddEnvironment(

@Test
public void immutable() throws Exception {
final IdentityProviderConfig c = IdentityProviderConfig.getBuilder(
Builder b = IdentityProviderConfig.getBuilder(
"MyProv",
new URL("http://login.com"),
new URL("http://api.com"),
Expand All @@ -275,8 +275,8 @@ public void immutable() throws Exception {
new URL("https://linkredirect.com"))
.withCustomConfiguration("foo", "bar")
.withCustomConfiguration("baz", "bat")
.withEnvironment("e", new URL("http://foo.com"), new URL("http://foo.com"))
.build();
.withEnvironment("e", new URL("http://foo.com"), new URL("http://foo.com"));
final IdentityProviderConfig c = b.build();

try {
c.getCustomConfiguation().put("foo", "bar");
Expand All @@ -291,6 +291,14 @@ public void immutable() throws Exception {
} catch (UnsupportedOperationException e) {
// test passed
}

// bugfix check - ensure modifying the builders maps doesn't modify old builds
b.withCustomConfiguration("whee", "whoo")
.withEnvironment("e1", new URL("http://whoo.com"), new URL("http://whee.com"));
assertThat("incorrect custom config", c.getCustomConfiguation(), is(ImmutableMap.of(
"foo", "bar", "baz", "bat"
)));
assertThat("incorrect envs", c.getEnvironments(), is(set("e")));
}

}
Loading