use of com.sequenceiq.cloudbreak.common.user.CloudbreakUser in project cloudbreak by hortonworks.
the class WorkspaceConfigurationFilterTest method filterWhenWorkspaceExists.
@Test
public void filterWhenWorkspaceExists() throws ServletException, IOException {
CloudbreakUser cbUser = createCbUserWithCrn();
when(authenticatedUserService.getCbUser()).thenReturn(cbUser);
when(userService.getOrCreate(any())).thenReturn(new User());
when(workspaceService.getByName(anyString(), any())).thenReturn(Optional.of(createWorkspace()));
underTest.doFilterInternal(request, response, filterChain);
verify(workspaceService, times(1)).getByName(eq(Crn.fromString(cbUser.getUserCrn()).getAccountId()), any());
verify(workspaceService, times(0)).getByName(eq(cbUser.getTenant()), any());
}
use of com.sequenceiq.cloudbreak.common.user.CloudbreakUser in project cloudbreak by hortonworks.
the class WorkspaceConfigurationFilterTest method filterWhenWorkspaceDoesntExist.
@Test
public void filterWhenWorkspaceDoesntExist() throws ServletException, IOException {
CloudbreakUser cbUser = createCbUserWithCrn();
when(authenticatedUserService.getCbUser()).thenReturn(cbUser);
when(userService.getOrCreate(any())).thenReturn(new User());
when(workspaceService.getByName(anyString(), any())).thenReturn(Optional.empty());
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("Tenant default workspace does not exist!");
underTest.doFilterInternal(request, response, filterChain);
verify(workspaceService, times(1)).getByName(eq(Crn.fromString(cbUser.getUserCrn()).getAccountId()), any());
verify(workspaceService, times(0)).getByName(eq(cbUser.getTenant()), any());
}
Aggregations