Skip to content

Commit

Permalink
Fix warnings in develop-aplus tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelGusse committed May 24, 2024
1 parent 21fa00d commit 0982189
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 0 additions & 1 deletion aplus/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@
]
TIME_ZONE = 'EET'
USE_I18N = True
USE_L10N = True
USE_TZ = True
FORMAT_MODULE_PATH = 'aplus'
LOCALE_PATHS = (
Expand Down
6 changes: 4 additions & 2 deletions edit_course/operations/clone.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import logging

from datetime import datetime
from django.utils import timezone
from django.db import transaction
from django.contrib.auth.models import User
from course.models import CourseInstance
Expand Down Expand Up @@ -34,8 +36,8 @@ def set_sis(instance: CourseInstance, id: str, enroll: bool) -> None: # pylint:
return

if coursedata.get('starting_time') and coursedata.get('ending_time'):
instance.starting_time = coursedata['starting_time']
instance.ending_time = coursedata['ending_time']
instance.starting_time = timezone.make_aware(datetime.strptime(coursedata['starting_time'], '%Y-%m-%d'))
instance.ending_time = timezone.make_aware(datetime.strptime(coursedata['ending_time'], '%Y-%m-%d'))

instance.sis_id = id
instance.sis_enroll = enroll
Expand Down
5 changes: 3 additions & 2 deletions external_services/api/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ def verify_oauth_body_hash_and_signature(request, req_body_hash, lti_exercise=No

# check the OAuth timestamp. Do not allow old requests in order to prevent replay attacks.
try:
timestamp = datetime.datetime.utcfromtimestamp(int(req_oauth_params_dict.get('oauth_timestamp')))
timestamp = datetime.datetime.fromtimestamp(int(req_oauth_params_dict.get('oauth_timestamp')),
datetime.timezone.utc)
# oauth_timestamp: seconds since January 1, 1970 00:00:00 GMT
except ValueError:
return False, 'oauth_timestamp is missing or has an invalid format'

now = datetime.datetime.utcnow()
now = datetime.datetime.now(datetime.timezone.utc)
delta = datetime.timedelta(seconds=OAuthNonceCache.CACHE_TIMEOUT_SECONDS)
if not (now - delta < timestamp and timestamp < now + delta): # pylint: disable=chained-comparison
return False, 'oauth_timestamp has expired'
Expand Down

0 comments on commit 0982189

Please sign in to comment.