Skip to content
Permalink
Browse files

[JENKINS-25576] SecurityConfigUtils is removed after refactoring.

The only method that was in SecurityConfigUtils class is moved into
ProjectBasedMatrixAuthorizationStrategy. As a result of refactoring,
the class is removed.

Change-Id: Id185e1d13ae6f6baa08350bafbe296810b7b6f6b
  • Loading branch information
Bowen Cheng Bowen Cheng
Bowen Cheng authored and Bowen Cheng committed Nov 12, 2014
1 parent 2c87fd8 commit 3d8e0bda3ccbd1c1610944fdc1cb9662889f7f21
@@ -11,4 +11,19 @@
public ProjectBasedMatrixAuthorizationStrategy(GlobalSecurityConfig context, String path) {
super(context, path);
}

/**
* Add and authorize given user admin role under "Project-based Matrix Authorization Strategy"
*
* @param user user to be added and authorized as admin
* @param security page object
* @return security page object
*/
public static GlobalSecurityConfig authorizeUserAsAdmin(String user, GlobalSecurityConfig security) {
ProjectBasedMatrixAuthorizationStrategy auth;
auth = security.useAuthorizationStrategy(ProjectBasedMatrixAuthorizationStrategy.class);
MatrixRow userAuth = auth.addUser(user);
userAuth.admin();
return security;
}
}

This file was deleted.

@@ -28,6 +28,7 @@
import org.jenkinsci.test.acceptance.plugins.active_directory.ActiveDirectoryEnv;
import org.jenkinsci.test.acceptance.utils.pluginTests.SecurityDisabler;
import org.jenkinsci.test.acceptance.plugins.active_directory.ActiveDirectorySecurityRealm;
import org.jenkinsci.test.acceptance.plugins.matrix_auth.ProjectBasedMatrixAuthorizationStrategy;
import org.jenkinsci.test.acceptance.po.GlobalSecurityConfig;
import org.junit.After;
import org.junit.Before;
@@ -36,7 +37,6 @@

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.jenkinsci.test.acceptance.utils.pluginTests.SecurityConfigUtils.authorizeUserAsAdmin;

/**
* Set these (data) at mvn-test command line to use this test:<br>
@@ -139,7 +139,7 @@ private void userCanLoginToJenkinsAsAdmin(String userOrGroupToAddAsAdmin) {
private GlobalSecurityConfig saveSecurityConfig(String userOrGroupToAddAsAdmin) {
GlobalSecurityConfig security = new GlobalSecurityConfig(jenkins);
security.configure();
security = authorizeUserAsAdmin(userOrGroupToAddAsAdmin, security);
security = ProjectBasedMatrixAuthorizationStrategy.authorizeUserAsAdmin(userOrGroupToAddAsAdmin, security);
security = configSecurityRealm(security);
security.save();
return security;
@@ -25,6 +25,7 @@

import org.jenkinsci.test.acceptance.junit.AbstractJUnitTest;
import org.jenkinsci.test.acceptance.junit.WithPlugins;
import org.jenkinsci.test.acceptance.plugins.matrix_auth.ProjectBasedMatrixAuthorizationStrategy;
import org.jenkinsci.test.acceptance.utils.pluginTests.SecurityDisabler;
import org.jenkinsci.test.acceptance.plugins.ldap.LdapDetails;
import org.jenkinsci.test.acceptance.plugins.ldap.LdapEnv;
@@ -36,7 +37,6 @@

import static org.hamcrest.MatcherAssert.assertThat;
import static org.jenkinsci.test.acceptance.Matchers.hasLoggedInUser;
import static org.jenkinsci.test.acceptance.utils.pluginTests.SecurityConfigUtils.*;

/**
* Set these (data) at mvn-test command line to use this test:<br>
@@ -63,8 +63,6 @@
* -ldapCacheSize (default 20) <br>
* -ldapCacheTTL (default 300)<br>
* <br>
* Consider setting -Dhudson.plugins.active_directory.ActiveDirectorySecurityRealm.forceLdaps=true<br>
* <br>
* Test(s) disables security once over.
*
* @author Bowen.Cheng@ericsson.com
@@ -145,7 +143,7 @@ private GlobalSecurityConfig saveSecurityConfig(String userOrGroupToAddAsAdmin)
GlobalSecurityConfig security = new GlobalSecurityConfig(jenkins);
security.configure();
security = configSecurityRealm(security);
security = authorizeUserAsAdmin(userOrGroupToAddAsAdmin, security);
security = ProjectBasedMatrixAuthorizationStrategy.authorizeUserAsAdmin(userOrGroupToAddAsAdmin, security);
security.save();
return security;
}

0 comments on commit 3d8e0bd

Please sign in to comment.
You can’t perform that action at this time.