use of org.jenkinsci.test.acceptance.po.GlobalSecurityConfig in project acceptance-test-harness by jenkinsci.
the class AntisamyMarkupFormatterTest method safeHtmlTest.
@Test
public void safeHtmlTest() {
final GlobalSecurityConfig security = new GlobalSecurityConfig(jenkins);
security.open();
security.selectSafeHtmlFormatter();
security.save();
final FreeStyleJob job = jenkins.jobs.create(FreeStyleJob.class);
job.description(NO_HTML, true);
assertThat(driver, hasContent(NO_HTML));
job.description(String.format(HREF_ELEM, HREF_VALID), true);
assertThat(driver, hasContent(HREF_MESSAGE));
this.assertHref(HREF_VALID, true);
job.description(String.format(HREF_ELEM, HREF_INVALID), true);
assertThat(driver, hasContent(HREF_MESSAGE));
this.assertHref(HREF_INVALID, false);
}
use of org.jenkinsci.test.acceptance.po.GlobalSecurityConfig in project acceptance-test-harness by jenkinsci.
the class JenkinsDatabaseSecurityRealmTest method setUp.
@Before
public void setUp() {
GlobalSecurityConfig security = new GlobalSecurityConfig(jenkins);
security.configure();
realm = security.useRealm(JenkinsDatabaseSecurityRealm.class);
realm.allowUsersToSignUp(true);
security.save();
}
use of org.jenkinsci.test.acceptance.po.GlobalSecurityConfig in project acceptance-test-harness by jenkinsci.
the class JobDslPluginTest method setUpSecurity.
/**
* Set up global security. Two users 'admin', with admin permission,
* and 'user', with permissions necessary to manipulate jobs, will be generated.
* Script security for Job DSL scripts will be enabled.
* @return The global security configuration.
*/
private GlobalSecurityConfig setUpSecurity() {
GlobalSecurityConfig sc = new GlobalSecurityConfig(jenkins);
sc.configure(() -> {
MockSecurityRealm ms = sc.useRealm(MockSecurityRealm.class);
ms.configure(ADMIN, USER);
MatrixAuthorizationStrategy mas = sc.useAuthorizationStrategy(MatrixAuthorizationStrategy.class);
MatrixRow a = mas.addUser(ADMIN);
a.admin();
MatrixRow b = mas.addUser(USER);
b.developer();
sc.setJobDslScriptSecurity(true);
});
return sc;
}
use of org.jenkinsci.test.acceptance.po.GlobalSecurityConfig in project acceptance-test-harness by jenkinsci.
the class JobDslPluginTest method should_disallow_importing_groovy_classes_when_script_security_enabled.
/**
* Verifies that if script security for Job DSL scripts is enabled and Jenkins
* security is enabled, it is not possible to import Groovy classes from the
* workspace.
*/
@Test
@WithPlugins({ "matrix-auth@2.3", "mock-security-realm" })
public void should_disallow_importing_groovy_classes_when_script_security_enabled() {
GlobalSecurityConfig sc = setUpSecurity();
jenkins.login().doLogin(ADMIN);
FreeStyleJob seedJob = createSeedJob();
seedJob.copyResource(resource("/job_dsl_plugin/MyUtilities.groovy"), "utilities/MyUtilities.groovy");
JobDslBuildStep jobDsl = seedJob.addBuildStep(JobDslBuildStep.class);
jobDsl.setScript("import utilities.MyUtilities\n" + "\n" + "def newJob = job('New_Job')\n" + "MyUtilities.addDescription(newJob)");
seedJob.save();
// Build should fail because importing Groovy classes not allowed if script security is enabled
Build build = seedJob.scheduleBuild().shouldFail();
assertThat(build.getConsole(), containsString("unable to resolve class utilities.MyUtilities"));
sc.configure(() -> sc.setJobDslScriptSecurity(false));
seedJob.scheduleBuild().shouldSucceed();
}
use of org.jenkinsci.test.acceptance.po.GlobalSecurityConfig in project acceptance-test-harness by jenkinsci.
the class LdapPluginTest method useLdapAsSecurityRealm.
/**
* "Jenkins is using ldap as security realm"
*/
private void useLdapAsSecurityRealm(LdapDetails ldapDetails) {
GlobalSecurityConfig security = new GlobalSecurityConfig(jenkins);
security.configure();
LdapSecurityRealm realm = security.useRealm(LdapSecurityRealm.class);
realm.configure(ldapDetails);
security.save();
}
Aggregations