Skip to content

Commit

Permalink
add another test
Browse files Browse the repository at this point in the history
Signed-off-by: JerrySentry <jerry.feng@sentry.io>
  • Loading branch information
JerrySentry committed May 15, 2024
1 parent 92130f2 commit 53ff7fe
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions graphql_api/tests/mutation/test_delete_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,31 @@ def test_when_authenticated(self):
query, owner=self.owner, variables={"input": {"sessionid": sessionid}}
)
assert len(Session.objects.filter(sessionid=sessionid)) == 0

def test_when_authenticated_session_not_valid(self):
user = UserFactory()
self.owner.user = user
self.owner.save()

login_query = "{ me { user { username }} }"
self.gql_request(login_query, owner=self.owner)

user = auth.get_user(self.client)
assert user.is_authenticated

django_session_id = DjangoSession.objects.all()
assert len(django_session_id) == 1

django_session_id = django_session_id[0]

Session.objects.create(
lastseen=timezone.now(),
useragent="Firefox",
ip="0.0.0.0",
login_session=django_session_id,
type=Session.SessionType.LOGIN,
owner=self.owner,
).sessionid

self.gql_request(query, owner=self.owner, variables={"input": {"sessionid": 0}})
assert len(Session.objects.all()) == 1

0 comments on commit 53ff7fe

Please sign in to comment.