Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Django Auth Lti
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marcel Heijink
Django Auth Lti
Commits
01340440
Commit
01340440
authored
10 years ago
by
Benjamin Zagorsky
Browse files
Options
Downloads
Patches
Plain Diff
slight code reduction
parent
819b8064
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
django_auth_lti/tests/test_verification.py
+1
-2
1 addition, 2 deletions
django_auth_lti/tests/test_verification.py
django_auth_lti/verification.py
+3
-3
3 additions, 3 deletions
django_auth_lti/verification.py
with
4 additions
and
5 deletions
django_auth_lti/tests/test_verification.py
+
1
−
2
View file @
01340440
...
...
@@ -2,12 +2,11 @@ from unittest import TestCase
from
mock
import
MagicMock
from
django_auth_lti.verification
import
is_allowed
from
django.core.exceptions
import
ImproperlyConfigured
,
PermissionDenied
from
django.http
import
HttpRequest
class
TestVerification
(
TestCase
):
def
test_is_allowed_config_failure
(
self
):
request
=
MagicMock
(
session
=
{
"
LTI_LAUNCH
"
:
None
})
request
=
MagicMock
(
session
=
{})
allowed_roles
=
[
"
admin
"
,
"
student
"
]
self
.
assertRaises
(
ImproperlyConfigured
,
is_allowed
,
request
,
allowed_roles
,
False
)
...
...
This diff is collapsed.
Click to expand it.
django_auth_lti/verification.py
+
3
−
3
View file @
01340440
...
...
@@ -8,12 +8,12 @@ def is_allowed(request, allowed_roles, raise_exception):
else
:
allowed
=
allowed_roles
lti_params
=
request
.
session
.
get
(
'
LTI_LAUNCH
'
,
None
)
if
lti_params
is
None
:
if
(
"
LTI_LAUNCH
"
not
in
request
.
session
or
request
.
session
[
"
LTI_LAUNCH
"
]
is
None
)
:
# If this is raised, then likely the project doesn't have
# the correct settings or is being run outside of an lti context
raise
ImproperlyConfigured
(
"
No LTI_LAUNCH vale found in session
"
)
user_roles
=
lti_params
.
get
(
'
roles
'
,
[])
user_roles
=
request
.
session
[
'
LTI_LAUNCH
'
]
.
get
(
'
roles
'
,
[])
is_user_allowed
=
set
(
allowed
)
&
set
(
user_roles
)
if
not
is_user_allowed
and
raise_exception
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment