use of jenkins.model.Jenkins in project configuration-as-code-plugin by jenkinsci.
the class SystemCredentialsTest method configure_system_credentials.
@Test
@ConfiguredWithCode("SystemCredentialsTest.yml")
public void configure_system_credentials() throws Exception {
Jenkins jenkins = Jenkins.getInstance();
List<UsernamePasswordCredentials> ups = CredentialsProvider.lookupCredentials(UsernamePasswordCredentials.class, jenkins, ACL.SYSTEM, Collections.emptyList());
assertThat(ups, hasSize(1));
assertThat(ups.get(0).getPassword().getPlainText(), equalTo("1234"));
List<CertificateCredentials> certs = CredentialsProvider.lookupCredentials(CertificateCredentials.class, jenkins, ACL.SYSTEM, Collections.emptyList());
assertThat(certs, hasSize(1));
assertThat(certs.get(0).getPassword().getPlainText(), equalTo("ABCD"));
List<BasicSSHUserPrivateKey> sshPrivateKeys = CredentialsProvider.lookupCredentials(BasicSSHUserPrivateKey.class, jenkins, ACL.SYSTEM, Collections.emptyList());
assertThat(sshPrivateKeys, hasSize(2));
assertThat(sshPrivateKeys.get(0).getPassphrase().getPlainText(), equalTo("ABCD"));
}
use of jenkins.model.Jenkins in project configuration-as-code-plugin by jenkinsci.
the class AdminWhitelistRuleConfiguratorTest method checkM2SSecurityKillSwitch_disabled.
@Test
@Issue("Issue #28")
@ConfiguredWithCode("AdminWhitelistRuleConfigurator/Slave2MasterSecurityKillSwitch_disabled.yml")
public void checkM2SSecurityKillSwitch_disabled() throws Exception {
final Jenkins jenkins = Jenkins.getInstance();
AdminWhitelistRule rule = jenkins.getInjector().getInstance(AdminWhitelistRule.class);
Assert.assertFalse("MasterToSlave Security should be disabled", rule.getMasterKillSwitch());
}
use of jenkins.model.Jenkins in project configuration-as-code-plugin by jenkinsci.
the class GetConfiguratorsTest method shouldGetAllConfigurators.
@Test
@ConfiguredWithCode(value = "GetConfiguratorsTest.yml")
public void shouldGetAllConfigurators() throws Exception {
final Jenkins jenkins = Jenkins.getInstance();
ConfigurationAsCode configurationAsCode = jenkins.getExtensionList(ManagementLink.class).get(ConfigurationAsCode.class);
assertThat(configurationAsCode.getConfigurators(), hasSize(greaterThan(0)));
}
use of jenkins.model.Jenkins in project configuration-as-code-plugin by jenkinsci.
the class GitToolInstallationTest method configure_git_installations.
@Test
@ConfiguredWithCode("GitToolInstallationTest.yml")
public void configure_git_installations() throws Exception {
final Jenkins jenkins = Jenkins.getInstance();
final GitTool.DescriptorImpl descriptor = (GitTool.DescriptorImpl) jenkins.getDescriptor(GitTool.class);
assertEquals(2, descriptor.getInstallations().length);
assertEquals("/usr/local/bin/git", descriptor.getInstallation("another_git").getGitExe());
assertEquals("/bin/git", descriptor.getInstallation("git").getGitExe());
}
use of jenkins.model.Jenkins in project configuration-as-code-plugin by jenkinsci.
the class JenkinsConfiguratorTest method jenkins_abstract_describable_attributes.
@Test
@ConfiguredWithCode("HeteroDescribable.yml")
public void jenkins_abstract_describable_attributes() throws Exception {
final Jenkins jenkins = Jenkins.getInstance();
assertTrue(jenkins.getSecurityRealm() instanceof HudsonPrivateSecurityRealm);
assertTrue(jenkins.getAuthorizationStrategy() instanceof FullControlOnceLoggedInAuthorizationStrategy);
assertFalse(((FullControlOnceLoggedInAuthorizationStrategy) jenkins.getAuthorizationStrategy()).isAllowAnonymousRead());
}
Aggregations