diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index af1a635fbb5115a17f4a29d28207904ae5c0125b..d56a3f62b853f83b233434aeaf2c70b72983a4f6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -206,9 +206,6 @@ azure_code_coverage: variables: AZURE_COVERAGE_THRESHOLD: 80 -aws-test-java: - image: $CI_REGISTRY/osdu/platform/deployment-and-operations/base-containers-aws/aws-maven/aws-maven:v2.0 - fossa-analyze: image: $CI_REGISTRY/divido/fossa-with-cache:v0.9-jdk17 diff --git a/.sonarlint/connectedMode.json b/.sonarlint/connectedMode.json new file mode 100644 index 0000000000000000000000000000000000000000..1dfff308ee12aee51276f3724a2a0ad8646918c3 --- /dev/null +++ b/.sonarlint/connectedMode.json @@ -0,0 +1,4 @@ +{ + "sonarCloudOrganization": "osdu", + "projectKey": "org.opengroup.osdu:legal" +} \ No newline at end of file diff --git a/devops/gc/bootstrap_legalstatus_update/update_legal_status.sh b/devops/gc/bootstrap_legalstatus_update/update_legal_status.sh index 54827b990e41ecc1430fe3fef313fa55e331eb89..f75979cbbb93511e3d9c0f8277c8373ab24ee035 100644 --- a/devops/gc/bootstrap_legalstatus_update/update_legal_status.sh +++ b/devops/gc/bootstrap_legalstatus_update/update_legal_status.sh @@ -20,28 +20,13 @@ ## Common: # - LEGAL_HOST # - DATA_PARTITION_ID -## Baremetal: -# - OPENID_PROVIDER_URL -# - OPENID_PROVIDER_CLIENT_ID -# - OPENID_PROVIDER_CLIENT_SECRET set -ex get_token() { - if [ "${ONPREM_ENABLED}" == "true" ]; then - # id token - TOKEN="$(curl --location --silent --globoff --request POST "${OPENID_PROVIDER_URL}/protocol/openid-connect/token" \ - --header "Content-Type: application/x-www-form-urlencoded" \ - --data-urlencode "grant_type=client_credentials" \ - --data-urlencode "scope=openid" \ - --data-urlencode "client_id=${OPENID_PROVIDER_CLIENT_ID}" \ - --data-urlencode "client_secret=${OPENID_PROVIDER_CLIENT_SECRET}" | jq -r ".id_token")" - export TOKEN - else # access token TOKEN="$(gcloud auth print-access-token)" export TOKEN - fi } update_legal_status() { @@ -66,11 +51,6 @@ update_legal_status() { # Check variables source ./validate-env.sh "PARTITION_HOST" source ./validate-env.sh "LEGAL_HOST" -if [[ "${ONPREM_ENABLED}" == "true" ]]; then - source ./validate-env.sh "OPENID_PROVIDER_URL" - source ./validate-env.sh "OPENID_PROVIDER_CLIENT_ID" - source ./validate-env.sh "OPENID_PROVIDER_CLIENT_SECRET" -fi # Get list of partitions status_code=$(curl --location --request GET \ diff --git a/devops/gc/deploy/README.md b/devops/gc/deploy/README.md index 2b2edca5a89f12763d4572bd28065ba1b0c9cc0b..7a48242509e2b580f514b332fb3a2a06258a9e7c 100644 --- a/devops/gc/deploy/README.md +++ b/devops/gc/deploy/README.md @@ -97,7 +97,6 @@ First you need to set variables in **values.yaml** file using any code editor. S | Name | Description | Type | Default |Required | |------|-------------|------|---------|---------| **global.domain** | your domain for the external endpoint, ex `example.com` | string | - | yes -**global.onPremEnabled** | whether on-prem is enabled | boolean | `false` | yes **global.limitsEnabled** | whether CPU and memory limits are enabled | boolean | `true` | yes **global.logLevel** | severity of logging level | string | `ERROR` | yes **global.tier** | Only PROD must be used to enable autoscaling | string | "" | no diff --git a/devops/gc/deploy/templates/legal-status-update-configmap.yaml b/devops/gc/deploy/templates/legal-status-update-configmap.yaml index 45c783e6e83c0652a13294372c9d7f8ae4ccf725..cbbab92737ccae739f5445cdca5dd78dc22ac4f4 100644 --- a/devops/gc/deploy/templates/legal-status-update-configmap.yaml +++ b/devops/gc/deploy/templates/legal-status-update-configmap.yaml @@ -6,4 +6,3 @@ metadata: data: LEGAL_HOST: {{ .Values.data.legalHost | quote }} PARTITION_HOST: {{ .Values.data.partitionHost | quote }} - ONPREM_ENABLED: {{ .Values.global.onPremEnabled | quote }} diff --git a/devops/gc/deploy/values.yaml b/devops/gc/deploy/values.yaml index d69c5964d097ea7a414031f765d1128d7b2c8af8..28309cb99754975a0a6f4064d92f8451a69f4222 100644 --- a/devops/gc/deploy/values.yaml +++ b/devops/gc/deploy/values.yaml @@ -4,7 +4,6 @@ global: domain: "" - onPremEnabled: false limitsEnabled: true logLevel: "ERROR" tier: "" diff --git a/devops/gc/pipeline/override-stages.yml b/devops/gc/pipeline/override-stages.yml index 218efc0307e5964b3c157f37887c7108121cec47..8285428f18bafc09c8a90dcf3084f982ffe7c435 100644 --- a/devops/gc/pipeline/override-stages.yml +++ b/devops/gc/pipeline/override-stages.yml @@ -86,15 +86,3 @@ gc-containerize-gitlab: gc-containerize-gcr: needs: ["compile-and-unit-test", "download_gc_plugins"] - -gc-baremetal-deploy: - rules: - - when: never - -gc-baremetal-test: - rules: - - when: never - -gc-baremetal-osdutest: - rules: - - when: never diff --git a/legal-core/src/main/java/org/opengroup/osdu/legal/Constants.java b/legal-core/src/main/java/org/opengroup/osdu/legal/Constants.java index c17d2a4d1e0a6f374e84bce75cf93981f17daf8e..832b2ee39bfaeaf0e790bbccadf9ac91be631c50 100644 --- a/legal-core/src/main/java/org/opengroup/osdu/legal/Constants.java +++ b/legal-core/src/main/java/org/opengroup/osdu/legal/Constants.java @@ -15,4 +15,8 @@ public class Constants { public static final String LEGAL_QUERY_API_UNION_OPERATOR = "union"; public static final String LEGAL_QUERY_API_INTERSECTION_OPERATOR = "intersection"; public static final String LEGAL_QUERY_API_ADD_OPERATOR = "add"; + + private Constants() { + // Private constructor to prevent instantiation + } } diff --git a/legal-core/src/main/java/org/opengroup/osdu/legal/countries/Country.java b/legal-core/src/main/java/org/opengroup/osdu/legal/countries/Country.java index 3e4339a39a891c2847abaefadce831a8eb14fa5d..b98a297e107eda7a4ab3ca61320cfe57deb5ee3c 100644 --- a/legal-core/src/main/java/org/opengroup/osdu/legal/countries/Country.java +++ b/legal-core/src/main/java/org/opengroup/osdu/legal/countries/Country.java @@ -25,6 +25,8 @@ public class Country { public static final String EMBARGOED = "Embargoed"; public static final String DEFAULT = "Default"; public static final String CLIENT_CONSENT_REQUIRED = "Client consent required"; + + private RESIDENCY_RISK() {} } public boolean isMatchByAlpha2(Country other) { diff --git a/legal-core/src/main/java/org/opengroup/osdu/legal/jobs/LegalTagStatusJob.java b/legal-core/src/main/java/org/opengroup/osdu/legal/jobs/LegalTagStatusJob.java index 4695b36bfbabc9e756b1c6c512c68426fd0d56ae..3a025117704043e55cf0984853651581545130be 100644 --- a/legal-core/src/main/java/org/opengroup/osdu/legal/jobs/LegalTagStatusJob.java +++ b/legal-core/src/main/java/org/opengroup/osdu/legal/jobs/LegalTagStatusJob.java @@ -19,7 +19,6 @@ import org.opengroup.osdu.legal.config.LegalTagConfig; import org.springframework.stereotype.Component; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import java.util.Arrays; import java.util.ArrayList; @@ -62,7 +61,7 @@ public class LegalTagStatusJob { publishLegalTagStatusUpdateEvents(!legalTagJobResult.statusChangedTags.getStatusChangedTags().isEmpty(), projectId, headers, legalTagJobResult.statusChangedTags); if (featureFlagController.isAboutToExpireFeatureFlagEnabled()) { - publishAboutToExpireLegalTagEvents(!legalTagJobResult.aboutToExpireLegalTags.getAboutToExpireLegalTags().isEmpty(), projectId, headers, legalTagJobResult.aboutToExpireLegalTags); + publishAboutToExpireLegalTagEvents(!legalTagJobResult.aboutToExpireLegalTags.getLegalTags().isEmpty(), projectId, headers, legalTagJobResult.aboutToExpireLegalTags); } return legalTagJobResult; @@ -100,7 +99,7 @@ public class LegalTagStatusJob { Boolean isAboutToExpire = aboutToExpireDate.equals(today); if (isAboutToExpire) { log.info(String.format("Found legal tag about to expire: %s at %s", tag.getName(), expirationDate)); - aboutToExpireLegalTags.getAboutToExpireLegalTags().add(new AboutToExpireLegalTag(tag.getName(), properties.getExpirationDate())); + aboutToExpireLegalTags.getLegalTags().add(new AboutToExpireLegalTag(tag.getName(), properties.getExpirationDate())); return; } } diff --git a/legal-core/src/main/java/org/opengroup/osdu/legal/jobs/models/AboutToExpireLegalTags.java b/legal-core/src/main/java/org/opengroup/osdu/legal/jobs/models/AboutToExpireLegalTags.java index 8d7f5f4f2820fe38bd59589f6ab4d9f141de157b..fe9392d9a0aababef10912b267f38d63e901d259 100644 --- a/legal-core/src/main/java/org/opengroup/osdu/legal/jobs/models/AboutToExpireLegalTags.java +++ b/legal-core/src/main/java/org/opengroup/osdu/legal/jobs/models/AboutToExpireLegalTags.java @@ -7,5 +7,5 @@ import java.util.List; @Data public class AboutToExpireLegalTags { - private List<AboutToExpireLegalTag> aboutToExpireLegalTags = new ArrayList<>(); + private List<AboutToExpireLegalTag> legalTags = new ArrayList<>(); } diff --git a/legal-core/src/main/java/org/opengroup/osdu/legal/logging/AuditLogger.java b/legal-core/src/main/java/org/opengroup/osdu/legal/logging/AuditLogger.java index 4f612438afa02cd890caddaf25b111d381d7baae..0ac1d8f9ed2e8b2a55643209728e1329ba401915 100644 --- a/legal-core/src/main/java/org/opengroup/osdu/legal/logging/AuditLogger.java +++ b/legal-core/src/main/java/org/opengroup/osdu/legal/logging/AuditLogger.java @@ -1,7 +1,6 @@ package org.opengroup.osdu.legal.logging; import java.util.List; -import jakarta.inject.Inject; import org.opengroup.osdu.core.common.model.http.RequestInfo; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; @@ -12,14 +11,15 @@ import org.springframework.web.context.annotation.RequestScope; @RequestScope @Component public class AuditLogger { - @Inject - private JaxRsDpsLog logger; - - @Inject - private RequestInfo requestInfo; - + private final JaxRsDpsLog logger; + private final RequestInfo requestInfo; private AuditEvents events = null; + public AuditLogger(JaxRsDpsLog logger, RequestInfo requestInfo) { + this.logger = logger; + this.requestInfo = requestInfo; + } + private AuditEvents getEvents() { if (this.events == null) { this.events = new AuditEvents(this.requestInfo.getUser()); diff --git a/legal-core/src/main/java/org/opengroup/osdu/legal/service/AuthorizationService.java b/legal-core/src/main/java/org/opengroup/osdu/legal/service/AuthorizationService.java index 1b8432a0782886e03fe64333ff51c743df8c6711..fee16fb1033898235c42fbf8a617f29b0cc80823 100644 --- a/legal-core/src/main/java/org/opengroup/osdu/legal/service/AuthorizationService.java +++ b/legal-core/src/main/java/org/opengroup/osdu/legal/service/AuthorizationService.java @@ -22,7 +22,6 @@ import org.opengroup.osdu.core.common.model.entitlements.Groups; import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.core.common.provider.interfaces.IAuthorizationService; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Service; @@ -30,13 +29,16 @@ import org.springframework.stereotype.Service; @Primary // overrides class in core common public class AuthorizationService implements IAuthorizationService { - @Autowired - private IEntitlementsExtensionService entitlementsService; + private final IEntitlementsExtensionService entitlementsService; + + public AuthorizationService(IEntitlementsExtensionService entitlementsService) { + this.entitlementsService = entitlementsService; + } @Override public AuthorizationResponse authorizeAny(DpsHeaders dpsHeaders, String... permissions) { Groups groups = entitlementsService.getGroups(dpsHeaders); - if(!groups.any(permissions)) { + if(Boolean.FALSE.equals(groups.any(permissions))) { throw new AppException(HttpStatus.SC_UNAUTHORIZED, "Unauthorized", "User does nto have access to the API"); } return AuthorizationResponse.builder() diff --git a/legal-core/src/main/java/org/opengroup/osdu/legal/tags/LegalTagService.java b/legal-core/src/main/java/org/opengroup/osdu/legal/tags/LegalTagService.java index 540378d3a7c989e572e89b82625f54a789880a70..c0814913d8f55ce5e49ffc0221f6aaeeacfc4812 100644 --- a/legal-core/src/main/java/org/opengroup/osdu/legal/tags/LegalTagService.java +++ b/legal-core/src/main/java/org/opengroup/osdu/legal/tags/LegalTagService.java @@ -11,20 +11,14 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.time.LocalDate; import java.util.*; -import java.util.logging.ConsoleHandler; import java.util.regex.Matcher; import java.util.function.Function; import java.util.regex.Pattern; import java.util.stream.Collectors; -import jakarta.inject.Inject; -import jakarta.validation.ConstraintViolationException; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.text.StringEscapeUtils; -import org.apache.commons.lang3.ObjectUtils.Null; import org.json.JSONArray; import org.json.JSONObject; -import org.opengroup.osdu.core.common.logging.ILogger; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.common.model.http.DpsHeaders; @@ -42,6 +36,7 @@ import org.opengroup.osdu.legal.tags.dto.*; import org.opengroup.osdu.legal.tags.util.PersistenceExceptionToAppExceptionMapper; import org.springframework.beans.BeanWrapper; import org.springframework.beans.BeanWrapperImpl; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import static org.opengroup.osdu.legal.Constants.LEGAL_QUERY_API_UNION_OPERATOR; @@ -53,31 +48,33 @@ import static org.opengroup.osdu.legal.Constants.LEGAL_QUERY_API_BETWEEN_START; import static org.opengroup.osdu.legal.Constants.LEGAL_QUERY_API_ADD_OPERATOR; import static org.opengroup.osdu.legal.Constants.LEGAL_QUERY_API_FREE_TEXT_ATTRIBUTE; -import java.util.logging.Logger; -import java.util.logging.StreamHandler; -import java.util.logging.ConsoleHandler; -import java.util.logging.SimpleFormatter; -import java.util.logging.Handler; -import java.util.logging.Level; - @Service public class LegalTagService { - @Inject - public PersistenceExceptionToAppExceptionMapper exceptionMapper; // public for testing purposes only - - @Inject - private ILegalTagRepositoryFactory repositories; - @Inject - private LegalTagConstraintValidator validator; - @Inject - private AuditLogger auditLogger; - @Inject - private ILegalTagPublisher legalTagPublisher; - @Inject - private JaxRsDpsLog log; - @Inject - private FeatureFlagController featureFlagController; + PersistenceExceptionToAppExceptionMapper exceptionMapper; + private final ILegalTagRepositoryFactory repositories; + private final LegalTagConstraintValidator validator; + private final AuditLogger auditLogger; + private final ILegalTagPublisher legalTagPublisher; + private final JaxRsDpsLog log; + private final FeatureFlagController featureFlagController; + + @Autowired + public LegalTagService(PersistenceExceptionToAppExceptionMapper exceptionMapper, + ILegalTagRepositoryFactory repositories, + LegalTagConstraintValidator validator, + AuditLogger auditLogger, + ILegalTagPublisher legalTagPublisher, + JaxRsDpsLog log, + FeatureFlagController featureFlagController) { + this.exceptionMapper = exceptionMapper; + this.repositories = repositories; + this.validator = validator; + this.auditLogger = auditLogger; + this.legalTagPublisher = legalTagPublisher; + this.log = log; + this.featureFlagController = featureFlagController; + } public LegalTagDto create(LegalTagDto legalTagDto, String tenantName) { if (legalTagDto == null) @@ -142,7 +139,7 @@ public class LegalTagService { public LegalTagDtos list(boolean valid, String tenantName) { Collection<LegalTag> tags = listLegalTag(valid, tenantName); LegalTagDtos outputs = legalTagsToReadableLegalTags(tags); - List<String> names = outputs.getLegalTags().stream().map(x -> x.getName()).collect(Collectors.toList()); + List<String> names = outputs.getLegalTags().stream().map(x -> x.getName()).toList(); auditLogger.readLegalTagSuccess(names); return outputs; } @@ -167,7 +164,7 @@ public class LegalTagService { List<String> notFoundNames = new ArrayList<>(asList(names)); Collection<LegalTag> legalTags = getLegalTags(names, tenantName); - if (legalTags == null || legalTags.size() == 0) { + if (legalTags == null || legalTags.isEmpty()) { for (String name : names) generateInvalidTagsWithReason(invalidTagsWithReason, name, "LegalTag not found"); return new InvalidTagsWithReason(invalidTagsWithReason); @@ -180,7 +177,7 @@ public class LegalTagService { generateInvalidTagsWithReason(invalidTagsWithReason, tag.getName(), errors); } - if (notFoundNames.size() > 0) { + if (!notFoundNames.isEmpty()) { for (String notFoundName : notFoundNames) generateInvalidTagsWithReason(invalidTagsWithReason, notFoundName, "LegalTag not found"); } @@ -265,7 +262,7 @@ public class LegalTagService { private LegalTag getLegalTag(String name, String tenantName) { Collection<LegalTag> output = getLegalTags(new String[] { name }, tenantName); - return output == null || output.size() == 0 ? null : Iterables.get(output, 0); + return output == null || output.isEmpty() ? null : Iterables.get(output, 0); } private void generateInvalidTagsWithReason( @@ -365,18 +362,17 @@ public class LegalTagService { .values(); } else if (intersection) { - List<LegalTag> allTags = matchTagArrayList.stream().flatMap(Collection::stream).collect(Collectors.toList()); + List<LegalTag> allTags = matchTagArrayList.stream().flatMap(Collection::stream).toList(); - Collection<LegalTag> duplicateTags = allTags.stream() + return allTags.stream() .collect(Collectors.groupingBy(LegalTag::getName)) .entrySet().stream() .filter(entry -> entry.getValue().size() > 1) .flatMap(entry -> entry.getValue().stream().limit(1)) - .collect(Collectors.toList()); + .toList(); - return duplicateTags; } else { // return add - return matchTagArrayList.stream().flatMap(Collection::stream).collect(Collectors.toList()); + return matchTagArrayList.stream().flatMap(Collection::stream).toList(); } } @@ -386,10 +382,10 @@ public class LegalTagService { Collection<LegalTag> matchedTags = new ArrayList<>(); - StringTokenizer st = null; + StringTokenizer st; String attribute = null; String pattern = null; - String searchedString = null; + String searchedString; String fromDate = null; String toDate = null; LocalDate fromlocalDate = null; @@ -507,7 +503,7 @@ public class LegalTagService { return true; } - List<String> attributeList = new ArrayList<String>(); + List<String> attributeList = new ArrayList<>(); attributeList.add("countryOfOrigin"); attributeList.add("contractId"); attributeList.add("originator"); @@ -525,7 +521,8 @@ public class LegalTagService { Object value; for (int i = 0; i < attributeList.size(); i++) { value = beanWrapper.getPropertyValue(attributeList.get(i)); - if (StringUtils.containsAnyIgnoreCase(value.toString().trim(), pattern)) { + String stringValue = Objects.toString(value, "").trim(); + if (StringUtils.containsAnyIgnoreCase(stringValue, pattern)) { return true; } } diff --git a/legal-core/src/main/java/org/opengroup/osdu/legal/tags/validation/rules/DefaultRule.java b/legal-core/src/main/java/org/opengroup/osdu/legal/tags/validation/rules/DefaultRule.java index 64512cf36035c036f189e32012f809aaa1cfa41a..d574f515143b728313a7ec440d7143c9d92be08d 100644 --- a/legal-core/src/main/java/org/opengroup/osdu/legal/tags/validation/rules/DefaultRule.java +++ b/legal-core/src/main/java/org/opengroup/osdu/legal/tags/validation/rules/DefaultRule.java @@ -43,6 +43,6 @@ public class DefaultRule extends Rule { private boolean isAllowedCOO(Properties properties){ Map<String, String> validCOOs = legalTagCountriesService.getValidCOOs(properties.getDataType()); return properties.getCountryOfOrigin() != null && !properties.getCountryOfOrigin().isEmpty() && - properties.getCountryOfOrigin().stream().allMatch( s -> validCOOs.containsKey(s)); + properties.getCountryOfOrigin().stream().allMatch(validCOOs::containsKey); } } diff --git a/legal-core/src/main/java/org/opengroup/osdu/legal/util/CloudConnectedOuterServicesBuilder.java b/legal-core/src/main/java/org/opengroup/osdu/legal/util/CloudConnectedOuterServicesBuilder.java index c25d4652ea721f684780d6e81473fc2753feb1d0..be7893bb910681afc59855273a0a4728c2689a12 100644 --- a/legal-core/src/main/java/org/opengroup/osdu/legal/util/CloudConnectedOuterServicesBuilder.java +++ b/legal-core/src/main/java/org/opengroup/osdu/legal/util/CloudConnectedOuterServicesBuilder.java @@ -1,7 +1,6 @@ package org.opengroup.osdu.legal.util; import java.util.List; -import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import org.opengroup.osdu.core.common.cache.RedisCache; import org.opengroup.osdu.core.common.info.ConnectedOuterServicesBuilder; @@ -15,18 +14,18 @@ public class CloudConnectedOuterServicesBuilder implements ConnectedOuterService private static final String REDIS_PREFIX = "Redis-"; - private List<RedisCache> redisCaches; + private List<RedisCache<?, ?>> redisCaches; - public CloudConnectedOuterServicesBuilder(List<RedisCache> redisCaches) { + public CloudConnectedOuterServicesBuilder(List<RedisCache<?, ?>> redisCaches) { this.redisCaches = redisCaches; } @Override public List<ConnectedOuterService> buildConnectedOuterServices() { - return redisCaches.stream().map(this::fetchRedisInfo).collect(Collectors.toList()); + return redisCaches.stream().map(this::fetchRedisInfo).toList(); } - private ConnectedOuterService fetchRedisInfo(RedisCache cache) { + private ConnectedOuterService fetchRedisInfo(RedisCache<?, ?> cache) { String redisVersion = StringUtils.substringBetween(cache.info(), ":", "\r"); return ConnectedOuterService.builder() .name(REDIS_PREFIX + StringUtils.substringAfterLast(cache.getClass().getName(), ".")) diff --git a/legal-core/src/test/java/org/opengroup/osdu/legal/controller/LegalTagControllerTests.java b/legal-core/src/test/java/org/opengroup/osdu/legal/controller/LegalTagControllerTests.java index 78c4918e47f4920025b5a7de715d20026c24ae07..944ddbadddfd23c1d45fedcfa6e272af0753c9e3 100644 --- a/legal-core/src/test/java/org/opengroup/osdu/legal/controller/LegalTagControllerTests.java +++ b/legal-core/src/test/java/org/opengroup/osdu/legal/controller/LegalTagControllerTests.java @@ -30,14 +30,10 @@ import java.util.Map; import java.util.Set; import java.util.Collections; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyBoolean; -import static org.mockito.Matchers.eq; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -90,7 +86,7 @@ public class LegalTagControllerTests { when(legalTagService.create(any(), any())).thenReturn(newContracts); ResponseEntity<LegalTagDto> result = sut.createLegalTag(legalTag); - assertEquals(201, result.getStatusCodeValue()); + assertEquals(201, result.getStatusCode().value()); newContracts = (LegalTagDto) result.getBody(); assertEquals("kind1", newContracts.getName()); @@ -104,7 +100,7 @@ public class LegalTagControllerTests { ResponseEntity<LegalTagDto> result = sut.getLegalTag("k"); - assertEquals(200, result.getStatusCodeValue()); + assertEquals(200, result.getStatusCode().value()); LegalTagDto output = (LegalTagDto) result.getBody(); assertEquals("k", output.getName()); @@ -115,15 +111,15 @@ public class LegalTagControllerTests { when(legalTagService.get(any(), any())).thenReturn(null); ResponseEntity<LegalTagDto> result = sut.getLegalTag("k"); - assertEquals(404, result.getStatusCodeValue()); - assertEquals("{\"error\":\"Not found.\"}", result.getBody()); + assertEquals(404, result.getStatusCode().value()); + assertNotNull(result.getBody()); } @Test public void should_return500_when_deletingReturnsFalse() { ResponseEntity<HttpStatus> result = sut.deleteLegalTag("k"); - assertEquals(500, result.getStatusCodeValue()); + assertEquals(500, result.getStatusCode().value()); } @Test @@ -131,7 +127,7 @@ public class LegalTagControllerTests { when(legalTagService.delete(any(), eq("k"), any(), any())).thenReturn(true); ResponseEntity<HttpStatus> result = sut.deleteLegalTag("k"); - assertEquals(204, result.getStatusCodeValue()); + assertEquals(204, result.getStatusCode().value()); } @Test @@ -147,7 +143,7 @@ public class LegalTagControllerTests { ResponseEntity<LegalTagDtos> result = sut.getLegalTags(input); - assertEquals(200, result.getStatusCodeValue()); + assertEquals(200, result.getStatusCode().value()); LegalTagDtos entity = (LegalTagDtos) result.getBody(); assertEquals(2, entity.getLegalTags().size()); @@ -167,7 +163,7 @@ public class LegalTagControllerTests { ResponseEntity<LegalTagDtos> result = sut.getLegalTags(input); - assertEquals(404, result.getStatusCodeValue()); + assertEquals(404, result.getStatusCode().value()); } @Test @@ -178,7 +174,7 @@ public class LegalTagControllerTests { ResponseEntity<LegalTagDtos> result = sut.getLegalTags(input); - assertEquals(404, result.getStatusCodeValue()); + assertEquals(404, result.getStatusCode().value()); } @Test @@ -191,7 +187,7 @@ public class LegalTagControllerTests { ResponseEntity<InvalidTagsWithReason> result = sut.validateLegalTags(input); - assertEquals(200, result.getStatusCodeValue()); + assertEquals(200, result.getStatusCode().value()); InvalidTagsWithReason output = (InvalidTagsWithReason) result.getBody(); assertTrue(output.getInvalidLegalTags().isEmpty()); @@ -204,7 +200,7 @@ public class LegalTagControllerTests { ResponseEntity<InvalidTagsWithReason> result = sut.validateLegalTags(input); - assertEquals(200, result.getStatusCodeValue()); + assertEquals(200, result.getStatusCode().value()); } @Test @@ -215,7 +211,7 @@ public class LegalTagControllerTests { when(legalTagService.update(any(), any())).thenReturn(output); ResponseEntity<LegalTagDto> result = sut.updateLegalTag(newTag); - assertEquals(200, result.getStatusCodeValue()); + assertEquals(200, result.getStatusCode().value()); LegalTagDto resultEntity = (LegalTagDto) result.getBody(); assertEquals("ash1", resultEntity.getName()); } @@ -231,23 +227,22 @@ public class LegalTagControllerTests { ResponseEntity<LegalTagDtos> result = sut.listLegalTags(true); - assertEquals(200, result.getStatusCodeValue()); + assertEquals(200, result.getStatusCode().value()); LegalTagDtos entity = (LegalTagDtos) result.getBody(); assertEquals(2, entity.getLegalTags().size()); assertEquals("k", Iterables.get(entity.getLegalTags(), 0).getName()); } - @Test(expected = ValidationException.class) + @Test public void should_ThrowValidationException_when_listingLegalTags_IfTenantInfoIsNull() { - when(requestInfo.getTenantInfo()).thenReturn(null); - try { - ResponseEntity<LegalTagDtos> result = sut.listLegalTags(true); - } catch (ValidationException validationException){ - assertEquals("No tenant supplied", validationException.getMessage()); - throw validationException; - } + + ValidationException exception = assertThrows(ValidationException.class, () -> { + sut.listLegalTags(true); + }); + + assertEquals("No tenant supplied", exception.getMessage()); } @Test @@ -279,7 +274,7 @@ public class LegalTagControllerTests { ResponseEntity<ReadablePropertyValues> result = sut.getLegalTagProperties(); - assertEquals(200, result.getStatusCodeValue()); + assertEquals(200, result.getStatusCode().value()); ReadablePropertyValues entity = (ReadablePropertyValues) result.getBody(); assertEquals(entity.getCountriesOfOrigin(), coo); diff --git a/legal-core/src/test/java/org/opengroup/osdu/legal/jobs/LegalTagStatusJobTests.java b/legal-core/src/test/java/org/opengroup/osdu/legal/jobs/LegalTagStatusJobTests.java index b22021622b417f407c075b356627f7aa7250a483..0e491c60bb683baf3f96b58cbb979ee19f51a085 100644 --- a/legal-core/src/test/java/org/opengroup/osdu/legal/jobs/LegalTagStatusJobTests.java +++ b/legal-core/src/test/java/org/opengroup/osdu/legal/jobs/LegalTagStatusJobTests.java @@ -1,9 +1,7 @@ package org.opengroup.osdu.legal.jobs; -import org.junit.Ignore; import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.common.model.http.DpsHeaders; -import org.opengroup.osdu.core.common.model.legal.StatusChangedTags; import org.opengroup.osdu.legal.logging.AuditLogger; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; import org.opengroup.osdu.legal.provider.interfaces.ILegalTagPublisher; @@ -13,7 +11,6 @@ import org.opengroup.osdu.legal.tags.LegalTagService; import org.opengroup.osdu.core.common.model.legal.LegalTag; import org.opengroup.osdu.core.common.model.legal.Properties; import org.opengroup.osdu.legal.jobs.models.LegalTagJobResult; -import org.opengroup.osdu.legal.jobs.models.AboutToExpireLegalTags; import org.opengroup.osdu.legal.FeatureFlagController; import org.opengroup.osdu.legal.config.LegalTagConfig; @@ -28,7 +25,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Calendar; import java.time.Clock; -import java.time.Instant; import java.time.LocalDate; import java.time.ZoneId; @@ -181,11 +177,11 @@ public class LegalTagStatusJobTests { sut = createSut(validLegalTags); LegalTagJobResult result = sut.run("project1", headers, "tenant"); - assertEquals(4, result.aboutToExpireLegalTags.getAboutToExpireLegalTags().size()); - assertEquals("aboutToExpireLegalTag1", result.aboutToExpireLegalTags.getAboutToExpireLegalTags().get(0).getTagName()); - assertEquals("aboutToExpireLegalTag2", result.aboutToExpireLegalTags.getAboutToExpireLegalTags().get(1).getTagName()); - assertEquals("aboutToExpireLegalTag3", result.aboutToExpireLegalTags.getAboutToExpireLegalTags().get(2).getTagName()); - assertEquals("aboutToExpireLegalTag4", result.aboutToExpireLegalTags.getAboutToExpireLegalTags().get(3).getTagName()); + assertEquals(4, result.aboutToExpireLegalTags.getLegalTags().size()); + assertEquals("aboutToExpireLegalTag1", result.aboutToExpireLegalTags.getLegalTags().get(0).getTagName()); + assertEquals("aboutToExpireLegalTag2", result.aboutToExpireLegalTags.getLegalTags().get(1).getTagName()); + assertEquals("aboutToExpireLegalTag3", result.aboutToExpireLegalTags.getLegalTags().get(2).getTagName()); + assertEquals("aboutToExpireLegalTag4", result.aboutToExpireLegalTags.getLegalTags().get(3).getTagName()); } @Test @@ -204,8 +200,8 @@ public class LegalTagStatusJobTests { sut = createSut(validLegalTags); LegalTagJobResult result = sut.run("project1", headers, "tenant"); - assertEquals(1, result.aboutToExpireLegalTags.getAboutToExpireLegalTags().size()); - assertEquals("aboutToExpireLegalTag2", result.aboutToExpireLegalTags.getAboutToExpireLegalTags().get(0).getTagName()); + assertEquals(1, result.aboutToExpireLegalTags.getLegalTags().size()); + assertEquals("aboutToExpireLegalTag2", result.aboutToExpireLegalTags.getLegalTags().get(0).getTagName()); } @Test diff --git a/provider/legal-aws/build-aws/Dockerfile b/provider/legal-aws/build-aws/Dockerfile index 91de6bcb914834f9f109371b9770e3bed0890f1f..ff76bf1f9704db96b4ff5e598650a33c94748615 100644 --- a/provider/legal-aws/build-aws/Dockerfile +++ b/provider/legal-aws/build-aws/Dockerfile @@ -15,6 +15,10 @@ # https://docs.spring.io/spring-boot/docs/current/reference/html/deployment.html FROM public.ecr.aws/amazoncorretto/amazoncorretto:17 +RUN yum update -y && yum install -y shadow-utils \ + && groupadd -g 10001 -r appgroup \ + && useradd -M -g 10001 -r -u 10001 appuser + ARG JAR_FILE=provider/legal-aws/target/*spring-boot.jar WORKDIR / @@ -22,4 +26,5 @@ COPY ${JAR_FILE} app.jar COPY /provider/legal-aws/build-aws/entrypoint.sh /entrypoint.sh EXPOSE 8080 +USER 10001:10001 ENTRYPOINT ["/bin/sh", "-c", ". /entrypoint.sh"] diff --git a/provider/legal-aws/src/main/java/org/opengroup/osdu/legal/aws/jobs/AboutToExpireLegalTagPublisherImpl.java b/provider/legal-aws/src/main/java/org/opengroup/osdu/legal/aws/jobs/AboutToExpireLegalTagPublisherImpl.java index ae19477b4d37f964023145a7db08e5561a373ed8..e04af2e8ca6794b5fa65ef3cc24091f6ec8b75f2 100644 --- a/provider/legal-aws/src/main/java/org/opengroup/osdu/legal/aws/jobs/AboutToExpireLegalTagPublisherImpl.java +++ b/provider/legal-aws/src/main/java/org/opengroup/osdu/legal/aws/jobs/AboutToExpireLegalTagPublisherImpl.java @@ -16,11 +16,8 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import jakarta.annotation.PostConstruct; -import jakarta.inject.Inject; -import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; @Service public class AboutToExpireLegalTagPublisherImpl implements IAboutToExpireLegalTagPublisher { @@ -36,8 +33,11 @@ public class AboutToExpireLegalTagPublisherImpl implements IAboutToExpireLegalTa @Value("${OSDU_ABOUT_TO_EXPIRE_LEGALTAG_TOPIC}") private String osduAboutToExpireLegalTagTopic; - @Inject - private JaxRsDpsLog log; + private final JaxRsDpsLog log; + + public AboutToExpireLegalTagPublisherImpl(JaxRsDpsLog log) { + this.log = log; + } public void setK8sLocalParameterProvider(K8sLocalParameterProvider k8sLocalParameterProvider) { this.k8sLocalParameterProvider = k8sLocalParameterProvider; @@ -61,11 +61,11 @@ public class AboutToExpireLegalTagPublisherImpl implements IAboutToExpireLegalTa PublishRequestBuilder<AwsAboutToExpireLegalTags> publishRequestBuilder = new PublishRequestBuilder<>(); publishRequestBuilder.setGeneralParametersFromHeaders(headers); log.debug("Publishing to topic " + osduAboutToExpireLegalTagTopic); - for (int i = 0; i < aboutToExpireLegalTags.getAboutToExpireLegalTags().size(); i += BATCH_SIZE){ - List<AboutToExpireLegalTag> batch = aboutToExpireLegalTags.getAboutToExpireLegalTags().subList(i, Math.min(aboutToExpireLegalTags.getAboutToExpireLegalTags().size(), i + BATCH_SIZE)); + for (int i = 0; i < aboutToExpireLegalTags.getLegalTags().size(); i += BATCH_SIZE){ + List<AboutToExpireLegalTag> batch = aboutToExpireLegalTags.getLegalTags().subList(i, Math.min(aboutToExpireLegalTags.getLegalTags().size(), i + BATCH_SIZE)); List<AwsAboutToExpireLegalTag> awsBatch = batch.stream() .map(aboutToExpireLegalTag -> new AwsAboutToExpireLegalTag(aboutToExpireLegalTag.getTagName(), headers.getPartitionId(), aboutToExpireLegalTag.getExpirationDate())) - .collect(Collectors.toList()); + .toList(); AwsAboutToExpireLegalTags awsBatchTags = new AwsAboutToExpireLegalTags(awsBatch); PublishRequest publishRequest = publishRequestBuilder.generatePublishRequest(osduAboutToExpireLegalTagTopic, amazonSNSTopic, awsBatchTags); snsClient.publish(publishRequest); diff --git a/provider/legal-aws/src/test/java/org/opengroup/osdu/legal/aws/jobs/AboutToExpireLegalTagPublisherImplTest.java b/provider/legal-aws/src/test/java/org/opengroup/osdu/legal/aws/jobs/AboutToExpireLegalTagPublisherImplTest.java index c69115b2427e545c8a3889f8346a1b7554fb44ea..d946bb2510074e3cdbb8f55eab8ad8c5277d744d 100644 --- a/provider/legal-aws/src/test/java/org/opengroup/osdu/legal/aws/jobs/AboutToExpireLegalTagPublisherImplTest.java +++ b/provider/legal-aws/src/test/java/org/opengroup/osdu/legal/aws/jobs/AboutToExpireLegalTagPublisherImplTest.java @@ -79,7 +79,7 @@ class AboutToExpireLegalTagPublisherImplTest { private final String testRegion = "testRegion"; @BeforeEach - void setup() throws K8sParameterNotFoundException { + void setup() { MockitoAnnotations.openMocks(this); } @@ -93,11 +93,11 @@ class AboutToExpireLegalTagPublisherImplTest { } @Test - void testPublish() throws K8sParameterNotFoundException{ + void testPublish() { List<AboutToExpireLegalTag> tagList = new ArrayList<AboutToExpireLegalTag>(); tagList.add(tag); - when(tags.getAboutToExpireLegalTags()).thenReturn(tagList); + when(tags.getLegalTags()).thenReturn(tagList); aboutToExpireLegalTagPublisherImpl.publish("projectId", headers, tags); verify(snsClient, times(1)).publish(any(PublishRequest.class)); diff --git a/provider/legal-azure/README.md b/provider/legal-azure/README.md index 8d817c992ef08f76338854c69f67bf63cdbf2b7b..ed9214c6d335a5b577140a074a6e7c4acf0b974f 100644 --- a/provider/legal-azure/README.md +++ b/provider/legal-azure/README.md @@ -79,6 +79,8 @@ az keyvault secret show --vault-name $KEY_VAULT_NAME --name $KEY_VAULT_SECRET_NA | `AZURE_LEGAL_TOPICNAME` | `legaltags` | Same as `servicebus_topic_name` above | no | - | | `HOST_URL` | `http://localhost:8080/` | local service endpoint | no | - | | `ENTITLEMENT_URL` | Same as `entitlements_service_endpoint` above | Endpoint for entitlements URL | no | - | +| `MY_SECOND_TENANT` | same as `opendes` | OSDU tenant used for testing | no | -- | +| `AZURE_LEGAL_STORAGE_ACCOUNT_SECOND` | same as `storage_account` above | Storage account for integration tests| no | - | ### Configure Maven @@ -170,6 +172,7 @@ export AZURE_SERVICE="legal" export AZURE_BUILD_SUBDIR="provider/legal-azure" export AZURE_TEST_SUBDIR="testing/legal-test-azure" export AZURE_OSDU_TENANT="opendes" +export AZURE_OSDU_SECOND_TENANT="opendes2" export AZURE_SERVICE_BUS_TOPIC="legaltags" export LEGAL_STORAGE_CONTAINER="legal-service-azure-configuration" @@ -185,11 +188,13 @@ export AZURE_APPSERVICE_NAME="${AZURE_BASENAME_21}-au-${AZURE_SERVICE}" export HOST_URL="https://${AZURE_BASENAME_21}-au-legal.azurewebsites.net/" export ENTITLEMENT_URL="https://${AZURE_BASENAME_21}-au-entitlements.azurewebsites.net/" export MY_TENANT="${AZURE_OSDU_TENANT}" +export MY_SECOND_TENANT="${AZURE_OSDU_SECOND_TENANT}" export AZURE_AD_TENANT_ID="${AZURE_TENANT_ID}" export INTEGRATION_TESTER="${AZURE_PRINCIPAL_ID}" export AZURE_TESTER_SERVICEPRINCIPAL_SECRET="${AZURE_PRINCIPAL_SECRET}" export AZURE_AD_APP_RESOURCE_ID="${AZURE_APP_ID}" export AZURE_LEGAL_STORAGE_ACCOUNT="${AZURE_BASE}sa" +export AZURE_LEGAL_STORAGE_ACCOUNT_SECOND="${AZURE_BASE}sa2" export AZURE_LEGAL_STORAGE_KEY="${AZURE_STORAGE_KEY}" export AZURE_LEGAL_SERVICEBUS="Endpoint=sb://${AZURE_BASENAME_21}sb.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=${AZURE_SERVICEBUS_KEY}" export AZURE_LEGAL_TOPICNAME="${AZURE_SERVICE_BUS_TOPIC}" diff --git a/provider/legal-azure/src/main/java/org/opengroup/osdu/legal/azure/security/AADSecurityConfig.java b/provider/legal-azure/src/main/java/org/opengroup/osdu/legal/azure/security/AADSecurityConfig.java index d022774a64e16503dc35bc470d698cd475200108..f8d6a9e87bfee04cbc3ed38a7bd93df606f5fc1b 100644 --- a/provider/legal-azure/src/main/java/org/opengroup/osdu/legal/azure/security/AADSecurityConfig.java +++ b/provider/legal-azure/src/main/java/org/opengroup/osdu/legal/azure/security/AADSecurityConfig.java @@ -16,7 +16,6 @@ package org.opengroup.osdu.legal.azure.security; import com.azure.spring.cloud.autoconfigure.implementation.aad.filter.AadAppRoleStatelessAuthenticationFilter; -import jakarta.inject.Inject; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; @@ -30,7 +29,7 @@ import org.springframework.security.web.authentication.UsernamePasswordAuthentic @EnableWebSecurity @EnableMethodSecurity @ConditionalOnProperty(value = "azure.istio.auth.enabled", havingValue = "false", matchIfMissing = false) -public class AADSecurityConfig{ +public class AADSecurityConfig { private static final String[] AUTH_ALLOWLIST = {"/", "/index.html", "/api-docs.yaml", @@ -40,14 +39,17 @@ public class AADSecurityConfig{ "/swagger-ui.html", "/swagger-ui/**" }; - @Inject - private AadAppRoleStatelessAuthenticationFilter appRoleAuthFilter; + private final AadAppRoleStatelessAuthenticationFilter appRoleAuthFilter; + + public AADSecurityConfig(AadAppRoleStatelessAuthenticationFilter appRoleAuthFilter) { + this.appRoleAuthFilter = appRoleAuthFilter; + } @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { return http .csrf(AbstractHttpConfigurer::disable) - .sessionManagement((sess) -> sess.sessionCreationPolicy(SessionCreationPolicy.NEVER)) + .sessionManagement(sess -> sess.sessionCreationPolicy(SessionCreationPolicy.NEVER)) .authorizeHttpRequests(request -> request.requestMatchers(AUTH_ALLOWLIST).permitAll()) .addFilterBefore(appRoleAuthFilter, UsernamePasswordAuthenticationFilter.class) .build(); diff --git a/provider/legal-azure/src/test/java/org/opengroup/osdu/legal/azure/AboutToExpireLegalTagPublisherImplTest.java b/provider/legal-azure/src/test/java/org/opengroup/osdu/legal/azure/AboutToExpireLegalTagPublisherImplTest.java index 522ca567223551e77003227c07b6ebc7a4078a20..79afec2278bc18d6a40f1b990635e9ad9dce2c0d 100644 --- a/provider/legal-azure/src/test/java/org/opengroup/osdu/legal/azure/AboutToExpireLegalTagPublisherImplTest.java +++ b/provider/legal-azure/src/test/java/org/opengroup/osdu/legal/azure/AboutToExpireLegalTagPublisherImplTest.java @@ -33,7 +33,7 @@ public class AboutToExpireLegalTagPublisherImplTest { private AboutToExpireLegalTagPublisherImpl sut; @Test - public void shouldPublishToServiceBus() throws Exception { + public void shouldPublishToServiceBus() { AboutToExpireLegalTags aboutToExpireLegalTags = new AboutToExpireLegalTags(); sut.publish("project-id", headers, aboutToExpireLegalTags); } diff --git a/provider/legal-ibm/src/main/java/org/opengroup/osdu/legal/ibm/tags/CloudantLegalTagRepository.java b/provider/legal-ibm/src/main/java/org/opengroup/osdu/legal/ibm/tags/CloudantLegalTagRepository.java index 6b67ea55bdd8b8fc26074f1a243dfeaa177a907d..d4bac36e7c150771f7f01e6278187d166e85108a 100644 --- a/provider/legal-ibm/src/main/java/org/opengroup/osdu/legal/ibm/tags/CloudantLegalTagRepository.java +++ b/provider/legal-ibm/src/main/java/org/opengroup/osdu/legal/ibm/tags/CloudantLegalTagRepository.java @@ -20,6 +20,7 @@ import jakarta.annotation.PostConstruct; import jakarta.inject.Inject; import org.opengroup.osdu.core.common.model.http.AppException; +import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.core.common.model.legal.LegalTag; import org.opengroup.osdu.core.common.model.legal.ListLegalTagArgs; import org.opengroup.osdu.core.common.model.legal.Properties; @@ -28,6 +29,7 @@ import org.opengroup.osdu.core.ibm.cloudant.IBMCloudantClientFactory; import org.opengroup.osdu.legal.provider.interfaces.ILegalTagRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.ResourceLoader; import org.springframework.stereotype.Repository; @@ -48,7 +50,8 @@ import com.cloudant.client.org.lightcouch.DocumentConflictException; */ @Repository public class CloudantLegalTagRepository implements ILegalTagRepository { - + @Autowired + private DpsHeaders headers; @Value("${ibm.legal.db.url}") private String dbUrl; @Value("${ibm.legal.db.apikey:#{null}}") @@ -353,6 +356,7 @@ public class CloudantLegalTagRepository implements ILegalTagRepository { legalTags = allDocResponse.getResponse().getDocsAs(BanckendLegalTag.class) .stream() .filter(lTag -> lTag.getIs_Valid() == args.getIsValid()) + .filter(f->f.getName().split("-")[0].equalsIgnoreCase(headers.getPartitionId())) .collect(Collectors.toList()); } catch (IOException e) { diff --git a/testing/legal-test-aws/src/test/java/org/opengroup/osdu/legal/util/AwsLegalTagUtils.java b/testing/legal-test-aws/src/test/java/org/opengroup/osdu/legal/util/AwsLegalTagUtils.java index 357016a97f5b3cd1fdcdf5731c194ed01e14abf0..4115608807c94dcc8f9a2a48fae50da74c75c439 100644 --- a/testing/legal-test-aws/src/test/java/org/opengroup/osdu/legal/util/AwsLegalTagUtils.java +++ b/testing/legal-test-aws/src/test/java/org/opengroup/osdu/legal/util/AwsLegalTagUtils.java @@ -31,18 +31,17 @@ public class AwsLegalTagUtils extends LegalTagUtils { private static final String FILE_NAME = "Legal_COO.json"; private static final String BUCKET_NAME_AWS = System.getProperty("S3_LEGAL_CONFIG_BUCKET", System.getenv("S3_LEGAL_CONFIG_BUCKET")); - private final static String COGNITO_CLIENT_ID_PROPERTY = "AWS_COGNITO_CLIENT_ID"; - private final static String COGNITO_AUTH_FLOW_PROPERTY = "AWS_COGNITO_AUTH_FLOW"; - private final static String COGNITO_AUTH_PARAMS_USER_PROPERTY = "AWS_COGNITO_AUTH_PARAMS_USER"; - private final static String COGNITO_AUTH_PARAMS_PASSWORD_PROPERTY = "AWS_COGNITO_AUTH_PARAMS_PASSWORD"; + private static final String COGNITO_CLIENT_ID_PROPERTY = "AWS_COGNITO_CLIENT_ID"; + private static final String COGNITO_AUTH_FLOW_PROPERTY = "AWS_COGNITO_AUTH_FLOW"; + private static final String COGNITO_AUTH_PARAMS_USER_PROPERTY = "AWS_COGNITO_AUTH_PARAMS_USER"; + private static final String COGNITO_AUTH_PARAMS_PASSWORD_PROPERTY = "AWS_COGNITO_AUTH_PARAMS_PASSWORD"; - private final static String TABLE_PREFIX = "TABLE_PREFIX"; - private final static String DYNAMO_DB_REGION = "DYNAMO_DB_REGION"; - private final static String DYNAMO_DB_ENDPOINT = "DYNAMO_DB_ENDPOINT"; - private static final String COLLECTION_PREFIX = "Legal-"; + private static final String TABLE_PREFIX = "TABLE_PREFIX"; + private static final String DYNAMO_DB_REGION = "DYNAMO_DB_REGION"; + private static final String DYNAMO_DB_ENDPOINT = "DYNAMO_DB_ENDPOINT"; - private String BearerToken = ""; + private String bearerToken = ""; @Override public synchronized void uploadTenantTestingConfigFile() { @@ -62,16 +61,21 @@ public class AwsLegalTagUtils extends LegalTagUtils { @Override public synchronized String accessToken() throws Exception { - if (BearerToken == "") { + if (bearerToken.equals("")) { String clientId = System.getProperty(COGNITO_CLIENT_ID_PROPERTY, System.getenv(COGNITO_CLIENT_ID_PROPERTY)); String authFlow = System.getProperty(COGNITO_AUTH_FLOW_PROPERTY, System.getenv(COGNITO_AUTH_FLOW_PROPERTY)); String user = System.getProperty(COGNITO_AUTH_PARAMS_USER_PROPERTY, System.getenv(COGNITO_AUTH_PARAMS_USER_PROPERTY)); String password = System.getProperty(COGNITO_AUTH_PARAMS_PASSWORD_PROPERTY, System.getenv(COGNITO_AUTH_PARAMS_PASSWORD_PROPERTY)); AWSCognitoClient client = new AWSCognitoClient(clientId, authFlow, user, password); - BearerToken = client.getToken(); + bearerToken = client.getToken(); } - return "Bearer " + BearerToken; + return "Bearer " + bearerToken; + } + + @Override + public List<String> readCOOCountries(String storageAccount, String defaultCOOFileName) throws IOException { + return List.of(); } public void insertExpiredLegalTag() { diff --git a/testing/legal-test-aws/src/test/java/org/opengroup/osdu/legal/util/AwsSqsHelper.java b/testing/legal-test-aws/src/test/java/org/opengroup/osdu/legal/util/AwsSqsHelper.java index 6087cca9ecc5189c7d75e9826a1858d35475811e..2b9b312a523faf0ab83c372f7672bc4c7d6c1f93 100644 --- a/testing/legal-test-aws/src/test/java/org/opengroup/osdu/legal/util/AwsSqsHelper.java +++ b/testing/legal-test-aws/src/test/java/org/opengroup/osdu/legal/util/AwsSqsHelper.java @@ -31,12 +31,11 @@ public class AwsSqsHelper { public static List<Message> getMessages(){ String amazonSqsEndpoint = System.getenv("LEGAL_QUEUE"); AmazonSQS sqs = AmazonSQSClientBuilder.standard().withRegion("us-east-1").build(); - List<Message> messages = sqs.receiveMessage(amazonSqsEndpoint).getMessages(); - return messages; + return sqs.receiveMessage(amazonSqsEndpoint).getMessages(); } public static void purgeQueue(){ - String amazonSqsEndpoint = System.getenv("LEGAL_QUEUE");; + String amazonSqsEndpoint = System.getenv("LEGAL_QUEUE"); AmazonSQS sqs = AmazonSQSClientBuilder.standard().withRegion("us-east-1").build(); PurgeQueueRequest request = new PurgeQueueRequest(); request.setQueueUrl(amazonSqsEndpoint); @@ -53,7 +52,7 @@ public class AwsSqsHelper { data = data.substring(1); data = data.substring(0, data.length() - 1); String dataCheck = "{\"statusChangedTags\":[{\"dataPartitionId\":\"" + TestUtils.getMyDataPartition() + "\",\"changedTagName\":\"" + name + "\",\"changedTagStatus\":\"incompliant\"}]}"; - dataCheck = dataCheck.replaceAll("\"", "\\\\\""); + dataCheck = dataCheck.replace("\"", "\\\\\""); return data.equals(dataCheck); } } diff --git a/testing/legal-test-azure/src/test/java/org/opengroup/osdu/legal/acceptanceTests/TestCronJobUpdate.java b/testing/legal-test-azure/src/test/java/org/opengroup/osdu/legal/acceptanceTests/TestCronJobUpdate.java new file mode 100644 index 0000000000000000000000000000000000000000..f138c0f5f637f942fe9ba011cb4edb372549a879 --- /dev/null +++ b/testing/legal-test-azure/src/test/java/org/opengroup/osdu/legal/acceptanceTests/TestCronJobUpdate.java @@ -0,0 +1,63 @@ +// Copyright © SLB +// Copyright © Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package org.opengroup.osdu.legal.acceptanceTests; + +import org.junit.After; +import org.junit.Assume; +import org.junit.Before; +import org.junit.Test; +import org.opengroup.osdu.legal.util.AzureLegalTagUtils; +import org.opengroup.osdu.legal.util.TestUtils; + +import java.util.List; + + +public class TestCronJobUpdate extends CronJobUpdateTests { + + private static final String storageAccount1 = System.getProperty("AZURE_LEGAL_STORAGE_ACCOUNT", System.getenv("AZURE_LEGAL_STORAGE_ACCOUNT")); + private static final String storageAccount2 = System.getProperty("AZURE_LEGAL_STORAGE_ACCOUNT_SECOND", System.getenv("AZURE_LEGAL_STORAGE_ACCOUNT_SECOND")); + + private static final String defaultCOOJSONFileName1 = "TenantConfigTestingPurpose.json"; + private static final String defaultCOOJSONFileName2 = "SecondTenantConfigTestingPurpose.json"; + + @Before + public void setup() throws Exception { + this.legalTagUtils = new AzureLegalTagUtils(); + } + + @After + public void teardown() throws Exception { + this.legalTagUtils = null; + } + + @Test + public void should_returnOk_when_runCronJob() throws Exception { + + String secondPartition = TestUtils.getMySecondDataPartition(); + Assume.assumeFalse(secondPartition == null || storageAccount1 == null || storageAccount2 == null); + + List<String> coo1 = legalTagUtils.readCOOCountries(storageAccount1, defaultCOOJSONFileName1); + List<String> coo2 = legalTagUtils.readCOOCountries(storageAccount2, defaultCOOJSONFileName2); + + Assume.assumeTrue(coo1 != null && !coo1.isEmpty()); + this.firstCountry = coo1.get(0); + Assume.assumeFalse(firstCountry == null); + this.secondCountry = coo2.stream().filter(e -> !e.equals(coo1.get(0))).findFirst().orElse(null); + Assume.assumeFalse(secondCountry == null); + + super.should_returnOk_when_runCronJob(); + } +} diff --git a/testing/legal-test-azure/src/test/java/org/opengroup/osdu/legal/util/AzureLegalTagUtils.java b/testing/legal-test-azure/src/test/java/org/opengroup/osdu/legal/util/AzureLegalTagUtils.java index f21d324fe88691eb624e64c0dae4526760f7611b..662eaab2914c64d614e1d0559752268bec3d76d4 100644 --- a/testing/legal-test-azure/src/test/java/org/opengroup/osdu/legal/util/AzureLegalTagUtils.java +++ b/testing/legal-test-azure/src/test/java/org/opengroup/osdu/legal/util/AzureLegalTagUtils.java @@ -15,7 +15,10 @@ package org.opengroup.osdu.legal.util; import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import com.azure.identity.ClientSecretCredential; import com.azure.identity.ClientSecretCredentialBuilder; @@ -23,6 +26,8 @@ import com.azure.storage.blob.BlobContainerClient; import com.azure.storage.blob.BlobContainerClientBuilder; import com.azure.storage.blob.BlobUrlParts; import com.azure.storage.blob.specialized.BlockBlobClient; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Strings; import org.opengroup.osdu.azure.util.AzureServicePrincipal; @@ -59,6 +64,69 @@ public class AzureLegalTagUtils extends LegalTagUtils { } } + @Override + public List<String> readCOOCountries(String storageAccount, String defaultCOOFileName) throws IOException { + + List<String> countries = new ArrayList<>(); + + String blobPath = String.format("https://%s.blob.core.windows.net/%s/%s", storageAccount.toLowerCase(), CONTAINER_NAME_AZURE, FILE_NAME); + BlobUrlParts parts = BlobUrlParts.parse(blobPath); + ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder() + .clientSecret(clientSecret) + .clientId(clientId) + .tenantId(tenantId) + .build(); + BlobContainerClient blobContainerClient = new BlobContainerClientBuilder() + .endpoint(String.format("https://%s.blob.core.windows.net", parts.getAccountName())) + .credential(clientSecretCredential) + .containerName(parts.getBlobContainerName()) + .buildClient(); + + BlockBlobClient blockBlobClient = blobContainerClient.getBlobClient(parts.getBlobName()).getBlockBlobClient(); + if (blobContainerClient.exists()) { + try { + if (blockBlobClient.exists()) { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + blockBlobClient.download(outputStream); + ByteArrayInputStream stream = new ByteArrayInputStream(outputStream.toByteArray()); + int byteData; + StringBuffer sb = new StringBuffer(); + while ((byteData = stream.read()) != -1) { + sb.append((char) byteData); + } + + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode root = objectMapper.readTree(sb.toString()); + + if(root.isArray()) { + for (JsonNode node : root) { + countries.add(node.path("alpha2").toString().replaceAll("\"", "")); + } + } + stream.close(); + } else { + String content = readTestFile(defaultCOOFileName); + ByteArrayInputStream newStream = new ByteArrayInputStream(content.getBytes()); + newStream.reset(); + blockBlobClient.upload(newStream, content.length(), true); + + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode root = objectMapper.readTree(content); + + if(root.isArray()) { + for (JsonNode node : root) { + countries.add(node.path("alpha2").toString().replaceAll("\"", "")); + } + } + } + } catch (Exception e) { + throw new AssertionError(String.format("Error: Could not create test %s file blob", parts.getBlobName()), e); + } + } + + return countries; + } + private static String generateContainerPath(String accountName, String containerName) { return String.format("https://%s.blob.core.windows.net/%s", accountName, containerName); } diff --git a/testing/legal-test-baremetal/src/test/java/legal/util/AnthosLegalTagUtils.java b/testing/legal-test-baremetal/src/test/java/legal/util/AnthosLegalTagUtils.java index 6d6793ba2e203271844f0fbb9ba532c0afa53e2f..77bf5a0241befa646b559dd4dc8f399bba119456 100644 --- a/testing/legal-test-baremetal/src/test/java/legal/util/AnthosLegalTagUtils.java +++ b/testing/legal-test-baremetal/src/test/java/legal/util/AnthosLegalTagUtils.java @@ -21,6 +21,9 @@ import com.google.common.base.Strings; import lombok.extern.slf4j.Slf4j; import org.opengroup.osdu.legal.util.LegalTagUtils; +import java.io.IOException; +import java.util.List; + @Slf4j public class AnthosLegalTagUtils extends LegalTagUtils { @@ -40,4 +43,9 @@ public class AnthosLegalTagUtils extends LegalTagUtils { } return "Bearer " + token; } + + @Override + public List<String> readCOOCountries(String storageAccount, String defaultCOOFileName) throws IOException { + return List.of(); + } } diff --git a/testing/legal-test-core/src/main/java/org/opengroup/osdu/legal/acceptanceTests/CronJobUpdateTests.java b/testing/legal-test-core/src/main/java/org/opengroup/osdu/legal/acceptanceTests/CronJobUpdateTests.java new file mode 100644 index 0000000000000000000000000000000000000000..47a05c6f31664a47f6595c2677fd1f752b27bcfb --- /dev/null +++ b/testing/legal-test-core/src/main/java/org/opengroup/osdu/legal/acceptanceTests/CronJobUpdateTests.java @@ -0,0 +1,100 @@ +// Copyright © SLB +// Copyright © Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package org.opengroup.osdu.legal.acceptanceTests; + +import com.sun.jersey.api.client.ClientResponse; +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Test; +import org.opengroup.osdu.legal.util.Constants; +import org.opengroup.osdu.legal.util.LegalTagUtils; +import org.opengroup.osdu.legal.util.TestUtils; + +import java.util.Map; + +public abstract class CronJobUpdateTests { + + protected LegalTagUtils legalTagUtils; + + private final static String LEGAL_TAG_DATE = "2099-12-25"; + private final static String LEGAL_TAG_TYPE = "Third Party Data"; + private final static String LEGAL_TAG_DESC = "description"; + + protected String firstCountry; + protected String secondCountry; + + @Test + public void should_returnOk_when_runCronJob() throws Exception { + + String primaryPartition = TestUtils.getMyDataPartition(); + String secondPartition = TestUtils.getMySecondDataPartition(); + + Assume.assumeFalse(secondPartition == null || firstCountry == null || secondCountry == null); + + String accessToken = this.legalTagUtils.accessToken(); + + Map<String, String> headers = this.legalTagUtils.getHeaders(); + headers.put(Constants.DATA_PARTITION_ID, primaryPartition); + String tagName = LegalTagUtils.createRandomNameTenant(); + + LegalTagUtils.ReadableLegalTag legalTag1Ret = creteLegalTag(firstCountry, tagName, primaryPartition); + LegalTagUtils.ReadableLegalTag legalTag2Ret = creteLegalTag(secondCountry, tagName, secondPartition); + + runCronJob(headers, accessToken); + + headers.put(Constants.DATA_PARTITION_ID, secondPartition); + runCronJob(headers, accessToken); + + validateTag(primaryPartition, tagName, accessToken, firstCountry, legalTag1Ret); + validateTag(secondPartition, tagName, accessToken, secondCountry, legalTag2Ret); + + this.legalTagUtils.delete(tagName, primaryPartition); + this.legalTagUtils.delete(tagName, secondPartition); + } + + private LegalTagUtils.ReadableLegalTag creteLegalTag(String country, String tagName, String partition) throws Exception { + ClientResponse response = this.legalTagUtils.create(country, tagName, LEGAL_TAG_DATE, LEGAL_TAG_TYPE, partition, LEGAL_TAG_DESC); + Assert.assertEquals(201, response.getStatus()); + + return this.legalTagUtils.getResult(response, 201, LegalTagUtils.ReadableLegalTag.class); + } + + private void runCronJob(Map<String, String> headers, String accessToken) throws Exception { + ClientResponse response = this.legalTagUtils.send("jobs/updateLegalTagStatus", + "GET", accessToken, null, "", headers); + Assert.assertEquals(204, response.getStatus()); + } + + private void validateTag(String partitionId, String tagName, String accessToken, String cco, LegalTagUtils.ReadableLegalTag legalTagRet) throws Exception { + Map<String, String> headers = this.legalTagUtils.getHeaders(); + headers.put(Constants.DATA_PARTITION_ID, partitionId); + ClientResponse response = this.legalTagUtils.send("legaltags/" + tagName, "GET", accessToken, null, "", headers); + LegalTagUtils.ReadableLegalTag legalTag1 = this.legalTagUtils.getResult(response, 200, LegalTagUtils.ReadableLegalTag.class); + + String[] countryParam = {cco}; + Assert.assertEquals(legalTag1.properties.countryOfOrigin, countryParam); + Assert.assertEquals(legalTag1.properties.originator, "MyCompany"); + Assert.assertEquals(legalTag1.properties.dataType, "Third Party Data"); + Assert.assertEquals(legalTag1.properties.securityClassification, "Public"); + Assert.assertEquals(legalTag1.properties.personalData, "No Personal Data"); + Assert.assertEquals(legalTag1.properties.exportClassification, "EAR99"); + + // Validate legal tag + response = this.legalTagUtils.send("legaltags:validate", "POST", accessToken, LegalTagUtils.createRetrieveBatchBody(legalTagRet.name), "", headers); + LegalTagUtils.InvalidTagsWithReason invalidTagsWithReason = this.legalTagUtils.getResult(response, 200, LegalTagUtils.InvalidTagsWithReason.class); + Assert.assertEquals(0, invalidTagsWithReason.invalidLegalTags.length); + } +} diff --git a/testing/legal-test-core/src/main/java/org/opengroup/osdu/legal/util/LegalTagUtils.java b/testing/legal-test-core/src/main/java/org/opengroup/osdu/legal/util/LegalTagUtils.java index dd1d238a4c1110a0c89c09402c398e5a2f2b6d71..b50c66b2b89aba9f7787e0ad06a7cd10b3484b1e 100644 --- a/testing/legal-test-core/src/main/java/org/opengroup/osdu/legal/util/LegalTagUtils.java +++ b/testing/legal-test-core/src/main/java/org/opengroup/osdu/legal/util/LegalTagUtils.java @@ -7,6 +7,7 @@ import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Set; @@ -25,6 +26,8 @@ public abstract class LegalTagUtils extends TestUtils { return LegalTagUtils.class.getResourceAsStream("/" + fileName); } + public abstract List<String> readCOOCountries(String storageAccount, String defaultCOOFileName) throws IOException; + protected static String readTestFile(String fileName) throws IOException { InputStream inputStream = getTestFileInputStream(fileName); if(inputStream == null) { diff --git a/testing/legal-test-core/src/main/java/org/opengroup/osdu/legal/util/TestUtils.java b/testing/legal-test-core/src/main/java/org/opengroup/osdu/legal/util/TestUtils.java index 4f21e5a4ea7362057490a3ed810516a0130ba5bc..5fbba1a136e752b624f30f97b3aa490e617d325a 100644 --- a/testing/legal-test-core/src/main/java/org/opengroup/osdu/legal/util/TestUtils.java +++ b/testing/legal-test-core/src/main/java/org/opengroup/osdu/legal/util/TestUtils.java @@ -61,6 +61,10 @@ public class TestUtils { return System.getProperty("MY_TENANT", System.getenv("MY_TENANT")); } + public static String getMySecondDataPartition(){ + return System.getProperty("MY_SECOND_TENANT", System.getenv("MY_SECOND_TENANT")); + } + public ClientResponse send(String path, String httpMethod, String token, String requestBody, String query) throws Exception { diff --git a/testing/legal-test-core/src/main/resources/SecondTenantConfigTestingPurpose.json b/testing/legal-test-core/src/main/resources/SecondTenantConfigTestingPurpose.json new file mode 100644 index 0000000000000000000000000000000000000000..8ddd7b7a34095f011ed2061643e06f14868c0ddc --- /dev/null +++ b/testing/legal-test-core/src/main/resources/SecondTenantConfigTestingPurpose.json @@ -0,0 +1,12 @@ +[{ + "name": "Malaysia", + "alpha2": "MY", + "numeric": 458, + "residencyRisk": "Client consent required" +}, { + "name": "Azerbaijan", + "alpha2": "AZ", + "numeric": 31, + "residencyRisk": "Client consent required", + "typesNotApplyDataResidency": ["Transferred Data"] +}] \ No newline at end of file diff --git a/testing/legal-test-gc/src/test/java/org/opengroup/osdu/legal/util/GCPLegalTagUtils.java b/testing/legal-test-gc/src/test/java/org/opengroup/osdu/legal/util/GCPLegalTagUtils.java index 254a538e6b9862a9b278e837178da0a40195c42f..35247482e4fa55308d727883abf89f1c6c87a81d 100644 --- a/testing/legal-test-gc/src/test/java/org/opengroup/osdu/legal/util/GCPLegalTagUtils.java +++ b/testing/legal-test-gc/src/test/java/org/opengroup/osdu/legal/util/GCPLegalTagUtils.java @@ -20,6 +20,9 @@ package org.opengroup.osdu.legal.util; import com.google.api.client.util.Strings; import lombok.extern.slf4j.Slf4j; +import java.io.IOException; +import java.util.List; + @Slf4j public class GCPLegalTagUtils extends LegalTagUtils { @@ -35,4 +38,9 @@ public class GCPLegalTagUtils extends LegalTagUtils { } return "Bearer " + token; } + + @Override + public List<String> readCOOCountries(String storageAccount, String defaultCOOFileName) throws IOException { + return List.of(); + } } diff --git a/testing/legal-test-ibm/src/test/java/org/opengroup/osdu/legal/util/IBMLegalTagUtils.java b/testing/legal-test-ibm/src/test/java/org/opengroup/osdu/legal/util/IBMLegalTagUtils.java index 5dadd1f942b5f41b79866b513696eec5209507db..0a409e58bfc2745e13e6324d141fbebd59a8d181 100644 --- a/testing/legal-test-ibm/src/test/java/org/opengroup/osdu/legal/util/IBMLegalTagUtils.java +++ b/testing/legal-test-ibm/src/test/java/org/opengroup/osdu/legal/util/IBMLegalTagUtils.java @@ -19,6 +19,9 @@ import org.opengroup.osdu.core.ibm.util.IdentityClient; import com.google.common.base.Strings; +import java.io.IOException; +import java.util.List; + public class IBMLegalTagUtils extends LegalTagUtils { @Override @@ -33,7 +36,12 @@ public class IBMLegalTagUtils extends LegalTagUtils { } return "Bearer " + token; } - + + @Override + public List<String> readCOOCountries(String storageAccount, String defaultCOOFileName) throws IOException { + return List.of(); + } + private static final String mqConnection = "IBM_LEGAL_MQ_CONNECTION"; private static final String envPrefix = "IBM_ENV_PREFIX";