use of com.amazonaws.services.rds.model.AuthorizeDBSecurityGroupIngressRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class DatabaseSecuritySetupTest method testAddEC2SecurityGroup.
/**
* Verify the request is made as expected.
*/
@Test
public void testAddEC2SecurityGroup() {
String dbGroupName = "dbGroupName";
AuthorizeDBSecurityGroupIngressRequest expectedIngress = new AuthorizeDBSecurityGroupIngressRequest(dbGroupName);
expectedIngress.setEC2SecurityGroupOwnerId(elasticSecurityGroup.getOwnerId());
expectedIngress.setEC2SecurityGroupName(elasticSecurityGroup.getGroupName());
AmazonServiceException unknown = new AmazonServiceException("Unknonwn");
unknown.setErrorCode(ERROR_CODE_AUTHORIZATION_ALREADY_EXITS);
when(mockClient.authorizeDBSecurityGroupIngress(any(AuthorizeDBSecurityGroupIngressRequest.class))).thenReturn(new DBSecurityGroup());
// Make the call
databaseSecuritySetup.addEC2SecurityGroup(dbGroupName, elasticSecurityGroup);
// Validate the data was passed
verify(mockClient, times(1)).authorizeDBSecurityGroupIngress(expectedIngress);
}
use of com.amazonaws.services.rds.model.AuthorizeDBSecurityGroupIngressRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class DatabaseSecuritySetupTest method testAddCIDRToGroupDuplicateError.
/**
* When a duplicate is error is thrown we it should not be re-thrown.
*/
@Test
public void testAddCIDRToGroupDuplicateError() {
String dbGroupName = "dbGroupName";
String cIDR = "0.0.0.0/255";
AuthorizeDBSecurityGroupIngressRequest expectedIngress = new AuthorizeDBSecurityGroupIngressRequest(dbGroupName);
expectedIngress.setCIDRIP(cIDR);
AmazonServiceException unknown = new AmazonServiceException("Unknonwn");
unknown.setErrorCode(ERROR_CODE_AUTHORIZATION_ALREADY_EXITS);
when(mockClient.authorizeDBSecurityGroupIngress(any(AuthorizeDBSecurityGroupIngressRequest.class))).thenThrow(unknown);
// Make the call
databaseSecuritySetup.addCIDRToGroup(dbGroupName, cIDR);
// Validate the data was passed
verify(mockClient, times(1)).authorizeDBSecurityGroupIngress(expectedIngress);
}
Aggregations