Ejemplo n.º 1
0
    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()
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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()
Ejemplo n.º 4
0
    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()
Ejemplo n.º 5
0
    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()
Ejemplo n.º 6
0
 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)
Ejemplo n.º 7
0
    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)
Ejemplo n.º 8
0
 def setUp(self):
     self.config = ApiGatewayConfig(self.CONFIG_FILE_PATH)
     self.services = ["a", "b", Foo]
     self.launcher = EntrypointLauncher(config=self.config,
                                        services=self.services)
Ejemplo n.º 9
0
 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)
Ejemplo n.º 10
0
    def test_overwrite_with_environment_cors(self):
        config = ApiGatewayConfig(path=self.config_file_path)
        cors = config.rest.cors

        self.assertEqual(False, cors.enabled)
Ejemplo n.º 11
0
 def test_overwrite_with_environment_discovery_port(self):
     config = ApiGatewayConfig(path=self.config_file_path)
     self.assertEqual(4040, config.discovery.port)
Ejemplo n.º 12
0
 def test_overwrite_with_environment(self):
     config = ApiGatewayConfig(path=self.config_file_path)
     rest = config.rest
     self.assertEqual("::1", rest.host)
Ejemplo n.º 13
0
 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)
Ejemplo n.º 14
0
 def test_overwrite_with_environment_discovery_host(self):
     config = ApiGatewayConfig(path=self.config_file_path)
     self.assertEqual("::1", config.discovery.host)
Ejemplo n.º 15
0
    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)
Ejemplo n.º 16
0
 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)
Ejemplo n.º 17
0
    def test_config_rest_cors(self):
        config = ApiGatewayConfig(path=self.config_file_path)
        cors = config.rest.cors

        self.assertEqual(True, cors.enabled)
Ejemplo n.º 18
0
    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)
Ejemplo n.º 19
0
 def test_config_ini_fail(self):
     with self.assertRaises(ApiGatewayConfigException):
         ApiGatewayConfig(path=BASE_PATH / "test_fail_config.yaml")
Ejemplo n.º 20
0
    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)
Ejemplo n.º 21
0
    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)
Ejemplo n.º 22
0
 def setUp(self) -> None:
     self.config = ApiGatewayConfig(self.CONFIG_FILE_PATH)
     super().setUp()
Ejemplo n.º 23
0
 def test_config_rest_auth_none(self):
     config = ApiGatewayConfig(path=BASE_PATH / "config_without_auth.yml")
     self.assertIsNone(config.rest.auth)
Ejemplo n.º 24
0
    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)
Ejemplo n.º 25
0
    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)