Search in sources :

Example 6 with MatrixAuthorizationStrategy

use of org.jenkinsci.test.acceptance.plugins.matrix_auth.MatrixAuthorizationStrategy in project acceptance-test-harness by jenkinsci.

the class JobDslPluginTest method runBuildAsUserWhoTriggered.

/**
 * Add project default build access control to the global security configuration.
 * Additionally the permission ist added to 'user' that allows users to run
 * jobs as them on agents. Without this permission the job could not be executed.
 * @param sc A global security configuration.
 */
private void runBuildAsUserWhoTriggered(GlobalSecurityConfig sc) {
    jenkins.login().doLogin(ADMIN);
    sc.configure(() -> {
        final ProjectDefaultBuildAccessControl control = sc.addBuildAccessControl(ProjectDefaultBuildAccessControl.class);
        control.runAsUserWhoTriggered();
        MatrixAuthorizationStrategy mas = sc.useAuthorizationStrategy(MatrixAuthorizationStrategy.class);
        mas.getUser(USER).on("hudson.model.Computer.Build");
    });
    jenkins.logout();
}
Also used : ProjectDefaultBuildAccessControl(org.jenkinsci.test.acceptance.plugins.authorize_project.ProjectDefaultBuildAccessControl) MatrixAuthorizationStrategy(org.jenkinsci.test.acceptance.plugins.matrix_auth.MatrixAuthorizationStrategy)

Aggregations

MatrixAuthorizationStrategy (org.jenkinsci.test.acceptance.plugins.matrix_auth.MatrixAuthorizationStrategy)6 MockSecurityRealm (org.jenkinsci.test.acceptance.plugins.mock_security_realm.MockSecurityRealm)4 GlobalSecurityConfig (org.jenkinsci.test.acceptance.po.GlobalSecurityConfig)4 MatrixRow (org.jenkinsci.test.acceptance.plugins.matrix_auth.MatrixRow)3 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)1 ProjectDefaultBuildAccessControl (org.jenkinsci.test.acceptance.plugins.authorize_project.ProjectDefaultBuildAccessControl)1 ProjectBasedMatrixAuthorizationStrategy (org.jenkinsci.test.acceptance.plugins.matrix_auth.ProjectBasedMatrixAuthorizationStrategy)1 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)1 Before (org.junit.Before)1 Test (org.junit.Test)1