use of io.jenkins.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.
the class JenkinsConfiguratorTest method shouldSetEnvironmentVariable.
@Test
@Issue("Issue #173")
@ConfiguredWithCode("SetEnvironmentVariable.yml")
public void shouldSetEnvironmentVariable() throws Exception {
final DescribableList<NodeProperty<?>, NodePropertyDescriptor> properties = Jenkins.get().getNodeProperties();
EnvVars env = new EnvVars();
for (NodeProperty<?> property : properties) {
property.buildEnvVars(env, TaskListener.NULL);
}
assertEquals("BAR", env.get("FOO"));
}
use of io.jenkins.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() {
final Jenkins jenkins = Jenkins.get();
assertTrue(jenkins.getSecurityRealm() instanceof HudsonPrivateSecurityRealm);
assertTrue(jenkins.getAuthorizationStrategy() instanceof FullControlOnceLoggedInAuthorizationStrategy);
assertFalse(((FullControlOnceLoggedInAuthorizationStrategy) jenkins.getAuthorizationStrategy()).isAllowAnonymousRead());
}
use of io.jenkins.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.
the class JenkinsConfiguratorTest method shouldImportLabelAtoms.
@Test
@ConfiguredWithCode("ConfigureLabels.yml")
public void shouldImportLabelAtoms() {
LabelAtom label1 = Jenkins.get().getLabelAtom("label1");
assertNotNull(label1);
assertThat(label1.getProperties(), hasSize(2));
assertEquals(2, label1.getProperties().get(TestProperty.class).value);
assertEquals(4, label1.getProperties().get(AnotherTestProperty.class).otherProperty);
LabelAtom label2 = Jenkins.get().getLabelAtom("label2");
assertNotNull(label2);
assertThat(label2.getProperties(), hasSize(1));
assertEquals(3, label2.getProperties().get(TestProperty.class).value);
}
use of io.jenkins.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.
the class ProxyConfiguratorTest method shouldSetProxyWithAllFields.
@Test
@ConfiguredWithCode("Proxy.yml")
public void shouldSetProxyWithAllFields() throws Exception {
ProxyConfiguration proxy = j.jenkins.proxy;
assertEquals(proxy.name, "proxyhost");
assertEquals(proxy.port, 80);
assertEquals(proxy.getUserName(), "login");
assertThat(proxy.getSecretPassword(), hasPlainText("password"));
assertEquals(proxy.noProxyHost, "externalhost");
assertEquals(proxy.getTestUrl(), "http://google.com");
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(6, mapping.size());
assertEquals("proxyhost", mapping.getScalarValue("name"));
}
use of io.jenkins.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.
the class ProxyConfiguratorTest method shouldNotWritePasswordToLog.
@Test
@Env(name = "PROXY_USER", value = "proxy_user")
@Env(name = "PROXY_PASSWORD", value = "proxy_password")
@ConfiguredWithCode("ProxyWithSecrets.yml")
// Fixed in 1.20
@Issue("SECURITY-1303")
public void shouldNotWritePasswordToLog() {
ProxyConfiguration proxy = j.jenkins.proxy;
assertEquals(proxy.getUserName(), "proxy_user");
assertThat(proxy.getSecretPassword(), hasPlainText("proxy_password"));
// Check logs
assertLogContains(logging, "secretPassword");
assertNotInLog(logging, "proxy_password");
}
Aggregations