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