use of org.pmiops.workbench.firecloud.model.Me in project workbench by all-of-us.
the class FireCloudServiceImplTest method testIsRequesterEnabledInFirecloud_enabledNoFlags.
@Test
public void testIsRequesterEnabledInFirecloud_enabledNoFlags() throws ApiException {
Me me = new Me();
me.setEnabled(new Enabled());
when(profileApi.me()).thenReturn(me);
assertThat(service.isRequesterEnabledInFirecloud()).isFalse();
}
use of org.pmiops.workbench.firecloud.model.Me in project workbench by all-of-us.
the class FireCloudServiceImplTest method testIsRequesterEnabledInFirecloud_enabledNull.
@Test
public void testIsRequesterEnabledInFirecloud_enabledNull() throws ApiException {
when(profileApi.me()).thenReturn(new Me());
assertThat(service.isRequesterEnabledInFirecloud()).isFalse();
}
use of org.pmiops.workbench.firecloud.model.Me in project workbench by all-of-us.
the class FireCloudServiceImplTest method testIsRequesterEnabledInFirecloud_noAllUsers.
@Test
public void testIsRequesterEnabledInFirecloud_noAllUsers() throws ApiException {
Me me = new Me();
Enabled enabled = new Enabled();
enabled.setGoogle(true);
enabled.setLdap(true);
me.setEnabled(enabled);
when(profileApi.me()).thenReturn(me);
assertThat(service.isRequesterEnabledInFirecloud()).isTrue();
}
use of org.pmiops.workbench.firecloud.model.Me 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.Me 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