use of org.finra.herd.model.api.xml.S3PropertiesLocation in project herd by FINRAOS.
the class JobServiceTest method testCreateJobWithS3PropertiesPrecedenceJobRequestS3OverridesDefinitionParams.
/**
* Creates a job where the definition has S3 properties and parameters and request has S3 properties. The job create request's S3 properties should take
* precedence if there are name clashes.
*
* @throws Exception
*/
@Test
public void testCreateJobWithS3PropertiesPrecedenceJobRequestS3OverridesDefinitionParams() throws Exception {
Parameter jobDefinitionS3Parameter = new Parameter("testName", "testValue1");
Parameter jobDefinitionRequestParameter = new Parameter("testName", "testValue2");
Parameter jobCreateRequestS3Parameter = new Parameter("testName", "expectedValue");
String s3BucketName = "s3BucketName";
S3PropertiesLocation jobDefinitionS3PropertiesLocation = getS3PropertiesLocation(s3BucketName, "jobDefinitionObjectKey", jobDefinitionS3Parameter);
S3PropertiesLocation jobCreateRequestS3PropertiesLocation = getS3PropertiesLocation(s3BucketName, "jobCreateRequestObjectKey", jobCreateRequestS3Parameter);
Job resultJob = createJobWithParameters(jobDefinitionS3PropertiesLocation, Arrays.asList(jobDefinitionRequestParameter), jobCreateRequestS3PropertiesLocation, null);
List<Parameter> actualParameters = resultJob.getParameters();
assertParameterEquals(jobCreateRequestS3Parameter, actualParameters);
}
use of org.finra.herd.model.api.xml.S3PropertiesLocation in project herd by FINRAOS.
the class JobServiceTest method getS3PropertiesLocation.
/**
* Puts a Java properties into S3 where the key-value is the given parameter. Returns a {@link S3PropertiesLocation} with the S3 info.
*
* @param s3BucketName the S3 bucket name
* @param s3ObjectKey the S3 object key
* @param parameter the parameter
*
* @return the S3 properties location
*/
private S3PropertiesLocation getS3PropertiesLocation(String s3BucketName, String s3ObjectKey, Parameter parameter) {
putParameterIntoS3(s3BucketName, s3ObjectKey, parameter);
S3PropertiesLocation jobDefinitionS3PropertiesLocation = new S3PropertiesLocation();
jobDefinitionS3PropertiesLocation.setBucketName(s3BucketName);
jobDefinitionS3PropertiesLocation.setKey(s3ObjectKey);
return jobDefinitionS3PropertiesLocation;
}
use of org.finra.herd.model.api.xml.S3PropertiesLocation in project herd by FINRAOS.
the class JdbcServiceTest method testExecuteJdbcParamValidationS3PropertiesLocationKeyBlank.
/**
* When S3 properties location is specified, object key must not be a blank string.
*/
@Test
public void testExecuteJdbcParamValidationS3PropertiesLocationKeyBlank() {
JdbcExecutionRequest jdbcExecutionRequest = jdbcServiceTestHelper.createDefaultUpdateJdbcExecutionRequest();
jdbcExecutionRequest.setS3PropertiesLocation(new S3PropertiesLocation("test_bucket", BLANK_TEXT));
try {
jdbcService.executeJdbc(jdbcExecutionRequest);
Assert.fail("expected an IllegalArgumentException, but no exception was thrown");
} catch (Exception e) {
Assert.assertEquals("thrown exception type", IllegalArgumentException.class, e.getClass());
Assert.assertEquals("thrown exception message", "S3 properties location key is required", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.S3PropertiesLocation in project herd by FINRAOS.
the class JdbcServiceTest method testExecuteJdbcSensitiveDataIsMaskedInErrorMessage.
/**
* Some JDBC exception messages echoes back parts of the SQL statement. This is problem for security if some of the variables were replaced, and may
* accidentally expose secret information in the response error message. The application should mask any values given in the properties which exist in the
* exception message.
* <p/>
* This test will use a SQL that will throw an exception, and the exception message is known. Then asserts that the value has been replaced with a mask in
* the response error message.
*/
@Test
public void testExecuteJdbcSensitiveDataIsMaskedInErrorMessage() {
String s3BucketName = "test_bucket";
String s3ObjectKey = "test_key";
String content = "foo=DataIntegrityViolationException";
putS3Object(s3BucketName, s3ObjectKey, content);
JdbcExecutionRequest jdbcExecutionRequest = jdbcServiceTestHelper.createDefaultUpdateJdbcExecutionRequest();
jdbcExecutionRequest.getStatements().get(0).setSql(MockJdbcOperations.CASE_2_SQL);
jdbcExecutionRequest.setS3PropertiesLocation(new S3PropertiesLocation(s3BucketName, s3ObjectKey));
JdbcExecutionResponse jdbcExecutionResponse = jdbcService.executeJdbc(jdbcExecutionRequest);
Assert.assertEquals("jdbc execution response statement [0] error message", "java.sql.SQLException: test **** cause", jdbcExecutionResponse.getStatements().get(0).getErrorMessage());
}
use of org.finra.herd.model.api.xml.S3PropertiesLocation in project herd by FINRAOS.
the class JdbcServiceTest method testExecuteJdbcWithS3PropertiesParamUrlBlankAfterReplace.
/**
* If the result of replacing URL using S3 properties is blank, throws a validation error.
*/
@Test
public void testExecuteJdbcWithS3PropertiesParamUrlBlankAfterReplace() {
String s3BucketName = "test_bucket";
String s3ObjectKey = "test_key";
String content = "foo=";
putS3Object(s3BucketName, s3ObjectKey, content);
JdbcExecutionRequest jdbcExecutionRequest = jdbcServiceTestHelper.createDefaultUpdateJdbcExecutionRequest();
jdbcExecutionRequest.getConnection().setUrl("${foo}");
jdbcExecutionRequest.setS3PropertiesLocation(new S3PropertiesLocation(s3BucketName, s3ObjectKey));
try {
jdbcService.executeJdbc(jdbcExecutionRequest);
Assert.fail("expected an IllegalArgumentException, but no exception was thrown");
} catch (Exception e) {
Assert.assertEquals("thrown exception type", IllegalArgumentException.class, e.getClass());
Assert.assertEquals("thrown exception message", "JDBC connection URL is required", e.getMessage());
}
}
Aggregations