Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
e4cd4351
Commit
e4cd4351
authored
9 years ago
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Share some code for testing ACLs
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
db66580e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
27 deletions
+34
-27
weblate/trans/tests/test_acl.py
weblate/trans/tests/test_acl.py
+34
-27
No files found.
weblate/trans/tests/test_acl.py
View file @
e4cd4351
...
...
@@ -32,6 +32,12 @@ class ACLViewTest(ViewTestCase):
super
(
ACLViewTest
,
self
).
setUp
()
self
.
project
.
enable_acl
=
True
self
.
project
.
save
()
self
.
project_url
=
reverse
(
'project'
,
kwargs
=
self
.
kw_project
)
self
.
second_user
=
User
.
objects
.
create_user
(
'seconduser'
,
'noreply@example.org'
,
'testpassword'
)
def
add_acl
(
self
):
"""
...
...
@@ -42,18 +48,14 @@ class ACLViewTest(ViewTestCase):
def
test_acl_denied
(
self
):
"""No access to the project without ACL.
"""
response
=
self
.
client
.
get
(
reverse
(
'project'
,
kwargs
=
self
.
kw_project
)
)
response
=
self
.
client
.
get
(
self
.
project_url
)
self
.
assertEqual
(
response
.
status_code
,
403
)
def
test_acl
(
self
):
"""Regular user should not have access to user management.
"""
self
.
add_acl
()
response
=
self
.
client
.
get
(
reverse
(
'project'
,
kwargs
=
self
.
kw_project
)
)
response
=
self
.
client
.
get
(
self
.
project_url
)
self
.
assertNotContains
(
response
,
'Manage users'
)
def
test_edit_acl
(
self
):
...
...
@@ -61,43 +63,48 @@ class ACLViewTest(ViewTestCase):
"""
self
.
add_acl
()
self
.
make_manager
()
response
=
self
.
client
.
get
(
reverse
(
'project'
,
kwargs
=
self
.
kw_project
)
)
response
=
self
.
client
.
get
(
self
.
project_url
)
self
.
assertContains
(
response
,
'Manage users'
)
def
test_
add_acl
(
self
):
"""
Adding and removing user from the ACL projec
t.
def
test_
edit_acl_owner
(
self
):
"""
Owner should have access to user managemen
t.
"""
self
.
add_acl
()
self
.
project
.
owners
.
add
(
self
.
user
)
response
=
self
.
client
.
get
(
self
.
project_url
)
self
.
assertContains
(
response
,
'Manage users'
)
def
add_user
(
self
):
self
.
add_acl
()
self
.
make_manager
()
project_url
=
reverse
(
'project'
,
kwargs
=
self
.
kw_project
)
second_user
=
User
.
objects
.
create_user
(
'seconduser'
,
'noreply@example.org'
,
'testpassword'
)
# Add user
response
=
self
.
client
.
post
(
reverse
(
'add-user'
,
kwargs
=
self
.
kw_project
),
{
'name'
:
second_user
.
username
}
{
'name'
:
se
lf
.
se
cond_user
.
username
}
)
self
.
assertRedirects
(
response
,
'{0}#acl'
.
format
(
project_url
))
self
.
assertRedirects
(
response
,
'{0}#acl'
.
format
(
self
.
project_url
))
# Ensure user is now listed
response
=
self
.
client
.
get
(
project_url
)
self
.
assertContains
(
response
,
second_user
.
username
)
self
.
assertContains
(
response
,
second_user
.
email
)
response
=
self
.
client
.
get
(
self
.
project_url
)
self
.
assertContains
(
response
,
se
lf
.
se
cond_user
.
username
)
self
.
assertContains
(
response
,
se
lf
.
se
cond_user
.
email
)
def
remove_user
(
self
):
# Remove user
response
=
self
.
client
.
post
(
reverse
(
'delete-user'
,
kwargs
=
self
.
kw_project
),
{
'name'
:
second_user
.
username
}
{
'name'
:
se
lf
.
se
cond_user
.
username
}
)
self
.
assertRedirects
(
response
,
'{0}#acl'
.
format
(
project_url
))
self
.
assertRedirects
(
response
,
'{0}#acl'
.
format
(
self
.
project_url
))
# Ensure user is now not listed
response
=
self
.
client
.
get
(
project_url
)
self
.
assertNotContains
(
response
,
second_user
.
username
)
self
.
assertNotContains
(
response
,
second_user
.
email
)
response
=
self
.
client
.
get
(
self
.
project_url
)
self
.
assertNotContains
(
response
,
self
.
second_user
.
username
)
self
.
assertNotContains
(
response
,
self
.
second_user
.
email
)
def
test_add_acl
(
self
):
"""Adding and removing user from the ACL project.
"""
self
.
add_user
()
self
.
remove_user
()
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment