Example #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()
Example #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)
Example #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()
Example #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()
Example #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()
Example #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)
Example #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)
Example #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)
Example #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)
Example #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)
Example #11
0
 def test_overwrite_with_environment_discovery_port(self):
     config = ApiGatewayConfig(path=self.config_file_path)
     self.assertEqual(4040, config.discovery.port)
Example #12
0
 def test_overwrite_with_environment(self):
     config = ApiGatewayConfig(path=self.config_file_path)
     rest = config.rest
     self.assertEqual("::1", rest.host)
Example #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)
Example #14
0
 def test_overwrite_with_environment_discovery_host(self):
     config = ApiGatewayConfig(path=self.config_file_path)
     self.assertEqual("::1", config.discovery.host)
Example #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)
Example #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)
Example #17
0
    def test_config_rest_cors(self):
        config = ApiGatewayConfig(path=self.config_file_path)
        cors = config.rest.cors

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