Search in sources :

Example 51 with ConfiguredWithCode

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

the class MissingConfiguratorTest method testThrowsSuggestion.

@ConfiguredWithCode(value = "MissingConfiguratorTest.yml", expected = IllegalArgumentException.class, message = "No hudson.security.AuthorizationStrategy implementation found for globalMatrix")
@Test
public void testThrowsSuggestion() {
    // No config check needed, should fail with IllegalArgumentException
    // We're purposely trying to configure a plugin for which there is no configurator
    // admin user should not be created due to IllegalArgumentException
    User user = User.getById("admin", false);
    assertThat(user, is(nullValue()));
}
Also used : User(hudson.model.User) Test(org.junit.Test) ConfiguredWithCode(io.jenkins.plugins.casc.misc.ConfiguredWithCode)

Example 52 with ConfiguredWithCode

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

the class MavenConfiguratorTest method should_configure_maven_tools_and_global_config.

@Test
@ConfiguredWithCode("MavenConfiguratorTest.yml")
public void should_configure_maven_tools_and_global_config() {
    final Maven.DescriptorImpl descriptor = (Maven.DescriptorImpl) j.jenkins.getDescriptorOrDie(Maven.class);
    Assert.assertEquals(1, descriptor.getInstallations().length);
    Assert.assertEquals("/usr/share/maven", descriptor.getInstallations()[0].getHome());
    InstallSourceProperty installSourceProperty = descriptor.getInstallations()[0].getProperties().get(InstallSourceProperty.class);
    Assert.assertEquals("3.5.0", installSourceProperty.installers.get(Maven.MavenInstaller.class).id);
    final SettingsProvider provider = GlobalMavenConfig.get().getSettingsProvider();
    Assert.assertTrue(provider instanceof FilePathSettingsProvider);
    Assert.assertEquals("/usr/share/maven-settings.xml", ((FilePathSettingsProvider) provider).getPath());
}
Also used : SettingsProvider(jenkins.mvn.SettingsProvider) FilePathSettingsProvider(jenkins.mvn.FilePathSettingsProvider) Maven(hudson.tasks.Maven) InstallSourceProperty(hudson.tools.InstallSourceProperty) FilePathSettingsProvider(jenkins.mvn.FilePathSettingsProvider) Test(org.junit.Test) ConfiguredWithCode(io.jenkins.plugins.casc.misc.ConfiguredWithCode)

Aggregations

ConfiguredWithCode (io.jenkins.plugins.casc.misc.ConfiguredWithCode)52 Test (org.junit.Test)51 Issue (org.jvnet.hudson.test.Issue)18 CNode (io.jenkins.plugins.casc.model.CNode)16 Jenkins (jenkins.model.Jenkins)15 ConfigurationContext (io.jenkins.plugins.casc.ConfigurationContext)8 ConfiguratorRegistry (io.jenkins.plugins.casc.ConfiguratorRegistry)8 Util.toYamlString (io.jenkins.plugins.casc.misc.Util.toYamlString)8 Mapping (io.jenkins.plugins.casc.model.Mapping)7 BasicSSHUserPrivateKey (com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey)5 Configurator (io.jenkins.plugins.casc.Configurator)5 ProxyConfiguration (hudson.ProxyConfiguration)4 StandardUsernamePasswordCredentials (com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials)3 UsernamePasswordCredentials (com.cloudbees.plugins.credentials.common.UsernamePasswordCredentials)3 AdminWhitelistRule (jenkins.security.s2m.AdminWhitelistRule)3 CredentialsRootConfigurator (com.cloudbees.plugins.credentials.casc.CredentialsRootConfigurator)2 Role (com.michelin.cio.hudson.plugins.rolestrategy.Role)2 RoleBasedAuthorizationStrategy (com.michelin.cio.hudson.plugins.rolestrategy.RoleBasedAuthorizationStrategy)2 FreeStyleProject (hudson.model.FreeStyleProject)2 User (hudson.model.User)2