Search in sources :

Example 1 with SignCclaPage

use of io.pivotal.cla.webdriver.pages.SignCclaPage in project pivotal-cla by pivotalsoftware.

the class CclaControllerTests method signTelephoneRequired.

@Test
public void signTelephoneRequired() throws Exception {
    when(mockClaRepository.findByNameAndPrimaryTrue(cla.getName())).thenReturn(cla);
    when(mockClaRepository.findOne(cla.getId())).thenReturn(cla);
    when(mockGitHub.getOrganizations(anyString())).thenReturn(Arrays.asList("spring", "pivotal"));
    SignCclaPage signPage = SignCclaPage.go(getDriver(), cla.getName());
    Form form = signPage.form();
    signPage = form.name("Rob Winch").email("rob@gmail.com").mailingAddress("123 Seasame St").country("USA").companyName("Pivotal").gitHubOrganization("pivotal").title("Director").confirm().sign(SignCclaPage.class);
    signPage.assertAt();
    form = signPage.form();
    form.assertName().hasNoErrors();
    form.assertEmail().hasNoErrors();
    form.assertMailingAddress().hasNoErrors();
    form.assertCountry().hasNoErrors();
    form.assertTelephone().hasRequiredError();
    form.assertConfirm().hasNoErrors();
}
Also used : Form(io.pivotal.cla.webdriver.pages.SignCclaPage.Form) SignCclaPage(io.pivotal.cla.webdriver.pages.SignCclaPage) Test(org.junit.Test)

Example 2 with SignCclaPage

use of io.pivotal.cla.webdriver.pages.SignCclaPage in project pivotal-cla by pivotalsoftware.

the class CclaControllerTests method signOrganizationRequired.

@Test
public void signOrganizationRequired() throws Exception {
    when(mockClaRepository.findByNameAndPrimaryTrue(cla.getName())).thenReturn(cla);
    when(mockClaRepository.findOne(cla.getId())).thenReturn(cla);
    when(mockGitHub.getOrganizations(anyString())).thenReturn(Arrays.asList("spring", "pivotal"));
    SignCclaPage signPage = SignCclaPage.go(getDriver(), cla.getName());
    Form form = signPage.form();
    signPage = form.name("Rob Winch").email("rob@gmail.com").mailingAddress("123 Seasame St").country("USA").telephone("123.456.7890").companyName("Pivotal").title("Director").confirm().sign(SignCclaPage.class);
    signPage.assertAt();
    form = signPage.form();
    form.assertName().hasNoErrors();
    form.assertEmail().hasNoErrors();
    form.assertCompanyName().hasNoErrors();
    form.assertGitHubOrganization().hasRequiredError();
    form.assertConfirm().hasNoErrors();
}
Also used : Form(io.pivotal.cla.webdriver.pages.SignCclaPage.Form) SignCclaPage(io.pivotal.cla.webdriver.pages.SignCclaPage) Test(org.junit.Test)

Example 3 with SignCclaPage

use of io.pivotal.cla.webdriver.pages.SignCclaPage in project pivotal-cla by pivotalsoftware.

the class CclaControllerTests method signNoRepositoryIdWithPullRequestId.

@Test
public void signNoRepositoryIdWithPullRequestId() {
    when(mockClaRepository.findByNameAndPrimaryTrue(cla.getName())).thenReturn(cla);
    when(mockClaRepository.findOne(cla.getId())).thenReturn(cla);
    SignCclaPage signPage = SignCclaPage.go(getDriver(), cla.getName(), "rwinch/176_test", 2);
    signPage = signPage.form().name("Rob Winch").email("rob@gmail.com").sign(SignCclaPage.class);
    signPage.assertAt();
}
Also used : SignCclaPage(io.pivotal.cla.webdriver.pages.SignCclaPage) Test(org.junit.Test)

Example 4 with SignCclaPage

use of io.pivotal.cla.webdriver.pages.SignCclaPage in project pivotal-cla by pivotalsoftware.

the class CclaControllerTests method signNameRequired.

