Beispiel #1
0
    def test_url_host_blacklist_and_url_host_blacklist_params_are_mutually_exclusive(self):
        runner_parameters = {
            'url': 'http://www.example.com',
            'method': 'GET',
            'url_hosts_blacklist': ['http://127.0.0.1'],
            'url_hosts_whitelist': ['http://127.0.0.1'],
        }
        runner = HttpRunner('id')
        runner.runner_parameters = runner_parameters
        runner.pre_run()

        expected_msg = (r'"url_hosts_blacklist" and "url_hosts_whitelist" parameters are mutually '
                        'exclusive.')
        self.assertRaisesRegexp(ValueError, expected_msg, runner.run, {})
Beispiel #2
0
    def test_url_host_blacklist_and_url_host_blacklist_params_are_mutually_exclusive(
        self, ):
        runner_parameters = {
            "url": "http://www.example.com",
            "method": "GET",
            "url_hosts_blacklist": ["http://127.0.0.1"],
            "url_hosts_whitelist": ["http://127.0.0.1"],
        }
        runner = HttpRunner("id")
        runner.runner_parameters = runner_parameters
        runner.pre_run()

        expected_msg = (
            r'"url_hosts_blacklist" and "url_hosts_whitelist" parameters are mutually '
            "exclusive.")
        self.assertRaisesRegexp(ValueError, expected_msg, runner.run, {})
Beispiel #3
0
    def test_get_success(self, mock_requests):
        mock_result = MockResult()

        # Unknown content type, body should be returned raw
        mock_result.text = "foo bar ponies"
        mock_result.headers = {"Content-Type": "text/html"}
        mock_result.status_code = 200

        mock_requests.request.return_value = mock_result

        runner_parameters = {"url": "http://www.example.com", "method": "GET"}
        runner = HttpRunner("id")
        runner.runner_parameters = runner_parameters
        runner.pre_run()

        status, result, _ = runner.run({})
        self.assertEqual(status, LIVEACTION_STATUS_SUCCEEDED)
        self.assertEqual(result["body"], "foo bar ponies")
        self.assertEqual(result["status_code"], 200)
        self.assertEqual(result["parsed"], False)
Beispiel #4
0
    def test_get_success(self, mock_requests):
        mock_result = MockResult()

        # Unknown content type, body should be returned raw
        mock_result.text = 'foo bar ponies'
        mock_result.headers = {'Content-Type': 'text/html'}
        mock_result.status_code = 200

        mock_requests.request.return_value = mock_result

        runner_parameters = {'url': 'http://www.example.com', 'method': 'GET'}
        runner = HttpRunner('id')
        runner.runner_parameters = runner_parameters
        runner.pre_run()

        status, result, _ = runner.run({})
        self.assertEqual(status, LIVEACTION_STATUS_SUCCEEDED)
        self.assertEqual(result['body'], 'foo bar ponies')
        self.assertEqual(result['status_code'], 200)
        self.assertEqual(result['parsed'], False)