new URIBuilder().setScheme(getUriScheme()).setHost(regServerAccessParamsDto.getRegServerHost()).setPort(regServerAccessParamsDto.getRegServerPort()) .setPath(HERD_APP_REST_URI_PREFIX + "/businessObjectData/search").setParameter("pageNum", pageNum.toString()); .createHttpClient(regServerAccessParamsDto.isTrustSelfSignedCertificate(), regServerAccessParamsDto.isDisableHostnameVerification())) if (regServerAccessParamsDto.isUseSsl())
public Object copyTo(ObjectLocator locator, Object target, CopyStrategy2 strategy) { final Object draftCopy = ((target == null)?createNewInstance():target); if (draftCopy instanceof RegServerAccessParamsDto) { final RegServerAccessParamsDto copy = ((RegServerAccessParamsDto) draftCopy); if (disableHostnameVerificationShouldBeCopiedAndSet == Boolean.TRUE) { Boolean sourceDisableHostnameVerification; sourceDisableHostnameVerification = this.isDisableHostnameVerification(); Boolean copyDisableHostnameVerification = ((Boolean) strategy.copy(LocatorUtils.property(locator, "disableHostnameVerification", sourceDisableHostnameVerification), sourceDisableHostnameVerification, (this.disableHostnameVerification!= null))); copy.setDisableHostnameVerification(copyDisableHostnameVerification); } else { if (disableHostnameVerificationShouldBeCopiedAndSet == Boolean.FALSE) { if (passwordShouldBeCopiedAndSet == Boolean.TRUE) { String sourcePassword; sourcePassword = this.getPassword(); String copyPassword = ((String) strategy.copy(LocatorUtils.property(locator, "password", sourcePassword), sourcePassword, (this.password!= null))); copy.setPassword(copyPassword); } else { if (passwordShouldBeCopiedAndSet == Boolean.FALSE) { if (regServerHostShouldBeCopiedAndSet == Boolean.TRUE) { String sourceRegServerHost; sourceRegServerHost = this.getRegServerHost(); String copyRegServerHost = ((String) strategy.copy(LocatorUtils.property(locator, "regServerHost", sourceRegServerHost), sourceRegServerHost, (this.regServerHost!= null))); copy.setRegServerHost(copyRegServerHost); } else { if (regServerHostShouldBeCopiedAndSet == Boolean.FALSE) { if (regServerPortShouldBeCopiedAndSet == Boolean.TRUE) {
@Test public void testWebClientRegServerAccessParamsDtoSetterAndGetter() { // Create and initialize an instance of RegServerAccessParamsDto. RegServerAccessParamsDto regServerAccessParamsDto = new RegServerAccessParamsDto(); regServerAccessParamsDto.setRegServerHost(WEB_SERVICE_HOSTNAME); regServerAccessParamsDto.setRegServerPort(WEB_SERVICE_HTTPS_PORT); regServerAccessParamsDto.setUseSsl(true); regServerAccessParamsDto.setUsername(WEB_SERVICE_HTTPS_USERNAME); regServerAccessParamsDto.setPassword(WEB_SERVICE_HTTPS_PASSWORD); // Set the DTO. downloaderWebClient.setRegServerAccessParamsDto(regServerAccessParamsDto); // Retrieve the DTO and validate the results. RegServerAccessParamsDto resultRegServerAccessParamsDto = downloaderWebClient.getRegServerAccessParamsDto(); // validate the results. assertEquals(WEB_SERVICE_HOSTNAME, resultRegServerAccessParamsDto.getRegServerHost()); assertEquals(WEB_SERVICE_HTTPS_PORT, resultRegServerAccessParamsDto.getRegServerPort()); assertTrue(resultRegServerAccessParamsDto.isUseSsl()); assertEquals(WEB_SERVICE_HTTPS_USERNAME, resultRegServerAccessParamsDto.getUsername()); assertEquals(WEB_SERVICE_HTTPS_PASSWORD, resultRegServerAccessParamsDto.getPassword()); }
/** * Returns an authorization header required for HTTPS client authentication with the registration server. * * @return the authorization header */ protected BasicHeader getAuthorizationHeader() { String combined = regServerAccessParamsDto.getUsername() + ":" + regServerAccessParamsDto.getPassword(); byte[] encodedBytes = Base64.encodeBase64(combined.getBytes(StandardCharsets.UTF_8)); return new BasicHeader("Authorization", "Basic " + new String(encodedBytes, StandardCharsets.UTF_8)); }
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { theDisableHostnameVerification = this.isDisableHostnameVerification(); strategy.appendField(locator, this, "disableHostnameVerification", buffer, theDisableHostnameVerification, (this.disableHostnameVerification!= null)); thePassword = this.getPassword(); strategy.appendField(locator, this, "password", buffer, thePassword, (this.password!= null)); theRegServerHost = this.getRegServerHost(); strategy.appendField(locator, this, "regServerHost", buffer, theRegServerHost, (this.regServerHost!= null)); theRegServerPort = this.getRegServerPort(); strategy.appendField(locator, this, "regServerPort", buffer, theRegServerPort, (this.regServerPort!= null)); theTrustSelfSignedCertificate = this.isTrustSelfSignedCertificate(); strategy.appendField(locator, this, "trustSelfSignedCertificate", buffer, theTrustSelfSignedCertificate, (this.trustSelfSignedCertificate!= null)); theUseSsl = this.isUseSsl(); strategy.appendField(locator, this, "useSsl", buffer, theUseSsl, (this.useSsl!= null)); theUsername = this.getUsername(); strategy.appendField(locator, this, "username", buffer, theUsername, (this.username!= null));
@Before public void before() { dataBridgeWebClient = new DataBridgeWebClient() { }; RegServerAccessParamsDto regServerAccessParamsDto = new RegServerAccessParamsDto(); regServerAccessParamsDto.setUseSsl(false); regServerAccessParamsDto.setRegServerPort(8080); dataBridgeWebClient.setRegServerAccessParamsDto(regServerAccessParamsDto); dataBridgeWebClient.httpClientHelper = httpClientHelper; dataBridgeWebClient.httpClientOperations = httpClientOperations; dataBridgeWebClient.herdStringHelper = herdStringHelper; }
RegServerAccessParamsDto.builder().withRegServerHost(WEB_SERVICE_HOSTNAME).withRegServerPort(WEB_SERVICE_HTTPS_PORT).withUseSsl(true) .withUsername(WEB_SERVICE_HTTPS_USERNAME).withPassword(WEB_SERVICE_HTTPS_PASSWORD).withTrustSelfSignedCertificate(true) .withDisableHostnameVerification(true).build();
@Test public void testDestroyBusinessObjectData() throws Exception { retentionExpirationDestroyerWebClient.getRegServerAccessParamsDto().setUseSsl(false); BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey("test", "test", "test", "test", 0, "test", Collections.singletonList("test"), 0); BusinessObjectData result = retentionExpirationDestroyerWebClient.destroyBusinessObjectData(businessObjectDataKey); assertNotNull(result); }
@Test public void testAddStorageFilesResponse200BadContentReturnsNull() throws Exception { dataBridgeWebClient.regServerAccessParamsDto.setRegServerHost(MockHttpClientOperationsImpl.HOSTNAME_RESPOND_WITH_STATUS_CODE_200_AND_INVALID_CONTENT); dataBridgeWebClient.regServerAccessParamsDto.setUseSsl(false); BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(); UploaderInputManifestDto manifest = getUploaderInputManifestDto(); S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = new S3FileTransferRequestParamsDto(); String storageName = "testStorage"; BusinessObjectDataStorageFilesCreateResponse businessObjectDataStorageFilesCreateResponse = dataBridgeWebClient.addStorageFiles(businessObjectDataKey, manifest, s3FileTransferRequestParamsDto, storageName); assertNull("businessObjectDataStorageFilesCreateResponse", businessObjectDataStorageFilesCreateResponse); }
@Test public void testGetBusinessObjectDefinitionException() throws Exception { retentionExpirationExporterWebClient.getRegServerAccessParamsDto().setRegServerHost(MockHttpClientOperationsImpl.HOSTNAME_THROW_IO_EXCEPTION); try { retentionExpirationExporterWebClient.getBusinessObjectDefinition(NAMESPACE, BUSINESS_OBJECT_DEFINITION_NAME); } catch (IOException e) { assertEquals("testThrowIoException", e.getMessage()); } }
/** * Returns an URI scheme. */ protected String getUriScheme() { return regServerAccessParamsDto.isUseSsl() ? "https" : "http"; }
/** * Create an instance of {@link RegServerAccessParamsDto } * */ public RegServerAccessParamsDto createRegServerAccessParamsDto() { return new RegServerAccessParamsDto(); }
lhsDisableHostnameVerification = this.isDisableHostnameVerification(); Boolean rhsDisableHostnameVerification; rhsDisableHostnameVerification = that.isDisableHostnameVerification(); if (!strategy.equals(LocatorUtils.property(thisLocator, "disableHostnameVerification", lhsDisableHostnameVerification), LocatorUtils.property(thatLocator, "disableHostnameVerification", rhsDisableHostnameVerification), lhsDisableHostnameVerification, rhsDisableHostnameVerification, (this.disableHostnameVerification!= null), (that.disableHostnameVerification!= null))) { return false; lhsPassword = this.getPassword(); String rhsPassword; rhsPassword = that.getPassword(); if (!strategy.equals(LocatorUtils.property(thisLocator, "password", lhsPassword), LocatorUtils.property(thatLocator, "password", rhsPassword), lhsPassword, rhsPassword, (this.password!= null), (that.password!= null))) { return false; lhsRegServerHost = this.getRegServerHost(); String rhsRegServerHost; rhsRegServerHost = that.getRegServerHost(); if (!strategy.equals(LocatorUtils.property(thisLocator, "regServerHost", lhsRegServerHost), LocatorUtils.property(thatLocator, "regServerHost", rhsRegServerHost), lhsRegServerHost, rhsRegServerHost, (this.regServerHost!= null), (that.regServerHost!= null))) { return false; lhsRegServerPort = this.getRegServerPort(); Integer rhsRegServerPort; rhsRegServerPort = that.getRegServerPort(); if (!strategy.equals(LocatorUtils.property(thisLocator, "regServerPort", lhsRegServerPort), LocatorUtils.property(thatLocator, "regServerPort", rhsRegServerPort), lhsRegServerPort, rhsRegServerPort, (this.regServerPort!= null), (that.regServerPort!= null))) { return false; lhsTrustSelfSignedCertificate = this.isTrustSelfSignedCertificate(); Boolean rhsTrustSelfSignedCertificate; rhsTrustSelfSignedCertificate = that.isTrustSelfSignedCertificate(); if (!strategy.equals(LocatorUtils.property(thisLocator, "trustSelfSignedCertificate", lhsTrustSelfSignedCertificate), LocatorUtils.property(thatLocator, "trustSelfSignedCertificate", rhsTrustSelfSignedCertificate), lhsTrustSelfSignedCertificate, rhsTrustSelfSignedCertificate, (this.trustSelfSignedCertificate!= null), (that.trustSelfSignedCertificate!= null))) { return false;
@Test(expected = IllegalArgumentException.class) public void testPerformUploadManifestContainsDuplicateFileNames() throws Exception { List<ManifestFile> duplicateTestDataFiles = new ArrayList<>(); duplicateTestDataFiles.addAll(testManifestFiles); duplicateTestDataFiles.add(testManifestFiles.get(0)); // Create local data files in LOCAL_TEMP_PATH_INPUT directory for (ManifestFile manifestFile : testManifestFiles) { createLocalFile(LOCAL_TEMP_PATH_INPUT.toString(), manifestFile.getFileName(), FILE_SIZE_1_KB); } // Create uploader input manifest file in LOCAL_TEMP_PATH_INPUT directory UploaderInputManifestDto uploaderInputManifestDto = getTestUploaderInputManifestDto(); uploaderInputManifestDto.setManifestFiles(duplicateTestDataFiles); File manifestFile = createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), uploaderInputManifestDto); Assert.assertTrue(manifestFile.isFile()); // Try to upload business object data having duplicate file names. RegServerAccessParamsDto regServerAccessParamsDto = RegServerAccessParamsDto.builder().withRegServerHost(WEB_SERVICE_HOSTNAME).withRegServerPort(WEB_SERVICE_HTTPS_PORT).withUseSsl(true) .withUsername(WEB_SERVICE_HTTPS_USERNAME).withPassword(WEB_SERVICE_HTTPS_PASSWORD).build(); uploaderController.performUpload(regServerAccessParamsDto, manifestFile, getTestS3FileTransferRequestParamsDto(), false, false, TEST_RETRY_ATTEMPTS, TEST_RETRY_DELAY_SECS); }
@Test public void testDestroyBusinessObjectDataUseSsl() throws Exception { retentionExpirationDestroyerWebClient.getRegServerAccessParamsDto().setUseSsl(true); BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey("test", "test", "test", "test", 0, "test", Collections.singletonList("test"), 0); BusinessObjectData result = retentionExpirationDestroyerWebClient.destroyBusinessObjectData(businessObjectDataKey); assertNotNull(result); } }
@Test public void testSearchBusinessObjectDataException() throws Exception { retentionExpirationExporterWebClient.getRegServerAccessParamsDto().setRegServerHost(MockHttpClientOperationsImpl.HOSTNAME_THROW_IO_EXCEPTION); try { retentionExpirationExporterWebClient.searchBusinessObjectData(new BusinessObjectDataSearchRequest(), 1); } catch (IOException e) { assertEquals("testThrowIoException", e.getMessage()); } }
/** * Returns an authorization header required for HTTPS client authentication with the registration server. * * @return the authorization header */ protected BasicHeader getAuthorizationHeader() { String combined = regServerAccessParamsDto.getUsername() + ":" + regServerAccessParamsDto.getPassword(); byte[] encodedBytes = Base64.encodeBase64(combined.getBytes(StandardCharsets.UTF_8)); return new BasicHeader("Authorization", "Basic " + new String(encodedBytes, StandardCharsets.UTF_8)); }
/** * Returns an URI scheme. */ protected String getUriScheme() { return regServerAccessParamsDto.isUseSsl() ? "https" : "http"; }
public Object createNewInstance() { return new RegServerAccessParamsDto(); }
new URIBuilder().setScheme(getUriScheme()).setHost(regServerAccessParamsDto.getRegServerHost()).setPort(regServerAccessParamsDto.getRegServerPort()) .setPath(uriPathBuilder); .createHttpClient(regServerAccessParamsDto.isTrustSelfSignedCertificate(), regServerAccessParamsDto.isDisableHostnameVerification())) if (regServerAccessParamsDto.isUseSsl())