This repository was archived by the owner on Jun 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -806,6 +806,26 @@ def test_fetch_owner_on_unauthenticated_enteprise_guest_access_not_activated(sel
806806 assert e .message == UnauthorizedGuestAccess .message
807807 assert e .extensions ["code" ] == UnauthorizedGuestAccess .code
808808
809+ @override_settings (IS_ENTERPRISE = True , GUEST_ACCESS = False )
810+ def test_fetch_owner_plan_activated_users_is_none (self ):
811+ """
812+ This test is when Enterprise guest access is disabled, and you are
813+ trying to view an org that does not track plan activated users (e.g., historic data)
814+ """
815+ user = OwnerFactory (username = "sample-user" )
816+ owner = OwnerFactory (username = "sample-owner" , plan_activated_users = None )
817+ user .save ()
818+ owner .save ()
819+ query = """{
820+ owner(username: "%s") {
821+ username
822+ }
823+ }
824+ """ % (owner .username )
825+
826+ data = self .gql_request (query , owner = user )
827+ assert data ["owner" ]["username" ] == "sample-owner"
828+
809829 def test_fetch_current_user_is_okta_authenticated (self ):
810830 account = AccountFactory ()
811831 owner = OwnerFactory (username = "sample-owner" , service = "github" , account = account )
Original file line number Diff line number Diff line change @@ -52,8 +52,17 @@ async def resolve_owner(
5252 if not user or not user .is_authenticated :
5353 raise UnauthorizedGuestAccess ()
5454
55- target = await get_owner (service , username )
56- if user .ownerid not in target .plan_activated_users :
55+ # if the owner tracks plan activated users, check if the user is in the list
56+ target_owner = await get_owner (service , username )
57+ has_plan_activated_users = (
58+ target_owner
59+ and target_owner .plan_activated_users is not None
60+ and len (target_owner .plan_activated_users ) > 0
61+ )
62+ if (
63+ has_plan_activated_users
64+ and user .ownerid not in target_owner .plan_activated_users
65+ ):
5766 raise UnauthorizedGuestAccess ()
5867
5968 return await get_owner (service , username )
You can’t perform that action at this time.
0 commit comments