Beispiel #1
0
    def test_endpoint(self, mock_config, mock_temp, mock_stfrtime):
        f = Flare()
        f._ask_for_email = lambda: None
        f._open_tarfile()
        f._tar.close()

        with self.assertRaises(Exception) as cm:
            f.upload()

        self.assertEqual(str(cm.exception), "Your request is incorrect: Invalid inputs: 'API key unknown'")
Beispiel #2
0
    def test_endpoint(self, mock_config, mock_temp, mock_stfrtime):
        if os.environ['FLARE_BROKEN']:
            raise unittest.case.SkipTest('Flare broken, acknowledged')
        f = Flare()
        f._ask_for_email = lambda: None
        f._open_tarfile()
        f._tar.close()

        with self.assertRaises(Exception) as cm:
            f.upload()

        self.assertEqual(str(cm.exception), "Your request is incorrect: Invalid inputs: 'API key unknown'")
Beispiel #3
0
    def test_endpoint(self, mock_config, mock_temp, mock_stfrtime, mock_os_remove):
        if os.environ.get('FLARE_BROKEN'):
            raise unittest.case.SkipTest('Flare broken, acknowledged')
        f = Flare()
        f._ask_for_email = lambda: None
        f._open_tarfile()
        f._tar.close()

        with self.assertRaises(Exception) as cm:
            f.upload()

        self.assertEqual(str(cm.exception), "403 Client Error: Forbidden for url: https://app.datadoghq.com/support/flare?api_key=APIKEY")
Beispiel #4
0
    def test_endpoint(self, mock_config, mock_temp, mock_stfrtime, mock_os_remove):
        if os.environ.get('FLARE_BROKEN'):
            raise unittest.case.SkipTest('Flare broken, acknowledged')
        f = Flare()
        f._ask_for_email = lambda: None
        f._open_tarfile()
        f._tar.close()

        with self.assertRaises(Exception) as cm:
            f.upload()

        self.assertEqual(str(cm.exception), "Your request is incorrect: Invalid inputs: 'API key unknown'")
Beispiel #5
0
    def test_upload_no_case(self, mock_config, mock_tempdir, mock_stfrtime,
                            mock_version, mock_requests, mock_os_remove):
        f = Flare()
        f._ask_for_email = lambda: '*****@*****.**'
        f._open_tarfile()
        f._tar.close()

        assert not mock_requests.called
        f.upload()
        assert mock_requests.called
        args, kwargs = mock_requests.call_args_list[0]
        self.assertEqual(
            args, ('https://app.datadoghq.com/support/flare?api_key=APIKEY', ))
        self.assertEqual(
            kwargs['files']['flare_file'].name,
            os.path.join(get_mocked_temp(), "stackstate-agent-1.tar.bz2"))
        self.assertEqual(kwargs['data']['case_id'], None)
        self.assertEqual(kwargs['data']['email'], '*****@*****.**')
        assert kwargs['data']['hostname']
Beispiel #6
0
    def test_upload_with_case(self, mock_config, mock_tempdir, mock_stfrtime, mock_version, mock_requests):
        f = Flare(case_id=1337)
        f._ask_for_email = lambda: '*****@*****.**'
        f._open_tarfile()
        f._tar.close()

        assert not mock_requests.called
        f.upload()
        assert mock_requests.called
        args, kwargs = mock_requests.call_args_list[0]
        self.assertEqual(
            args,
            ('https://6-6-6-flare.agent.datadoghq.com/support/flare/1337?api_key=APIKEY',)
        )
        self.assertEqual(
            kwargs['files']['flare_file'].name,
            os.path.join(get_mocked_temp(), "datadog-agent-1.tar.bz2")
        )
        self.assertEqual(kwargs['data']['case_id'], 1337)
        self.assertEqual(kwargs['data']['email'], '*****@*****.**')
        assert kwargs['data']['hostname']
Beispiel #7
0
    def test_upload_with_case_proxy(self, mock_config, mock_tempdir, mock_stfrtime, mock_version, mock_requests):
        f = Flare(case_id=1337)
        f._ask_for_email = lambda: '*****@*****.**'
        f._open_tarfile()
        f._tar.close()

        assert not mock_requests.called
        f.upload()
        assert mock_requests.called
        args, kwargs = mock_requests.call_args_list[0]
        self.assertEqual(
            args,
            ('https://6-6-6-flare.agent.datadoghq.com/support/flare/1337?api_key=APIKEY',)
        )
        self.assertEqual(
            kwargs['files']['flare_file'].name,
            os.path.join(get_mocked_temp(), "datadog-agent-1.tar.bz2")
        )
        self.assertEqual(kwargs['data']['case_id'], 1337)
        self.assertEqual(kwargs['data']['email'], '*****@*****.**')
        assert kwargs['data']['hostname']
        assert kwargs['proxies']['https'] == 'http://*****:*****@proxy.host.com:3128'
        assert not kwargs['verify']