Skip to content

Commit

Permalink
DMP-3125 (#1495)
Browse files Browse the repository at this point in the history
Co-authored-by: hmcts-jenkins-cnp <60659747+hmcts-jenkins-cnp[bot]@users.noreply.github.com>
  • Loading branch information
mario-paniccia and hmcts-jenkins-cnp[bot] authored May 29, 2024
1 parent d154d67 commit 6cc5715
Show file tree
Hide file tree
Showing 28 changed files with 371 additions and 626 deletions.
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ WORKDIR /usr/local/bin
ADD lib/ffmpeg-release-amd64-static.tar.xz /usr/local/bin
RUN cp -p ffmpeg*/ffmpeg /usr/bin

ADD lib/azcopy_linux_amd64_10.24.0.tar.gz /usr/local/bin
RUN cp -p azcopy*/azcopy /usr/bin
RUN chmod 777 /usr/bin/azcopy

# renovate: datasource=github-releases depName=microsoft/ApplicationInsights-Java
FROM hmctspublic.azurecr.io/base/java:17-distroless
COPY --from=build-env /usr/bin/ffmpeg /usr/bin
COPY --from=build-env /usr/bin/azcopy /usr/bin

COPY lib/applicationinsights.json /opt/app/
COPY build/libs/darts-api.jar /opt/app/
Expand Down
4 changes: 3 additions & 1 deletion Jenkinsfile_CNP
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ def secrets = [
secret('AzureAdB2CFuncTestROPCGlobalUsername', 'AZURE_AD_FUNCTIONAL_TEST_GLOBAL_USERNAME'),
secret('AzureAdB2CFuncTestROPCGlobalPassword', 'AZURE_AD_FUNCTIONAL_TEST_GLOBAL_PASSWORD'),
secret('ARMSasEndpoint', 'ARM_SAS_ENDPOINT'),
secret('DETSSasURLEndpoint', 'DETS_SAS_URL_ENDPOINT')
secret('DETSSasURLEndpoint', 'DETS_SAS_URL_ENDPOINT'),
secret('DartsInboundStorageSasUrl', 'DARTS_INBOUND_STORAGE_SAS_URL'),
secret('DartsUnstructuredStorageSasUrl', 'DARTS_UNSTRUCTURED_STORAGE_SAS_URL')
],
]

Expand Down
5 changes: 3 additions & 2 deletions Jenkinsfile_nightly
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ def secrets = [
secret('AzureAdB2CFuncTestROPCGlobalUsername', 'AZURE_AD_FUNCTIONAL_TEST_GLOBAL_USERNAME'),
secret('AzureAdB2CFuncTestROPCGlobalPassword', 'AZURE_AD_FUNCTIONAL_TEST_GLOBAL_PASSWORD'),
secret('ARMSasEndpoint', 'ARM_SAS_ENDPOINT'),
secret('DETSSasURLEndpoint', 'DETS_SAS_URL_ENDPOINT')

secret('DETSSasURLEndpoint', 'DETS_SAS_URL_ENDPOINT'),
secret('DartsInboundStorageSasUrl', 'DARTS_INBOUND_STORAGE_SAS_URL'),
secret('DartsUnstructuredStorageSasUrl', 'DARTS_UNSTRUCTURED_STORAGE_SAS_URL')
],
]

Expand Down
4 changes: 3 additions & 1 deletion Jenkinsfile_parameterized
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def secrets = [
secret('AzureAdB2CFuncTestROPCGlobalUsername', 'AZURE_AD_FUNCTIONAL_TEST_GLOBAL_USERNAME'),
secret('AzureAdB2CFuncTestROPCGlobalPassword', 'AZURE_AD_FUNCTIONAL_TEST_GLOBAL_PASSWORD'),
secret('ARMSasEndpoint', 'ARM_SAS_ENDPOINT'),
secret('DETSSasURLEndpoint', 'DETS_SAS_URL_ENDPOINT')
secret('DETSSasURLEndpoint', 'DETS_SAS_URL_ENDPOINT'),
secret('DartsInboundStorageSasUrl', 'DARTS_INBOUND_STORAGE_SAS_URL'),
secret('DartsUnstructuredStorageSasUrl', 'DARTS_UNSTRUCTURED_STORAGE_SAS_URL')
],
]

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ The required value of each variable is stored in Azure Key Vault as a Secret.
| AAD_TENANT_ID_JUSTICE | AzureADTenantIdJustice |
| AAD_CLIENT_ID_JUSTICE | AzureADClientIdJustice |
| AAD_CLIENT_SECRET_JUSTICE | AzureADClientSecretJustice |
| DARTS_INBOUND_STORAGE_SAS_URL | DartsInboundStorageSasUrl |
| DARTS_UNSTRUCTURED_STORAGE_SAS_URL | DartsUnstructuredStorageSasUrl |

