forked from Onlineberatung/onlineBeratung-userService
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
6 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,37 @@ | ||
package de.caritas.cob.userservice.api.adapters.web.controller; | ||
|
||
import static de.caritas.cob.userservice.api.adapters.web.controller.UserAdminControllerIT.ADMIN_DATA_PATH; | ||
import static de.caritas.cob.userservice.api.adapters.web.controller.UserAdminControllerIT.AGENCY_ADMIN_PATH; | ||
import static de.caritas.cob.userservice.api.adapters.web.controller.UserAdminControllerIT.CONSULTANT_PATH; | ||
import static de.caritas.cob.userservice.api.adapters.web.controller.UserAdminControllerIT.TENANT_ADMIN_PATH; | ||
import static de.caritas.cob.userservice.api.adapters.web.controller.UserAdminControllerIT.TENANT_ADMIN_PATH_WITHOUT_SLASH; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.hamcrest.Matchers.hasSize; | ||
import static org.hamcrest.Matchers.is; | ||
import static org.hamcrest.Matchers.notNullValue; | ||
import static org.hamcrest.Matchers.nullValue; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.ArgumentMatchers.anyLong; | ||
import static org.mockito.Mockito.when; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.jayway.jsonpath.JsonPath; | ||
import de.caritas.cob.userservice.api.adapters.keycloak.dto.KeycloakCreateUserResponseDTO; | ||
import de.caritas.cob.userservice.api.adapters.rocketchat.RocketChatCredentialsProvider; | ||
import de.caritas.cob.userservice.api.adapters.web.dto.CreateAdminDTO; | ||
import de.caritas.cob.userservice.api.adapters.web.dto.CreateConsultantDTO; | ||
import de.caritas.cob.userservice.api.adapters.web.dto.PatchAdminDTO; | ||
import de.caritas.cob.userservice.api.adapters.web.dto.UpdateAgencyAdminDTO; | ||
import de.caritas.cob.userservice.api.adapters.web.dto.UpdateTenantAdminDTO; | ||
import de.caritas.cob.userservice.api.admin.service.tenant.TenantService; | ||
import de.caritas.cob.userservice.api.config.apiclient.AgencyServiceApiControllerFactory; | ||
import de.caritas.cob.userservice.api.config.apiclient.ConsultingTypeServiceApiControllerFactory; | ||
import de.caritas.cob.userservice.api.config.apiclient.MailServiceApiControllerFactory; | ||
import de.caritas.cob.userservice.api.config.auth.Authority.AuthorityValue; | ||
import de.caritas.cob.userservice.api.config.auth.IdentityConfig; | ||
import de.caritas.cob.userservice.api.helper.AuthenticatedUser; | ||
import de.caritas.cob.userservice.api.model.Admin.AdminType; | ||
import de.caritas.cob.userservice.api.model.User; | ||
import de.caritas.cob.userservice.api.port.out.AdminRepository; | ||
import de.caritas.cob.userservice.api.port.out.IdentityClient; | ||
import de.caritas.cob.userservice.api.tenant.TenantResolverService; | ||
import de.caritas.cob.userservice.api.testConfig.TestAgencyControllerApi; | ||
import de.caritas.cob.userservice.consultingtypeservice.generated.web.ConsultingTypeControllerApi; | ||
import de.caritas.cob.userservice.mailservice.generated.web.MailsControllerApi; | ||
import de.caritas.cob.userservice.tenantservice.generated.web.model.RestrictedTenantDTO; | ||
import de.caritas.cob.userservice.topicservice.generated.web.TopicControllerApi; | ||
import java.util.LinkedHashMap; | ||
import javax.servlet.http.Cookie; | ||
import net.minidev.json.JSONArray; | ||
import org.jeasy.random.EasyRandom; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.keycloak.admin.client.Keycloak; | ||
import org.mockito.Mockito; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
|
@@ -69,7 +46,6 @@ | |
import org.springframework.test.web.servlet.MockMvc; | ||
import org.springframework.test.web.servlet.MvcResult; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
@SpringBootTest | ||
@AutoConfigureMockMvc | ||
|
@@ -107,11 +83,9 @@ class UserAdminControllerMultiTenancyTrueE2EIT { | |
|
||
@MockBean TenantService tenantService; | ||
|
||
@MockBean | ||
TenantResolverService tenantResolverService; | ||
@MockBean TenantResolverService tenantResolverService; | ||
|
||
@MockBean | ||
AuthenticatedUser authenticatedUser; | ||
@MockBean AuthenticatedUser authenticatedUser; | ||
|
||
@AfterEach | ||
void reset() { | ||
|
@@ -169,8 +143,7 @@ void createNewAgencyAdmin_Should_returnOk_When_requiredCreateAgencyAdminIsGiven( | |
|
||
@Test | ||
@WithMockUser(authorities = {AuthorityValue.USER_ADMIN}) | ||
void createNewAgencyAdmin_Should_return500_When_superAdminHasNullTenantID() | ||
throws Exception { | ||
void createNewAgencyAdmin_Should_return500_When_superAdminHasNullTenantID() throws Exception { | ||
// given | ||
CreateAdminDTO createAdminDTO = new EasyRandom().nextObject(CreateAdminDTO.class); | ||
createAdminDTO.setEmail("[email protected]"); | ||
|
@@ -197,38 +170,7 @@ private void givenTenantSuperAdmin() { | |
|
||
private void givenTenant() { | ||
when(tenantResolverService.resolve(any())).thenReturn(95L); | ||
when(tenantService.getRestrictedTenantData(anyLong())).thenReturn(new RestrictedTenantDTO().subdomain("subdomain")); | ||
when(tenantService.getRestrictedTenantData(anyLong())) | ||
.thenReturn(new RestrictedTenantDTO().subdomain("subdomain")); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters