Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into feat/gherkinmigration
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Schrottner <[email protected]>
  • Loading branch information
aepfli committed Jan 8, 2025
2 parents 6d86a96 + 905b42b commit 55feac0
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[submodule "providers/openfeature-provider-flagd/test-harness"]
path = providers/openfeature-provider-flagd/openfeature/test-harness
url = [email protected]: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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
2 changes: 1 addition & 1 deletion providers/openfeature-provider-flagd/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions providers/openfeature-provider-flagd/tests/e2e/conftest.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@

import pytest
import yaml
from e2e.conftest import TEST_HARNESS_PATH

KEY_EVALUATORS = "$evaluators"

KEY_FLAGS = "flags"

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
14 changes: 14 additions & 0 deletions providers/openfeature-provider-ofrep/tests/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/"

0 comments on commit 55feac0

Please sign in to comment.