use of com.thoughtworks.go.plugin.domain.common.ValidationResult in project gocd by gocd.
the class SecurityAuthConfigServiceTest method verifyConnection_shouldFailForAInvalidAuthConfig.
@Test
public void verifyConnection_shouldFailForAInvalidAuthConfig() throws Exception {
SecurityAuthConfig ldap = new SecurityAuthConfig("ldap", "cd.go.ldap", new ConfigurationProperty(new ConfigurationKey("username"), new ConfigurationValue()));
ValidationResult validationResult = new ValidationResult();
validationResult.addError(new ValidationError("password", "Password cannot be blank"));
validationResult.addError(new ValidationError("username", "Username cannot be blank"));
VerifyConnectionResponse validationFailed = new VerifyConnectionResponse("validation-failed", "Connection check passed", validationResult);
when(extension.verifyConnection("cd.go.ldap", ldap.getConfigurationAsMap(true))).thenReturn(validationFailed);
VerifyConnectionResponse response = securityAuthConfigService.verifyConnection(ldap);
assertThat(response, is(validationFailed));
assertThat(ldap.getProperty("username").errors().get("username").get(0), is("Username cannot be blank"));
assertThat(ldap.getProperty("password").errors().get("password").get(0), is("Password cannot be blank"));
}
use of com.thoughtworks.go.plugin.domain.common.ValidationResult in project gocd by gocd.
the class SecurityAuthConfigServiceTest method verifyConnection_shouldSendConnectionFailedResponseOnUnSuccessfulVerification.
@Test
public void verifyConnection_shouldSendConnectionFailedResponseOnUnSuccessfulVerification() throws Exception {
VerifyConnectionResponse success = new VerifyConnectionResponse("failure", "Connection check failed", new ValidationResult());
SecurityAuthConfig ldap = new SecurityAuthConfig("ldap", "cd.go.ldap");
when(extension.verifyConnection("cd.go.ldap", ldap.getConfigurationAsMap(true))).thenReturn(success);
VerifyConnectionResponse response = securityAuthConfigService.verifyConnection(ldap);
assertThat(response, is(success));
}
use of com.thoughtworks.go.plugin.domain.common.ValidationResult in project gocd by gocd.
the class SecurityAuthConfigServiceTest method verifyConnection_shouldSendSuccessResponseOnSuccessfulVerification.
@Test
public void verifyConnection_shouldSendSuccessResponseOnSuccessfulVerification() throws Exception {
VerifyConnectionResponse success = new VerifyConnectionResponse("success", "Connection check passed", new ValidationResult());
SecurityAuthConfig ldap = new SecurityAuthConfig("ldap", "cd.go.ldap");
when(extension.verifyConnection("cd.go.ldap", ldap.getConfigurationAsMap(true))).thenReturn(success);
VerifyConnectionResponse response = securityAuthConfigService.verifyConnection(ldap);
assertThat(response, is(success));
}
Aggregations