Skip to content

Commit

Permalink
Merge pull request #206 from Onlineberatung/CONNECTA-163
Browse files Browse the repository at this point in the history
do not cache topics to avoid multitenancy issues
  • Loading branch information
tkuzynow authored Mar 21, 2024
2 parents 73476ed + d3ca840 commit 314ef0d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/dockerImage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- "develop"
- "staging"
- "release"
- "tsys-release"
tags:
- "dockerImage.v.*"
- "v*"
Expand Down Expand Up @@ -64,7 +65,7 @@ jobs:
push_to_registry:
strategy:
matrix:
registry: ["docker.pkg.github.com", "ghcr.io"]
registry: ["ghcr.io"]
needs: [test]
name: Push Docker image to GitHub Packages
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,16 @@ private List<TopicDTO> getTopics() {
}

private List<TopicDTO> getTopics(List<AgencyTopic> agencyTopics) {
return agencyTopics.stream().map(AgencyTopic::getTopicData).toList();
return agencyTopics.stream().map(agencyTopic -> createTopicDTO(agencyTopic)).toList();
}

private TopicDTO createTopicDTO(AgencyTopic agencyTopic) {
return new TopicDTO().id(agencyTopic.getTopicId())
.name(agencyTopic.getTopicData().getName())
.description(agencyTopic.getTopicData().getDescription())
.status(agencyTopic.getTopicData().getStatus())
.internalIdentifier(agencyTopic.getTopicData().getInternalIdentifier());

}

private AgencyLinks createAgencyLinks() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class TopicService {
private final @NonNull SecurityHeaderSupplier securityHeaderSupplier;
private final @NonNull TenantHeaderSupplier tenantHeaderSupplier;

@Cacheable(cacheNames = CacheManagerConfig.TOPICS_CACHE)
public List<TopicDTO> getAllTopics() {
TopicControllerApi controllerApi = topicServiceApiControllerFactory.createControllerApi();
addDefaultHeaders(controllerApi.getApiClient());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.google.common.collect.Lists;
import de.caritas.cob.agencyservice.api.model.AgencyAdminFullResponseDTO;
import de.caritas.cob.agencyservice.api.model.AgencyAdminResponseDTO;
import de.caritas.cob.agencyservice.api.model.AgencyDTO;
import de.caritas.cob.agencyservice.api.model.AgencyLinks;
import de.caritas.cob.agencyservice.api.model.DataProtectionContactDTO;
import de.caritas.cob.agencyservice.api.model.HalLink.MethodEnum;
import de.caritas.cob.agencyservice.api.model.TopicDTO;
import de.caritas.cob.agencyservice.api.repository.agency.Agency;
import de.caritas.cob.agencyservice.api.repository.agency.DataProtectionResponsibleEntity;
import de.caritas.cob.agencyservice.api.repository.agency.Gender;
import de.caritas.cob.agencyservice.api.repository.agencytopic.AgencyTopic;
import de.caritas.cob.agencyservice.api.util.JsonConverter;
import org.assertj.core.groups.Tuple;
import org.jeasy.random.EasyRandom;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -33,6 +37,7 @@ public void init() {
this.agency.setDataProtectionAgencyResponsibleContactData(JsonConverter.convertToJson(new DataProtectionContactDTO()));
this.agency.setDataProtectionOfficerContactData(JsonConverter.convertToJson(new DataProtectionContactDTO()));
this.agency.setDataProtectionAlternativeContactData(JsonConverter.convertToJson(new DataProtectionContactDTO()));
this.agency.setAgencyTopics(Lists.newArrayList(AgencyTopic.builder().topicId(1L).topicData(new TopicDTO().id(1L).name("topic name")).build()));
this.agency.setTenantId(TENANT_ID);
this.agencyAdminFullResponseDTOBuilder = new AgencyAdminFullResponseDTOBuilder(agency);
this.agency.setCounsellingRelations(AgencyDTO.CounsellingRelationsEnum.PARENTAL_COUNSELLING.getValue() + "," + AgencyDTO.CounsellingRelationsEnum.RELATIVE_COUNSELLING.getValue());
Expand Down Expand Up @@ -62,6 +67,8 @@ private void assertBaseDTOAttributesAreMapped(AgencyAdminFullResponseDTO result)
assertEquals(String.valueOf(agency.getCreateDate()), result.getEmbedded().getCreateDate());
assertEquals(String.valueOf(agency.getUpdateDate()), result.getEmbedded().getUpdateDate());
assertEquals(String.valueOf(agency.getDeleteDate()), result.getEmbedded().getDeleteDate());
assertThat(result.getEmbedded().getTopics()).extracting("id", "name").containsExactly(
Tuple.tuple(1L, "topic name"));
}

@Test
Expand Down

0 comments on commit 314ef0d

Please sign in to comment.