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();
}
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");
}
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);
}
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();
}
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());
}
Aggregations