use of org.finra.herd.model.api.xml.JdbcExecutionRequest 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.JdbcExecutionRequest in project herd by FINRAOS.
the class JdbcServiceTest method testExecuteJdbcErrorConnection.
@Test
public void testExecuteJdbcErrorConnection() {
JdbcExecutionRequest jdbcExecutionRequest = jdbcServiceTestHelper.createDefaultUpdateJdbcExecutionRequest();
jdbcExecutionRequest.getStatements().get(0).setSql(MockJdbcOperations.CASE_3_SQL);
try {
// Execute
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", "java.sql.SQLException: test CannotGetJdbcConnectionException cause", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.JdbcExecutionRequest in project herd by FINRAOS.
the class JdbcServiceTest method testExecuteJdbcParamValidationConnectionNull.
/**
* Parameter validation, request connection is null
*/
@Test
public void testExecuteJdbcParamValidationConnectionNull() {
JdbcExecutionRequest jdbcExecutionRequest = jdbcServiceTestHelper.createDefaultUpdateJdbcExecutionRequest();
jdbcExecutionRequest.setConnection(null);
try {
// Execute
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 is required", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.JdbcExecutionRequest 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.JdbcExecutionRequest in project herd by FINRAOS.
the class JdbcServiceTest method testExecuteJdbcParamValidationStatementTypeNull.
/**
* Parameter validation, request statement type is null
*/
@Test
public void testExecuteJdbcParamValidationStatementTypeNull() {
JdbcExecutionRequest jdbcExecutionRequest = jdbcServiceTestHelper.createDefaultUpdateJdbcExecutionRequest();
jdbcExecutionRequest.getStatements().get(0).setType(null);
try {
// Execute
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 statement [0] type is required", e.getMessage());
}
}
Aggregations