use of org.pmiops.workbench.firecloud.model.FirecloudUserInfo in project workbench by all-of-us.
the class AuthInterceptorTest method preHandleGet_firecloudLookupSucceeds.
@Test
public void preHandleGet_firecloudLookupSucceeds() throws Exception {
mockGetCallWithBearerToken();
Userinfo userInfo = new Userinfo();
userInfo.setEmail("bob@bad-domain.org");
when(userInfoService.getUserInfo("foo")).thenReturn(userInfo);
FirecloudUserInfo fcUserInfo = new FirecloudUserInfo();
fcUserInfo.setUserEmail("bob@fake-domain.org");
FirecloudMe me = new FirecloudMe();
me.setUserInfo(fcUserInfo);
when(fireCloudService.getMe()).thenReturn(me);
when(userDao.findUserByUsername("bob@fake-domain.org")).thenReturn(user);
assertThat(interceptor.preHandle(mockRequest, mockResponse, mockHandler)).isTrue();
}
use of org.pmiops.workbench.firecloud.model.FirecloudUserInfo in project workbench by all-of-us.
the class AuthInterceptorTest method preHandleGet_firecloudLookupSucceedsNoUserRecordWrongDomain.
@Test
public void preHandleGet_firecloudLookupSucceedsNoUserRecordWrongDomain() throws Exception {
mockGetCallWithBearerToken();
Userinfo userInfo = new Userinfo();
userInfo.setEmail("bob@bad-domain.org");
when(userInfoService.getUserInfo("foo")).thenReturn(userInfo);
FirecloudUserInfo fcUserInfo = new FirecloudUserInfo();
fcUserInfo.setUserEmail("bob@also-bad-domain.org");
FirecloudMe me = new FirecloudMe();
me.setUserInfo(fcUserInfo);
when(fireCloudService.getMe()).thenReturn(me);
when(userDao.findUserByUsername("bob@also-bad-domain.org")).thenReturn(null);
assertThat(interceptor.preHandle(mockRequest, mockResponse, mockHandler)).isFalse();
verify(mockResponse).sendError(HttpServletResponse.SC_UNAUTHORIZED);
}
Aggregations