Search in sources :

Example 16 with ConfiguredWithCode

use of org.jenkinsci.plugins.casc.misc.ConfiguredWithCode 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());
}
Also used : Jenkins(jenkins.model.Jenkins) GitTool(hudson.plugins.git.GitTool) Test(org.junit.Test) ConfiguredWithCode(org.jenkinsci.plugins.casc.misc.ConfiguredWithCode)

Example 17 with ConfiguredWithCode

use of org.jenkinsci.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.

the class GithubOrganisationFolderTest method configure_github_organisation_folder_seed_job.

// @Test
// Fails as Items do override submit() with manual data-binding implementation
@ConfiguredWithCode("GithubOrganisationFolderTest.yml")
public void configure_github_organisation_folder_seed_job() throws Exception {
    final TopLevelItem job = Jenkins.getInstance().getItem("ndeloof");
    assertNotNull(job);
    assertTrue(job instanceof OrganizationFolder);
    OrganizationFolder folder = (OrganizationFolder) job;
    assertEquals(1, folder.getNavigators().size());
    final GitHubSCMNavigator github = folder.getNavigators().get(GitHubSCMNavigator.class);
    assertNotNull(github);
    assertEquals("ndeloof", github.getRepoOwner());
}
Also used : OrganizationFolder(jenkins.branch.OrganizationFolder) TopLevelItem(hudson.model.TopLevelItem) GitHubSCMNavigator(org.jenkinsci.plugins.github_branch_source.GitHubSCMNavigator) ConfiguredWithCode(org.jenkinsci.plugins.casc.misc.ConfiguredWithCode)

Example 18 with ConfiguredWithCode

use of org.jenkinsci.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.

the class GlobalLibrariesTest method configure_global_library.

@Test
@ConfiguredWithCode("GlobalLibrariesTest.yml")
public void configure_global_library() throws Exception {
    assertEquals(1, GlobalLibraries.get().getLibraries().size());
    final LibraryConfiguration library = GlobalLibraries.get().getLibraries().get(0);
    assertEquals("awesome-lib", library.getName());
    final SCMSourceRetriever retriever = (SCMSourceRetriever) library.getRetriever();
    final GitSCMSource scm = (GitSCMSource) retriever.getScm();
    assertEquals("https://github.com/jenkins-infra/pipeline-library.git", scm.getRemote());
}
Also used : SCMSourceRetriever(org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever) LibraryConfiguration(org.jenkinsci.plugins.workflow.libs.LibraryConfiguration) GitSCMSource(jenkins.plugins.git.GitSCMSource) Test(org.junit.Test) ConfiguredWithCode(org.jenkinsci.plugins.casc.misc.ConfiguredWithCode)

Example 19 with ConfiguredWithCode

use of org.jenkinsci.plugins.casc.misc.ConfiguredWithCode 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());
}
Also used : Jenkins(jenkins.model.Jenkins) FullControlOnceLoggedInAuthorizationStrategy(hudson.security.FullControlOnceLoggedInAuthorizationStrategy) HudsonPrivateSecurityRealm(hudson.security.HudsonPrivateSecurityRealm) Test(org.junit.Test) ConfiguredWithCode(org.jenkinsci.plugins.casc.misc.ConfiguredWithCode)

Example 20 with ConfiguredWithCode

use of org.jenkinsci.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.

the class LDAPSecurityRealmTest method configure_securityRealm.

@Test
@ConfiguredWithCode("LDAPSecurityRealmTest.yml")
public void configure_securityRealm() {
    final Jenkins jenkins = Jenkins.getInstance();
    final LDAPSecurityRealm securityRealm = (LDAPSecurityRealm) jenkins.getSecurityRealm();
    assertEquals(1, securityRealm.getConfigurations().size());
    assertTrue(securityRealm.getUserIdStrategy() instanceof IdStrategy.CaseInsensitive);
    assertTrue(securityRealm.getGroupIdStrategy() instanceof IdStrategy.CaseSensitive);
    final LDAPConfiguration configuration = securityRealm.getConfigurations().get(0);
    assertEquals("ldap.acme.com", configuration.getServer());
    assertEquals("SECRET", configuration.getManagerPassword());
}
Also used : Jenkins(jenkins.model.Jenkins) LDAPSecurityRealm(hudson.security.LDAPSecurityRealm) IdStrategy(jenkins.model.IdStrategy) LDAPConfiguration(jenkins.security.plugins.ldap.LDAPConfiguration) Test(org.junit.Test) ConfiguredWithCode(org.jenkinsci.plugins.casc.misc.ConfiguredWithCode)

Aggregations

ConfiguredWithCode (org.jenkinsci.plugins.casc.misc.ConfiguredWithCode)21 Test (org.junit.Test)20 Jenkins (jenkins.model.Jenkins)13 Issue (org.jvnet.hudson.test.Issue)3 DockerCloud (com.nirima.jenkins.plugins.docker.DockerCloud)2 DockerTemplate (com.nirima.jenkins.plugins.docker.DockerTemplate)2 TopLevelItem (hudson.model.TopLevelItem)2 User (hudson.model.User)2 FullControlOnceLoggedInAuthorizationStrategy (hudson.security.FullControlOnceLoggedInAuthorizationStrategy)2 HudsonPrivateSecurityRealm (hudson.security.HudsonPrivateSecurityRealm)2 ArrayList (java.util.ArrayList)2 AdminWhitelistRule (jenkins.security.s2m.AdminWhitelistRule)2 Folder (com.cloudbees.hudson.plugins.folder.Folder)1 BasicSSHUserPrivateKey (com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey)1 CertificateCredentials (com.cloudbees.plugins.credentials.common.CertificateCredentials)1 UsernamePasswordCredentials (com.cloudbees.plugins.credentials.common.UsernamePasswordCredentials)1 Role (com.michelin.cio.hudson.plugins.rolestrategy.Role)1 RoleBasedAuthorizationStrategy (com.michelin.cio.hudson.plugins.rolestrategy.RoleBasedAuthorizationStrategy)1 Computer (hudson.model.Computer)1 FreeStyleProject (hudson.model.FreeStyleProject)1