Search in sources :

Example 1 with IndividualSignature

use of io.pivotal.cla.data.IndividualSignature in project pivotal-cla by pivotalsoftware.

the class BaseWebDriverTests method setup.

@Before
public void setup() {
    driver = MockMvcHtmlUnitDriverBuilder.mockMvcSetup(mockMvc).useMockMvcForHosts("github.com").build();
    MarkdownContent corporate = new MarkdownContent();
    corporate.setMarkdown("# Corporate");
    corporate.setHtml("[h1]Corporate[/h1]");
    MarkdownContent individual = new MarkdownContent();
    individual.setMarkdown("# Individual");
    individual.setHtml("[h1]Individual[/h1]");
    cla = new ContributorLicenseAgreement();
    cla.setName("pivotal");
    cla.setCorporateContent(corporate);
    cla.setIndividualContent(individual);
    cla.setId(1L);
    individualSignature = new IndividualSignature();
    individualSignature.setCla(cla);
    individualSignature.setGitHubLogin("rwinch");
    individualSignature.setEmail("rob@gmail.com");
    individualSignature.setName("Rob Winch");
    individualSignature.setMailingAddress("123 Seasame Street");
    individualSignature.setTelephone("123.456.7890");
    corporateSignature = new CorporateSignature();
    corporateSignature.setCla(cla);
    corporateSignature.setGitHubLogin("rwinch");
    corporateSignature.setEmail("rob@gmail.com");
    corporateSignature.setName("Rob Winch");
    corporateSignature.setMailingAddress("123 Seasame Street");
    corporateSignature.setTelephone("123.456.7890");
    corporateSignature.setGitHubOrganization("organization");
}
Also used : ContributorLicenseAgreement(io.pivotal.cla.data.ContributorLicenseAgreement) MarkdownContent(io.pivotal.cla.data.MarkdownContent) CorporateSignature(io.pivotal.cla.data.CorporateSignature) IndividualSignature(io.pivotal.cla.data.IndividualSignature) Before(org.junit.Before)

Example 2 with IndividualSignature

use of io.pivotal.cla.data.IndividualSignature in project pivotal-cla by pivotalsoftware.

the class IclaControllerTests method assertThatClaIsSigned.

private void assertThatClaIsSigned(SignClaForm form) {
    ArgumentCaptor<IndividualSignature> signatureCaptor = ArgumentCaptor.forClass(IndividualSignature.class);
    verify(mockIndividualSignatureRepository).save(signatureCaptor.capture());
    IndividualSignature signature = signatureCaptor.getValue();
    assertThat(signature.getCla()).isEqualTo(cla);
    String country = form.getCountry();
    assertThat(signature.getCountry()).isEqualTo(country);
    assertThat(signature.getName()).isEqualTo(form.getName());
    assertThat(signature.getEmail()).isEqualTo(form.getEmail());
    assertThat(signature.getMailingAddress()).isEqualTo(form.getMailingAddress());
    assertThat(signature.getTelephone()).isEqualTo(form.getTelephone());
    assertThat(signature.getDateOfSignature()).isCloseTo(new Date(), TimeUnit.SECONDS.toMillis(5));
    verifyZeroInteractions(mockGitHub);
}
Also used : Date(java.util.Date) IndividualSignature(io.pivotal.cla.data.IndividualSignature)

Example 3 with IndividualSignature

use of io.pivotal.cla.data.IndividualSignature in project pivotal-cla by pivotalsoftware.

the class IndividualSignatureRepositoryTests method createSignature.

private static IndividualSignature createSignature(ContributorLicenseAgreement cla, User user) {
    IndividualSignature signature = DataUtils.iclaSignature(cla);
    signature.setGitHubLogin(user.getGitHubLogin());
    signature.setEmail(user.getEmails().iterator().next());
    return signature;
}
Also used : IndividualSignature(io.pivotal.cla.data.IndividualSignature)

Example 4 with IndividualSignature

