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

mozilla / fx-private-relay / d3128616-238d-446e-82c5-ab66cd38ceaf

09 May 2024 06:22PM CUT coverage: 84.07% (-0.6%) from 84.64%
d3128616-238d-446e-82c5-ab66cd38ceaf

push

circleci

web-flow
Merge pull request #4684 from mozilla/enable-flak8-bandit-checks-mpp-3802

fix MPP-3802: stop ignoring bandit security checks

3601 of 4734 branches covered (76.07%)

Branch coverage included in aggregate %.

74 of 158 new or added lines in 24 files covered. (46.84%)

5 existing lines in 5 files now uncovered.

14686 of 17018 relevant lines covered (86.3%)

10.86 hits per line

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

54.69
/phones/apps.py
1
import logging
1✔
2

3
from django.apps import AppConfig, apps
1✔
4
from django.conf import settings
1✔
5
from django.utils.functional import cached_property
1✔
6

7
from twilio.base.instance_resource import InstanceResource
1✔
8
from twilio.request_validator import RequestValidator
1✔
9
from twilio.rest import Client
1✔
10

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

13

14
class PhonesConfig(AppConfig):
1✔
15
    name = "phones"
1✔
16

17
    @cached_property
1✔
18
    def twilio_client(self) -> Client:
1✔
19
        if not all((settings.TWILIO_ACCOUNT_SID, settings.TWILIO_AUTH_TOKEN)):
×
20
            raise Exception("Must define TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN")
×
21
        return Client(settings.TWILIO_ACCOUNT_SID, settings.TWILIO_AUTH_TOKEN)
×
22

23
    @cached_property
1✔
24
    def twiml_app(self) -> InstanceResource:
1✔
25
        if not settings.TWILIO_SMS_APPLICATION_SID:
×
26
            raise Exception("Must define TWILIO_SMS_APPLICATION_SID")
×
27
        instance = self.twilio_client.applications(
×
28
            settings.TWILIO_SMS_APPLICATION_SID
29
        ).fetch()
NEW
30
        if not isinstance(instance, InstanceResource):
×
NEW
31
            raise TypeError("instance must be type InstanceResource")
×
UNCOV
32
        return instance
×
33

34
    @cached_property
1✔
35
    def twilio_test_client(self) -> Client:
1✔
36
        if not all((settings.TWILIO_TEST_ACCOUNT_SID, settings.TWILIO_TEST_AUTH_TOKEN)):
×
37
            raise Exception(
×
38
                "Must define TWILIO_TEST_ACCOUNT_SID, TWILIO_TEST_AUTH_TOKEN"
39
            )
40
        return Client(settings.TWILIO_TEST_ACCOUNT_SID, settings.TWILIO_TEST_AUTH_TOKEN)
×
41

42
    @cached_property
1✔
43
    def twilio_validator(self) -> RequestValidator:
1✔
44
        if not settings.TWILIO_AUTH_TOKEN:
×
45
            raise Exception("Must define TWILIO_AUTH_TOKEN")
×
46
        return RequestValidator(settings.TWILIO_AUTH_TOKEN)
×
47

48

49
def phones_config() -> PhonesConfig:
1✔
50
    phones_config = apps.get_app_config("phones")
1✔
51
    if not isinstance(phones_config, PhonesConfig):
1!
NEW
52
        raise TypeError("phones_config must be type PhonesConfig")
×
53
    return phones_config
1✔
54

55

56
def twilio_client() -> Client:
1✔
57
    if settings.PHONES_NO_CLIENT_CALLS_IN_TEST:
1!
NEW
58
        raise ValueError(
×
59
            "settings.PHONES_NO_CLIENT_CALLS_IN_TEST must be False when "
60
            "calling twilio_client()"
61
        )
62
    return phones_config().twilio_client
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