Search in sources :

Example 1 with Me

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();
}
Also used : Me(org.pmiops.workbench.firecloud.model.Me) Enabled(org.pmiops.workbench.firecloud.model.Enabled) Test(org.junit.Test)

Example 2 with Me

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();
}
Also used : Me(org.pmiops.workbench.firecloud.model.Me) Test(org.junit.Test)

Example 3 with Me

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();
}
Also used : Me(org.pmiops.workbench.firecloud.model.Me) Enabled(org.pmiops.workbench.firecloud.model.Enabled) Test(org.junit.Test)

Example 4 with Me

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);
}
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 5 with Me

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

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