Skip to content

Commit c5b8559

Browse files
authored
25377 - Overrides existing BASIC account creation into PREMIUM (#3225)
1 parent 18475e5 commit c5b8559

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

auth-api/flags.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"flagValues": {
33
"string-flag": "a string value",
44
"bool-flag": true,
5-
"integer-flag": 10
5+
"integer-flag": 10,
6+
"remove-premium-restrictions": false
67
}
7-
}
8+
}

auth-api/src/auth_api/services/org.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from auth_api.models.dataclass import Activity, DeleteAffiliationRequest
3838
from auth_api.models.org import OrgSearch
3939
from auth_api.schemas import ContactSchema, InvitationSchema, MembershipSchema, OrgSchema
40+
from auth_api.services.flags import flags
4041
from auth_api.services.user import User as UserService
4142
from auth_api.services.validators.access_type import validate as access_type_validate
4243
from auth_api.services.validators.account_limit import validate as account_limit_validate
@@ -107,6 +108,7 @@ def create_org(org_info: dict, user_id):
107108
mailing_address = org_info.pop("mailingAddress", None)
108109
payment_info = org_info.pop("paymentInfo", {})
109110
product_subscriptions = org_info.pop("productSubscriptions", None)
111+
type_code = org_info.get("typeCode", None)
110112

111113
bcol_profile_flags = None
112114
response = Org._validate_and_raise_error(org_info)
@@ -119,7 +121,10 @@ def create_org(org_info: dict, user_id):
119121
access_type = response.get("access_type")
120122

121123
# set premium for GOVM accounts..TODO remove if not needed this logic
122-
if access_type == AccessType.GOVM.value:
124+
# we are depreciating BASIC accounts
125+
if access_type == AccessType.GOVM.value or (
126+
type_code == OrgType.BASIC.value and flags.is_on("remove-premium-restrictions", default=False) is True
127+
):
123128
org_info.update({"typeCode": OrgType.PREMIUM.value})
124129

125130
org = OrgModel.create_from_dict(camelback2snake(org_info))

auth-api/tests/unit/services/test_flags.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
app = None
2323

2424

25-
@pytest.fixture
25+
@pytest.fixture(autouse=True)
2626
def setup():
2727
"""Initialize app with dev env for testing."""
2828
global app
@@ -131,6 +131,7 @@ def test_flags_read_from_json_missing_flag(setup):
131131
("boolean flag", "bool-flag", True),
132132
("string flag", "string-flag", "a string value"),
133133
("integer flag", "integer-flag", 10),
134+
("remove premium restrictions flag", "remove-premium-restrictions", False),
134135
],
135136
)
136137
def test_flags_read_flag_values_from_json(setup, test_name, flag_name, expected):

0 commit comments

Comments
 (0)