Skip to content

Commit

Permalink
[JENKINS-30574] Added tests to configuration of GlobalQueueItemAuthen…
Browse files Browse the repository at this point in the history
…ticator.
  • Loading branch information
ikedam committed Mar 6, 2016
1 parent 12a36be commit 6137153
Showing 1 changed file with 33 additions and 0 deletions.
Expand Up @@ -15,6 +15,7 @@
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.JenkinsRule.WebClient;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
Expand Down Expand Up @@ -83,4 +84,36 @@ public void testWorkForFreeStyleProject() throws Exception {
assertEquals("bob", checker.authentication.getPrincipal());
}
}

@Test
public void testConfiguration() throws Exception {
GlobalQueueItemAuthenticator auth = new GlobalQueueItemAuthenticator(
new AnonymousAuthorizationStrategy()
);
QueueItemAuthenticatorConfiguration.get().getAuthenticators().add(auth);

WebClient wc = j.createWebClient();
j.submit(wc.goTo("configureSecurity").getFormByName("config"));

j.assertEqualDataBoundBeans(
auth,
QueueItemAuthenticatorConfiguration.get().getAuthenticators().get(GlobalQueueItemAuthenticator.class)
);
}

@Test
public void testConfigurationWithDescriptorNewInstance() throws Exception {
GlobalQueueItemAuthenticator auth = new GlobalQueueItemAuthenticator(
new SpecificUsersAuthorizationStrategy("admin", true)
);
QueueItemAuthenticatorConfiguration.get().getAuthenticators().add(auth);

WebClient wc = j.createWebClient();
j.submit(wc.goTo("configureSecurity").getFormByName("config"));

j.assertEqualDataBoundBeans(
auth,
QueueItemAuthenticatorConfiguration.get().getAuthenticators().get(GlobalQueueItemAuthenticator.class)
);
}
}

0 comments on commit 6137153

Please sign in to comment.