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();
}
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();
}
Aggregations