Search in sources :

Example 1 with UserInfo

use of org.pmiops.workbench.firecloud.model.UserInfo in project workbench by all-of-us.

the class AuthInterceptorTest method preHandleGet_firecloudLookupSucceedsNoUserRecordWrongDomain.

@Test
public void preHandleGet_firecloudLookupSucceedsNoUserRecordWrongDomain() throws Exception {
    when(handler.getMethod()).thenReturn(getProfileApiMethod("getBillingProjects"));
    when(request.getMethod()).thenReturn(HttpMethods.GET);
    when(request.getHeader(HttpHeaders.AUTHORIZATION)).thenReturn("Bearer foo");
    Userinfoplus userInfo = new Userinfoplus();
    userInfo.setEmail("bob@bad-domain.org");
    when(userInfoService.getUserInfo("foo")).thenReturn(userInfo);
    UserInfo fcUserInfo = new UserInfo();
    fcUserInfo.setUserEmail("bob@also-bad-domain.org");
    Me me = new Me();
    me.setUserInfo(fcUserInfo);
    when(fireCloudService.getMe()).thenReturn(me);
    when(userDao.findUserByEmail("bob@also-bad-domain.org")).thenReturn(null);
    assertThat(interceptor.preHandle(request, response, handler)).isFalse();
    verify(response).sendError(HttpServletResponse.SC_NOT_FOUND);
}
Also used : Userinfoplus(com.google.api.services.oauth2.model.Userinfoplus) Me(org.pmiops.workbench.firecloud.model.Me) UserInfo(org.pmiops.workbench.firecloud.model.UserInfo) Test(org.junit.Test)

Example 2 with UserInfo

use of org.pmiops.workbench.firecloud.model.UserInfo in project workbench by all-of-us.

the class AuthInterceptorTest method preHandleGet_firecloudLookupSucceeds.

@Test
public void preHandleGet_firecloudLookupSucceeds() throws Exception {
    when(handler.getMethod()).thenReturn(getProfileApiMethod("getBillingProjects"));
    when(request.getMethod()).thenReturn(HttpMethods.GET);
    when(request.getHeader(HttpHeaders.AUTHORIZATION)).thenReturn("Bearer foo");
    Userinfoplus userInfo = new Userinfoplus();
    userInfo.setEmail("bob@bad-domain.org");
    when(userInfoService.getUserInfo("foo")).thenReturn(userInfo);
    UserInfo fcUserInfo = new UserInfo();
    fcUserInfo.setUserEmail("bob@fake-domain.org");
    Me me = new Me();
    me.setUserInfo(fcUserInfo);
    when(fireCloudService.getMe()).thenReturn(me);
    when(userDao.findUserByEmail("bob@fake-domain.org")).thenReturn(user);
    assertThat(interceptor.preHandle(request, response, handler)).isTrue();
}
Also used : Userinfoplus(com.google.api.services.oauth2.model.Userinfoplus) Me(org.pmiops.workbench.firecloud.model.Me) UserInfo(org.pmiops.workbench.firecloud.model.UserInfo) Test(org.junit.Test)

Aggregations

Userinfoplus (com.google.api.services.oauth2.model.Userinfoplus)2 Test (org.junit.Test)2 Me (org.pmiops.workbench.firecloud.model.Me)2 UserInfo (org.pmiops.workbench.firecloud.model.UserInfo)2