Search in sources :

Example 6 with AuthorizeDBSecurityGroupIngressRequest

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);
}
Also used : AuthorizeDBSecurityGroupIngressRequest(com.amazonaws.services.rds.model.AuthorizeDBSecurityGroupIngressRequest) AmazonServiceException(com.amazonaws.AmazonServiceException) DBSecurityGroup(com.amazonaws.services.rds.model.DBSecurityGroup) Test(org.junit.Test)

Example 7 with AuthorizeDBSecurityGroupIngressRequest

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);
}
Also used : AuthorizeDBSecurityGroupIngressRequest(com.amazonaws.services.rds.model.AuthorizeDBSecurityGroupIngressRequest) AmazonServiceException(com.amazonaws.AmazonServiceException) Test(org.junit.Test)

Aggregations

AuthorizeDBSecurityGroupIngressRequest (com.amazonaws.services.rds.model.AuthorizeDBSecurityGroupIngressRequest)7 AmazonServiceException (com.amazonaws.AmazonServiceException)6 Test (org.junit.Test)5 DBSecurityGroup (com.amazonaws.services.rds.model.DBSecurityGroup)3 CreateDBSecurityGroupRequest (com.amazonaws.services.rds.model.CreateDBSecurityGroupRequest)1 DescribeDBSecurityGroupsRequest (com.amazonaws.services.rds.model.DescribeDBSecurityGroupsRequest)1 DescribeDBSecurityGroupsResult (com.amazonaws.services.rds.model.DescribeDBSecurityGroupsResult)1