@Test
public void signNameRequired() throws Exception {
    when(mockClaRepository.findByNameAndPrimaryTrue(cla.getName())).thenReturn(cla);
    when(mockClaRepository.findOne(cla.getId())).thenReturn(cla);
    when(mockGitHub.getOrganizations(anyString())).thenReturn(Arrays.asList("spring", "pivotal"));
    SignCclaPage signPage = SignCclaPage.go(getDriver(), cla.getName());
    Form form = signPage.form();
    signPage = form.email("rob@gmail.com").mailingAddress("123 Seasame St").country("USA").telephone("123.456.7890").companyName("Pivotal").gitHubOrganization("pivotal").title("Director").confirm().sign(SignCclaPage.class);
    signPage.assertAt();
    form = signPage.form();
    form.assertName().hasRequiredError();
    form.assertEmail().hasNoErrors();
    form.assertCompanyName().hasNoErrors();
    form.assertGitHubOrganization().hasNoErrors();
    form.assertConfirm().hasNoErrors();
}
Also used : Form(io.pivotal.cla.webdriver.pages.SignCclaPage.Form) SignCclaPage(io.pivotal.cla.webdriver.pages.SignCclaPage) Test(org.junit.Test)

Example 5 with SignCclaPage

use of io.pivotal.cla.webdriver.pages.SignCclaPage in project pivotal-cla by pivotalsoftware.

the class CclaControllerTests method signWithRepositoryIdWithPullRequestId.

@Test
public void signWithRepositoryIdWithPullRequestId() throws Exception {
    String repositoryId = "rwinch/176_test";
    when(mockClaRepository.findByNameAndPrimaryTrue(cla.getName())).thenReturn(cla);
    when(mockClaRepository.findOne(cla.getId())).thenReturn(cla);
    when(mockGitHub.getOrganizations(anyString())).thenReturn(Arrays.asList("spring", "pivotal"));
    when(mockGitHub.getShaForPullRequest(any(PullRequestStatus.class))).thenReturn("abc123");
    when(mockCorporateSignatureRepository.findSignature(anyString(), anyCollectionOf(String.class), anyCollectionOf(String.class))).thenReturn(null, corporateSignature);
    when(mockTokenRepo.findOne(repositoryId)).thenReturn(new AccessToken(repositoryId, "access-token-123"));
    int pullRequestId = 2;
    SignCclaPage signPage = SignCclaPage.go(getDriver(), cla.getName(), repositoryId, pullRequestId);
    signPage = signPage.form().name("Rob Winch").email("rob@gmail.com").mailingAddress("123 Seasame St").country("USA").telephone("123.456.7890").companyName("Pivotal").gitHubOrganization("pivotal").title("Director").confirm().sign(SignCclaPage.class);
    signPage.assertAt();
    signPage.assertPullRequestLink(repositoryId, pullRequestId);
    ArgumentCaptor<PullRequestStatus> updatePullRequestCaptor = ArgumentCaptor.forClass(PullRequestStatus.class);
    verify(mockGitHub).save(updatePullRequestCaptor.capture());
    PullRequestStatus updatePr = updatePullRequestCaptor.getValue();
    String commitStatusUrl = "http://localhost/sign/" + cla.getName() + "?repositoryId=" + repositoryId + "&pullRequestId=" + pullRequestId;
    assertThat(updatePr.getUrl()).isEqualTo(commitStatusUrl);
    assertThat(updatePr.getGitHubUsername()).isEqualTo(WithSigningUserFactory.create().getGitHubLogin());
    assertThat(updatePr.getPullRequestId()).isEqualTo(pullRequestId);
    assertThat(updatePr.getRepoId()).isEqualTo(repositoryId);
}
Also used : AccessToken(io.pivotal.cla.data.AccessToken) SignCclaPage(io.pivotal.cla.webdriver.pages.SignCclaPage) Matchers.anyString(org.mockito.Matchers.anyString) PullRequestStatus(io.pivotal.cla.service.github.PullRequestStatus) Test(org.junit.Test)

Aggregations

SignCclaPage (io.pivotal.cla.webdriver.pages.SignCclaPage)19 Test (org.junit.Test)19 Form (io.pivotal.cla.webdriver.pages.SignCclaPage.Form)9 WithSigningUser (io.pivotal.cla.security.WithSigningUser)3 Matchers.anyString (org.mockito.Matchers.anyString)3 ContributorLicenseAgreement (io.pivotal.cla.data.ContributorLicenseAgreement)2 PullRequestStatus (io.pivotal.cla.service.github.PullRequestStatus)2 SignClaPage (io.pivotal.cla.webdriver.pages.SignClaPage)2 AccessToken (io.pivotal.cla.data.AccessToken)1 CorporateSignature (io.pivotal.cla.data.CorporateSignature)1 User (io.pivotal.cla.data.User)1 Date (java.util.Date)1 WithAnonymousUser (org.springframework.security.test.context.support.WithAnonymousUser)1