From adc563fb9e5e2e4af17b153a8698db78bb1a4280 Mon Sep 17 00:00:00 2001 From: Ee Durbin Date: Fri, 5 Sep 2025 05:19:57 -0400 Subject: [PATCH] Remove all organization feature flag gating MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Organizations features are now fully deployed and no longer need feature flag gating. This removes all DISABLE_ORGANIZATIONS flag checks and related infrastructure. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- tests/conftest.py | 8 -- tests/functional/manage/test_views.py | 2 - tests/unit/accounts/test_core.py | 14 ++-- tests/unit/admin/views/test_organizations.py | 65 -------------- tests/unit/manage/test_views.py | 39 +-------- tests/unit/manage/views/test_organizations.py | 84 ------------------- tests/unit/manage/views/test_teams.py | 18 +--- tests/unit/mock/test_billing.py | 12 +-- tests/unit/test_predicates.py | 9 -- warehouse/accounts/__init__.py | 6 +- warehouse/admin/flags.py | 1 - warehouse/locale/messages.pot | 20 ++--- warehouse/manage/views/organizations.py | 23 ----- warehouse/mock/billing.py | 4 +- warehouse/predicates.py | 14 +--- 15 files changed, 31 insertions(+), 288 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 1c5c53be8e24..f03f8a7d7a8f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -636,14 +636,6 @@ def _enable_all_oidc_providers(webtest): flag_db.enabled = original_flag_values[flag] -@pytest.fixture -def _enable_organizations(db_request): - flag = db_request.db.get(AdminFlag, AdminFlagValue.DISABLE_ORGANIZATIONS.value) - flag.enabled = False - yield - flag.enabled = True - - @pytest.fixture def send_email(pyramid_request, monkeypatch): send_email_stub = pretend.stub( diff --git a/tests/functional/manage/test_views.py b/tests/functional/manage/test_views.py index 4e53ea6e2b81..0d6fe73b2d35 100644 --- a/tests/functional/manage/test_views.py +++ b/tests/functional/manage/test_views.py @@ -6,7 +6,6 @@ import faker import pretend -import pytest from webob.multidict import MultiDict @@ -104,7 +103,6 @@ def test_changing_password_succeeds(self, webtest, socket_enabled): class TestManageOrganizations: - @pytest.mark.usefixtures("_enable_organizations") def test_create_organization_application( self, pyramid_services, diff --git a/tests/unit/accounts/test_core.py b/tests/unit/accounts/test_core.py index 14cd5dde9c9f..3fa5a2602c54 100644 --- a/tests/unit/accounts/test_core.py +++ b/tests/unit/accounts/test_core.py @@ -83,28 +83,24 @@ def test_without_identity(self): class TestOrganizationAccess: @pytest.mark.parametrize( - ("identity", "flag", "orgs", "expected"), + ("identity", "orgs", "expected"), [ - (False, True, [], False), # Unauth'd always have no access - (False, False, [], False), # Unauth'd always have no access - (True, False, [], True), # Flag allows all authenticated users - (True, True, [], False), # Flag blocks all authenticated users without orgs + (False, [], False), # Unauth'd always have no access + (True, [], False), # Authenticated users without orgs have no access ( - True, True, [pretend.stub()], True, - ), # Flag allows users with organizations + ), # Authenticated users with organizations have access ], ) - def test_organization_access(self, db_session, identity, flag, orgs, expected): + def test_organization_access(self, db_session, identity, orgs, expected): user = None if not identity else UserFactory() request = pretend.stub( identity=UserContext(user, None), find_service=lambda interface, context=None: pretend.stub( get_organizations_by_user=lambda x: orgs ), - flags=pretend.stub(enabled=lambda flag_name: flag), ) assert expected == accounts._organization_access(request) diff --git a/tests/unit/admin/views/test_organizations.py b/tests/unit/admin/views/test_organizations.py index 92e59015fb2b..85182a572e2e 100644 --- a/tests/unit/admin/views/test_organizations.py +++ b/tests/unit/admin/views/test_organizations.py @@ -85,7 +85,6 @@ def test_validate_field_too_long(self): class TestOrganizationList: - @pytest.mark.usefixtures("_enable_organizations") def test_no_query(self, db_request): organizations = sorted( OrganizationFactory.create_batch(30), @@ -95,7 +94,6 @@ def test_no_query(self, db_request): assert result == {"organizations": organizations[:25], "query": "", "terms": []} - @pytest.mark.usefixtures("_enable_organizations") def test_with_page(self, db_request): organizations = sorted( OrganizationFactory.create_batch(30), @@ -106,7 +104,6 @@ def test_with_page(self, db_request): assert result == {"organizations": organizations[25:], "query": "", "terms": []} - @pytest.mark.usefixtures("_enable_organizations") def test_with_invalid_page(self): request = pretend.stub( flags=pretend.stub(enabled=lambda *a: False), @@ -116,7 +113,6 @@ def test_with_invalid_page(self): with pytest.raises(HTTPBadRequest): views.organization_list(request) - @pytest.mark.usefixtures("_enable_organizations") def test_basic_query(self, db_request): organizations = sorted( OrganizationFactory.create_batch(5), @@ -129,7 +125,6 @@ def test_basic_query(self, db_request): assert result["query"] == organizations[0].name assert result["terms"] == [organizations[0].name] - @pytest.mark.usefixtures("_enable_organizations") def test_name_query(self, db_request): organizations = sorted( OrganizationFactory.create_batch(5), @@ -142,7 +137,6 @@ def test_name_query(self, db_request): assert result["query"] == f"name:{organizations[0].name}" assert result["terms"] == [f"name:{organizations[0].name}"] - @pytest.mark.usefixtures("_enable_organizations") def test_organization_query(self, db_request): organizations = sorted( OrganizationFactory.create_batch(5), @@ -155,7 +149,6 @@ def test_organization_query(self, db_request): assert result["query"] == f"organization:{organizations[0].display_name}" assert result["terms"] == [f"organization:{organizations[0].display_name}"] - @pytest.mark.usefixtures("_enable_organizations") def test_url_query(self, db_request): organizations = sorted( OrganizationFactory.create_batch(5), @@ -168,7 +161,6 @@ def test_url_query(self, db_request): assert result["query"] == f"url:{organizations[0].link_url}" assert result["terms"] == [f"url:{organizations[0].link_url}"] - @pytest.mark.usefixtures("_enable_organizations") def test_description_query(self, db_request): organizations = sorted( OrganizationFactory.create_batch(5), @@ -181,7 +173,6 @@ def test_description_query(self, db_request): assert result["query"] == f"description:'{organizations[0].description}'" assert result["terms"] == [f"description:{organizations[0].description}"] - @pytest.mark.usefixtures("_enable_organizations") def test_is_active_query(self, db_request): organizations = sorted( OrganizationFactory.create_batch(5), @@ -201,7 +192,6 @@ def test_is_active_query(self, db_request): "terms": ["is:active"], } - @pytest.mark.usefixtures("_enable_organizations") def test_is_inactive_query(self, db_request): organizations = sorted( OrganizationFactory.create_batch(5), @@ -221,7 +211,6 @@ def test_is_inactive_query(self, db_request): "terms": ["is:inactive"], } - @pytest.mark.usefixtures("_enable_organizations") def test_type_query(self, db_request): company_org = OrganizationFactory.create(orgtype=OrganizationType.Company) community_org = OrganizationFactory.create(orgtype=OrganizationType.Community) @@ -243,7 +232,6 @@ def test_type_query(self, db_request): "terms": ["type:community"], } - @pytest.mark.usefixtures("_enable_organizations") def test_invalid_type_query(self, db_request): company_org = OrganizationFactory.create(orgtype=OrganizationType.Company) @@ -256,7 +244,6 @@ def test_invalid_type_query(self, db_request): "terms": ["type:invalid"], } - @pytest.mark.usefixtures("_enable_organizations") def test_is_invalid_query(self, db_request): organizations = sorted( OrganizationFactory.create_batch(5), @@ -273,7 +260,6 @@ def test_is_invalid_query(self, db_request): class TestOrganizationDetail: - @pytest.mark.usefixtures("_enable_organizations") def test_detail(self, db_request): organization = OrganizationFactory.create( name="example", @@ -297,7 +283,6 @@ def test_detail(self, db_request): assert result["role_forms"] == {} assert isinstance(result["add_role_form"], views.AddOrganizationRoleForm) - @pytest.mark.usefixtures("_enable_organizations") def test_detail_is_approved_true(self, db_request): organization = OrganizationFactory.create( name="example", @@ -321,7 +306,6 @@ def test_detail_is_approved_true(self, db_request): assert result["role_forms"] == {} assert isinstance(result["add_role_form"], views.AddOrganizationRoleForm) - @pytest.mark.usefixtures("_enable_organizations") def test_detail_is_approved_false(self, db_request): organization = OrganizationFactory.create( name="example", @@ -345,7 +329,6 @@ def test_detail_is_approved_false(self, db_request): assert result["role_forms"] == {} assert isinstance(result["add_role_form"], views.AddOrganizationRoleForm) - @pytest.mark.usefixtures("_enable_organizations") def test_detail_not_found(self, db_request): db_request.matchdict = { "organization_id": "00000000-0000-0000-0000-000000000000" @@ -476,7 +459,6 @@ def test_does_not_update_with_invalid_form(self, db_request): assert "display_name" in result["form"].errors assert "link_url" in result["form"].errors - @pytest.mark.usefixtures("_enable_organizations") def test_detail_with_roles(self, db_request): """Test that organization detail view includes roles""" organization = OrganizationFactory.create(name="pypi") @@ -521,7 +503,6 @@ def test_detail_with_roles(self, db_request): assert isinstance(result["add_role_form"], views.AddOrganizationRoleForm) - @pytest.mark.usefixtures("_enable_organizations") def test_detail_no_roles(self, db_request): """Test that organization detail view works with no roles""" organization = OrganizationFactory.create(name="pypi") @@ -539,7 +520,6 @@ def test_detail_no_roles(self, db_request): class TestOrganizationActions: - @pytest.mark.usefixtures("_enable_organizations") def test_rename_not_found(self, db_request): admin = UserFactory.create() @@ -555,7 +535,6 @@ def test_rename_not_found(self, db_request): with pytest.raises(HTTPNotFound): views.organization_rename(db_request) - @pytest.mark.usefixtures("_enable_organizations") def test_rename(self, db_request): admin = UserFactory.create() organization = OrganizationFactory.create(name="example") @@ -579,7 +558,6 @@ def test_rename(self, db_request): assert result.status_code == 303 assert result.location == f"/admin/organizations/{organization.id}/" - @pytest.mark.usefixtures("_enable_organizations") def test_rename_fails_on_conflict(self, db_request): admin = UserFactory.create() OrganizationFactory.create(name="widget") @@ -606,7 +584,6 @@ def test_rename_fails_on_conflict(self, db_request): class TestOrganizationApplicationList: - @pytest.mark.usefixtures("_enable_organizations") def test_no_query(self, db_request): organization_applications = sorted( OrganizationApplicationFactory.create_batch(30), @@ -620,7 +597,6 @@ def test_no_query(self, db_request): "terms": [], } - @pytest.mark.usefixtures("_enable_organizations") def test_basic_query(self, db_request): organization_applications = sorted( OrganizationApplicationFactory.create_batch(5), @@ -633,7 +609,6 @@ def test_basic_query(self, db_request): assert result["query"] == organization_applications[0].name assert result["terms"] == [organization_applications[0].name] - @pytest.mark.usefixtures("_enable_organizations") def test_name_query(self, db_request): organization_applications = sorted( OrganizationApplicationFactory.create_batch(5), @@ -646,7 +621,6 @@ def test_name_query(self, db_request): assert result["query"] == f"name:{organization_applications[0].name}" assert result["terms"] == [f"name:{organization_applications[0].name}"] - @pytest.mark.usefixtures("_enable_organizations") def test_organization_application_query(self, db_request): organization_applications = sorted( OrganizationApplicationFactory.create_batch(5), @@ -666,7 +640,6 @@ def test_organization_application_query(self, db_request): f"organization:{organization_applications[0].display_name}" ] - @pytest.mark.usefixtures("_enable_organizations") def test_url_query(self, db_request): organization_applications = sorted( OrganizationApplicationFactory.create_batch(5), @@ -679,7 +652,6 @@ def test_url_query(self, db_request): assert result["query"] == f"url:{organization_applications[0].link_url}" assert result["terms"] == [f"url:{organization_applications[0].link_url}"] - @pytest.mark.usefixtures("_enable_organizations") def test_description_query(self, db_request): organization_applications = sorted( OrganizationApplicationFactory.create_batch(5), @@ -699,7 +671,6 @@ def test_description_query(self, db_request): f"description:{organization_applications[0].description}" ] - @pytest.mark.usefixtures("_enable_organizations") def test_is_approved_query(self, db_request): organization_applications = sorted( OrganizationApplicationFactory.create_batch(5), @@ -719,7 +690,6 @@ def test_is_approved_query(self, db_request): "terms": ["is:approved"], } - @pytest.mark.usefixtures("_enable_organizations") def test_is_declined_query(self, db_request): organization_applications = sorted( OrganizationApplicationFactory.create_batch(5), @@ -739,7 +709,6 @@ def test_is_declined_query(self, db_request): "terms": ["is:declined"], } - @pytest.mark.usefixtures("_enable_organizations") def test_is_submitted_query(self, db_request): organization_applications = sorted( OrganizationApplicationFactory.create_batch(5), @@ -759,7 +728,6 @@ def test_is_submitted_query(self, db_request): "terms": ["is:submitted"], } - @pytest.mark.usefixtures("_enable_organizations") def test_type_query(self, db_request): company_org = OrganizationApplicationFactory.create( orgtype=OrganizationType.Company @@ -785,7 +753,6 @@ def test_type_query(self, db_request): "terms": ["type:community"], } - @pytest.mark.usefixtures("_enable_organizations") def test_invalid_type_query(self, db_request): company_org = OrganizationApplicationFactory.create( orgtype=OrganizationType.Company @@ -800,7 +767,6 @@ def test_invalid_type_query(self, db_request): "terms": ["type:invalid"], } - @pytest.mark.usefixtures("_enable_organizations") def test_is_invalid_query(self, db_request): organization_applications = sorted( OrganizationApplicationFactory.create_batch(5), @@ -817,7 +783,6 @@ def test_is_invalid_query(self, db_request): class TestOrganizationApplicationDetail: - @pytest.mark.usefixtures("_enable_organizations") def test_detail(self, db_request): organization_application = OrganizationApplicationFactory.create() db_request.matchdict["organization_application_id"] = ( @@ -829,7 +794,6 @@ def test_detail(self, db_request): assert result["conflicting_applications"] == [] assert result["organization_application"] == organization_application - @pytest.mark.usefixtures("_enable_organizations") def test_detail_edit(self, db_request): organization_application = OrganizationApplicationFactory.create() db_request.matchdict["organization_application_id"] = ( @@ -861,7 +825,6 @@ def test_detail_edit(self, db_request): assert organization_application.name == new_org_name - @pytest.mark.usefixtures("_enable_organizations") def test_detail_edit_invalid(self, db_request): existing_organization = OrganizationFactory.create() organization_application = OrganizationApplicationFactory.create() @@ -881,7 +844,6 @@ def test_detail_edit_invalid(self, db_request): assert result["conflicting_applications"] == [] assert result["organization_application"] == organization_application - @pytest.mark.usefixtures("_enable_organizations") def test_detail_is_approved_true(self, db_request): organization_application = OrganizationApplicationFactory.create( status=OrganizationApplicationStatus.Approved @@ -895,7 +857,6 @@ def test_detail_is_approved_true(self, db_request): assert result["conflicting_applications"] == [] assert result["organization_application"] == organization_application - @pytest.mark.usefixtures("_enable_organizations") def test_detail_is_approved_false(self, db_request): organization_application = OrganizationApplicationFactory.create( status=OrganizationApplicationStatus.Declined @@ -909,7 +870,6 @@ def test_detail_is_approved_false(self, db_request): assert result["conflicting_applications"] == [] assert result["organization_application"] == organization_application - @pytest.mark.usefixtures("_enable_organizations") @pytest.mark.parametrize( ("name", "conflicts", "conflicting_prefixes", "not_conflicting"), [ @@ -945,7 +905,6 @@ def test_detail_conflicting_applications( assert set(result["conflicting_applications"]) == set(conflicting_applications) assert result["organization_application"] == organization_application - @pytest.mark.usefixtures("_enable_organizations") def test_detail_not_found(self): organization_service = pretend.stub( get_organization_application=lambda *a, **kw: None, @@ -974,7 +933,6 @@ def _organization_application_routes( class TestOrganizationApplicationActions: - @pytest.mark.usefixtures("_enable_organizations") def test_approve(self, db_request): admin = UserFactory.create() user = UserFactory.create() @@ -1018,7 +976,6 @@ def test_approve(self, db_request): assert result.status_code == 303 assert result.location == f"/admin/organizations/{organization.id}/" - @pytest.mark.usefixtures("_enable_organizations") def test_approve_turbo_mode(self, db_request): admin = UserFactory.create() user = UserFactory.create() @@ -1069,7 +1026,6 @@ def _approve(*a, **kw): assert result.status_code == 303 assert result.location == "/admin/" - @pytest.mark.usefixtures("_enable_organizations") def test_approve_not_found(self): organization_service = pretend.stub( get_organization_application=lambda *a, **kw: None, @@ -1083,7 +1039,6 @@ def test_approve_not_found(self): with pytest.raises(HTTPNotFound): views.organization_application_approve(request) - @pytest.mark.usefixtures("_enable_organizations") def test_defer(self, db_request): admin = UserFactory.create() user = UserFactory.create() @@ -1126,7 +1081,6 @@ def test_defer(self, db_request): == f"/admin/organization_applications/{organization_application.id}/" ) - @pytest.mark.usefixtures("_enable_organizations") def test_defer_turbo_mode(self, db_request): admin = UserFactory.create() user = UserFactory.create() @@ -1169,7 +1123,6 @@ def test_defer_turbo_mode(self, db_request): == f"/admin/organization_applications/{organization_application.id}/" ) - @pytest.mark.usefixtures("_enable_organizations") def test_defer_not_found(self): organization_service = pretend.stub( get_organization_application=lambda *a, **kw: None, @@ -1183,7 +1136,6 @@ def test_defer_not_found(self): with pytest.raises(HTTPNotFound): views.organization_application_defer(request) - @pytest.mark.usefixtures("_enable_organizations") def test_request_more_information(self, db_request): admin = UserFactory.create() user = UserFactory.create() @@ -1229,7 +1181,6 @@ def test_request_more_information(self, db_request): == f"/admin/organization_applications/{organization_application.id}/" ) - @pytest.mark.usefixtures("_enable_organizations") def test_request_more_information_turbo_mode(self, db_request): admin = UserFactory.create() user = UserFactory.create() @@ -1278,7 +1229,6 @@ def test_request_more_information_turbo_mode(self, db_request): == f"/admin/organization_applications/{organization_application.id}/" ) - @pytest.mark.usefixtures("_enable_organizations") def test_request_more_information_for_not_found(self): organization_service = pretend.stub( get_organization_application=lambda *a, **kw: None, @@ -1292,7 +1242,6 @@ def test_request_more_information_for_not_found(self): with pytest.raises(HTTPNotFound): views.organization_application_request_more_information(request) - @pytest.mark.usefixtures("_enable_organizations") def test_request_more_information_no_message(self, db_request): admin = UserFactory.create() user = UserFactory.create() @@ -1330,7 +1279,6 @@ def test_request_more_information_no_message(self, db_request): == f"/admin/organization_applications/{organization_application.id}/" ) - @pytest.mark.usefixtures("_enable_organizations") def test_decline(self, db_request): admin = UserFactory.create() user = UserFactory.create() @@ -1376,7 +1324,6 @@ def test_decline(self, db_request): == f"/admin/organization_applications/{organization_application.id}/" ) - @pytest.mark.usefixtures("_enable_organizations") def test_decline_turbo_mode(self, db_request): admin = UserFactory.create() user = UserFactory.create() @@ -1423,7 +1370,6 @@ def test_decline_turbo_mode(self, db_request): == f"/admin/organization_applications/{organization_application.id}/" ) - @pytest.mark.usefixtures("_enable_organizations") def test_decline_not_found(self): organization_service = pretend.stub( get_organization_application=lambda *a, **kw: None, @@ -2347,7 +2293,6 @@ def test_delete_manual_activation_organization_not_found( class TestSetUploadLimit: - @pytest.mark.usefixtures("_enable_organizations") def test_set_upload_limit_with_integer(self, db_request): organization = OrganizationFactory.create(name="foo") @@ -2369,7 +2314,6 @@ def test_set_upload_limit_with_integer(self, db_request): assert result.location == "/admin/organizations/1/" assert organization.upload_limit == 150 * views.ONE_MIB - @pytest.mark.usefixtures("_enable_organizations") def test_set_upload_limit_with_none(self, db_request): organization = OrganizationFactory.create(name="foo") organization.upload_limit = 150 * views.ONE_MIB @@ -2392,7 +2336,6 @@ def test_set_upload_limit_with_none(self, db_request): assert result.location == "/admin/organizations/1/" assert organization.upload_limit is None - @pytest.mark.usefixtures("_enable_organizations") def test_set_upload_limit_invalid_value(self, db_request): organization = OrganizationFactory.create(name="foo") @@ -2415,14 +2358,12 @@ def test_set_upload_limit_invalid_value(self, db_request): ] assert result.status_code == 303 - @pytest.mark.usefixtures("_enable_organizations") def test_set_upload_limit_not_found(self, db_request): db_request.matchdict["organization_id"] = "00000000-0000-0000-0000-000000000000" with pytest.raises(HTTPNotFound): views.set_upload_limit(db_request) - @pytest.mark.usefixtures("_enable_organizations") def test_set_upload_limit_above_cap(self, db_request): organization = OrganizationFactory.create(name="foo") @@ -2445,7 +2386,6 @@ def test_set_upload_limit_above_cap(self, db_request): ] assert result.status_code == 303 - @pytest.mark.usefixtures("_enable_organizations") def test_set_upload_limit_below_default(self, db_request): organization = OrganizationFactory.create(name="foo") @@ -2470,7 +2410,6 @@ def test_set_upload_limit_below_default(self, db_request): class TestSetTotalSizeLimit: - @pytest.mark.usefixtures("_enable_organizations") def test_set_total_size_limit_with_integer(self, db_request): organization = OrganizationFactory.create(name="foo") @@ -2492,7 +2431,6 @@ def test_set_total_size_limit_with_integer(self, db_request): assert result.location == "/admin/organizations/1/" assert organization.total_size_limit == 150 * views.ONE_GIB - @pytest.mark.usefixtures("_enable_organizations") def test_set_total_size_limit_with_none(self, db_request): organization = OrganizationFactory.create(name="foo") organization.total_size_limit = 150 * views.ONE_GIB @@ -2515,7 +2453,6 @@ def test_set_total_size_limit_with_none(self, db_request): assert result.location == "/admin/organizations/1/" assert organization.total_size_limit is None - @pytest.mark.usefixtures("_enable_organizations") def test_set_total_size_limit_invalid_value(self, db_request): organization = OrganizationFactory.create(name="foo") @@ -2538,14 +2475,12 @@ def test_set_total_size_limit_invalid_value(self, db_request): ] assert result.status_code == 303 - @pytest.mark.usefixtures("_enable_organizations") def test_set_total_size_limit_not_found(self, db_request): db_request.matchdict["organization_id"] = "00000000-0000-0000-0000-000000000000" with pytest.raises(HTTPNotFound): views.set_total_size_limit(db_request) - @pytest.mark.usefixtures("_enable_organizations") def test_set_total_size_limit_below_default(self, db_request): organization = OrganizationFactory.create(name="foo") diff --git a/tests/unit/manage/test_views.py b/tests/unit/manage/test_views.py index 34ac24b282af..62e4eabe2b21 100644 --- a/tests/unit/manage/test_views.py +++ b/tests/unit/manage/test_views.py @@ -2994,7 +2994,7 @@ def test_remove_organization_project_wrong_confirm(self): user=user, organization_access=True, session=pretend.stub(flash=pretend.call_recorder(lambda *a, **kw: None)), - route_path=lambda *a, **kw: "/foo/bar/", + route_path=pretend.call_recorder(lambda *a, **kw: "/foo/bar/"), ) with pytest.raises(HTTPSeeOther) as exc: @@ -3012,21 +3012,6 @@ def test_remove_organization_project_wrong_confirm(self): ) ] - def test_remove_organization_project_disable_organizations(self): - project = pretend.stub(name="foo", normalized_name="foo") - request = pretend.stub( - organization_access=False, - route_path=pretend.call_recorder(lambda *a, **kw: "/the-redirect"), - session=pretend.stub(flash=pretend.call_recorder(lambda *a, **kw: None)), - ) - - result = org_views.remove_organization_project(project, request) - - assert isinstance(result, HTTPSeeOther) - assert result.headers["Location"] == "/the-redirect" - assert request.session.flash.calls == [ - pretend.call("Organizations are disabled", queue="error") - ] assert request.route_path.calls == [ pretend.call("manage.project.settings", project_name="foo") ] @@ -3250,26 +3235,6 @@ def test_transfer_organization_project_wrong_confirm(self): ) ] - def test_transfer_organization_project_disable_organizations(self): - project = pretend.stub(name="foo", normalized_name="foo") - request = pretend.stub( - organization_access=False, - route_path=pretend.call_recorder(lambda *a, **kw: "/the-redirect"), - session=pretend.stub(flash=pretend.call_recorder(lambda *a, **kw: None)), - ) - - result = org_views.transfer_organization_project(project, request) - assert isinstance(result, HTTPSeeOther) - assert result.headers["Location"] == "/the-redirect" - - assert request.session.flash.calls == [ - pretend.call("Organizations are disabled", queue="error") - ] - - assert request.route_path.calls == [ - pretend.call("manage.project.settings", project_name="foo") - ] - def test_transfer_organization_project_no_current_organization( self, monkeypatch, db_request ): @@ -4808,7 +4773,7 @@ def test_delete_project_release_file_bad_confirm(self, db_request): class TestManageProjectRoles: @pytest.fixture - def organization(self, _enable_organizations, pyramid_user): + def organization(self, pyramid_user): organization = OrganizationFactory.create() OrganizationRoleFactory.create( organization=organization, diff --git a/tests/unit/manage/views/test_organizations.py b/tests/unit/manage/views/test_organizations.py index 846e8ecadb5f..2fd2b01f2fcc 100644 --- a/tests/unit/manage/views/test_organizations.py +++ b/tests/unit/manage/views/test_organizations.py @@ -387,17 +387,6 @@ def test_manage_organizations(self, monkeypatch): assert result == default_response - def test_manage_organizations_disable_organizations(self): - request = pretend.stub( - find_service=lambda *a, **kw: pretend.stub(), - organization_access=False, - ) - - view = org_views.ManageOrganizationsViews(request) - with pytest.raises(HTTPNotFound): - view.manage_organizations() - - @pytest.mark.usefixtures("_enable_organizations") def test_create_organization_application(self, monkeypatch): admins = [] user_service = pretend.stub( @@ -516,7 +505,6 @@ def test_create_organization_application(self, monkeypatch): ] assert isinstance(result, HTTPSeeOther) - @pytest.mark.usefixtures("_enable_organizations") def test_create_organization_application_with_subscription(self, monkeypatch): admins = [] user_service = pretend.stub( @@ -720,19 +708,8 @@ def test_create_organization_application_validation_fails(self, monkeypatch): "create_organization_application_form": create_organization_application_obj } - def test_create_organization_application_disable_organizations(self): - request = pretend.stub( - find_service=lambda *a, **kw: pretend.stub(), - organization_access=False, - ) - - view = org_views.ManageOrganizationsViews(request) - with pytest.raises(HTTPNotFound): - view.create_organization_application() - class TestManageOrganizationSettings: - @pytest.mark.usefixtures("_enable_organizations") def test_manage_organization(self, db_request, organization_service, monkeypatch): db_request.user = pretend.stub() organization = OrganizationFactory.create() @@ -779,7 +756,6 @@ def test_manage_organization(self, db_request, organization_service, monkeypatch ), ] - @pytest.mark.usefixtures("_enable_organizations") @pytest.mark.parametrize( ("orgtype", "has_customer"), [(orgtype, True) for orgtype in list(OrganizationType)] @@ -872,7 +848,6 @@ def test_save_organization( ), ] - @pytest.mark.usefixtures("_enable_organizations") def test_save_organization_validation_fails( self, db_request, organization_service, monkeypatch ): @@ -916,7 +891,6 @@ def test_save_organization_validation_fails( } assert organization_service.update_organization.calls == [] - @pytest.mark.usefixtures("_enable_organizations") def test_save_organization_name_wrong_confirm( self, db_request, organization_service, monkeypatch ): @@ -944,7 +918,6 @@ def test_save_organization_name_wrong_confirm( ) ] - @pytest.mark.usefixtures("_enable_organizations") def test_disable_save_organization_name( self, db_request, @@ -998,7 +971,6 @@ def test_disable_save_organization_name( assert send_email.calls == [] # When support for renaming orgs is re-introduced - # @pytest.mark.usefixtures("_enable_organizations") # def test_save_organization_name( # self, # db_request, @@ -1075,7 +1047,6 @@ def test_disable_save_organization_name( # ), # ] - # @pytest.mark.usefixtures("_enable_organizations") # def test_save_organization_name_validation_fails( # self, db_request, organization_service, monkeypatch # ): @@ -1120,7 +1091,6 @@ def test_disable_save_organization_name( # } # assert organization_service.rename_organization.calls == [] - @pytest.mark.usefixtures("_enable_organizations") def test_delete_organization( self, db_request, @@ -1171,7 +1141,6 @@ def test_delete_organization( ] assert db_request.route_path.calls == [pretend.call("manage.organizations")] - @pytest.mark.usefixtures("_enable_organizations") def test_delete_organization_with_active_projects( self, db_request, @@ -1216,7 +1185,6 @@ def test_delete_organization_with_active_projects( assert organization_service.delete_organization.calls == [] assert db_request.route_path.calls == [] - @pytest.mark.usefixtures("_enable_organizations") def test_delete_organization_with_subscriptions( self, db_request, @@ -1336,20 +1304,6 @@ def test_customer_id_local_mock( assert customer_id.startswith("mockcus_") - def test_disable_organizations( - self, - db_request, - billing_service, - subscription_service, - organization, - ): - db_request.organization_access = False - view = org_views.ManageOrganizationBillingViews(organization, db_request) - - with pytest.raises(HTTPNotFound): - view.create_or_manage_subscription() - - @pytest.mark.usefixtures("_enable_organizations") def test_activate_subscription( self, db_request, @@ -1376,7 +1330,6 @@ def test_activate_subscription( "form": organization_activate_billing_form_obj, } - @pytest.mark.usefixtures("_enable_organizations") def test_post_activate_subscription_valid( self, db_request, @@ -1397,7 +1350,6 @@ def test_post_activate_subscription_valid( assert isinstance(result, HTTPSeeOther) assert result.headers["Location"] == "mock-billing-url" - @pytest.mark.usefixtures("_enable_organizations") def test_post_activate_subscription_invalid( self, db_request, @@ -1416,7 +1368,6 @@ def test_post_activate_subscription_invalid( "Terms of Service must be accepted." ] - @pytest.mark.usefixtures("_enable_organizations") def test_create_subscription( self, db_request, @@ -1456,7 +1407,6 @@ def test_create_subscription( assert isinstance(result, HTTPSeeOther) assert result.headers["Location"] == "session-url" - @pytest.mark.usefixtures("_enable_organizations") def test_create_subscription_local_mock( self, db_request, @@ -1492,7 +1442,6 @@ def test_create_subscription_local_mock( assert isinstance(result, HTTPSeeOther) assert result.headers["Location"] == "mock-session-url" - @pytest.mark.usefixtures("_enable_organizations") def test_manage_subscription( self, db_request, @@ -1529,7 +1478,6 @@ def test_manage_subscription( assert isinstance(result, HTTPSeeOther) assert result.headers["Location"] == "session-url" - @pytest.mark.usefixtures("_enable_organizations") def test_manage_subscription_local_mock( self, db_request, @@ -1565,7 +1513,6 @@ def test_manage_subscription_local_mock( class TestManageOrganizationTeams: - @pytest.mark.usefixtures("_enable_organizations") def test_manage_teams( self, db_request, @@ -1589,7 +1536,6 @@ def test_manage_teams( "create_team_form": form, } - @pytest.mark.usefixtures("_enable_organizations") def test_create_team( self, db_request, @@ -1636,7 +1582,6 @@ def add_team(name, *args, **kwargs): ) ] - @pytest.mark.usefixtures("_enable_organizations") def test_create_team_invalid( self, db_request, @@ -1670,7 +1615,6 @@ def test_create_team_invalid( class TestManageOrganizationProjects: - @pytest.mark.usefixtures("_enable_organizations") def test_manage_organization_projects( self, db_request, @@ -1705,7 +1649,6 @@ def test_manage_organization_projects( } assert len(add_organization_project_cls.calls) == 1 - @pytest.mark.usefixtures("_enable_organizations") def test_add_organization_project_existing_project( self, db_request, @@ -1771,7 +1714,6 @@ def add_organization_project(*args, **kwargs): ) ] - @pytest.mark.usefixtures("_enable_organizations") def test_add_organization_project_existing_project_no_individual_owner( self, db_request, @@ -1836,7 +1778,6 @@ def add_organization_project(*args, **kwargs): ) ] - @pytest.mark.usefixtures("_enable_organizations") def test_add_organization_project_existing_project_invalid( self, db_request, @@ -1880,7 +1821,6 @@ def test_add_organization_project_existing_project_invalid( assert len(add_organization_project_cls.calls) == 1 assert len(organization.projects) == 1 - @pytest.mark.usefixtures("_enable_organizations") def test_add_organization_project_new_project( self, db_request, @@ -1939,7 +1879,6 @@ def test_add_organization_project_new_project( ) ] - @pytest.mark.usefixtures("_enable_organizations") @pytest.mark.parametrize( ("invalid_name", "expected"), [ @@ -2001,7 +1940,6 @@ def test_add_organization_project_new_project_exception( assert add_organization_project_obj.new_project_name.errors == [expected] assert len(organization.projects) == 1 - @pytest.mark.usefixtures("_enable_organizations") def test_add_organization_project_new_project_name_conflict( self, db_request, @@ -2058,7 +1996,6 @@ def test_add_organization_project_new_project_name_conflict( class TestManageOrganizationRoles: - @pytest.mark.usefixtures("_enable_organizations") def test_get_manage_organization_roles(self, db_request, pyramid_user): organization = OrganizationFactory.create(name="foobar") form_obj = pretend.stub() @@ -2077,7 +2014,6 @@ def form_class(*a, **kw): "organizations_with_sole_owner": [], } - @pytest.mark.usefixtures("_enable_organizations") @freeze_time(datetime.datetime.now(datetime.UTC)) @pytest.mark.parametrize("orgtype", list(OrganizationType)) def test_post_new_organization_role( @@ -2192,7 +2128,6 @@ def test_post_new_organization_role( ) ] - @pytest.mark.usefixtures("_enable_organizations") def test_post_duplicate_organization_role( self, db_request, organization_service, user_service ): @@ -2240,7 +2175,6 @@ def test_post_duplicate_organization_role( assert isinstance(result, HTTPSeeOther) - @pytest.mark.usefixtures("_enable_organizations") @pytest.mark.parametrize("with_email", [True, False]) def test_post_unverified_email( self, @@ -2292,7 +2226,6 @@ def test_post_unverified_email( assert isinstance(result, HTTPSeeOther) - @pytest.mark.usefixtures("_enable_organizations") def test_cannot_reinvite_organization_role( self, db_request, organization_service, user_service ): @@ -2354,7 +2287,6 @@ def test_cannot_reinvite_organization_role( ] assert isinstance(result, HTTPSeeOther) - @pytest.mark.usefixtures("_enable_organizations") @freeze_time(datetime.datetime.now(datetime.UTC)) def test_reinvite_organization_role_after_expiration( self, @@ -2483,7 +2415,6 @@ def test_reinvite_organization_role_after_expiration( ) ] - @pytest.mark.usefixtures("_enable_organizations") def test_manage_organization_roles_not_in_good_standing( self, db_request, monkeypatch ): @@ -2522,7 +2453,6 @@ def test_manage_organization_roles_not_in_good_standing( class TestResendOrganizationInvitations: - @pytest.mark.usefixtures("_enable_organizations") @freeze_time(datetime.datetime.now(datetime.UTC)) def test_resend_invitation(self, db_request, token_service, monkeypatch): organization = OrganizationFactory.create(name="foobar") @@ -2638,7 +2568,6 @@ def test_resend_invitation(self, db_request, token_service, monkeypatch): ) ] - @pytest.mark.usefixtures("_enable_organizations") def test_resend_invitation_fails_corrupt_token(self, db_request, token_service): organization = OrganizationFactory.create(name="foobar") user = UserFactory.create(username="testuser") @@ -2687,7 +2616,6 @@ def test_resend_invitation_fails_corrupt_token(self, db_request, token_service): assert isinstance(result, HTTPSeeOther) assert result.headers["Location"] == "/manage/organizations" - @pytest.mark.usefixtures("_enable_organizations") def test_resend_invitation_fails_missing_invitation( self, db_request, token_service ): @@ -2733,7 +2661,6 @@ def test_resend_invitation_fails_missing_invitation( class TestRevokeOrganizationInvitation: - @pytest.mark.usefixtures("_enable_organizations") def test_revoke_invitation(self, db_request, token_service, monkeypatch): organization = OrganizationFactory.create(name="foobar") user = UserFactory.create(username="testuser") @@ -2815,7 +2742,6 @@ def test_revoke_invitation(self, db_request, token_service, monkeypatch): assert isinstance(result, HTTPSeeOther) assert result.headers["Location"] == "/manage/organizations" - @pytest.mark.usefixtures("_enable_organizations") def test_invitation_does_not_exist(self, db_request, token_service): organization = OrganizationFactory.create(name="foobar") user = UserFactory.create(username="testuser") @@ -2847,7 +2773,6 @@ def test_invitation_does_not_exist(self, db_request, token_service): assert isinstance(result, HTTPSeeOther) assert result.headers["Location"] == "/manage/organizations" - @pytest.mark.usefixtures("_enable_organizations") def test_token_expired(self, db_request, token_service): organization = OrganizationFactory.create(name="foobar") user = UserFactory.create(username="testuser") @@ -2891,7 +2816,6 @@ def test_token_expired(self, db_request, token_service): class TestChangeOrganizationRole: - @pytest.mark.usefixtures("_enable_organizations") @pytest.mark.parametrize("orgtype", list(OrganizationType)) def test_change_role(self, db_request, orgtype, monkeypatch): organization = OrganizationFactory.create(name="foobar", orgtype=orgtype) @@ -2963,7 +2887,6 @@ def test_change_role(self, db_request, orgtype, monkeypatch): assert isinstance(result, HTTPSeeOther) assert result.headers["Location"] == "/the-redirect" - @pytest.mark.usefixtures("_enable_organizations") def test_change_organization_role_invalid_role_name(self, db_request): organization = OrganizationFactory.create(name="foobar") @@ -2983,7 +2906,6 @@ def test_change_organization_role_invalid_role_name(self, db_request): assert isinstance(result, HTTPSeeOther) assert result.headers["Location"] == "/the-redirect" - @pytest.mark.usefixtures("_enable_organizations") def test_change_missing_organization_role(self, db_request): organization = OrganizationFactory.create(name="foobar") missing_role_id = str(uuid.uuid4()) @@ -3004,7 +2926,6 @@ def test_change_missing_organization_role(self, db_request): assert isinstance(result, HTTPSeeOther) assert result.headers["Location"] == "/the-redirect" - @pytest.mark.usefixtures("_enable_organizations") def test_change_own_owner_organization_role(self, db_request): organization = OrganizationFactory.create(name="foobar") user = UserFactory.create(username="testuser") @@ -3030,7 +2951,6 @@ def test_change_own_owner_organization_role(self, db_request): class TestDeleteOrganizationRoles: - @pytest.mark.usefixtures("_enable_organizations") def test_delete_role(self, db_request, monkeypatch): organization = OrganizationFactory.create(name="foobar") user = UserFactory.create(username="testuser") @@ -3097,7 +3017,6 @@ def test_delete_role(self, db_request, monkeypatch): assert isinstance(result, HTTPSeeOther) assert result.headers["Location"] == "/the-redirect" - @pytest.mark.usefixtures("_enable_organizations") def test_delete_missing_role(self, db_request, monkeypatch): organization = OrganizationFactory.create(name="foobar") missing_role_id = str(uuid.uuid4()) @@ -3128,7 +3047,6 @@ def test_delete_missing_role(self, db_request, monkeypatch): assert isinstance(result, HTTPSeeOther) assert result.headers["Location"] == "/the-redirect" - @pytest.mark.usefixtures("_enable_organizations") def test_delete_other_role_as_nonowner(self, db_request): organization = OrganizationFactory.create(name="foobar") user = UserFactory.create(username="testuser") @@ -3161,7 +3079,6 @@ def test_delete_other_role_as_nonowner(self, db_request): assert isinstance(result, HTTPSeeOther) assert result.headers["Location"] == "/the-redirect" - @pytest.mark.usefixtures("_enable_organizations") def test_delete_own_owner_role(self, db_request): organization = OrganizationFactory.create(name="foobar") user = UserFactory.create(username="testuser") @@ -3187,7 +3104,6 @@ def test_delete_own_owner_role(self, db_request): assert isinstance(result, HTTPSeeOther) assert result.headers["Location"] == "/the-redirect" - @pytest.mark.usefixtures("_enable_organizations") def test_delete_non_owner_role(self, db_request): organization = OrganizationFactory.create(name="foobar") user = UserFactory.create(username="testuser") diff --git a/tests/unit/manage/views/test_teams.py b/tests/unit/manage/views/test_teams.py index 7b862b00a892..d3589309b716 100644 --- a/tests/unit/manage/views/test_teams.py +++ b/tests/unit/manage/views/test_teams.py @@ -36,7 +36,6 @@ class TestManageTeamSettings: - @pytest.mark.usefixtures("_enable_organizations") def test_manage_team(self, db_request, organization_service, user_service): team = TeamFactory.create() @@ -52,7 +51,6 @@ def test_manage_team(self, db_request, organization_service, user_service): "save_team_form": form, } - @pytest.mark.usefixtures("_enable_organizations") def test_save_team(self, db_request, pyramid_user, organization_service): team = TeamFactory.create(name="Team Name") db_request.POST = MultiDict({"name": "Team name"}) @@ -65,7 +63,6 @@ def test_save_team(self, db_request, pyramid_user, organization_service): assert result.headers["Location"] == "/foo/bar/" assert team.name == "Team name" - @pytest.mark.usefixtures("_enable_organizations") def test_save_team_validation_fails(self, db_request, organization_service): organization = OrganizationFactory.create() team = TeamFactory.create( @@ -92,7 +89,6 @@ def test_save_team_validation_fails(self, db_request, organization_service): "This team name has already been used. Choose a different team name." ] - @pytest.mark.usefixtures("_enable_organizations") def test_delete_team( self, db_request, @@ -122,7 +118,6 @@ def test_delete_team( ), ] - @pytest.mark.usefixtures("_enable_organizations") def test_delete_team_no_confirm( self, db_request, @@ -146,7 +141,6 @@ def test_delete_team_no_confirm( pretend.call("Confirm the request", queue="error") ] - @pytest.mark.usefixtures("_enable_organizations") def test_delete_team_wrong_confirm( self, db_request, @@ -178,7 +172,6 @@ def test_delete_team_wrong_confirm( class TestManageTeamProjects: - @pytest.mark.usefixtures("_enable_organizations") def test_manage_team_projects( self, db_request, @@ -207,7 +200,6 @@ def test_manage_team_projects( class TestManageTeamRoles: - @pytest.mark.usefixtures("_enable_organizations") def test_manage_team_roles( self, db_request, @@ -228,7 +220,6 @@ def test_manage_team_roles( "form": form, } - @pytest.mark.usefixtures("_enable_organizations") def test_create_team_role( self, db_request, @@ -311,7 +302,6 @@ def test_create_team_role( ] assert isinstance(result, HTTPSeeOther) - @pytest.mark.usefixtures("_enable_organizations") def test_create_team_role_duplicate_member( self, db_request, @@ -363,7 +353,6 @@ def test_create_team_role_duplicate_member( "form": form, } - @pytest.mark.usefixtures("_enable_organizations") def test_create_team_role_not_a_member( self, db_request, @@ -405,7 +394,6 @@ def test_create_team_role_not_a_member( assert form.username.errors == ["Not a valid choice."] - @pytest.mark.usefixtures("_enable_organizations") def test_delete_team_role( self, db_request, @@ -488,7 +476,6 @@ def test_delete_team_role( ] assert isinstance(result, HTTPSeeOther) - @pytest.mark.usefixtures("_enable_organizations") def test_delete_team_role_not_a_member( self, db_request, @@ -539,7 +526,6 @@ def test_delete_team_role_not_a_member( ] assert isinstance(result, HTTPSeeOther) - @pytest.mark.usefixtures("_enable_organizations") def test_delete_team_role_not_a_manager( self, db_request, @@ -707,7 +693,7 @@ def test_raises_404_with_out_of_range_page(self, db_request): class TestChangeTeamProjectRole: @pytest.fixture - def organization(self, _enable_organizations, pyramid_user): + def organization(self, pyramid_user): organization = OrganizationFactory.create() OrganizationRoleFactory.create( organization=organization, @@ -898,7 +884,7 @@ def test_change_own_owner_role( class TestDeleteTeamProjectRole: @pytest.fixture - def organization(self, _enable_organizations, pyramid_user): + def organization(self, pyramid_user): organization = OrganizationFactory.create() OrganizationRoleFactory.create( organization=organization, diff --git a/tests/unit/mock/test_billing.py b/tests/unit/mock/test_billing.py index 5d63b4e3a1b2..1478ea96f0fe 100644 --- a/tests/unit/mock/test_billing.py +++ b/tests/unit/mock/test_billing.py @@ -1,5 +1,6 @@ # SPDX-License-Identifier: Apache-2.0 +import pretend import pytest from pyramid.httpexceptions import HTTPNotFound, HTTPSeeOther @@ -14,26 +15,27 @@ class TestMockBillingViews: def organization(self): return OrganizationFactory.create() - def test_disable_organizations(self, db_request, organization): - db_request.organization_access = False + def test_not_mock_billing_service_raises_404(self, db_request, organization): + # Test HTTPNotFound when billing service is not MockStripeBillingService + db_request.find_service = pretend.call_recorder( + lambda *a, **kw: pretend.stub() # Not MockStripeBillingService + ) + with pytest.raises(HTTPNotFound): billing.MockBillingViews(organization, db_request) - @pytest.mark.usefixtures("_enable_organizations") def test_mock_checkout_session(self, db_request, organization): view = billing.MockBillingViews(organization, db_request) result = view.mock_checkout_session() assert result == {"organization": organization} - @pytest.mark.usefixtures("_enable_organizations") def test_mock_portal_session(self, db_request, organization): view = billing.MockBillingViews(organization, db_request) result = view.mock_portal_session() assert result == {"organization": organization} - @pytest.mark.usefixtures("_enable_organizations") def test_mock_trigger_checkout_session_completed( self, db_request, organization, monkeypatch ): diff --git a/tests/unit/test_predicates.py b/tests/unit/test_predicates.py index 9b619a36685a..907c06e32dc9 100644 --- a/tests/unit/test_predicates.py +++ b/tests/unit/test_predicates.py @@ -132,11 +132,6 @@ def test_disable_predicate(self, db_request, organization): predicate = ActiveOrganizationPredicate(False, None) assert predicate(organization, db_request) - def test_disable_organizations(self, db_request, organization): - predicate = ActiveOrganizationPredicate(True, None) - assert not predicate(organization, db_request) - - @pytest.mark.usefixtures("_enable_organizations") def test_inactive_organization( self, db_request, @@ -153,7 +148,6 @@ def test_inactive_organization( assert db_request.route_path.calls == [pretend.call("manage.organizations")] - @pytest.mark.usefixtures("_enable_organizations") def test_inactive_subscription( self, db_request, @@ -170,7 +164,6 @@ def test_inactive_subscription( assert db_request.route_path.calls == [pretend.call("manage.organizations")] - @pytest.mark.usefixtures("_enable_organizations") def test_active_subscription( self, db_request, @@ -180,7 +173,6 @@ def test_active_subscription( predicate = ActiveOrganizationPredicate(True, None) assert predicate(organization, db_request) - @pytest.mark.usefixtures("_enable_organizations") def test_active_manual_activation( self, db_request, @@ -201,7 +193,6 @@ def test_active_manual_activation( predicate = ActiveOrganizationPredicate(True, None) assert predicate(organization, db_request) - @pytest.mark.usefixtures("_enable_organizations") def test_expired_manual_activation( self, db_request, diff --git a/warehouse/accounts/__init__.py b/warehouse/accounts/__init__.py index 0765f3bb9058..9e5748d478a7 100644 --- a/warehouse/accounts/__init__.py +++ b/warehouse/accounts/__init__.py @@ -29,7 +29,6 @@ unverify_emails_with_expired_domains, ) from warehouse.accounts.utils import UserContext -from warehouse.admin.flags import AdminFlagValue from warehouse.macaroons.security_policy import MacaroonSecurityPolicy from warehouse.oidc.utils import PublisherTokenContext from warehouse.organizations.services import IOrganizationService @@ -79,10 +78,7 @@ def _organization_access(request): organization_service = request.find_service(IOrganizationService, context=None) organizations = organization_service.get_organizations_by_user(user.id) - return ( - not request.flags.enabled(AdminFlagValue.DISABLE_ORGANIZATIONS) - or len(organizations) > 0 - ) + return len(organizations) > 0 def _unauthenticated_userid(request): diff --git a/warehouse/admin/flags.py b/warehouse/admin/flags.py index 83c5350a1b2b..2ea323b16b1c 100644 --- a/warehouse/admin/flags.py +++ b/warehouse/admin/flags.py @@ -9,7 +9,6 @@ class AdminFlagValue(enum.Enum): - DISABLE_ORGANIZATIONS = "disable-organizations" DISABLE_PEP740 = "disable-pep740" DISALLOW_DELETION = "disallow-deletion" DISALLOW_NEW_PROJECT_REGISTRATION = "disallow-new-project-registration" diff --git a/warehouse/locale/messages.pot b/warehouse/locale/messages.pot index 9fe7b6da9720..2abe101a5551 100644 --- a/warehouse/locale/messages.pot +++ b/warehouse/locale/messages.pot @@ -621,13 +621,13 @@ msgid "" msgstr "" #: warehouse/manage/views/__init__.py:2951 -#: warehouse/manage/views/organizations.py:962 +#: warehouse/manage/views/organizations.py:951 #, python-brace-format msgid "User '${username}' already has an active invite. Please try again later." msgstr "" #: warehouse/manage/views/__init__.py:3016 -#: warehouse/manage/views/organizations.py:1037 +#: warehouse/manage/views/organizations.py:1026 #, python-brace-format msgid "Invitation sent to '${username}'" msgstr "" @@ -641,37 +641,37 @@ msgid "Invitation already expired." msgstr "" #: warehouse/manage/views/__init__.py:3092 -#: warehouse/manage/views/organizations.py:1224 +#: warehouse/manage/views/organizations.py:1213 #, python-brace-format msgid "Invitation revoked from '${username}'." msgstr "" -#: warehouse/manage/views/organizations.py:938 +#: warehouse/manage/views/organizations.py:927 #, python-brace-format msgid "User '${username}' already has ${role_name} role for organization" msgstr "" -#: warehouse/manage/views/organizations.py:949 +#: warehouse/manage/views/organizations.py:938 #, python-brace-format msgid "" "User '${username}' does not have a verified primary email address and " "cannot be added as a ${role_name} for organization" msgstr "" -#: warehouse/manage/views/organizations.py:973 +#: warehouse/manage/views/organizations.py:962 msgid "Cannot invite new member. Organization is not in good standing." msgstr "" -#: warehouse/manage/views/organizations.py:1119 -#: warehouse/manage/views/organizations.py:1161 +#: warehouse/manage/views/organizations.py:1108 +#: warehouse/manage/views/organizations.py:1150 msgid "Could not find organization invitation." msgstr "" -#: warehouse/manage/views/organizations.py:1129 +#: warehouse/manage/views/organizations.py:1118 msgid "Organization invitation could not be re-sent." msgstr "" -#: warehouse/manage/views/organizations.py:1177 +#: warehouse/manage/views/organizations.py:1166 #, python-brace-format msgid "Expired invitation for '${username}' deleted." msgstr "" diff --git a/warehouse/manage/views/organizations.py b/warehouse/manage/views/organizations.py index db0f68e76a5f..fed21db15693 100644 --- a/warehouse/manage/views/organizations.py +++ b/warehouse/manage/views/organizations.py @@ -199,10 +199,6 @@ def default_response(self): @view_config(request_method="GET") def manage_organizations(self): - # Organizations must be enabled. - if not self.request.organization_access: - raise HTTPNotFound() - return self.default_response @view_config( @@ -210,9 +206,6 @@ def manage_organizations(self): request_param=CreateOrganizationApplicationForm.__params__, ) def create_organization_application(self): - # Organizations must be enabled. - if not self.request.organization_access: - raise HTTPNotFound() form = CreateOrganizationApplicationForm( self.request.POST, @@ -641,10 +634,6 @@ def activate_subscription(self): @view_config(route_name="manage.organization.subscription") def create_or_manage_subscription(self): - # Organizations must be enabled. - if not self.request.organization_access: - raise HTTPNotFound() - if not self.organization.manageable_subscription: # Create subscription if there are no manageable subscription. # This occurs if no subscription exists, or all subscriptions have reached @@ -1451,12 +1440,6 @@ def manage_organization_history(organization, request): require_reauth=True, ) def remove_organization_project(project, request): - if not request.organization_access: - request.session.flash("Organizations are disabled", queue="error") - return HTTPSeeOther( - request.route_path("manage.project.settings", project_name=project.name) - ) - if ( # Check that user has permission to remove projects from organization. (project.organization and request.user not in project.organization.owners) @@ -1545,12 +1528,6 @@ def remove_organization_project(project, request): require_reauth=True, ) def transfer_organization_project(project, request): - if not request.organization_access: - request.session.flash("Organizations are disabled", queue="error") - return HTTPSeeOther( - request.route_path("manage.project.settings", project_name=project.name) - ) - # Check that user has permission to remove projects from organization. if project.organization and request.user not in project.organization.owners: request.session.flash( diff --git a/warehouse/mock/billing.py b/warehouse/mock/billing.py index 3b65693c05c8..8da5da09a838 100644 --- a/warehouse/mock/billing.py +++ b/warehouse/mock/billing.py @@ -25,9 +25,7 @@ class MockBillingViews: def __init__(self, organization, request): billing_service = request.find_service(IBillingService, context=None) - if not request.organization_access or not isinstance( - billing_service, MockStripeBillingService - ): + if not isinstance(billing_service, MockStripeBillingService): raise HTTPNotFound self.organization = organization self.request = request diff --git a/warehouse/predicates.py b/warehouse/predicates.py index 275af978e6b9..35a19e7c0fe3 100644 --- a/warehouse/predicates.py +++ b/warehouse/predicates.py @@ -5,7 +5,6 @@ from pyramid.httpexceptions import HTTPSeeOther from pyramid.util import is_same_domain -from warehouse.admin.flags import AdminFlagValue from warehouse.organizations.models import Organization, Team @@ -57,12 +56,10 @@ def text(self): phash = text def __call__(self, context: Organization | Team, request): - """Check organizations are enabled globally and this organization is - operational. + """Check that this organization is operational. - 1. `AdminFlagValue.DISABLE_ORGANIZATIONS` flag is off. - 2. Organization is operational (uses consolidated is_in_good_standing() - method). + Organization is operational (uses consolidated is_in_good_standing() + method). """ if self.val is False: @@ -74,11 +71,6 @@ def __call__(self, context: Organization | Team, request): if organization.is_in_good_standing(): return True - elif ( - # Organization accounts are disabled. - request.flags.enabled(AdminFlagValue.DISABLE_ORGANIZATIONS) - ): - return False else: raise HTTPSeeOther(request.route_path("manage.organizations"))