Skip to content

Commit

Permalink
Merge pull request #55 from Onlineberatung/VIC-1495-add-new-settings
Browse files Browse the repository at this point in the history
adding two new settings
  • Loading branch information
tkuzynow authored Sep 12, 2022
2 parents 781cd08 + ef0e682 commit 2708e8b
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 54 deletions.
9 changes: 6 additions & 3 deletions api/applicationsettingsservice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ components:
useTenantService:
allOf:
- $ref: '#/components/schemas/FeatureToggleDTO'
enableTenantTheming:
allOf:
- $ref: '#/components/schemas/FeatureToggleDTO'
enableWalkthrough:
allOf:
- $ref: '#/components/schemas/FeatureToggleDTO'
Expand All @@ -58,6 +55,12 @@ components:
mainTenantSubdomainForSingleDomainMultitenancy:
allOf:
- $ref: '#/components/schemas/SettingDTO'
budibaseSSO:
allOf:
- $ref: '#/components/schemas/FeatureToggleDTO'
useOverviewPage:
allOf:
- $ref: '#/components/schemas/FeatureToggleDTO'


FeatureToggleDTO:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ public ApplicationSettingsDTO toDTO(ApplicationSettingsEntity applicationSetting
toFeatureToggleDTO(applicationSettings.getMultitenancyWithSingleDomainEnabled()))
.multitenancyEnabled(
toFeatureToggleDTO(applicationSettings.getMultitenancyEnabled()))
.enableTenantTheming(
toFeatureToggleDTO(applicationSettings.getEnableTenantTheming()))
.enableWalkthrough(
toFeatureToggleDTO(applicationSettings.getEnableWalkthrough()))
.disableVideoAppointments(
toFeatureToggleDTO(applicationSettings.getDisableVideoAppointments()))
.useTenantService(
toFeatureToggleDTO(applicationSettings.getUseTenantService()))
.mainTenantSubdomainForSingleDomainMultitenancy(
toSettingDTO(applicationSettings.getMainTenantSubdomainForSingleDomainMultitenancy()));
toSettingDTO(applicationSettings.getMainTenantSubdomainForSingleDomainMultitenancy()))
.budibaseSSO(toFeatureToggleDTO(applicationSettings.getBudibaseSSO()))
.useOverviewPage(toFeatureToggleDTO(applicationSettings.getUseOverviewPage()));
}

