Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sshin/fix/1859 add tests #963

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
22 changes: 21 additions & 1 deletion graphql_api/tests/test_owner.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,26 @@ def test_fetch_owner_on_unauthenticated_enteprise_guest_access(self):
assert e.message == UnauthorizedGuestAccess.message
assert e.extensions["code"] == UnauthorizedGuestAccess.code

@override_settings(IS_ENTERPRISE=True, GUEST_ACCESS=False)
def test_fetch_owner_enterprise_no_guest_access(self):
user = OwnerFactory(username="sample-user")
owner = OwnerFactory(username="sample-owner", plan_activated_users=[123, 456])
user.save()
owner.save()
query = """{
owner(username: "%s") {
isCurrentUserActivated
}
}
""" % (owner.username)

try:
self.gql_request(query, owner=user)

except GraphQLError as e:
assert e.message == UnauthorizedGuestAccess.message
assert e.extensions["code"] == UnauthorizedGuestAccess.code

def test_fetch_current_user_is_okta_authenticated(self):
account = AccountFactory()
owner = OwnerFactory(username="sample-owner", service="github", account=account)
Expand Down Expand Up @@ -843,7 +863,7 @@ def test_fetch_current_user_is_not_okta_authenticated_no_account(self):

@patch("shared.rate_limits.determine_entity_redis_key")
@patch("shared.rate_limits.determine_if_entity_is_rate_limited")
@override_settings(IS_ENTERPRISE=True, GUEST_ACCESS=False)
@override_settings(IS_ENTERPRISE=True, GUEST_ACCESS=True)
def test_fetch_is_github_rate_limited(
self, mock_determine_rate_limit, mock_determine_redis_key
):
Expand Down
Loading
Loading