def setUp(self) -> None: self.config = ApiGatewayConfig(self.CONFIG_FILE_PATH) self.discovery = MockServer( host=self.config.discovery.host, port=self.config.discovery.port, ) self.discovery.add_json_response( "/microservices", { "address": "localhost", "port": "5568", "status": True }, ) self.microservice = MockServer(host="localhost", port=5568) self.microservice.add_json_response("/order/5", "Microservice call correct!!!", methods=( "GET", "PUT", "PATCH", "DELETE", )) self.microservice.add_json_response("/order", "Microservice call correct!!!", methods=("POST", )) self.discovery.start() self.microservice.start() super().setUp()
def test_config_rest_auth(self): config = ApiGatewayConfig(path=self.config_file_path) auth = config.rest.auth self.assertEqual(True, auth.enabled) self.assertEqual("localhost", auth.host) self.assertEqual(8082, auth.port) self.assertEqual("POST", auth.method) self.assertEqual("/token", auth.path)
def setUp(self) -> None: self.config = ApiGatewayConfig(self.CONFIG_FILE_PATH) self.discovery = MockServer( host=self.config.discovery.host, port=self.config.discovery.port, ) self.discovery.start() super().setUp()
def setUp(self) -> None: self.config = ApiGatewayConfig(self.CONFIG_FILE_PATH) self.discovery = MockServer( host=self.config.discovery.host, port=self.config.discovery.port, ) self.discovery.add_callback_response("/microservices", lambda: abort(400), methods=("GET", )) self.discovery.start() super().setUp()
def setUp(self) -> None: self.config = ApiGatewayConfig(self.CONFIG_FILE_PATH) self.discovery = MockServer( host=self.config.discovery.host, port=self.config.discovery.port, ) self.discovery.add_json_response( "/microservices", { "address": "localhost", "port": "5568", "status": True }, ) self.discovery.start() super().setUp()
def test_overwrite_with_parameter_rest_cors(self): config = ApiGatewayConfig(path=self.config_file_path, api_gateway_rest_cors_enabled=False) cors = config.rest.cors self.assertEqual(False, cors.enabled)
def test_overwrite_with_environment_rest_auth_enabled(self): config = ApiGatewayConfig(path=self.config_file_path) auth = config.rest.auth self.assertEqual(False, auth.enabled)
def setUp(self): self.config = ApiGatewayConfig(self.CONFIG_FILE_PATH) self.services = ["a", "b", Foo] self.launcher = EntrypointLauncher(config=self.config, services=self.services)
def test_overwrite_with_environment_false(self): config = ApiGatewayConfig(path=self.config_file_path, with_environment=False) rest = config.rest self.assertEqual("localhost", rest.host)
def test_overwrite_with_environment_cors(self): config = ApiGatewayConfig(path=self.config_file_path) cors = config.rest.cors self.assertEqual(False, cors.enabled)
def test_overwrite_with_environment_discovery_port(self): config = ApiGatewayConfig(path=self.config_file_path) self.assertEqual(4040, config.discovery.port)
def test_overwrite_with_environment(self): config = ApiGatewayConfig(path=self.config_file_path) rest = config.rest self.assertEqual("::1", rest.host)
def test_overwrite_with_parameter(self): config = ApiGatewayConfig(path=self.config_file_path, api_gateway_rest_host="::1") rest = config.rest self.assertEqual("::1", rest.host)
def test_overwrite_with_environment_discovery_host(self): config = ApiGatewayConfig(path=self.config_file_path) self.assertEqual("::1", config.discovery.host)
def test_overwrite_with_parameter_rest_auth_port(self): config = ApiGatewayConfig(path=self.config_file_path, api_gateway_rest_auth_port="9999") auth = config.rest.auth self.assertEqual(9999, auth.port)
def test_overwrite_with_parameter_rest_auth_enabled(self): config = ApiGatewayConfig(path=self.config_file_path, api_gateway_rest_auth_enabled=False) auth = config.rest.auth self.assertEqual(False, auth.enabled)
def test_config_rest_cors(self): config = ApiGatewayConfig(path=self.config_file_path) cors = config.rest.cors self.assertEqual(True, cors.enabled)
def test_config_rest(self): config = ApiGatewayConfig(path=self.config_file_path) rest = config.rest self.assertEqual("localhost", rest.host) self.assertEqual(55909, rest.port)
def test_config_ini_fail(self): with self.assertRaises(ApiGatewayConfigException): ApiGatewayConfig(path=BASE_PATH / "test_fail_config.yaml")
def test_overwrite_with_parameter_rest_auth_path(self): config = ApiGatewayConfig(path=self.config_file_path, api_gateway_rest_auth_path="/auth") auth = config.rest.auth self.assertEqual("/auth", auth.path)
def test_overwrite_with_parameter_rest_auth_method(self): config = ApiGatewayConfig(path=self.config_file_path, api_gateway_rest_auth_method="GET") auth = config.rest.auth self.assertEqual("GET", auth.method)
def setUp(self) -> None: self.config = ApiGatewayConfig(self.CONFIG_FILE_PATH) super().setUp()
def test_config_rest_auth_none(self): config = ApiGatewayConfig(path=BASE_PATH / "config_without_auth.yml") self.assertIsNone(config.rest.auth)
def test_config_discovery(self): config = ApiGatewayConfig(path=self.config_file_path) discovery = config.discovery self.assertEqual("localhost", discovery.host) self.assertEqual(5567, discovery.port)
def test_overwrite_with_environment_rest_auth_path(self): config = ApiGatewayConfig(path=self.config_file_path) auth = config.rest.auth self.assertEqual("/auth", auth.path)