Search in sources :

Example 1 with FirecloudUserInfo

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();
}
Also used : Userinfo(com.google.api.services.oauth2.model.Userinfo) FirecloudMe(org.pmiops.workbench.firecloud.model.FirecloudMe) FirecloudUserInfo(org.pmiops.workbench.firecloud.model.FirecloudUserInfo) Test(org.junit.jupiter.api.Test)

Example 2 with FirecloudUserInfo

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);
}
Also used : Userinfo(com.google.api.services.oauth2.model.Userinfo) FirecloudMe(org.pmiops.workbench.firecloud.model.FirecloudMe) FirecloudUserInfo(org.pmiops.workbench.firecloud.model.FirecloudUserInfo) Test(org.junit.jupiter.api.Test)

Aggregations

Userinfo (com.google.api.services.oauth2.model.Userinfo)2 Test (org.junit.jupiter.api.Test)2 FirecloudMe (org.pmiops.workbench.firecloud.model.FirecloudMe)2 FirecloudUserInfo (org.pmiops.workbench.firecloud.model.FirecloudUserInfo)2