Search in sources :

Example 11 with CorporateSignature

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

the class CclaController method claForm.

@RequestMapping("/sign/{claName}/ccla")
public String claForm(@AuthenticationPrincipal User user, SignCorporateClaForm signCorporateClaForm, Map<String, Object> model) throws Exception {
    String claName = signCorporateClaForm.getClaName();
    Integer pullRequestId = signCorporateClaForm.getPullRequestId();
    String repositoryId = signCorporateClaForm.getRepositoryId();
    CorporateSignatureInfo corporateResponse = claService.findCorporateSignatureInfoFor(claName, user);
    ContributorLicenseAgreement cla = corporateResponse.getContributorLicenseAgreement();
    CorporateSignature signed = corporateResponse.getCorporateSignature();
    List<String> currentUserGitHubOrganizations = corporateResponse.getGitHubOrganizations();
    if (cla == null) {
        throw new ResourceNotFoundException();
    }
    if (cla.getSupersedingCla() != null) {
        cla = cla.getSupersedingCla();
    }
    signCorporateClaForm.setSigned(signed != null);
    signCorporateClaForm.setName(user.getName());
    signCorporateClaForm.setClaId(cla.getId());
    signCorporateClaForm.setRepositoryId(repositoryId);
    signCorporateClaForm.setPullRequestId(pullRequestId);
    signCorporateClaForm.setGitHubOrganizations(currentUserGitHubOrganizations);
    model.put("cla", cla);
    return "cla/ccla/sign";
}
Also used : ContributorLicenseAgreement(io.pivotal.cla.data.ContributorLicenseAgreement) CorporateSignature(io.pivotal.cla.data.CorporateSignature) CorporateSignatureInfo(io.pivotal.cla.service.CorporateSignatureInfo) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with CorporateSignature

use of io.pivotal.cla.data.CorporateSignature 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)

Example 13 with CorporateSignature

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

the class CorporateSignatureRepositoryTests method findSignaturesNullEmails.

/**
 * Happens in GitHubHooksController when user has not yet authenticated.
 */
@Test
public void findSignaturesNullEmails() {
    CorporateSignature emailSignature = createSignature(cla, user);
    emailSignature.setGitHubOrganization(null);
    emailSignature.setEmailDomain("gmail.com");
    emailSignature = signatures.save(emailSignature);
    assertThat(signatures.findSignatures(new PageRequest(0, 1), Arrays.asList("notorganization"), null)).isEmpty();
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) CorporateSignature(io.pivotal.cla.data.CorporateSignature) Test(org.junit.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 14 with CorporateSignature

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

the class CorporateSignatureRepositoryTests method findSignatureNullEmails.

/**
 * Happens in GitHubHooksController when user has not yet authenticated.
 */
@Test
public void findSignatureNullEmails() {
    CorporateSignature emailSignature = createSignature(cla, user);
    emailSignature.setGitHubOrganization(null);
    emailSignature.setEmailDomain("gmail.com");
    emailSignature = signatures.save(emailSignature);
    assertThat(signatures.findSignature(springCla.getName(), Arrays.asList("notorganization"), null)).isNull();
}
Also used : CorporateSignature(io.pivotal.cla.data.CorporateSignature) Test(org.junit.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 15 with CorporateSignature

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

the class CorporateSignatureRepositoryTests method findSignaturesByEmptyGitHubOrganizations.

@Test
public void findSignaturesByEmptyGitHubOrganizations() {
    CorporateSignature emailSignature = createSignature(cla, user);
    emailSignature.setGitHubOrganization(null);
    emailSignature.setEmailDomain("gmail.com");
    emailSignature = signatures.save(emailSignature);
    assertThat(signatures.findSignatures(new PageRequest(0, 1), Arrays.asList(), null)).isEmpty();
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) CorporateSignature(io.pivotal.cla.data.CorporateSignature) Test(org.junit.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Aggregations

CorporateSignature (io.pivotal.cla.data.CorporateSignature)18 Test (org.junit.Test)11 DataJpaTest (org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)10 PageRequest (org.springframework.data.domain.PageRequest)6 ContributorLicenseAgreement (io.pivotal.cla.data.ContributorLicenseAgreement)4 IndividualSignature (io.pivotal.cla.data.IndividualSignature)2 Date (java.util.Date)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 MarkdownContent (io.pivotal.cla.data.MarkdownContent)1 ClaPullRequestStatusRequest (io.pivotal.cla.service.ClaPullRequestStatusRequest)1 CorporateSignatureInfo (io.pivotal.cla.service.CorporateSignatureInfo)1 PullRequestStatus (io.pivotal.cla.service.github.PullRequestStatus)1 SignCclaPage (io.pivotal.cla.webdriver.pages.SignCclaPage)1 Before (org.junit.Before)1 Matchers.anyString (org.mockito.Matchers.anyString)1