Beispiel #1
0
    def test_unknown_host(self):
        endpoint = Endpoint.from_url('https://not-reachable')
        assert endpoint is not None

        target_path = self.temp_dir / 'atsprobe'

        atsprobe = DiagnoseUtility.compile_and_sign(target_path=target_path, )

        diagnostics_list = atsprobe.run({endpoint})

        self.assertEqual(len(diagnostics_list), 1)

        diagnostics = diagnostics_list[0]

        self.assertIn('url', diagnostics)
        self.assertEqual(diagnostics['url'], str(endpoint))

        self.assertIn('timestamp', diagnostics)
        self.assertIn('error', diagnostics)

        error = diagnostics['error']

        self.assertIn('code', error)
        self.assertEqual(error['code'], Error.CannotFindHost)
Beispiel #2
0
 def test_with_tls(self, value: str, expected_value: str):
     endpoint = Endpoint.from_url(value)
     assert endpoint is not None
     expected = Endpoint.from_url(expected_value)
     assert expected is not None
     self.assertEqual(endpoint.with_tls, expected)
Beispiel #3
0
 def test_uses_tls(self, value: str, expected: bool):
     endpoint = Endpoint.from_url(value)
     assert endpoint is not None
     self.assertEqual(endpoint.uses_tls, expected)
Beispiel #4
0
 def test_is_ip(self, value: str, expected: bool):
     endpoint = Endpoint.from_url(value)
     assert endpoint is not None
     self.assertEqual(endpoint.is_ip, expected)
Beispiel #5
0
 def test_from_url(self, value: str, expected: str):
     endpoint = Endpoint.from_url(value)
     self.assertIsNotNone(endpoint)
     self.assertEqual(expected, str(endpoint))
Beispiel #6
0
 def test_from_url_negative(self, value: str):
     endpoint = Endpoint.from_url(value)
     self.assertIsNone(endpoint)
Beispiel #7
0
 def endpoint(self) -> Endpoint:
     endpoint = Endpoint.from_url(f'https://localhost:{self.port}/')
     assert endpoint is not None
     return endpoint
Beispiel #8
0
 def test_find_best_configuration(self, url: str):
     endpoint = Endpoint.from_url(url)
     assert endpoint is not None
     configuration, diagnostics = find_best_configuration(endpoint)
     self.assertEqual(configuration, Configuration())
     self.assertEqual(diagnostics, [Diagnostics(endpoint)])
Beispiel #9
0
 def test_find_instances(self, value: str, expected: List[str]):
     actual = [str(endpoint) for endpoint in Endpoint.find_instances(value)]
     self.assertEqual(expected, actual)