Search in sources :

Example 21 with ConfiguredWithReadme

use of io.jenkins.plugins.casc.misc.ConfiguredWithReadme in project configuration-as-code-plugin by jenkinsci.

the class TopReadmeTest method configure_demo_fourth_code_block.

@Test
@ConfiguredWithReadme("README.md#3")
public void configure_demo_fourth_code_block() {
    final Jenkins jenkins = Jenkins.get();
    assertEquals(2, jenkins.getNodes().size());
    assertEquals("static-agent1", jenkins.getNode("static-agent1").getNodeName());
    assertEquals("static-agent2", jenkins.getNode("static-agent2").getNodeName());
}
Also used : Jenkins(jenkins.model.Jenkins) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 22 with ConfiguredWithReadme

use of io.jenkins.plugins.casc.misc.ConfiguredWithReadme in project configuration-as-code-plugin by jenkinsci.

the class TopReadmeTest method configure_demo_first_code_block.

@Test
@ConfiguredWithReadme("README.md#0")
public void configure_demo_first_code_block() {
    final Jenkins jenkins = Jenkins.get();
    assertEquals("Jenkins configured automatically by Jenkins Configuration as Code plugin\n\n", jenkins.getSystemMessage());
    final LDAPSecurityRealm securityRealm = (LDAPSecurityRealm) jenkins.getSecurityRealm();
    assertEquals(1, securityRealm.getConfigurations().size());
    assertEquals(50000, jenkins.getSlaveAgentPort());
    assertEquals(1, jenkins.getNodes().size());
    assertEquals("static-agent", jenkins.getNode("static-agent").getNodeName());
    final GitTool.DescriptorImpl gitTool = (GitTool.DescriptorImpl) jenkins.getDescriptor(GitTool.class);
    assertEquals(1, gitTool.getInstallations().length);
    List<BasicSSHUserPrivateKey> sshPrivateKeys = CredentialsProvider.lookupCredentials(BasicSSHUserPrivateKey.class, jenkins, ACL.SYSTEM, Collections.emptyList());
    assertThat(sshPrivateKeys, hasSize(1));
    final BasicSSHUserPrivateKey ssh_with_passphrase = sshPrivateKeys.get(0);
    assertThat(ssh_with_passphrase.getPassphrase().getPlainText(), equalTo("ABCD"));
    final DirectEntryPrivateKeySource source = (DirectEntryPrivateKeySource) ssh_with_passphrase.getPrivateKeySource();
    assertThat(source.getPrivateKey().getPlainText(), equalTo("s3cr3t"));
}
Also used : Jenkins(jenkins.model.Jenkins) LDAPSecurityRealm(hudson.security.LDAPSecurityRealm) DirectEntryPrivateKeySource(com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey.DirectEntryPrivateKeySource) GitTool(hudson.plugins.git.GitTool) BasicSSHUserPrivateKey(com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 23 with ConfiguredWithReadme

use of io.jenkins.plugins.casc.misc.ConfiguredWithReadme in project configuration-as-code-plugin by jenkinsci.

the class HudsonPrivateSecurityRealmConfiguratorTest method configure_all_attributes.

@Test
@ConfiguredWithReadme("embedded-userdatabase/README.md#1")
public void configure_all_attributes() {
    final User admin = User.getById("admin", false);
    assertNotNull(admin);
    assertThat(admin.getFullName(), is("Admin"));
    assertThat(admin.getDescription(), is("Superwoman"));
    SlackUserProperty slackUserProperty = admin.getProperty(SlackUserProperty.class);
    assertThat(slackUserProperty.getUserId(), is("ABCDEFGH"));
    UserProperty mailerProperty = admin.getProperty(UserProperty.class);
    assertThat(mailerProperty.getEmailAddress(), is("admin3@example.com"));
// Pending https://github.com/jenkinsci/ssh-cli-auth-module/pull/16
// UserPropertyImpl authorizedKeysProperty = admin.getProperty(UserPropertyImpl.class);
// assertThat(authorizedKeysProperty.authorizedKeys, is("ssh-rsa some-key\n"));
}
Also used : User(hudson.model.User) SlackUserProperty(jenkins.plugins.slack.user.SlackUserProperty) UserProperty(hudson.tasks.Mailer.UserProperty) SlackUserProperty(jenkins.plugins.slack.user.SlackUserProperty) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 24 with ConfiguredWithReadme

use of io.jenkins.plugins.casc.misc.ConfiguredWithReadme in project configuration-as-code-plugin by jenkinsci.

the class HudsonPrivateSecurityRealmConfiguratorTest method configure_local_security_and_admin_user.

@Test
@ConfiguredWithReadme("embedded-userdatabase/README.md#0")
public void configure_local_security_and_admin_user() {
    final Jenkins jenkins = Jenkins.get();
    final HudsonPrivateSecurityRealm securityRealm = (HudsonPrivateSecurityRealm) jenkins.getSecurityRealm();
    assertFalse(securityRealm.allowsSignup());
    final User admin = User.getById("admin", false);
    assertNotNull(admin);
    final HudsonPrivateSecurityRealm.Details details = admin.getProperty(HudsonPrivateSecurityRealm.Details.class);
    assertTrue(details.isPasswordCorrect("somethingsecret"));
    final FullControlOnceLoggedInAuthorizationStrategy authorizationStrategy = (FullControlOnceLoggedInAuthorizationStrategy) jenkins.getAuthorizationStrategy();
    assertTrue(authorizationStrategy.isAllowAnonymousRead());
}
Also used : Jenkins(jenkins.model.Jenkins) FullControlOnceLoggedInAuthorizationStrategy(hudson.security.FullControlOnceLoggedInAuthorizationStrategy) User(hudson.model.User) HudsonPrivateSecurityRealm(hudson.security.HudsonPrivateSecurityRealm) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 25 with ConfiguredWithReadme

use of io.jenkins.plugins.casc.misc.ConfiguredWithReadme in project configuration-as-code-plugin by jenkinsci.

the class HudsonPrivateSecurityRealmConfiguratorTest method config_local_security_and_hashed_admin_user.

@Test
@ConfiguredWithReadme("embedded-userdatabase/README.md#1")
public void config_local_security_and_hashed_admin_user() {
    final User admin = User.getById("hashedadmin", false);
    assertNotNull(admin);
    final HudsonPrivateSecurityRealm.Details details = admin.getProperty(HudsonPrivateSecurityRealm.Details.class);
    assertTrue(details.isPasswordCorrect("password"));
}
Also used : User(hudson.model.User) HudsonPrivateSecurityRealm(hudson.security.HudsonPrivateSecurityRealm) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Aggregations

ConfiguredWithReadme (io.jenkins.plugins.casc.misc.ConfiguredWithReadme)46 Test (org.junit.Test)46 Jenkins (jenkins.model.Jenkins)12 User (hudson.model.User)3 LDAPSecurityRealm (hudson.security.LDAPSecurityRealm)3 SecurityRealm (hudson.security.SecurityRealm)3 InstallSourceProperty (hudson.tools.InstallSourceProperty)3 BasicSSHUserPrivateKey (com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey)2 StandardUsernamePasswordCredentials (com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials)2 DockerCloud (com.nirima.jenkins.plugins.docker.DockerCloud)2 DockerTemplate (com.nirima.jenkins.plugins.docker.DockerTemplate)2 HudsonPrivateSecurityRealm (hudson.security.HudsonPrivateSecurityRealm)2 Util.toYamlString (io.jenkins.plugins.casc.misc.Util.toYamlString)2 CNode (io.jenkins.plugins.casc.model.CNode)2 AWSCredentialsImpl (com.cloudbees.jenkins.plugins.awscredentials.AWSCredentialsImpl)1 DirectEntryPrivateKeySource (com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey.DirectEntryPrivateKeySource)1 Credentials (com.cloudbees.plugins.credentials.Credentials)1 SecretBytes (com.cloudbees.plugins.credentials.SecretBytes)1 SystemCredentialsProvider (com.cloudbees.plugins.credentials.SystemCredentialsProvider)1 UsernamePasswordCredentials (com.cloudbees.plugins.credentials.common.UsernamePasswordCredentials)1