use of io.jenkins.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.
the class ProxyConfiguratorTest method describeProxyConfig.
@Test
@ConfiguredWithCode("Proxy.yml")
public void describeProxyConfig() throws Exception {
ConfiguratorRegistry registry = ConfiguratorRegistry.get();
ConfigurationContext context = new ConfigurationContext(registry);
final CNode configNode = getProxyNode(context);
Secret password = requireNonNull(Secret.decrypt(getProxyNode(context).getScalarValue("secretPassword")));
final String yamlConfig = Util.toYamlString(configNode);
assertEquals(String.join("\n", "name: \"proxyhost\"", "noProxyHost: \"externalhost\"", "port: 80", "secretPassword: \"" + password.getEncryptedValue() + "\"", "testUrl: \"http://google.com\"", "userName: \"login\"", ""), yamlConfig);
}
use of io.jenkins.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.
the class UpdateCenterConfiguratorTest method shouldSetUpdateCenterSites.
@Test
@ConfiguredWithCode("UpdateCenter.yml")
public void shouldSetUpdateCenterSites() throws Exception {
UpdateCenter updateCenter = j.jenkins.getUpdateCenter();
List<UpdateSite> sites = updateCenter.getSites();
assertEquals(2, sites.size());
UpdateSite siteOne = sites.get(0);
assertEquals("default", siteOne.getId());
assertEquals("https://updates.jenkins.io/update-center.json", siteOne.getUrl());
UpdateSite siteTwo = sites.get(1);
assertEquals("experimental", siteTwo.getId());
assertEquals("https://updates.jenkins.io/experimental/update-center.json", siteTwo.getUrl());
ConfiguratorRegistry registry = ConfiguratorRegistry.get();
ConfigurationContext context = new ConfigurationContext(registry);
final Configurator c = context.lookupOrFail(UpdateCenter.class);
final CNode node = c.describe(updateCenter, context);
assertNotNull(node);
Mapping site1 = node.asMapping().get("sites").asSequence().get(1).asMapping();
assertEquals("experimental", site1.getScalarValue("id"));
}
use of io.jenkins.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.
the class JenkinsConfiguratorCloudSupportTest method should_export_only_static_nodes.
@Test
@ConfiguredWithCode("JenkinsConfiguratorCloudSupportTest.yml")
public void should_export_only_static_nodes() throws Exception {
j.jenkins.addNode(new Cloud1PretendSlave());
ConfiguratorRegistry registry = ConfiguratorRegistry.get();
ConfigurationContext context = new ConfigurationContext(registry);
final CNode configNode = getJenkinsRoot(context).get("nodes");
final String yamlConfig = toYamlString(configNode);
assertThat(yamlConfig, containsString("name: \"agent1\""));
assertThat(yamlConfig, containsString("name: \"agent2\""));
assertThat(yamlConfig, not(containsString("name: \"testCloud\"")));
}
use of io.jenkins.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.
the class EssentialsTest method essentialsTest.
@Test
@ConfiguredWithCode("EssentialsTest.yml")
public void essentialsTest() {
final Jenkins jenkins = Jenkins.get();
assertEquals("Welcome to Jenkins Essentials!", jenkins.getSystemMessage());
final ExtensionList<MetricsAccessKey.DescriptorImpl> metricsDescriptors = ExtensionList.lookup(MetricsAccessKey.DescriptorImpl.class);
assertNotNull(metricsDescriptors);
assertThat(metricsDescriptors, hasSize(1));
MetricsAccessKey.DescriptorImpl metricsDescriptor = metricsDescriptors.get(0);
final List<MetricsAccessKey> accessKeys = metricsDescriptor.getAccessKeys();
assertThat(accessKeys, hasSize(1));
MetricsAccessKey accessKey = accessKeys.get(0);
assertThat(accessKey.getKey(), is("evergreen"));
assertThat(accessKey.getDescription(), is("Key for evergreen health-check"));
assertThat(accessKey.isCanHealthCheck(), is(true));
assertThat(accessKey.isCanPing(), is(false));
assertThat(accessKey.isCanPing(), is(false));
assertThat(accessKey.isCanThreadDump(), is(false));
assertThat(accessKey.isCanMetrics(), is(false));
assertThat(accessKey.getOrigins(), is("*"));
// metricsDescriptor.g
}
use of io.jenkins.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.
the class GitTest method checkAssemblaWebIsLoaded.
@Test
@Issue("JENKINS-57604")
@ConfiguredWithCode("GitTest.yml")
public void checkAssemblaWebIsLoaded() {
final Jenkins jenkins = Jenkins.get();
final GlobalLibraries libs = jenkins.getExtensionList(GlobalConfiguration.class).get(GlobalLibraries.class);
LibraryConfiguration lib = libs.getLibraries().get(0);
SCMRetriever retriever = (SCMRetriever) lib.getRetriever();
GitSCM scm = (GitSCM) retriever.getScm();
AssemblaWeb browser = (AssemblaWeb) scm.getBrowser();
assertEquals("assembla.acmecorp.com", browser.getRepoUrl());
}
Aggregations