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

mozilla / fx-private-relay / b2e067fe-ce4e-4099-9bef-07b368e99782

15 Apr 2024 04:18PM CUT coverage: 75.544% (+0.002%) from 75.542%
b2e067fe-ce4e-4099-9bef-07b368e99782

push

circleci

jwhitlock
Enable pyupgrade, fix issues

2443 of 3405 branches covered (71.75%)

Branch coverage included in aggregate %.

56 of 59 new or added lines in 14 files covered. (94.92%)

234 existing lines in 24 files now uncovered.

6793 of 8821 relevant lines covered (77.01%)

20.04 hits per line

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

82.05
/privaterelay/allauth.py
1
import logging
1✔
2
from urllib.parse import urlencode, urlparse
1✔
3

4
from django.http import Http404
1✔
5
from django.shortcuts import resolve_url
1✔
6
from django.urls import resolve
1✔
7

8
from allauth.account.adapter import DefaultAccountAdapter
1✔
9

10
from .middleware import RelayStaticFilesMiddleware
1✔
11

12
logger = logging.getLogger("events")
1✔
13

14

15
class AccountAdapter(DefaultAccountAdapter):
1✔
16
    def get_login_redirect_url(self, request):
1✔
17
        """
18
        Redirect to dashboard, preserving utm params from FXA.
19
        """
UNCOV
20
        assert request.user.is_authenticated
×
21
        url = "/accounts/profile/?"
×
22
        utm_params = {k: v for k, v in request.GET.items() if k.startswith("utm")}
×
23
        url += urlencode(utm_params)
×
24
        return resolve_url(url)
×
25

26
    def is_safe_url(self, url: str | None) -> bool:
1✔
27
        """Check if the redirect URL is a safe URL."""
28
        # Is the domain valid?
29
        if not super().is_safe_url(url):
1✔
30
            return False
1✔
31

32
        # Is this a known Django path?
33
        path = urlparse(url or "").path
1✔
34
        try:
1✔
35
            resolve(path)  # Is this a known Django path?
1✔
36
            return True
1✔
37
        except Http404:
1✔
38
            pass
1✔
39

40
        # Is this a known frontend path?
41
        try:
1✔
42
            middleware = RelayStaticFilesMiddleware()
1✔
43
        except Exception:
1✔
44
            # Staticfiles are not available
45
            pass
1✔
46
        else:
47
            found = middleware.find_file(path)
1✔
48
            if found:
1✔
49
                return True
1✔
50

51
        # The path is invalid
52
        logger.error("No matching URL for '%s'", url)
1✔
53
        return False
1✔
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