diff --git a/.gitmodules b/.gitmodules index 0ec57f2a..91761e36 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,7 +5,7 @@ [submodule "providers/openfeature-provider-flagd/test-harness"] path = providers/openfeature-provider-flagd/openfeature/test-harness url = git@github.com:open-feature/flagd-testbed.git - branch = v0.5.20 + branch = v0.5.21 [submodule "providers/openfeature-provider-flagd/spec"] path = providers/openfeature-provider-flagd/openfeature/spec url = https://github.com/open-feature/spec diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 16eb005e..23c715bf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ default_stages: [commit] repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.8.4 + rev: v0.8.6 hooks: - id: ruff args: [--fix] diff --git a/providers/openfeature-provider-flagd/pyproject.toml b/providers/openfeature-provider-flagd/pyproject.toml index c5f63c16..37cb2317 100644 --- a/providers/openfeature-provider-flagd/pyproject.toml +++ b/providers/openfeature-provider-flagd/pyproject.toml @@ -40,7 +40,7 @@ dependencies = [ "pytest-bdd", "testcontainers", "asserts", - "grpcio-health-checking==1.68.1", + "grpcio-health-checking==1.69.0", ] pre-install-commands = [ "hatch build", diff --git a/providers/openfeature-provider-flagd/tests/e2e/conftest.py b/providers/openfeature-provider-flagd/tests/e2e/conftest.py index d40d62c1..6c0e82ec 100644 --- a/providers/openfeature-provider-flagd/tests/e2e/conftest.py +++ b/providers/openfeature-provider-flagd/tests/e2e/conftest.py @@ -1,5 +1,6 @@ import typing +from tests.e2e.step._offline import * # noqa: F403 from tests.e2e.step.config_steps import * # noqa: F403 from tests.e2e.step.context_steps import * # noqa: F403 from tests.e2e.step.event_steps import * # noqa: F403 diff --git a/providers/openfeature-provider-flagd/tests/e2e/rpc/conftest.py b/providers/openfeature-provider-flagd/tests/e2e/rpc/conftest.py index ed43488a..55be37a1 100644 --- a/providers/openfeature-provider-flagd/tests/e2e/rpc/conftest.py +++ b/providers/openfeature-provider-flagd/tests/e2e/rpc/conftest.py @@ -1,11 +1,7 @@ import pytest -from tests.e2e.testFilter import TestFilter from openfeature.contrib.provider.flagd.config import ResolverType - -# from tests.e2e.step.config_steps import * -# from tests.e2e.step.event_steps import * -# from tests.e2e.step.provider_steps import * +from tests.e2e.testFilter import TestFilter resolver = ResolverType.RPC feature_list = ["~targetURI", "~unixsocket", "~sync"] diff --git a/providers/openfeature-provider-flagd/tests/e2e/step/_offline.py b/providers/openfeature-provider-flagd/tests/e2e/step/_offline.py index eaba0e7e..d9092d4e 100644 --- a/providers/openfeature-provider-flagd/tests/e2e/step/_offline.py +++ b/providers/openfeature-provider-flagd/tests/e2e/step/_offline.py @@ -7,7 +7,6 @@ import pytest import yaml -from e2e.conftest import TEST_HARNESS_PATH KEY_EVALUATORS = "$evaluators" @@ -15,6 +14,8 @@ MERGED_FILE = "merged_file" +TEST_HARNESS_PATH = "../../openfeature/test-harness" + # Everything below here, should be actually part of the provider steps - for now it is just easier this way diff --git a/providers/openfeature-provider-flagd/tests/e2e/step/provider_steps.py b/providers/openfeature-provider-flagd/tests/e2e/step/provider_steps.py index 98946a52..a6def606 100644 --- a/providers/openfeature-provider-flagd/tests/e2e/step/provider_steps.py +++ b/providers/openfeature-provider-flagd/tests/e2e/step/provider_steps.py @@ -7,7 +7,6 @@ import pytest from pytest_bdd import given, parsers, when from tests.e2e.flagd_container import FlagdContainer -from tests.e2e.step._offline import * # noqa: F403 from tests.e2e.step._utils import wait_for from openfeature import api diff --git a/providers/openfeature-provider-ofrep/src/openfeature/contrib/provider/ofrep/__init__.py b/providers/openfeature-provider-ofrep/src/openfeature/contrib/provider/ofrep/__init__.py index 90002d9f..8007afa7 100644 --- a/providers/openfeature-provider-ofrep/src/openfeature/contrib/provider/ofrep/__init__.py +++ b/providers/openfeature-provider-ofrep/src/openfeature/contrib/provider/ofrep/__init__.py @@ -107,6 +107,12 @@ def resolve_object_details( FlagType.OBJECT, flag_key, default_value, evaluation_context ) + def _get_ofrep_api_url(self, api_version: str = "v1") -> str: + ofrep_base_url = ( + self.base_url if self.base_url.endswith("/") else f"{self.base_url}/" + ) + return urljoin(ofrep_base_url, f"ofrep/{api_version}/") + def _resolve( self, flag_type: FlagType, @@ -124,7 +130,7 @@ def _resolve( try: response = self.session.post( - urljoin(self.base_url, f"/ofrep/v1/evaluate/flags/{flag_key}"), + urljoin(self._get_ofrep_api_url(), f"evaluate/flags/{flag_key}"), json=_build_request_data(evaluation_context), timeout=self.timeout, headers=self.headers_factory() if self.headers_factory else None, diff --git a/providers/openfeature-provider-ofrep/tests/test_provider.py b/providers/openfeature-provider-ofrep/tests/test_provider.py index ca7dbba1..f698a166 100644 --- a/providers/openfeature-provider-ofrep/tests/test_provider.py +++ b/providers/openfeature-provider-ofrep/tests/test_provider.py @@ -164,3 +164,17 @@ def test_provider_typecheck_flag_value(ofrep_provider, requests_mock): with pytest.raises(TypeMismatchError): ofrep_provider.resolve_boolean_details("flag_key", False) + + +@pytest.mark.parametrize( + "base_url", + [ + "https://localhost:8080", + "https://localhost:8080/", + "https://localhost:8080/tools/feature_flags", + "https://localhost:8080/tools/feature_flags/", + ], +) +def test_provider_api_path_resolution(base_url): + provider = OFREPProvider(base_url=base_url) + assert provider._get_ofrep_api_url() == f"{base_url.rstrip('/')}/ofrep/v1/"