• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

smartfile / django-session-jwt / 4120103744

pending completion
4120103744

Pull #47

github

GitHub
Merge 35e258ac2 into 1a507ba87
Pull Request #47: Bump cryptography from 35.0.0 to 39.0.1

278 of 291 relevant lines covered (95.53%)

26.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/django_session_jwt/test.py
1
from importlib import import_module
28✔
2

3
from django.conf import settings
28✔
4
from django.test.client import Client as BaseClient
28✔
5
from django.contrib.auth import SESSION_KEY, get_user_model
28✔
6

7
from django_session_jwt.middleware import convert_cookie, verify_jwt
28✔
8

9

10
User = get_user_model()
28✔
11

12

13
class Client(BaseClient):
28✔
14
    def login(self, **credentials):
28✔
15
        ret = super(Client, self).login(**credentials)
28✔
16
        if ret:
28✔
17
            user = User.objects.get(id=int(self.session[SESSION_KEY]))
28✔
18
            convert_cookie(self.cookies, user)
28✔
19
        return ret
28✔
20

21
    @property
28✔
22
    def session(self):
28✔
23
        """
24
        Obtains the current session variables.
25
        """
26
        engine = import_module(settings.SESSION_ENGINE)
28✔
27
        cookie = self.cookies.get(settings.SESSION_COOKIE_NAME)
28✔
28
        if cookie:
28✔
29
            sk = verify_jwt(cookie.value).get('sk', cookie.value)
28✔
30
            return engine.SessionStore(sk)
28✔
31

32
        session = engine.SessionStore()
28✔
33
        session.save()
28✔
34
        self.cookies[settings.SESSION_COOKIE_NAME] = session.session_key
28✔
35
        return session
28✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc