diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d900980..361bd339 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,14 @@ All notable changes to this project will be documented in this file. The format is roughly based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). -## [Current: 0.13.x] -- + +## [Current: 0.14.x] + +- Disassociate billing plans from user roles and don't list any for now ([openEOPlatform/architecture-docs#381](https://github.com/openEOPlatform/architecture-docs/issues/381)) + + +## [0.13.x] + - Fix compatibility with `openeo_driver>=0.75.0` (new `enable_basic_auth` config, which is going to be disabled by default) diff --git a/src/openeo_aggregator/about.py b/src/openeo_aggregator/about.py index 3631f21e..28615649 100644 --- a/src/openeo_aggregator/about.py +++ b/src/openeo_aggregator/about.py @@ -2,7 +2,7 @@ import sys from typing import Optional -__version__ = "0.13.0a1" +__version__ = "0.14.0a1" def log_version_info(logger: Optional[logging.Logger] = None): diff --git a/src/openeo_aggregator/backend.py b/src/openeo_aggregator/backend.py index 25040a09..dd3f8c42 100644 --- a/src/openeo_aggregator/backend.py +++ b/src/openeo_aggregator/backend.py @@ -1345,8 +1345,6 @@ def user_access_validation(self, user: User, request: flask.Request) -> User: ) if roles: user.add_roles(r.id for r in roles) - # TODO: better way of determining default_plan? - user.set_default_plan([r.billing_plan for r in roles][-1].name) else: _log.warning(f"user_access_validation failure: %r %r", enrollment_error_user_message, { "user_id": user.user_id, @@ -1391,15 +1389,6 @@ def capabilities_billing(self) -> dict: # TODO #96 check that all upstream back-ends use the same currency (credits) return { "currency": "credits", - "plans": [ - { - "name": p.name, - "description": p.description, - "url": p.url, - "paid": p.paid, - } - for p in openeo_aggregator.egi.OPENEO_PLATFORM_BILLING_PLANS - ] } def postprocess_capabilities(self, capabilities: dict) -> dict: diff --git a/src/openeo_aggregator/egi.py b/src/openeo_aggregator/egi.py index d09bb2a6..f2e82d8c 100644 --- a/src/openeo_aggregator/egi.py +++ b/src/openeo_aggregator/egi.py @@ -11,35 +11,6 @@ BillingPlan = namedtuple("BillingPlan", ["name", "description", "url", "paid"]) -_BILLING_PLAN_30DAY_TRIAL = BillingPlan( - name="30day-trial", - description="openEO.cloud 30 day free trial plan (experimental)", - url="https://docs.openeo.cloud/join/free_trial.html", - paid=False, -) - -_BILLING_PLAN_EARLY_ADOPTER = BillingPlan( - name="early-adopter", - description="openEO.cloud early adopter plan", - url="https://openeo.cloud/early-adopters/", - paid=True, -) - -# TODO: avoid using generic billing plan -_BILLING_PLAN_GENERIC = BillingPlan( - name="generic", - description="openEO.cloud generic plan", - url=None, - paid=True, -) - -OPENEO_PLATFORM_BILLING_PLANS = [ - _BILLING_PLAN_30DAY_TRIAL, - _BILLING_PLAN_EARLY_ADOPTER, - _BILLING_PLAN_GENERIC, -] - - # Regex to parse eduperson_entitlement strings, # like for example "urn:mace:egi.eu:group:vo.openeo.cloud:role=early_adopter#aai.egi.eu" _eduperson_entitlement_regex = re.compile( @@ -80,28 +51,20 @@ class UserRole: "_id", # Normalized version of role name (for case/whitespace-insensitive comparison) "_normalized", - # Associated billing plan - "_billing_plan", ] - def __init__(self, title: str, billing_plan: BillingPlan = _BILLING_PLAN_GENERIC): + def __init__(self, title: str): self._title = title self._id = "".join( w.title() if w.islower() else w for w in self._title.replace("-", " ").replace("_", " ").split() ) self._normalized = self.normalize_role(self._title) - self._billing_plan = billing_plan - @property def id(self) -> str: return self._id - @property - def billing_plan(self) -> BillingPlan: - return self._billing_plan - @staticmethod def normalize_role(role: Union[str, None]) -> Union[str, None]: if role: @@ -137,8 +100,8 @@ def extract_roles(self, entitlements: List[str]) -> List[UserRole]: # Based on https://github.com/openEOPlatform/documentation/issues/48 OPENEO_PLATFORM_USER_ROLES = OpeneoPlatformUserRoles( [ - UserRole("30-Day-Trial", billing_plan=_BILLING_PLAN_30DAY_TRIAL), - UserRole("Early_Adopter", billing_plan=_BILLING_PLAN_EARLY_ADOPTER), + UserRole("30-Day-Trial"), + UserRole("Early_Adopter"), # TODO: define a dedicated billing plan for each user role? UserRole("Basic_User"), UserRole("Professional_User"), diff --git a/tests/test_egi.py b/tests/test_egi.py index 9db7c4b3..777af7d8 100644 --- a/tests/test_egi.py +++ b/tests/test_egi.py @@ -53,7 +53,6 @@ class TestUserRole: def test_basic(self): role = UserRole("Foo") assert role.id == "Foo" - assert role.billing_plan.name == "generic" assert role.entitlement_match( "urn:mace:egi.eu:group:vo.openeo.cloud:role=Foo#aai.egi.eu" ) diff --git a/tests/test_views.py b/tests/test_views.py index dbc2b997..f1747f69 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -69,11 +69,9 @@ def test_capabilities_validation(self, api100): def test_billing_plans(self, api100): capabilities = api100.get("/").assert_status_code(200).json - billing = capabilities["billing"] - assert billing["currency"] == "credits" - plans = {p["name"]: p for p in billing["plans"]} - assert "early-adopter" in plans - assert plans["early-adopter"]["paid"] is True + assert capabilities["billing"] == { + "currency": "credits", + } def test_deploy_metadata(self, api100): capabilities = api100.get("/").assert_status_code(200).json @@ -449,7 +447,7 @@ def test_oidc_not_enrolled( assert re.search(warn_regex, warnings) @pytest.mark.parametrize( - ["eduperson_entitlement", "expected_roles", "expected_plan"], + ["eduperson_entitlement", "expected_roles"], [ ( [ @@ -457,7 +455,6 @@ def test_oidc_not_enrolled( "urn:mace:egi.eu:group:vo.openeo.cloud:role=30day-trial#aai.egi.eu", ], ["30DayTrial"], - "30day-trial", ), ( [ @@ -465,7 +462,6 @@ def test_oidc_not_enrolled( "urn:mace:egi.eu:group:vo.openeo.cloud:role=early_adopter#aai.egi.eu", ], ["EarlyAdopter"], - "early-adopter", ), ( [ @@ -474,14 +470,10 @@ def test_oidc_not_enrolled( "urn:mace:egi.eu:group:vo.openeo.cloud:role=Platform-developer#aai.egi.eu", ], ["BasicUser", "EarlyAdopter", "PlatformDeveloper"], - "generic", ), ], ) - def test_oidc_enrolled( - self, api100_with_entitlement_check, requests_mock, - eduperson_entitlement, expected_roles, expected_plan, - ): + def test_oidc_enrolled(self, api100_with_entitlement_check, requests_mock, eduperson_entitlement, expected_roles): requests_mock.get("https://egi.test/.well-known/openid-configuration", json={ "userinfo_endpoint": "https://egi.test/userinfo" }) @@ -495,7 +487,7 @@ def test_oidc_enrolled( data = res.json assert data["user_id"] == "john" assert data["roles"] == expected_roles - assert data["default_plan"] == expected_plan + assert "default_plan" not in data @pytest.mark.parametrize(["whitelist", "main_test_oidc_issuer", "success"], [ (["https://egi.test"], "https://egi.test", True),