Search in sources :

Example 31 with ConfiguredWithReadme

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

the class ConfigFileProviderTest method configure_config_file_provider.

@Test
@ConfiguredWithReadme(value = "config-file-provider/README.md")
public void configure_config_file_provider() {
    assertThat(GlobalConfigFiles.get().getConfigs(), hasSize(4));
    Config config = GlobalConfigFiles.get().getById("custom-test");
    assertThat(config.name, is("DummyCustom1"));
    assertThat(config.comment, is("dummy custom 1"));
    assertThat(config.content, is("dummy content 1"));
    config = GlobalConfigFiles.get().getById("json-test");
    assertThat(config.name, is("DummyJsonConfig"));
    assertThat(config.comment, is("dummy json config"));
    assertThat(config.content, containsString("{ \"dummydata\": {\"dummyKey\": \"dummyValue\"} }"));
    config = GlobalConfigFiles.get().getById("xml-test");
    assertThat(config.name, is("DummyXmlConfig"));
    assertThat(config.comment, is("dummy xml config"));
    assertThat(config.content, containsString("<root><dummy test=\"abc\"></dummy></root>"));
    MavenSettingsConfig mavenSettings = (MavenSettingsConfig) GlobalConfigFiles.get().getById("maven-test");
    assertThat(mavenSettings.name, is("DummySettings"));
    assertThat(mavenSettings.comment, is("dummy settings"));
    assertThat(mavenSettings.isReplaceAll, is(false));
    assertThat(mavenSettings.getServerCredentialMappings(), hasSize(2));
    assertThat(mavenSettings.getServerCredentialMappings().get(0).getServerId(), is("server1"));
    assertThat(mavenSettings.getServerCredentialMappings().get(0).getCredentialsId(), is("someCredentials1"));
    assertThat(mavenSettings.getServerCredentialMappings().get(1).getServerId(), is("server2"));
    assertThat(mavenSettings.getServerCredentialMappings().get(1).getCredentialsId(), is("someCredentials2"));
    assertThat(mavenSettings.content, containsString("<activeProfiles>"));
}
Also used : MavenSettingsConfig(org.jenkinsci.plugins.configfiles.maven.MavenSettingsConfig) MavenSettingsConfig(org.jenkinsci.plugins.configfiles.maven.MavenSettingsConfig) Config(org.jenkinsci.lib.configprovider.model.Config) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 32 with ConfiguredWithReadme

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

the class GitLabConfigurationTest method configure_gitlab_connection.

@Test
@ConfiguredWithReadme("gitlab/README.md")
public void configure_gitlab_connection() {
    final Jenkins jenkins = Jenkins.get();
    final GitLabConnectionConfig gitLabConnections = jenkins.getDescriptorByType(GitLabConnectionConfig.class);
    assertEquals(1, gitLabConnections.getConnections().size());
    final GitLabConnection gitLabConnection = gitLabConnections.getConnections().get(0);
    assertEquals("gitlab_token", gitLabConnection.getApiTokenId());
    assertEquals("my_gitlab_server", gitLabConnection.getName());
    assertEquals("autodetect", gitLabConnection.getClientBuilderId());
    assertEquals("https://gitlab.com/", gitLabConnection.getUrl());
    assertEquals(20, gitLabConnection.getConnectionTimeout());
    assertEquals(10, gitLabConnection.getReadTimeout());
    assertTrue(gitLabConnection.isIgnoreCertificateErrors());
}
Also used : Jenkins(jenkins.model.Jenkins) GitLabConnectionConfig(com.dabsquared.gitlabjenkins.connection.GitLabConnectionConfig) GitLabConnection(com.dabsquared.gitlabjenkins.connection.GitLabConnection) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 33 with ConfiguredWithReadme

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

the class GlobalMatrixAuthorizationTest method checkCorrectlyConfiguredPermissions.

@Test
@ConfiguredWithReadme("matrix-auth/README.md")
public void checkCorrectlyConfiguredPermissions() {
    assertEquals("The configured instance must use the Global Matrix Authentication Strategy", GlobalMatrixAuthorizationStrategy.class, Jenkins.get().getAuthorizationStrategy().getClass());
    GlobalMatrixAuthorizationStrategy gms = (GlobalMatrixAuthorizationStrategy) Jenkins.get().getAuthorizationStrategy();
    List<String> adminPermission = new ArrayList<>(gms.getGrantedPermissions().get(Jenkins.ADMINISTER));
    assertEquals("authenticated", adminPermission.get(0));
    List<String> readPermission = new ArrayList<>(gms.getGrantedPermissions().get(Jenkins.READ));
    assertEquals("anonymous", readPermission.get(0));
}
Also used : ArrayList(java.util.ArrayList) GlobalMatrixAuthorizationStrategy(hudson.security.GlobalMatrixAuthorizationStrategy) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 34 with ConfiguredWithReadme

use of io.jenkins.plugins.casc.misc.ConfiguredWithReadme 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)

Example 35 with ConfiguredWithReadme

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

the class MSBuildTest method configure_msbuild.

@Test
@ConfiguredWithReadme("msbuild/README.md")
public void configure_msbuild() {
    final DescriptorImpl msBuildDescriptor = ExtensionList.lookupSingleton(DescriptorImpl.class);
    assertNotNull(msBuildDescriptor);
    assertEquals(1, msBuildDescriptor.getInstallations().length);
    final MsBuildInstallation msBuildInstallation = msBuildDescriptor.getInstallations()[0];
    assertEquals("MSBuild Latest", msBuildInstallation.getName());
    assertEquals("C:\\WINDOWS\\Microsoft.NET\\Framework\\14.0\\Bin\\MSBuild.exe", msBuildInstallation.getHome());
    assertEquals("/p:Configuration=Debug", msBuildInstallation.getDefaultArgs());
}
Also used : DescriptorImpl(hudson.plugins.msbuild.MsBuildInstallation.DescriptorImpl) MsBuildInstallation(hudson.plugins.msbuild.MsBuildInstallation) 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