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

observatorycontrolsystem / ocs-authentication / 10325886202

09 Aug 2024 09:21PM UTC coverage: 86.348% (+5.6%) from 80.714%
10325886202

Pull #4

github

Jon
Removed auth classes from server called endpoint since its all handled by the permission
Pull Request #4: Ignore throttling from clients

3 of 4 new or added lines in 1 file covered. (75.0%)

1 existing line in 1 file now uncovered.

506 of 586 relevant lines covered (86.35%)

2.59 hits per line

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

96.97
/ocs_authentication/settings.py
1
from django.conf import settings as django_settings
3✔
2
from django.core.signals import setting_changed
3✔
3

4

5
DEFAULT_SETTINGS = {
3✔
6
    'OAUTH_TOKEN_URL': '',
3✔
7
    'OAUTH_PROFILE_URL': '',
3✔
8
    'OAUTH_CLIENT_ID': '',
3✔
9
    'OAUTH_CLIENT_SECRET': '',
3✔
10
    'OAUTH_SERVER_KEY': '',
3✔
11
    'REQUESTS_TIMEOUT_SECONDS': 60
3✔
12
}
13

14

15
class OCSAuthSettings:
3✔
16
    namespace = 'OCS_AUTHENTICATION'
3✔
17

18
    def __init__(self, default_settings=None) -> None:
3✔
19
        self.default_settings = DEFAULT_SETTINGS if default_settings is None else default_settings
3✔
20
        self._cached_settings = set()
3✔
21
        self.load()
3✔
22

23
    def load(self) -> None:
3✔
24
        # Clear out the current settings - they will be replaced
25
        for setting in self._cached_settings:
3✔
26
            if hasattr(self, setting):
3✔
27
                delattr(self, setting)
3✔
28
        self._cached_settings.clear()
3✔
29
        # Set the settings
30
        user_specified_settings = getattr(django_settings, self.namespace, {})
3✔
31
        for setting in self.default_settings:
3✔
32
            if setting in user_specified_settings:
3✔
33
                setattr(self, setting, user_specified_settings[setting])
3✔
34
            else:
×
35
                setattr(self, setting, self.default_settings[setting])
3✔
36
            self._cached_settings.add(setting)
3✔
37

38

39
ocs_auth_settings = OCSAuthSettings()
3✔
40

41

42
def reload_settings(*args, **kwargs):
3✔
43
    setting = kwargs.get('setting')
3✔
44
    if setting == OCSAuthSettings.namespace:
3✔
45
        ocs_auth_settings.load()
3✔
46

47

48
setting_changed.connect(reload_settings)
3✔
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