Search in sources :

Example 1 with ProjectDefaultBuildAccessControl

use of org.jenkinsci.test.acceptance.plugins.authorize_project.ProjectDefaultBuildAccessControl in project acceptance-test-harness by jenkinsci.

the class AuthorizeProjectTest method authorizeUserToLaunchProject.

private void authorizeUserToLaunchProject(final String user) {
    final GlobalSecurityConfig security = new GlobalSecurityConfig(jenkins);
    security.open();
    final ProjectDefaultBuildAccessControl control = security.addBuildAccessControl(ProjectDefaultBuildAccessControl.class);
    control.runAsSpecificUser(user);
    security.save();
}
Also used : GlobalSecurityConfig(org.jenkinsci.test.acceptance.po.GlobalSecurityConfig) ProjectDefaultBuildAccessControl(org.jenkinsci.test.acceptance.plugins.authorize_project.ProjectDefaultBuildAccessControl)

Example 2 with ProjectDefaultBuildAccessControl

use of org.jenkinsci.test.acceptance.plugins.authorize_project.ProjectDefaultBuildAccessControl 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

ProjectDefaultBuildAccessControl (org.jenkinsci.test.acceptance.plugins.authorize_project.ProjectDefaultBuildAccessControl)2 MatrixAuthorizationStrategy (org.jenkinsci.test.acceptance.plugins.matrix_auth.MatrixAuthorizationStrategy)1 GlobalSecurityConfig (org.jenkinsci.test.acceptance.po.GlobalSecurityConfig)1