Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
ced3f67a
Commit
ced3f67a
authored
10 years ago
by
Adam Palay
Browse files
Options
Downloads
Patches
Plain Diff
fix authentication check in auth
parent
9d2b85d3
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
common/djangoapps/student/auth.py
+1
-1
1 addition, 1 deletion
common/djangoapps/student/auth.py
common/djangoapps/student/tests/test_authz.py
+10
-6
10 additions, 6 deletions
common/djangoapps/student/tests/test_authz.py
with
11 additions
and
7 deletions
common/djangoapps/student/auth.py
+
1
−
1
View file @
ced3f67a
...
...
@@ -72,7 +72,7 @@ def _check_caller_authority(caller, role):
:param caller: a user
:param role: an AccessRole
"""
if
not
(
caller
.
is_authenticated
and
caller
.
is_active
):
if
not
(
caller
.
is_authenticated
()
and
caller
.
is_active
):
raise
PermissionDenied
# superuser
if
GlobalStaff
().
has_user
(
caller
):
...
...
This diff is collapsed.
Click to expand it.
common/djangoapps/student/tests/test_authz.py
+
10
−
6
View file @
ced3f67a
...
...
@@ -76,8 +76,10 @@ class CreatorGroupTest(TestCase):
"""
Tests that adding to creator group fails if user is not authenticated
"""
with
mock
.
patch
.
dict
(
'
django.conf.settings.FEATURES
'
,
{
'
DISABLE_COURSE_CREATION
'
:
False
,
"
ENABLE_CREATOR_GROUP
"
:
True
}):
with
mock
.
patch
.
dict
(
'
django.conf.settings.FEATURES
'
,
{
'
DISABLE_COURSE_CREATION
'
:
False
,
"
ENABLE_CREATOR_GROUP
"
:
True
}
):
anonymous_user
=
AnonymousUser
()
role
=
CourseCreatorRole
()
add_users
(
self
.
admin
,
role
,
anonymous_user
)
...
...
@@ -87,8 +89,10 @@ class CreatorGroupTest(TestCase):
"""
Tests that adding to creator group fails if user is not active
"""
with
mock
.
patch
.
dict
(
'
django.conf.settings.FEATURES
'
,
{
'
DISABLE_COURSE_CREATION
'
:
False
,
"
ENABLE_CREATOR_GROUP
"
:
True
}):
with
mock
.
patch
.
dict
(
'
django.conf.settings.FEATURES
'
,
{
'
DISABLE_COURSE_CREATION
'
:
False
,
"
ENABLE_CREATOR_GROUP
"
:
True
}
):
self
.
user
.
is_active
=
False
add_users
(
self
.
admin
,
CourseCreatorRole
(),
self
.
user
)
self
.
assertFalse
(
has_access
(
self
.
user
,
CourseCreatorRole
()))
...
...
@@ -108,7 +112,7 @@ class CreatorGroupTest(TestCase):
def
test_add_user_to_group_requires_authenticated
(
self
):
with
self
.
assertRaises
(
PermissionDenied
):
self
.
admin
.
is_authenticated
=
False
self
.
admin
.
is_authenticated
=
mock
.
Mock
(
return_value
=
False
)
add_users
(
self
.
admin
,
CourseCreatorRole
(),
self
.
user
)
def
test_remove_user_from_group_requires_staff_access
(
self
):
...
...
@@ -123,7 +127,7 @@ class CreatorGroupTest(TestCase):
def
test_remove_user_from_group_requires_authenticated
(
self
):
with
self
.
assertRaises
(
PermissionDenied
):
self
.
admin
.
is_authenticated
=
False
self
.
admin
.
is_authenticated
=
mock
.
Mock
(
return_value
=
False
)
remove_users
(
self
.
admin
,
CourseCreatorRole
(),
self
.
user
)
...
...
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