Search in sources :

Example 11 with ValidationBean

use of com.thoughtworks.go.domain.materials.ValidationBean in project gocd by gocd.

the class BackgroundEmailSenderTest method shouldReturnWhateverTheOtherSenderReturnsIfSendingDoesNotTimeout.

@Test
public void shouldReturnWhateverTheOtherSenderReturnsIfSendingDoesNotTimeout() {
    final ValidationBean validationBean = ValidationBean.valid();
    mockery.checking(new Expectations() {

        {
            one(sender).send("Subject", "body", "to@someone");
            will(returnValue(validationBean));
        }
    });
    BackgroundMailSender background = new BackgroundMailSender(sender, 1000);
    ValidationBean returned = background.send("Subject", "body", "to@someone");
    assertThat(returned, same(validationBean));
}
Also used : Expectations(org.jmock.Expectations) ValidationBean(com.thoughtworks.go.domain.materials.ValidationBean) Test(org.junit.Test)

Example 12 with ValidationBean

use of com.thoughtworks.go.domain.materials.ValidationBean in project gocd by gocd.

the class SvnCommandRemoteTest method shouldMaskPassword_CheckConnection.

@Test
public void shouldMaskPassword_CheckConnection() {
    ValidationBean goodResponse = command.checkConnection();
    assertThat(goodResponse.isValid(), Is.is(true));
    assertThat("Plain text password detected!", goodResponse.getError().contains(HARRYS_PASSWORD), Is.is(false));
    ValidationBean badResponse = badUserNameCommand().checkConnection();
    assertThat(badResponse.isValid(), Is.is(false));
    assertThat("Plain text password detected!", badResponse.getError().contains(HARRYS_PASSWORD), Is.is(false));
    badResponse = badPasswordCommand().checkConnection();
    assertThat(badResponse.isValid(), Is.is(false));
    assertThat("Plain text password detected!", badResponse.getError().contains("some_bad_password"), Is.is(false));
    badResponse = badUrlCommand().checkConnection();
    assertThat(badResponse.isValid(), Is.is(false));
    assertThat("Plain text password detected!", badResponse.getError().contains(HARRYS_PASSWORD), Is.is(false));
}
Also used : ValidationBean(com.thoughtworks.go.domain.materials.ValidationBean) Test(org.junit.Test)

Example 13 with ValidationBean

use of com.thoughtworks.go.domain.materials.ValidationBean in project gocd by gocd.

the class P4MaterialTestBase method shouldCheckConnection.

@Test
public void shouldCheckConnection() throws Exception {
    P4Material p4Material = new P4Material("localhost:9876", "p4view");
    p4Material.setPassword("secret");
    p4Material.setUseTickets(false);
    ValidationBean validation = p4Material.checkConnection(new TestSubprocessExecutionContext());
    assertThat(validation.isValid(), is(false));
    assertThat(validation.getError(), containsString("Unable to connect to server localhost:9876"));
    assertThat(validation.getError(), not(containsString("secret")));
}
Also used : TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) ValidationBean(com.thoughtworks.go.domain.materials.ValidationBean) Test(org.junit.Test)

Example 14 with ValidationBean

use of com.thoughtworks.go.domain.materials.ValidationBean in project gocd by gocd.

the class LengthValidatorTest method shouldReturnValidWhenNoInput.

@Test
public void shouldReturnValidWhenNoInput() {
    LengthValidator lengthValidator = new LengthValidator(2);
    ValidationBean validationBean = lengthValidator.validate(null);
    assertThat(validationBean.isValid(), is(true));
}
Also used : ValidationBean(com.thoughtworks.go.domain.materials.ValidationBean) Test(org.junit.Test)

Example 15 with ValidationBean

use of com.thoughtworks.go.domain.materials.ValidationBean in project gocd by gocd.

the class LengthValidatorTest method shouldReturnValidWhenLengthDoesNotExceeds.

@Test
public void shouldReturnValidWhenLengthDoesNotExceeds() {
    LengthValidator lengthValidator = new LengthValidator(2);
    ValidationBean validationBean = lengthValidator.validate("ab");
    assertThat(validationBean.isValid(), is(true));
}
Also used : ValidationBean(com.thoughtworks.go.domain.materials.ValidationBean) Test(org.junit.Test)

Aggregations

ValidationBean (com.thoughtworks.go.domain.materials.ValidationBean)25 Test (org.junit.Test)22 TestSubprocessExecutionContext (com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext)2 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)1 GoMailSender (com.thoughtworks.go.config.GoMailSender)1 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)1 Expectations (org.jmock.Expectations)1 Theory (org.junit.experimental.theories.Theory)1