use of com.amazonaws.services.rds.model.DBSecurityGroup in project Synapse-Stack-Builder by Sage-Bionetworks.
the class DatabaseSecuritySetup method createSecurityGroup.
/**
* Create a security group. If the group already exists
* @param ec2Client
* @param request
*/
void createSecurityGroup(CreateDBSecurityGroupRequest request) {
try {
// First create the EC2 group
log.info("Creating Database Security Group: " + request.getDBSecurityGroupName() + "...");
DBSecurityGroup result = rdsClient.createDBSecurityGroup(request);
} catch (AmazonServiceException e) {
if (ERROR_CODE_DB_SECURITY_GROUP_ALREADY_EXISTS.equals(e.getErrorCode())) {
// This group already exists
log.info("Database Security Group: " + request.getDBSecurityGroupName() + " already exits");
} else {
throw e;
}
}
}
use of com.amazonaws.services.rds.model.DBSecurityGroup in project Synapse-Stack-Builder by Sage-Bionetworks.
the class DatabaseSecuritySetupTest method testTeardownResources.
@Test
public void testTeardownResources() {
resources.setIdGeneratorDatabaseSecurityGroup(new DBSecurityGroup().withDBSecurityGroupName(config.getIdGeneratorDatabaseSecurityGroupName()));
resources.setStackInstancesDatabaseSecurityGroup(new DBSecurityGroup().withDBSecurityGroupName(config.getStackDatabaseSecurityGroupName()));
DeleteDBSecurityGroupRequest req = new DeleteDBSecurityGroupRequest().withDBSecurityGroupName(resources.getStackInstancesDatabaseSecurityGroup().getDBSecurityGroupName());
databaseSecuritySetup.teardownResources();
verify(mockClient, times(1)).deleteDBSecurityGroup(req);
assertNotNull(resources.getIdGeneratorDatabaseSecurityGroup());
assertNull(resources.getStackInstancesDatabaseSecurityGroup());
}
use of com.amazonaws.services.rds.model.DBSecurityGroup in project Synapse-Stack-Builder by Sage-Bionetworks.
the class DatabaseSecuritySetupTest method testCreateSecurityGroup.
/**
* Test that that the data is passed to the client as expected.
*/
@Test
public void testCreateSecurityGroup() {
CreateDBSecurityGroupRequest request = new CreateDBSecurityGroupRequest();
request.setDBSecurityGroupName("name");
request.setDBSecurityGroupDescription("description");
when(mockClient.createDBSecurityGroup(request)).thenReturn(new DBSecurityGroup());
databaseSecuritySetup.createSecurityGroup(request);
verify(mockClient, times(1)).createDBSecurityGroup(request);
}
use of com.amazonaws.services.rds.model.DBSecurityGroup in project Synapse-Stack-Builder by Sage-Bionetworks.
the class DatabaseSecuritySetupTest method testDescribeResourcesExist.
@Test
public void testDescribeResourcesExist() {
DescribeDBSecurityGroupsRequest reqIdGen = new DescribeDBSecurityGroupsRequest();
reqIdGen.setDBSecurityGroupName(config.getIdGeneratorDatabaseSecurityGroupName());
DescribeDBSecurityGroupsRequest reqStackInst = new DescribeDBSecurityGroupsRequest();
reqStackInst.setDBSecurityGroupName(config.getStackDatabaseSecurityGroupName());
when(mockClient.describeDBSecurityGroups(reqIdGen)).thenReturn(new DescribeDBSecurityGroupsResult().withDBSecurityGroups(new DBSecurityGroup().withDBSecurityGroupName(config.getIdGeneratorDatabaseSecurityGroupName())));
when(mockClient.describeDBSecurityGroups(reqStackInst)).thenReturn(new DescribeDBSecurityGroupsResult().withDBSecurityGroups(new DBSecurityGroup().withDBSecurityGroupName(config.getStackDatabaseSecurityGroupName())));
databaseSecuritySetup.describeResources();
assertNotNull(resources.getIdGeneratorDatabaseSecurityGroup());
assertNotNull(resources.getStackInstancesDatabaseSecurityGroup());
}
use of com.amazonaws.services.rds.model.DBSecurityGroup in project Synapse-Stack-Builder by Sage-Bionetworks.
the class DatabaseSecuritySetupTest method testDescribeSecurityGroupExists.
@Test
public void testDescribeSecurityGroupExists() {
DescribeDBSecurityGroupsRequest req = new DescribeDBSecurityGroupsRequest();
req.setDBSecurityGroupName("name");
when(mockClient.describeDBSecurityGroups(req)).thenReturn(new DescribeDBSecurityGroupsResult().withDBSecurityGroups(new DBSecurityGroup().withDBSecurityGroupName("name")));
DBSecurityGroup grp = databaseSecuritySetup.describeDBSecurityGroup("name");
assertEquals("name", grp.getDBSecurityGroupName());
}
Aggregations