private SettingDTO toSettingDTO(MainTenantSubdomainForSingleDomainMultitenancy mainTenantSubdomainForSingleDomainMultitenancy) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import de.caritas.cob.consultingtypeservice.api.model.ApplicationSettingsEntity;
import de.caritas.cob.consultingtypeservice.api.repository.ApplicationSettingsRepository;
import de.caritas.cob.consultingtypeservice.schemas.model.BudibaseSSO;
import de.caritas.cob.consultingtypeservice.schemas.model.DisableVideoAppointments;
import de.caritas.cob.consultingtypeservice.schemas.model.EnableTenantTheming;
import de.caritas.cob.consultingtypeservice.schemas.model.EnableWalkthrough;
import de.caritas.cob.consultingtypeservice.schemas.model.MainTenantSubdomainForSingleDomainMultitenancy;
import de.caritas.cob.consultingtypeservice.schemas.model.MultitenancyEnabled;
import de.caritas.cob.consultingtypeservice.schemas.model.MultitenancyWithSingleDomainEnabled;
import de.caritas.cob.consultingtypeservice.schemas.model.UseOverviewPage;
import de.caritas.cob.consultingtypeservice.schemas.model.UseTenantService;
import javax.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -49,14 +50,15 @@ private ApplicationSettingsEntity createDefaultApplicationSettings() {
entity.setDisableVideoAppointments(new DisableVideoAppointments().withValue(true).withReadOnly(false));
entity.setEnableWalkthrough(new EnableWalkthrough().withValue(false).withReadOnly(false));
entity.setUseTenantService(new UseTenantService().withValue(multitenancy).withReadOnly(false));
entity.setEnableTenantTheming(new EnableTenantTheming().withValue(multitenancy).withReadOnly(false));
entity.setMultitenancyEnabled(new MultitenancyEnabled().withValue(multitenancy).withReadOnly(true));
entity.setMultitenancyWithSingleDomainEnabled(new MultitenancyWithSingleDomainEnabled().withReadOnly(true)
.withValue(multitenancyWithSingleDomainEnabled));
entity.setMainTenantSubdomainForSingleDomainMultitenancy(
new MainTenantSubdomainForSingleDomainMultitenancy()
.withReadOnly(false)
.withValue(mainTenantSubdomainForSingleDomainMultitenancy));
entity.setUseOverviewPage(new UseOverviewPage().withValue(false).withReadOnly(false));
entity.setBudibaseSSO(new BudibaseSSO().withValue(false).withReadOnly(false));
return entity;
}
}
25 changes: 20 additions & 5 deletions src/main/resources/schemas/application-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"readOnly"
]
},
"enableTenantTheming": {
"enableWalkthrough": {
"type": "object",
"properties": {
"value": {
Expand All @@ -84,7 +84,7 @@
"readOnly"
]
},
"enableWalkthrough": {
"disableVideoAppointments": {
"type": "object",
"properties": {
"value": {
Expand All @@ -99,7 +99,22 @@
"readOnly"
]
},
"disableVideoAppointments": {
"mainTenantSubdomainForSingleDomainMultitenancy": {
"type": "object",
"properties": {
"value": {
"type": "string"
},
"readOnly": {
"type": "boolean"
}
},
"required": [
"value",
"readOnly"
]
},
"budibaseSSO": {
"type": "object",
"properties": {
"value": {
Expand All @@ -114,11 +129,11 @@
"readOnly"
]
},
"mainTenantSubdomainForSingleDomainMultitenancy": {
"useOverviewPage": {
"type": "object",
"properties": {
"value": {
"type": "string"
"type": "boolean"
},
"readOnly": {
"type": "boolean"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,47 +1,15 @@
package de.caritas.cob.consultingtypeservice.api.controller;

import static de.caritas.cob.consultingtypeservice.testHelper.TopicPathConstants.PATH_GET_PUBLIC_TOPIC_LIST;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.hasSize;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.authentication;
import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
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 de.caritas.cob.consultingtypeservice.ConsultingTypeServiceApplication;
import de.caritas.cob.consultingtypeservice.api.auth.UserRole;
import de.caritas.cob.consultingtypeservice.api.model.ApplicationSettingsEntity;
import de.caritas.cob.consultingtypeservice.api.model.TopicDTO;
import de.caritas.cob.consultingtypeservice.api.model.TopicStatus;
import de.caritas.cob.consultingtypeservice.api.repository.ApplicationSettingsRepository;
import de.caritas.cob.consultingtypeservice.api.tenant.TenantContext;
import de.caritas.cob.consultingtypeservice.api.util.JsonConverter;
import de.caritas.cob.consultingtypeservice.schemas.model.DisableVideoAppointments;
import de.caritas.cob.consultingtypeservice.schemas.model.EnableTenantTheming;
import de.caritas.cob.consultingtypeservice.schemas.model.EnableWalkthrough;
import de.caritas.cob.consultingtypeservice.schemas.model.MultitenancyEnabled;
import de.caritas.cob.consultingtypeservice.schemas.model.MultitenancyWithSingleDomainEnabled;
import de.caritas.cob.consultingtypeservice.schemas.model.UseTenantService;
import de.caritas.cob.consultingtypeservice.testHelper.TopicPathConstants;
import java.util.Map;
import org.assertj.core.util.Lists;
import org.assertj.core.util.Maps;
import org.assertj.core.util.Sets;
import org.jeasy.random.EasyRandom;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.keycloak.adapters.RefreshableKeycloakSecurityContext;
import org.keycloak.adapters.spi.KeycloakAccount;
import org.keycloak.adapters.springsecurity.account.SimpleKeycloakAccount;
import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken;
import org.keycloak.representations.AccessToken;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
Expand Down Expand Up @@ -85,17 +53,18 @@ void getApplicationSettings_Should_ReturnApplicationSettings_When_UserIsNotAuthe
.andExpect(jsonPath("$.multitenancyWithSingleDomainEnabled.readOnly").value(true))
.andExpect(jsonPath("$.multitenancyEnabled.value").value(false))
.andExpect(jsonPath("$.multitenancyEnabled.readOnly").value(true))
.andExpect(jsonPath("$.enableTenantTheming.value").value(false))
.andExpect(jsonPath("$.enableTenantTheming.readOnly").value(false))
.andExpect(jsonPath("$.useTenantService.value").value(false))
.andExpect(jsonPath("$.useTenantService.readOnly").value(false))
.andExpect(jsonPath("$.enableWalkthrough.value").value(false))
.andExpect(jsonPath("$.enableWalkthrough.readOnly").value(false))
.andExpect(jsonPath("$.disableVideoAppointments.value").value(true))
.andExpect(jsonPath("$.disableVideoAppointments.readOnly").value(false))
.andExpect(jsonPath("$.mainTenantSubdomainForSingleDomainMultitenancy.value").value("app"))
.andExpect(jsonPath("$.mainTenantSubdomainForSingleDomainMultitenancy.readOnly").value(false));

.andExpect(jsonPath("$.mainTenantSubdomainForSingleDomainMultitenancy.readOnly").value(false))
.andExpect(jsonPath("$.budibaseSSO.value").value(false))
.andExpect(jsonPath("$.budibaseSSO.readOnly").value(false))
.andExpect(jsonPath("$.useOverviewPage.value").value(false))
.andExpect(jsonPath("$.useOverviewPage.readOnly").value(false));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

import de.caritas.cob.consultingtypeservice.api.model.ApplicationSettingsDTO;
import de.caritas.cob.consultingtypeservice.api.model.ApplicationSettingsEntity;
import de.caritas.cob.consultingtypeservice.schemas.model.BudibaseSSO;
import de.caritas.cob.consultingtypeservice.schemas.model.DisableVideoAppointments;
import de.caritas.cob.consultingtypeservice.schemas.model.EnableTenantTheming;
import de.caritas.cob.consultingtypeservice.schemas.model.EnableWalkthrough;
import de.caritas.cob.consultingtypeservice.schemas.model.MainTenantSubdomainForSingleDomainMultitenancy;
import de.caritas.cob.consultingtypeservice.schemas.model.MultitenancyEnabled;
import de.caritas.cob.consultingtypeservice.schemas.model.MultitenancyWithSingleDomainEnabled;
import de.caritas.cob.consultingtypeservice.schemas.model.UseOverviewPage;
import de.caritas.cob.consultingtypeservice.schemas.model.UseTenantService;
import org.junit.jupiter.api.Test;

Expand All @@ -26,9 +27,10 @@ void toDTO_Should_ConvertToDTEmptySettings() {
assertThat(applicationSettingsDTO.getDisableVideoAppointments()).isNull();
assertThat(applicationSettingsDTO.getMultitenancyWithSingleDomainEnabled()).isNull();
assertThat(applicationSettingsDTO.getMultitenancyEnabled()).isNull();
assertThat(applicationSettingsDTO.getEnableTenantTheming()).isNull();
assertThat(applicationSettingsDTO.getEnableWalkthrough()).isNull();
assertThat(applicationSettingsDTO.getUseTenantService()).isNull();
assertThat(applicationSettingsDTO.getBudibaseSSO()).isNull();
assertThat(applicationSettingsDTO.getUseOverviewPage()).isNull();
}

@Test
Expand All @@ -45,8 +47,6 @@ void toDTO_Should_ConvertToDTOAllSettings() {
assertThat(applicationSettingsDTO.getMultitenancyEnabled().getReadOnly()).isTrue();
assertThat(applicationSettingsDTO.getMultitenancyWithSingleDomainEnabled().getValue()).isTrue();
assertThat(applicationSettingsDTO.getMultitenancyWithSingleDomainEnabled().getReadOnly()).isTrue();
assertThat(applicationSettingsDTO.getEnableTenantTheming().getValue()).isFalse();
assertThat(applicationSettingsDTO.getEnableTenantTheming().getReadOnly()).isFalse();
assertThat(applicationSettingsDTO.getUseTenantService().getValue()).isTrue();
assertThat(applicationSettingsDTO.getUseTenantService().getReadOnly()).isFalse();
assertThat(applicationSettingsDTO.getEnableWalkthrough().getValue()).isTrue();
Expand All @@ -55,17 +55,22 @@ void toDTO_Should_ConvertToDTOAllSettings() {
assertThat(applicationSettingsDTO.getDisableVideoAppointments().getReadOnly()).isFalse();
assertThat(applicationSettingsDTO.getMainTenantSubdomainForSingleDomainMultitenancy().getValue()).isEqualTo("app");
assertThat(applicationSettingsDTO.getMainTenantSubdomainForSingleDomainMultitenancy().getReadOnly()).isFalse();
assertThat(applicationSettingsDTO.getBudibaseSSO().getValue()).isFalse();
assertThat(applicationSettingsDTO.getBudibaseSSO().getReadOnly()).isFalse();
assertThat(applicationSettingsDTO.getUseOverviewPage().getValue()).isFalse();
assertThat(applicationSettingsDTO.getUseOverviewPage().getReadOnly()).isFalse();
}

private ApplicationSettingsEntity giveApplicationSettings() {
var settings = new ApplicationSettingsEntity();
settings.setMultitenancyWithSingleDomainEnabled(new MultitenancyWithSingleDomainEnabled().withReadOnly(true).withValue(true));
settings.setMultitenancyEnabled(new MultitenancyEnabled().withReadOnly(true).withValue(true));
settings.setEnableTenantTheming(new EnableTenantTheming().withReadOnly(false).withValue(false));
settings.setUseTenantService(new UseTenantService().withReadOnly(false).withValue(true));
settings.setEnableWalkthrough(new EnableWalkthrough().withReadOnly(false).withValue(true));
settings.setDisableVideoAppointments(new DisableVideoAppointments().withReadOnly(false).withValue(true));
settings.setMainTenantSubdomainForSingleDomainMultitenancy(new MainTenantSubdomainForSingleDomainMultitenancy().withReadOnly(false).withValue("app"));
settings.setBudibaseSSO(new BudibaseSSO().withReadOnly(false).withValue(false));
settings.setUseOverviewPage(new UseOverviewPage().withReadOnly(false).withValue(false));
return settings;
}
}

0 comments on commit 2708e8b

Please sign in to comment.