Fix test to actually verify user has ADMINISTER permission
@@ -94,14 +94,18 @@ public class ConfigurationTest {
@Test public void doFillCredentialsIdItemsWithoutJobWhenAdmin() throws Exception {
r.jenkins.setSecurityRealm(r.createDummySecurityRealm());
- MockAuthorizationStrategy as = new MockAuthorizationStrategy();
- // This AuthorizationStrategy has the ADMINISTER permission granted by default
+ ProjectMatrixAuthorizationStrategy as = new ProjectMatrixAuthorizationStrategy();
+ as.add(Jenkins.ADMINISTER, "alice");
r.jenkins.setAuthorizationStrategy(as);
- UsernamePasswordCredentialsImpl c = new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, null, "test", "bob", "s3cr3t");
+ final UsernamePasswordCredentialsImpl c = new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, null, "test", "bob", "s3cr3t");
CredentialsProvider.lookupStores(r.jenkins).iterator().next().addCredentials(Domain.global(), c);
+ ACL.impersonate(User.get("alice").impersonate(), new Runnable() {
+ @Override public void run() {
ListBoxModel options = r.jenkins.getDescriptorByType(MercurialSCM.DescriptorImpl.class).doFillCredentialsIdItems(null, "http://nowhere.net/");
assertEquals(CredentialsNameProvider.name(c), options.get(1).name);
}
+ });
+ }
@Issue("SECURITY-158")
@Test public void doFillCredentialsIdItems() throws Exception {