There are few attributes which doesn't use Azure Keyvault secrets. Those environment variable values are controlled dynamically via Flux config

Expand Down Expand Up @@ -124,6 +126,8 @@ export ARM_SAS_ENDPOINT=
export ARM_URL=
export ARM_USERNAME=
export ARM_PASSWORD=
export DARTS_INBOUND_STORAGE_SAS_URL=
export DARTS_UNSTRUCTURED_STORAGE_SAS_URL=
```
### Storage Account
Expand Down
4 changes: 3 additions & 1 deletion bin/secrets-stg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ export AAD_TENANT_ID_JUSTICE="$(az keyvault secret show --vault-name darts-stg -
export AAD_CLIENT_ID_JUSTICE="$(az keyvault secret show --vault-name darts-stg --name AzureADClientIdJustice | jq .value -r)"
export AAD_CLIENT_SECRET_JUSTICE="$(az keyvault secret show --vault-name darts-stg --name AzureADClientSecretJustice | jq .value -r)"
export MAX_FILE_UPLOAD_SIZE_MEGABYTES="$(az keyvault secret show --vault-name darts-stg --name MaxFileUploadSizeInMegabytes | jq .value -r)"
export MAX_FILE_UPLOAD_REQUEST_SIZE_MEGABYTES="$(az keyvault secret show --vault-name darts-stg --name MaxFileUploadRequestSizeInMegabytes | jq .value -r)"
export MAX_FILE_UPLOAD_REQUEST_SIZE_MEGABYTES="$(az keyvault secret show --vault-name darts-stg --name MaxFileUploadRequestSizeInMegabytes | jq .value -r)"
export DARTS_INBOUND_STORAGE_SAS_URL="$(az keyvault secret show --vault-name darts-stg --name DartsInboundStorageSasUrl | jq .value -r)"
export DARTS_UNSTRUCTURED_STORAGE_SAS_URL="$(az keyvault secret show --vault-name darts-stg --name DartsUnstructuredStorageSasUrl | jq .value -r)"
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ sonarqube {
property "sonar.projectName", "DARTS :: darts-api"
property "sonar.projectKey", "uk.gov.hmcts.reform:darts-api"
property "sonar.exclusions", coverageExclusions.join(', ')
property 'sonar.coverage.exclusions', "**/entity/*,**/dto/*"
property 'sonar.coverage.exclusions', "**/entity/*,**/dto/*,**/AzureCopyUtil.java"
//duplicate code here due to OpenAPI codegen that creates identical
// objects (Transcript) in different packages
property "sonar.cpd.exclusions", "**/TranscriptionMapper.java"
Expand Down
2 changes: 1 addition & 1 deletion charts/darts-api/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ appVersion: "1.0"
description: A Helm chart for darts-api App
name: darts-api
home: https://github.com/hmcts/darts-api
version: 0.0.78
version: 0.0.79
maintainers:
- name: HMCTS darts team
dependencies:
Expand Down
4 changes: 4 additions & 0 deletions charts/darts-api/values.dev.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ java:
alias: ARM_USERNAME
- name: ArmPassword
alias: ARM_PASSWORD
- name: DartsInboundStorageSasUrl
alias: DARTS_INBOUND_STORAGE_SAS_URL
- name: DartsUnstructuredStorageSasUrl
alias: DARTS_UNSTRUCTURED_STORAGE_SAS_URL
environment:
ENABLE_FLYWAY: true
RUN_DB_MIGRATION_ON_STARTUP: true
Expand Down
8 changes: 8 additions & 0 deletions charts/darts-api/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ java:
alias: MAX_FILE_UPLOAD_SIZE_MEGABYTES
- name: MaxFileUploadRequestSizeInMegabytes
alias: MAX_FILE_UPLOAD_REQUEST_SIZE_MEGABYTES
- name: DartsInboundStorageSasUrl
alias: DARTS_INBOUND_STORAGE_SAS_URL
- name: DartsUnstructuredStorageSasUrl
alias: DARTS_UNSTRUCTURED_STORAGE_SAS_URL
environment:
NOTIFICATION_SCHEDULER_CRON: "3 */2 * * * MON-FRI"
POSTGRES_SSL_MODE: require
Expand Down Expand Up @@ -192,6 +196,10 @@ function:
alias: ARM_USERNAME
- name: ArmPassword
alias: ARM_PASSWORD
- name: DartsInboundStorageSasUrl
alias: DARTS_INBOUND_STORAGE_SAS_URL
- name: DartsUnstructuredStorageSasUrl
alias: DARTS_UNSTRUCTURED_STORAGE_SAS_URL
environment:
ATS_MODE: true
API_MODE: false
Expand Down
2 changes: 2 additions & 0 deletions docker-compose-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ services:
- ACTIVE_DIRECTORY_B2C_AUTH_URI=https://hmctsstgextid.b2clogin.com/hmctsstgextid.onmicrosoft.com
- MAX_FILE_UPLOAD_SIZE_MEGABYTES=350
- MAX_FILE_UPLOAD_REQUEST_SIZE_MEGABYTES=360
- DARTS_INBOUND_STORAGE_SAS_URL
- DARTS_UNSTRUCTURED_STORAGE_SAS_URL
build:
context: .
dockerfile: Dockerfile
Expand Down
Binary file added lib/azcopy_linux_amd64_10.24.0.tar.gz
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import org.springframework.test.context.ActiveProfiles;
import uk.gov.hmcts.darts.common.datamanagement.component.impl.DownloadResponseMetaData;
import uk.gov.hmcts.darts.common.datamanagement.enums.DatastoreContainerType;
import uk.gov.hmcts.darts.common.exception.AzureDeleteBlobException;
import uk.gov.hmcts.darts.datamanagement.config.DataManagementConfiguration;
import uk.gov.hmcts.darts.datamanagement.exception.FileNotDownloadedException;
import uk.gov.hmcts.darts.datamanagement.service.DataManagementService;

Expand Down Expand Up @@ -42,6 +44,8 @@ class DataManagementServiceTest {

@Autowired
DataManagementService dataManagementService;
@Autowired
DataManagementConfiguration dataManagementConfiguration;

@Test
void saveBinaryDataToBlobStorage() {
Expand Down Expand Up @@ -116,4 +120,28 @@ void saveBlobDataShouldSucceedAndReturnUuid() {
assertTrue(StringUtils.isNotEmpty(uuid.toString()));
}

@Test
void copyBetweenStorageContainers() throws AzureDeleteBlobException {

byte[] testStringInBytes = TEST_BINARY_STRING.getBytes(StandardCharsets.UTF_8);
BinaryData data = BinaryData.fromBytes(testStringInBytes);

var sourceUuid = dataManagementService.saveBlobData(dataManagementConfiguration.getInboundContainerName(), data);

UUID destinationUuid = dataManagementService.copyBlobData(
dataManagementConfiguration.getInboundContainerName(),
dataManagementConfiguration.getUnstructuredContainerName(),
sourceUuid);

var blobData = dataManagementService.getBlobData(
dataManagementConfiguration.getUnstructuredContainerName(),
destinationUuid
);

dataManagementService.deleteBlobData(dataManagementConfiguration.getInboundContainerName(), sourceUuid);
dataManagementService.deleteBlobData(dataManagementConfiguration.getUnstructuredContainerName(), destinationUuid);

assertEquals(TEST_BINARY_STRING, blobData.toString());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ void testSuccessfullyApplyRetentionToCaseTranscriptionDocuments() {
tr2.addHearing(hear2);
transcriptionRepository.save(tr2);

transcriptionStub.updateTranscriptionWithDocument(tr1, STORED, INBOUND);
transcriptionStub.updateTranscriptionWithDocument(tr1, STORED, INBOUND);
transcriptionStub.updateTranscriptionWithDocument(tr2, STORED, INBOUND);
transcriptionStub.updateTranscriptionWithDocument(tr1, STORED, INBOUND, UUID.randomUUID());
transcriptionStub.updateTranscriptionWithDocument(tr1, STORED, INBOUND, UUID.randomUUID());
transcriptionStub.updateTranscriptionWithDocument(tr2, STORED, INBOUND, UUID.randomUUID());

var trDoc1 = tr1.getTranscriptionDocumentEntities().get(0);
eodStub.createAndSaveExternalObjectDirectory(trDoc1.getId(), EodHelper.armDropZoneStatus(), EodHelper.armLocation());
Expand Down
Loading

0 comments on commit 6cc5715

Please sign in to comment.