def test_describe_security_group_present(self): with mock.patch('requests.get', self.mockRequestsGetDescribeSecurityGroups): (result, info) = niftycloud_fw.describe_security_group(self.mockModule, self.result['absent']) self.assertEqual(result, dict( created = False, changed_attributes = dict(), state = 'present', )) self.assertIsInstance(info, dict) self.assertEqual(info['group_name'], 'fw001') self.assertIsInstance(info['description'], str) self.assertEqual(info['description'], 'sample fw') self.assertEqual(info['log_limit'], 100000) self.assertEqual(info['ip_permissions'], [ dict( ip_protocol = 'TCP', in_out = 'IN', from_port = 10000, to_port = 10010, cidr_ip = None, group_name = 'fw002', ), dict( ip_protocol = 'ANY', in_out = 'OUT', from_port = None, to_port = None, cidr_ip = '0.0.0.0/0', group_name = None, ), ])
def test_describe_security_group_failed(self): with mock.patch('requests.get', self.mockRequestsInternalServerError): (result, info) = niftycloud_fw.describe_security_group(self.mockModule, self.result['absent']) self.assertEqual(result, dict( created = False, changed_attributes = dict(), state = 'absent', )) self.assertIsNone(info)
def test_describe_security_group_absent(self): with mock.patch('requests.get', self.mockRequestsGetDescribeSecurityGroupsNotFound): (result, info) = niftycloud_fw.describe_security_group(self.mockModule, self.result['absent']) self.assertEqual(result, dict( created = False, changed_attributes = dict(), state = 'absent', )) self.assertIsNone(info)
def test_describe_security_group_description_none(self): with mock.patch('requests.get', self.mockRequestsGetDescribeSecurityGroupsDescriptionNone): (result, info) = niftycloud_fw.describe_security_group(self.mockModule, self.result['absent']) self.assertEqual(result, dict( created = False, changed_attributes = dict(), state = 'present', )) self.assertIsInstance(info, dict) self.assertIsInstance(info['description'], str) self.assertEqual(info['description'], '')