def testDNSMissingParamHostname(self, mock_config, mock_processor): self.__setUpMocks(configFailed=False, hashFailed=False, updateFailed=False, mock_config=mock_config, mock_processor=mock_processor) event = { 'queryStringParameters': { 'hash': 'xyz', 'internalip': '2.2.2.2' }, 'requestContext': { 'identity': { 'sourceIp': '1.1.1.1' } } } context = {} result = handle(event, context) self.__checkJson( result, "FAIL", "You have to pass 'hostname' querystring parameters.") event = { 'queryStringParameters': { 'raw': '', 'hash': 'xyz', 'internalip': '2.2.2.2' }, 'requestContext': { 'identity': { 'sourceIp': '1.1.1.1' } } } context = {} result = handle(event, context) self.__checkRaw(result, "FAIL", "You have to pass 'hostname' querystring parameters.")
def testDNSSuccess(self, mock_config, mock_processor): self.__setUpMocks(configFailed=False, hashFailed=False, updateFailed=False, mock_config=mock_config, mock_processor=mock_processor) event = { 'queryStringParameters': { 'hostname': 'abc', 'hash': 'xyz', 'internalip': '2.2.2.2' }, 'requestContext': { 'identity': { 'sourceIp': '1.1.1.1' } } } context = {} result = handle(event, context) self.__checkJson(result, "SUCCESS", "OK") event = { 'queryStringParameters': { 'raw': '', 'hostname': 'abc', 'hash': 'xyz', 'internalip': '2.2.2.2' }, 'requestContext': { 'identity': { 'sourceIp': '1.1.1.1' } } } context = {} result = handle(event, context) self.__checkRaw(result, "SUCCESS", "OK")
def testDNSMissingParamSourceIp(self, mock_config, mock_processor): self.__setUpMocks(configFailed=False, hashFailed=False, updateFailed=False, mock_config=mock_config, mock_processor=mock_processor) event = { 'queryStringParameters': { 'hostname': 'abc', 'hash': 'xyz', 'internalip': '2.2.2.2' } } context = {} result = handle(event, context) self.__checkJson( result, "FAIL", "Source IP address cannot be extracted from request context.") event = { 'queryStringParameters': { 'raw': '', 'hostname': 'abc', 'hash': 'xyz', 'internalip': '2.2.2.2' } } context = {} result = handle(event, context) self.__checkRaw( result, "FAIL", "Source IP address cannot be extracted from request context.") event = { 'queryStringParameters': { 'hostname': 'abc', 'hash': 'xyz', 'internalip': '2.2.2.2' }, 'requestContext': {} } context = {} result = handle(event, context) self.__checkJson( result, "FAIL", "Source IP address cannot be extracted from request context.") event = { 'queryStringParameters': { 'raw': '', 'hostname': 'abc', 'hash': 'xyz', 'internalip': '2.2.2.2' }, 'requestContext': {} } context = {} result = handle(event, context) self.__checkRaw( result, "FAIL", "Source IP address cannot be extracted from request context.") event = { 'queryStringParameters': { 'hostname': 'abc', 'hash': 'xyz', 'internalip': '2.2.2.2' }, 'requestContext': None } context = {} result = handle(event, context) self.__checkJson( result, "FAIL", "Source IP address cannot be extracted from request context.") event = { 'queryStringParameters': { 'raw': '', 'hostname': 'abc', 'hash': 'xyz', 'internalip': '2.2.2.2' }, 'requestContext': None } context = {} result = handle(event, context) self.__checkRaw( result, "FAIL", "Source IP address cannot be extracted from request context.") event = { 'queryStringParameters': { 'hostname': 'abc', 'hash': 'xyz', 'internalip': '2.2.2.2' }, 'requestContext': { 'identity': {} } } context = {} result = handle(event, context) self.__checkJson( result, "FAIL", "Source IP address cannot be extracted from request context.") event = { 'queryStringParameters': { 'raw': '', 'hostname': 'abc', 'hash': 'xyz', 'internalip': '2.2.2.2' }, 'requestContext': { 'identity': {} } } context = {} result = handle(event, context) self.__checkRaw( result, "FAIL", "Source IP address cannot be extracted from request context.")