Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 0 additions & 2 deletions tests/functional/manage/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import faker
import pretend
import pytest

from webob.multidict import MultiDict

Expand Down Expand Up @@ -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,
Expand Down
14 changes: 5 additions & 9 deletions tests/unit/accounts/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Loading
Loading