use of io.pivotal.cla.data.IndividualSignature in project pivotal-cla by pivotalsoftware.

the class IclaController method signCla.

@RequestMapping(value = "/sign/{claName}/icla", method = RequestMethod.POST)
public String signCla(@AuthenticationPrincipal User user, @Valid SignClaForm signClaForm, BindingResult result, Map<String, Object> model, RedirectAttributes redirect) throws Exception {
    String claName = signClaForm.getClaName();
    Integer pullRequestId = signClaForm.getPullRequestId();
    String repositoryId = signClaForm.getRepositoryId();
    ContributorLicenseAgreement cla = clas.findOne(signClaForm.getClaId());
    if (result.hasErrors()) {
        model.put("cla", cla);
        return "cla/icla/sign";
    }
    IndividualSignature signature = new IndividualSignature();
    signature.setCla(cla);
    signature.setName(signClaForm.getName());
    signature.setCountry(signClaForm.getCountry());
    signature.setEmail(signClaForm.getEmail());
    signature.setMailingAddress(signClaForm.getMailingAddress());
    signature.setDateOfSignature(new Date());
    signature.setTelephone(signClaForm.getTelephone());
    signature.setGitHubLogin(user.getGitHubLogin());
    individual.save(signature);
    // update github
    redirect.addAttribute("claName", claName);
    if (repositoryId == null || pullRequestId == null) {
        return "redirect:/sign/{claName}/icla";
    }
    ClaPullRequestStatusRequest updatePullRequest = signClaForm.createUpdatePullRequestStatus(user.getGitHubLogin());
    if (updatePullRequest != null) {
        updatePullRequest.getCommitStatus().setSuccess(true);
        claService.savePullRequestStatus(updatePullRequest);
    }
    redirect.addAttribute("repositoryId", repositoryId);
    redirect.addAttribute("pullRequestId", pullRequestId);
    return "redirect:/sign/{claName}/icla";
}
Also used : ContributorLicenseAgreement(io.pivotal.cla.data.ContributorLicenseAgreement) ClaPullRequestStatusRequest(io.pivotal.cla.service.ClaPullRequestStatusRequest) Date(java.util.Date) IndividualSignature(io.pivotal.cla.data.IndividualSignature) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with IndividualSignature

use of io.pivotal.cla.data.IndividualSignature in project pivotal-cla by pivotalsoftware.

the class ClaService method hasSigned.

public boolean hasSigned(User user, String claName) {
    if (claName == null) {
        return false;
    }
    IndividualSignature signedIndividual = findIndividualSignaturesFor(user, claName);
    if (signedIndividual != null) {
        return true;
    }
    CorporateSignatureInfo corporateSignatureInfo = findCorporateSignatureInfoFor(claName, user);
    CorporateSignature corporateSignature = corporateSignatureInfo.getCorporateSignature();
    return corporateSignature != null;
}
Also used : CorporateSignature(io.pivotal.cla.data.CorporateSignature) IndividualSignature(io.pivotal.cla.data.IndividualSignature)

Aggregations

IndividualSignature (io.pivotal.cla.data.IndividualSignature)9 ContributorLicenseAgreement (io.pivotal.cla.data.ContributorLicenseAgreement)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 CorporateSignature (io.pivotal.cla.data.CorporateSignature)2 Date (java.util.Date)2 PageRequest (org.springframework.data.domain.PageRequest)2 MarkdownContent (io.pivotal.cla.data.MarkdownContent)1 User (io.pivotal.cla.data.User)1 ClaPullRequestStatusRequest (io.pivotal.cla.service.ClaPullRequestStatusRequest)1 CurrentUserRequest (io.pivotal.cla.service.github.CurrentUserRequest)1 OAuthAccessTokenParams (io.pivotal.cla.service.github.OAuthAccessTokenParams)1 Before (org.junit.Before)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 Authentication (org.springframework.security.core.Authentication)1