use of io.jenkins.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.
the class JenkinsConfiguratorTest method shouldExportLabelAtoms.
@Test
@ConfiguredWithCode("ConfigureLabels.yml")
public void shouldExportLabelAtoms() throws Exception {
DescribableList properties = Jenkins.get().getLabelAtom("label1").getProperties();
properties.add(new TestProperty(1));
final ByteArrayOutputStream out = new ByteArrayOutputStream();
ConfigurationAsCode.get().export(out);
final String exported = out.toString();
String content = FileUtils.readFileToString(new File(getClass().getResource("ExpectedLabelsConfiguration.yml").toURI()), "UTF-8");
assertThat(exported, containsString(content));
}
use of io.jenkins.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.
the class JenkinsConfiguratorTest method jenkins_primitive_attributes.
@Test
@ConfiguredWithCode("Primitives.yml")
public void jenkins_primitive_attributes() {
final Jenkins jenkins = Jenkins.get();
assertEquals(6666, jenkins.getSlaveAgentPort());
}
use of io.jenkins.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.
the class ProxyConfiguratorTest method shouldSetProxyWithMinimumFields.
@Test
@ConfiguredWithCode("ProxyMinimal.yml")
public void shouldSetProxyWithMinimumFields() throws Exception {
ProxyConfiguration proxy = j.jenkins.proxy;
assertEquals(proxy.name, "proxyhost");
assertEquals(proxy.port, 80);
assertNull(proxy.getUserName());
assertNull(proxy.getTestUrl());
ConfiguratorRegistry registry = ConfiguratorRegistry.get();
ConfigurationContext context = new ConfigurationContext(registry);
final Configurator c = context.lookupOrFail(ProxyConfiguration.class);
final CNode node = c.describe(proxy, context);
assertNotNull(node);
Mapping mapping = node.asMapping();
assertEquals(2, node.asMapping().size());
assertEquals("proxyhost", mapping.getScalarValue("name"));
assertEquals("80", mapping.getScalarValue("port"));
}
use of io.jenkins.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.
the class ProxyConfiguratorTest method describeMinimalProxyConfig.
@Test
@ConfiguredWithCode("ProxyMinimal.yml")
public void describeMinimalProxyConfig() throws Exception {
ConfiguratorRegistry registry = ConfiguratorRegistry.get();
ConfigurationContext context = new ConfigurationContext(registry);
final CNode configNode = getProxyNode(context);
final String yamlConfig = Util.toYamlString(configNode);
assertEquals(String.join("\n", "name: \"proxyhost\"", "port: 80", ""), yamlConfig);
}
use of io.jenkins.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.
the class ProxyConfiguratorTest method shouldSetProxyWithSecretInFields.
@Test
@Env(name = "PROXY_HOST", value = "proxyhost")
@Env(name = "PROXY_PORT", value = "80")
@Env(name = "PROXY_USER", value = "proxy_user")
@Env(name = "PROXY_PASSWORD", value = "proxy_password")
@Env(name = "PROXY_NOPROXY", value = "external.host")
@Env(name = "PROXY_TEST_URL", value = "http://google.com")
@ConfiguredWithCode("ProxyWithSecrets.yml")
public void shouldSetProxyWithSecretInFields() {
ProxyConfiguration proxy = j.jenkins.proxy;
assertEquals(proxy.name, "proxyhost");
assertEquals(proxy.port, 80);
assertEquals(proxy.getUserName(), "proxy_user");
assertThat(proxy.getSecretPassword(), hasPlainText("proxy_password"));
assertEquals(proxy.noProxyHost, "external.host");
assertEquals(proxy.getTestUrl(), "http://google.com");
}
Aggregations