Skip to content
Permalink
Browse files

[JENKINS-36483] Removes spaces from the Domain

  • Loading branch information
recampbell committed Feb 4, 2017
1 parent 2f95fae commit bd9d82204ef28f995331102ffd3cb20e41554495
@@ -105,7 +105,7 @@
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() {
@@ -15,6 +15,20 @@
@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");

0 comments on commit bd9d822

Please sign in to comment.