/** * Create an instance of {@link StorageUnitDownloadCredential } * */ public StorageUnitDownloadCredential createStorageUnitDownloadCredential() { return new StorageUnitDownloadCredential(); }
/** * Create an instance of {@link StorageUnitDownloadCredential } * */ public StorageUnitDownloadCredential createStorageUnitDownloadCredential() { return new StorageUnitDownloadCredential(); }
/** * Create an instance of {@link StorageUnitDownloadCredential } * */ public StorageUnitDownloadCredential createStorageUnitDownloadCredential() { return new StorageUnitDownloadCredential(); }
public Object createNewInstance() { return new StorageUnitDownloadCredential(); }
public Object createNewInstance() { return new StorageUnitDownloadCredential(); }
public Object createNewInstance() { return new StorageUnitDownloadCredential(); }
@NamespacePermission(fields = "#businessObjectDataKey?.namespace", permissions = NamespacePermissionEnum.READ) @Override public StorageUnitDownloadCredential getStorageUnitDownloadCredential(BusinessObjectDataKey businessObjectDataKey, String storageName) { StorageUnitDownloadCredential businessObjectDataDownloadCredential = new StorageUnitDownloadCredential(); businessObjectDataDownloadCredential.setAwsCredential(getBusinessObjectDataS3Credential(businessObjectDataKey, null, storageName, false)); return businessObjectDataDownloadCredential; }
@NamespacePermission(fields = "#businessObjectDataKey?.namespace", permissions = NamespacePermissionEnum.READ) @Override public StorageUnitDownloadCredential getStorageUnitDownloadCredential(BusinessObjectDataKey businessObjectDataKey, String storageName) { StorageUnitDownloadCredential businessObjectDataDownloadCredential = new StorageUnitDownloadCredential(); businessObjectDataDownloadCredential.setAwsCredential(getBusinessObjectDataS3Credential(businessObjectDataKey, null, storageName, false)); return businessObjectDataDownloadCredential; }
when(closeableHttpResponse.getEntity()).thenReturn(new StringEntity(xmlHelper.objectToXml(new StorageUnitDownloadCredential())));
@Test public void testGetBusinessObjectDataDownloadCredentialAssertNoAuthorizationHeaderWhenNoSsl() throws Exception { HttpClientOperations mockHttpClientOperations = mock(HttpClientOperations.class); HttpClientOperations originalHttpClientOperations = (HttpClientOperations) ReflectionTestUtils.getField(downloaderWebClient, "httpClientOperations"); ReflectionTestUtils.setField(downloaderWebClient, "httpClientOperations", mockHttpClientOperations); try { CloseableHttpResponse closeableHttpResponse = mock(CloseableHttpResponse.class); when(mockHttpClientOperations.execute(any(), any())).thenReturn(closeableHttpResponse); when(closeableHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(HttpVersion.HTTP_1_1, 200, "SUCCESS")); when(closeableHttpResponse.getEntity()).thenReturn(new StringEntity(xmlHelper.objectToXml(new StorageUnitDownloadCredential()))); DownloaderInputManifestDto downloaderInputManifestDto = new DownloaderInputManifestDto(); String storageName = "storageName"; boolean useSsl = false; downloaderWebClient.getRegServerAccessParamsDto().setUseSsl(useSsl); downloaderWebClient.getStorageUnitDownloadCredential(downloaderInputManifestDto, storageName); verify(mockHttpClientOperations).execute(any(), argThat(httpUriRequest -> httpUriRequest.getFirstHeader("Authorization") == null)); } finally { ReflectionTestUtils.setField(downloaderWebClient, "httpClientOperations", originalHttpClientOperations); } }
private void getStorageUnitDownloadCredentialResponse(MockCloseableHttpResponse response, URI uri) throws UnsupportedCharsetException, JAXBException { StorageUnitDownloadCredential storageUnitDownloadCredential = new StorageUnitDownloadCredential(); AwsCredential awsCredential = new AwsCredential(); awsCredential.setAwsAccessKey(uri.toString()); storageUnitDownloadCredential.setAwsCredential(awsCredential); response.setEntity(getHttpEntity(storageUnitDownloadCredential)); } }
@Test public void getStorageUnitDownloadCredential() { // Create a business object data key. BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION); // Create a delimited list of sub-partition values. String delimitedSubPartitionValues = String.join("|", SUBPARTITION_VALUES); // Create a storage unit download credential. StorageUnitDownloadCredential storageUnitDownloadCredential = new StorageUnitDownloadCredential( new AwsCredential(AWS_ASSUMED_ROLE_ACCESS_KEY, AWS_ASSUMED_ROLE_SECRET_KEY, AWS_ASSUMED_ROLE_SESSION_TOKEN, AWS_ASSUMED_ROLE_SESSION_EXPIRATION_TIME)); // Mock the external calls. when(herdStringHelper.splitStringWithDefaultDelimiterEscaped(delimitedSubPartitionValues)).thenReturn(SUBPARTITION_VALUES); when(storageUnitService.getStorageUnitDownloadCredential(businessObjectDataKey, STORAGE_NAME)).thenReturn(storageUnitDownloadCredential); // Call the method under test. StorageUnitDownloadCredential result = storageUnitRestController .getStorageUnitDownloadCredential(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, DATA_VERSION, STORAGE_NAME, delimitedSubPartitionValues); // Verify the external calls. verify(herdStringHelper).splitStringWithDefaultDelimiterEscaped(delimitedSubPartitionValues); verify(storageUnitService).getStorageUnitDownloadCredential(businessObjectDataKey, STORAGE_NAME); verifyNoMoreInteractionsHelper(); // Validate the results. assertEquals(storageUnitDownloadCredential, result); }
@Test public void testGetBusinessObjectDataDownloadCredential() { // Create a business object data key. BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION); // Create a delimited list of sub-partition values. String delimitedSubPartitionValues = String.join("|", SUBPARTITION_VALUES); // Create an AWS credential. AwsCredential awsCredential = new AwsCredential(AWS_ASSUMED_ROLE_ACCESS_KEY, AWS_ASSUMED_ROLE_SECRET_KEY, AWS_ASSUMED_ROLE_SESSION_TOKEN, AWS_ASSUMED_ROLE_SESSION_EXPIRATION_TIME); // Create a storage unit download credential. StorageUnitDownloadCredential storageUnitDownloadCredential = new StorageUnitDownloadCredential(awsCredential); // Mock the external calls. when(herdStringHelper.splitStringWithDefaultDelimiterEscaped(delimitedSubPartitionValues)).thenReturn(SUBPARTITION_VALUES); when(storageUnitService.getStorageUnitDownloadCredential(businessObjectDataKey, STORAGE_NAME)).thenReturn(storageUnitDownloadCredential); // Call the method under test. BusinessObjectDataDownloadCredential result = businessObjectDataRestController .getBusinessObjectDataDownloadCredential(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, DATA_VERSION, STORAGE_NAME, delimitedSubPartitionValues); // Verify the external calls. verify(herdStringHelper).splitStringWithDefaultDelimiterEscaped(delimitedSubPartitionValues); verify(storageUnitService).getStorageUnitDownloadCredential(businessObjectDataKey, STORAGE_NAME); verifyNoMoreInteractionsHelper(); // Validate the results. assertEquals(new BusinessObjectDataDownloadCredential(awsCredential), result); }
when(mockBusinessObjectDataHelper.getStorageUnitByStorageName(any(), any())).thenReturn(storageUnit); when(mockDownloaderWebClient.getS3KeyPrefix(any())).thenReturn(s3KeyPrefixInformation); when(mockDownloaderWebClient.getStorageUnitDownloadCredential(any(), any())).thenReturn(new StorageUnitDownloadCredential( new AwsCredential("awsAccessKey", "awsSecretKey", "awsSessionToken", DatatypeFactory.newInstance().newXMLGregorianCalendar()))); when(mockS3Service.downloadDirectory(any())).then(new Answer<S3FileTransferResultsDto>()