Skip to content

Commit

Permalink
[JENKINS-36483] Removes spaces from the Domain
Browse files Browse the repository at this point in the history
  • Loading branch information
recampbell committed Feb 4, 2017
1 parent 2f95fae commit bd9d822
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Expand Up @@ -105,7 +105,7 @@ public class GoogleOAuth2SecurityRealm extends SecurityRealm {
public GoogleOAuth2SecurityRealm(String clientId, String clientSecret, String domain) throws IOException {
this.clientId = clientId;
this.clientSecret = Secret.fromString(clientSecret);
this.domain = Util.fixEmpty(domain);
this.domain = Util.fixEmptyAndTrim(domain);
}

public String getClientId() {
Expand Down
Expand Up @@ -15,6 +15,20 @@ public class GoogleOAuth2SecurityRealmTest {
@Rule
public JenkinsRule jenkins = new JenkinsRule();

@Test
public void accidentallyBlank() throws IOException {
GoogleOAuth2SecurityRealm instance = setupInstanceWithDomains(" ");
assertTrue(instance.isDomainValid("acme.com"));
assertTrue(instance.isDomainValid("mycompany.com"));
}

@Test
public void trailingSpace() throws IOException {
GoogleOAuth2SecurityRealm instance = setupInstanceWithDomains("acme.com ");
assertTrue(instance.isDomainValid("acme.com"));
assertFalse(instance.isDomainValid("mycompany.com"));
}

@Test
public void validSingleDomain() throws IOException {
GoogleOAuth2SecurityRealm instance = setupInstanceWithDomains("acme.com");
Expand Down

0 comments on commit bd9d822

Please sign in to comment.