Search in sources :

Example 1 with SecurityRealm

use of hudson.security.SecurityRealm in project configuration-as-code-plugin by jenkinsci.

the class GithubOAuthTest method testSampleVersionForOAuth.

@Test
@ConfiguredWithCode("GithubOAuth.yml")
public void testSampleVersionForOAuth() {
    SecurityRealm realm = Jenkins.getInstance().getSecurityRealm();
    assertThat(realm, instanceOf(GithubSecurityRealm.class));
    GithubSecurityRealm gsh = (GithubSecurityRealm) realm;
    assertEquals("someId", gsh.getClientID());
    assertEquals("https://api.github.com", gsh.getGithubApiUri());
    assertEquals("https://github.com", gsh.getGithubWebUri());
    assertEquals("j985j8fhfhh377", gsh.getClientSecret().getPlainText());
    assertEquals("read:org,user:email", gsh.getOauthScopes());
}
Also used : GithubSecurityRealm(org.jenkinsci.plugins.GithubSecurityRealm) SecurityRealm(hudson.security.SecurityRealm) GithubSecurityRealm(org.jenkinsci.plugins.GithubSecurityRealm) Test(org.junit.Test) ConfiguredWithCode(org.jenkinsci.plugins.casc.misc.ConfiguredWithCode)

Example 2 with SecurityRealm

use of hudson.security.SecurityRealm in project configuration-as-code-plugin by jenkinsci.

the class Crowd2Test method configure_artifact_manager.

@Test
@ConfiguredWithReadme("crowd2/README.md")
public void configure_artifact_manager() {
    SecurityRealm realm = Jenkins.get().getSecurityRealm();
    assertThat(realm, instanceOf(CrowdSecurityRealm.class));
    CrowdSecurityRealm securityRealm = (CrowdSecurityRealm) realm;
    assertThat(securityRealm.applicationName, is("jenkins"));
    assertThat(securityRealm.group, is("jenkins-users"));
    assertThat(securityRealm.url, is("http://crowd.company.io"));
    assertThat(securityRealm.password, hasPlainText(PASSWORD_123));
}
Also used : CrowdSecurityRealm(de.theit.jenkins.crowd.CrowdSecurityRealm) SecurityRealm(hudson.security.SecurityRealm) CrowdSecurityRealm(de.theit.jenkins.crowd.CrowdSecurityRealm) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 3 with SecurityRealm

use of hudson.security.SecurityRealm in project configuration-as-code-plugin by jenkinsci.

the class GithubOAuthTest method testSampleVersionForOAuth.

@Test
@ConfiguredWithReadme("github-oauth/README.md")
public void testSampleVersionForOAuth() {
    SecurityRealm realm = Jenkins.get().getSecurityRealm();
    assertThat(realm, instanceOf(GithubSecurityRealm.class));
    GithubSecurityRealm gsh = (GithubSecurityRealm) realm;
    assertEquals("someId", gsh.getClientID());
    assertEquals("https://api.github.com", gsh.getGithubApiUri());
    assertEquals("https://github.com", gsh.getGithubWebUri());
    assertEquals("j985j8fhfhh377", gsh.getClientSecret().getPlainText());
    assertEquals("read:org,user:email", gsh.getOauthScopes());
}
Also used : GithubSecurityRealm(org.jenkinsci.plugins.GithubSecurityRealm) SecurityRealm(hudson.security.SecurityRealm) GithubSecurityRealm(org.jenkinsci.plugins.GithubSecurityRealm) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 4 with SecurityRealm

use of hudson.security.SecurityRealm in project configuration-as-code-plugin by jenkinsci.

the class KeycloakTest method configure_artifact_manager.

@Test
@ConfiguredWithReadme("keycloak/README.md")
public void configure_artifact_manager() {
    SecurityRealm realm = j.jenkins.get().getSecurityRealm();
    assertThat(realm, instanceOf(KeycloakSecurityRealm.class));
    KeycloakSecurityRealm securityRealm = (KeycloakSecurityRealm) realm;
    assertThat(securityRealm.getKeycloakJson(), containsString("\"auth-server-url\": \"https://my-keycloak-url/auth\""));
}
Also used : SecurityRealm(hudson.security.SecurityRealm) KeycloakSecurityRealm(org.jenkinsci.plugins.KeycloakSecurityRealm) KeycloakSecurityRealm(org.jenkinsci.plugins.KeycloakSecurityRealm) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Aggregations

SecurityRealm (hudson.security.SecurityRealm)4 Test (org.junit.Test)4 ConfiguredWithReadme (io.jenkins.plugins.casc.misc.ConfiguredWithReadme)3 GithubSecurityRealm (org.jenkinsci.plugins.GithubSecurityRealm)2 CrowdSecurityRealm (de.theit.jenkins.crowd.CrowdSecurityRealm)1 KeycloakSecurityRealm (org.jenkinsci.plugins.KeycloakSecurityRealm)1 ConfiguredWithCode (org.jenkinsci.plugins.casc.misc.ConfiguredWithCode)1