Search in sources :

Example 6 with SignClaPage

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

the class HomeControllerTests method learnMoreLink.

@Test
@WithSigningUser
public void learnMoreLink() {
    SignClaPage home = HomePage.go(driver);
    AboutPage aboutPage = home.learnMore();
    aboutPage.assertAt();
}
Also used : SignClaPage(io.pivotal.cla.webdriver.pages.SignClaPage) AboutPage(io.pivotal.cla.webdriver.pages.AboutPage) WithSigningUser(io.pivotal.cla.security.WithSigningUser) Test(org.junit.Test)

Example 7 with SignClaPage

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

the class AuthenticationTests method authenticateUser.

@Test
public void authenticateUser() throws Exception {
    User user = WithSigningUserFactory.create();
    when(mockClaRepository.findByNameAndPrimaryTrue(cla.getName())).thenReturn(cla);
    when(mockGitHub.getCurrentUser(any(CurrentUserRequest.class))).thenReturn(user);
    SignClaPage claPage = SignClaPage.go(driver, cla.getName());
    claPage.assertAt();
    ArgumentCaptor<CurrentUserRequest> userCaptor = ArgumentCaptor.forClass(CurrentUserRequest.class);
    verify(mockGitHub).getCurrentUser(userCaptor.capture());
    CurrentUserRequest userRequest = userCaptor.getValue();
    OAuthAccessTokenParams oauthParams = userRequest.getOauthParams();
    assertThat(userRequest.isRequestAdminAccess()).isFalse();
    assertThat(oauthParams.getCallbackUrl()).isEqualTo("https://localhost/login/oauth2/github");
    assertThat(oauthParams.getCode()).isEqualTo("abc");
}
Also used : SignClaPage(io.pivotal.cla.webdriver.pages.SignClaPage) WithSigningUser(io.pivotal.cla.security.WithSigningUser) User(io.pivotal.cla.data.User) CurrentUserRequest(io.pivotal.cla.service.github.CurrentUserRequest) OAuthAccessTokenParams(io.pivotal.cla.service.github.OAuthAccessTokenParams) Test(org.junit.Test)

Example 8 with SignClaPage

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

the class AuthenticationTests method userUrlWithAdminUserThenAdminUrl.

@SuppressWarnings("unchecked")
@Test
public void userUrlWithAdminUserThenAdminUrl() throws Exception {
    User currentUser = WithAdminUserFactory.create();
    currentUser.setAdmin(false);
    when(mockClaRepository.findByNameAndPrimaryTrue(cla.getName())).thenReturn(cla);
    when(mockGitHub.getCurrentUser(any(CurrentUserRequest.class))).thenAnswer(new Answer<User>() {

        @Override
        public User answer(InvocationOnMock invocation) throws Throwable {
            CurrentUserRequest request = invocation.getArgumentAt(0, CurrentUserRequest.class);
            User currentUser = WithAdminUserFactory.create();
            currentUser.setAdmin(request.isRequestAdminAccess());
            return currentUser;
        }
    });
    when(mockIndividualSignatureRepository.findByEmailIn(anySet())).thenReturn(Collections.emptyList());
    SignClaPage signClaPage = SignClaPage.go(driver, cla.getName());
    signClaPage.assertAt();
    when(mockClaRepository.findAll()).thenReturn(Arrays.asList(cla));
    when(mockGitHub.findRepositoryNamesWithAdminPermission(anyString())).thenReturn(Arrays.asList("test/this"));
    AdminLinkClaPage admin = AdminLinkClaPage.to(driver);
    admin.assertAt();
    ArgumentCaptor<CurrentUserRequest> userCaptor = ArgumentCaptor.forClass(CurrentUserRequest.class);
    verify(mockGitHub, times(2)).getCurrentUser(userCaptor.capture());
    assertThat(userCaptor.getAllValues()).extracting(CurrentUserRequest::isRequestAdminAccess).containsOnly(false, true);
}
Also used : SignClaPage(io.pivotal.cla.webdriver.pages.SignClaPage) WithSigningUser(io.pivotal.cla.security.WithSigningUser) User(io.pivotal.cla.data.User) InvocationOnMock(org.mockito.invocation.InvocationOnMock) CurrentUserRequest(io.pivotal.cla.service.github.CurrentUserRequest) AdminLinkClaPage(io.pivotal.cla.webdriver.pages.admin.AdminLinkClaPage) Test(org.junit.Test)

Example 9 with SignClaPage

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

the class AuthenticationTests method signOut.

@Test
@WithSigningUser
@SuppressWarnings("unchecked")
public void signOut() throws Exception {
    when(mockClaRepository.findByNameAndPrimaryTrue(cla.getName())).thenReturn(cla);
    when(mockIndividualSignatureRepository.findByEmailIn(anySet())).thenReturn(Arrays.asList(individualSignature));
    SignClaPage signClaPage = SignClaPage.go(driver, cla.getName());
    signClaPage.assertAt();
    TestSecurityContextHolder.clearContext();
    SignClaPage signOut = signClaPage.signOut();
    signOut.assertAt();
    signOut.assertLogoutSuccess();
}
Also used : SignClaPage(io.pivotal.cla.webdriver.pages.SignClaPage) WithSigningUser(io.pivotal.cla.security.WithSigningUser) Test(org.junit.Test)

Example 10 with SignClaPage

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

the class ClaControllerTests method claPivotal.

@Test
public void claPivotal() throws Exception {
    SignClaPage home = SignClaPage.go(driver, cla.getName());
    home.assertAt();
    home.assertClaLinks(cla.getName());
}
Also used : SignClaPage(io.pivotal.cla.webdriver.pages.SignClaPage) Test(org.junit.Test)

Aggregations

SignClaPage (io.pivotal.cla.webdriver.pages.SignClaPage)18 Test (org.junit.Test)18 WithSigningUser (io.pivotal.cla.security.WithSigningUser)12 User (io.pivotal.cla.data.User)4 SignIclaPage (io.pivotal.cla.webdriver.pages.SignIclaPage)3 CurrentUserRequest (io.pivotal.cla.service.github.CurrentUserRequest)2 PullRequestStatus (io.pivotal.cla.service.github.PullRequestStatus)2 AboutPage (io.pivotal.cla.webdriver.pages.AboutPage)2 SignCclaPage (io.pivotal.cla.webdriver.pages.SignCclaPage)2 AdminLinkClaPage (io.pivotal.cla.webdriver.pages.admin.AdminLinkClaPage)2 WithAnonymousUser (org.springframework.security.test.context.support.WithAnonymousUser)2 AccessToken (io.pivotal.cla.data.AccessToken)1 OAuthAccessTokenParams (io.pivotal.cla.service.github.OAuthAccessTokenParams)1 GitHubLoginPage (io.pivotal.cla.webdriver.pages.github.GitHubLoginPage)1 GitHubPullRequestPage (io.pivotal.cla.webdriver.pages.github.GitHubPullRequestPage)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1