use of io.jenkins.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.
the class RoleStrategyTest method shouldHandleNullItemsAndAgentsCorrectly.
@Test
@Issue("Issue #214")
@ConfiguredWithCode("RoleStrategy2.yml")
public void shouldHandleNullItemsAndAgentsCorrectly() {
AuthorizationStrategy s = j.jenkins.getAuthorizationStrategy();
assertThat("Authorization Strategy has been read incorrectly", s, instanceOf(RoleBasedAuthorizationStrategy.class));
RoleBasedAuthorizationStrategy rbas = (RoleBasedAuthorizationStrategy) s;
Map<Role, Set<String>> globalRoles = rbas.getGrantedRoles(RoleType.Global);
assertThat(globalRoles.size(), equalTo(2));
}
use of io.jenkins.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.
the class ProjectMatrixAuthorizationTest method checkCorrectlyConfiguredPermissions.
@Test
@ConfiguredWithCode("ProjectMatrixStrategy.yml")
public void checkCorrectlyConfiguredPermissions() {
assertEquals("The configured instance must use the Global Matrix Authentication Strategy", ProjectMatrixAuthorizationStrategy.class, Jenkins.get().getAuthorizationStrategy().getClass());
ProjectMatrixAuthorizationStrategy gms = (ProjectMatrixAuthorizationStrategy) 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));
}
use of io.jenkins.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.
the class SSHCredentialsTest method shouldSupportSinglelineBase64Certificates.
@Test
@ConfiguredWithCode("SSHCredentialsTest_Singleline_Key.yml")
@Issue("https://github.com/jenkinsci/configuration-as-code-plugin/issues/1189")
public void shouldSupportSinglelineBase64Certificates() {
BasicSSHUserPrivateKey certKey = getCredentials(BasicSSHUserPrivateKey.class);
assertThat("Private key roundtrip failed", certKey.getPrivateKey().trim().replace("\r\n", "\n"), equalTo(MySSHKeySecretSource.PRIVATE_SSH_KEY));
}
use of io.jenkins.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.
the class Security1446Test method testImportWithEnvVar.
@ConfiguredWithCode("Security1446Test.yml")
@Test
@Issue("SECURITY-1446")
public void testImportWithEnvVar() {
List<StandardUsernamePasswordCredentials> userPasswCred = CredentialsProvider.lookupCredentials(StandardUsernamePasswordCredentials.class, Jenkins.getInstanceOrNull(), null, Collections.emptyList());
assertThat(userPasswCred.size(), is(1));
for (StandardUsernamePasswordCredentials cred : userPasswCred) {
assertTrue("The JAVA_HOME environment variable should not be resolved", cred.getUsername().matches(JAVA_HOME_PATTERN));
assertTrue("The PATH environment variable should not be resolved", cred.getDescription().matches(PATH_PATTERN));
}
List<StringCredentials> stringCred = CredentialsProvider.lookupCredentials(StringCredentials.class, Jenkins.getInstanceOrNull(), null, Collections.emptyList());
assertThat(stringCred.size(), is(1));
for (StringCredentials cred : stringCred) {
assertTrue("The PATH environment variable should not be resolved", cred.getDescription().matches(PATH_PATTERN));
}
}
use of io.jenkins.plugins.casc.misc.ConfiguredWithCode in project configuration-as-code-plugin by jenkinsci.
the class SeedJobTest method configure_seed_job_with_secrets.
@Test
@ConfiguredWithCode("SeedJobTest_withSecrets.yml")
public void configure_seed_job_with_secrets() {
final Jenkins jenkins = Jenkins.get();
assertNotNull(jenkins.getItem("testJob2"));
}
Aggregations