Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3bf6afcd
authored
May 06, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: acl access remove tests
parent
c0aea736
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
118 additions
and
0 deletions
+118
-0
circle/dashboard/tests/test_views.py
+118
-0
No files found.
circle/dashboard/tests/test_views.py
View file @
3bf6afcd
...
...
@@ -1150,3 +1150,121 @@ class ProfileViewTest(LoginMixin, TestCase):
self
.
assertIsNotNone
(
authenticate
(
username
=
"user1"
,
password
=
"password"
))
self
.
assertIsNone
(
authenticate
(
username
=
"user1"
,
password
=
"asd"
))
class
AclViewTest
(
LoginMixin
,
TestCase
):
fixtures
=
[
'test-vm-fixture.json'
,
'node.json'
]
def
setUp
(
self
):
Instance
.
get_remote_queue_name
=
Mock
(
return_value
=
'test'
)
self
.
u1
=
User
.
objects
.
create
(
username
=
'user1'
)
self
.
u1
.
set_password
(
'password'
)
self
.
u1
.
save
()
self
.
u2
=
User
.
objects
.
create
(
username
=
'user2'
,
is_staff
=
True
)
self
.
u2
.
set_password
(
'password'
)
self
.
u2
.
save
()
self
.
us
=
User
.
objects
.
create
(
username
=
'superuser'
,
is_superuser
=
True
)
self
.
us
.
set_password
(
'password'
)
self
.
us
.
save
()
self
.
ut
=
User
.
objects
.
get
(
username
=
"test"
)
self
.
g1
=
Group
.
objects
.
create
(
name
=
'group1'
)
self
.
g1
.
user_set
.
add
(
self
.
u1
)
self
.
g1
.
user_set
.
add
(
self
.
u2
)
self
.
g1
.
save
()
settings
[
"default_vlangroup"
]
=
'public'
VlanGroup
.
objects
.
create
(
name
=
'public'
)
def
tearDown
(
self
):
super
(
AclViewTest
,
self
)
.
tearDown
()
self
.
u1
.
delete
()
self
.
u2
.
delete
()
self
.
us
.
delete
()
self
.
g1
.
delete
()
def
test_permitted_instance_access_revoke
(
self
):
c
=
Client
()
# this is from the fixtures
self
.
login
(
c
,
"test"
,
"test"
)
inst
=
Instance
.
objects
.
get
(
id
=
1
)
inst
.
set_level
(
self
.
u1
,
"user"
)
resp
=
c
.
post
(
"/dashboard/vm/1/acl/"
,
{
'remove-u-
%
d'
%
self
.
u1
.
pk
:
""
,
'perm-new-name'
:
""
,
'perm-new'
:
""
,
})
self
.
assertFalse
((
self
.
u1
,
"user"
)
in
inst
.
get_users_with_level
())
self
.
assertEqual
(
resp
.
status_code
,
302
)
def
test_unpermitted_instance_access_revoke
(
self
):
c
=
Client
()
self
.
login
(
c
,
self
.
u2
)
inst
=
Instance
.
objects
.
get
(
id
=
1
)
inst
.
set_level
(
self
.
u1
,
"user"
)
resp
=
c
.
post
(
"/dashboard/vm/1/acl/"
,
{
'remove-u-
%
d'
%
self
.
u1
.
pk
:
""
,
'perm-new-name'
:
""
,
'perm-new'
:
""
,
})
self
.
assertTrue
((
self
.
u1
,
"user"
)
in
inst
.
get_users_with_level
())
self
.
assertEqual
(
resp
.
status_code
,
403
)
def
test_instance_original_owner_access_revoke
(
self
):
c
=
Client
()
self
.
login
(
c
,
self
.
u1
)
inst
=
Instance
.
objects
.
get
(
id
=
1
)
inst
.
set_level
(
self
.
u1
,
"owner"
)
inst
.
set_level
(
self
.
ut
,
"owner"
)
resp
=
c
.
post
(
"/dashboard/vm/1/acl/"
,
{
'remove-u-
%
d'
%
self
.
ut
.
pk
:
""
,
'perm-new-name'
:
""
,
'perm-new'
:
""
,
})
self
.
assertEqual
(
self
.
ut
,
Instance
.
objects
.
get
(
id
=
1
)
.
owner
)
self
.
assertTrue
((
self
.
ut
,
"owner"
)
in
inst
.
get_users_with_level
())
self
.
assertEqual
(
resp
.
status_code
,
302
)
def
test_permitted_template_access_revoke
(
self
):
c
=
Client
()
# this is from the fixtures
self
.
login
(
c
,
"test"
,
"test"
)
tmpl
=
InstanceTemplate
.
objects
.
get
(
id
=
1
)
tmpl
.
set_level
(
self
.
u1
,
"user"
)
resp
=
c
.
post
(
"/dashboard/template/1/acl/"
,
{
'remove-u-
%
d'
%
self
.
u1
.
pk
:
""
,
'perm-new-name'
:
""
,
'perm-new'
:
""
,
})
self
.
assertFalse
((
self
.
u1
,
"user"
)
in
tmpl
.
get_users_with_level
())
self
.
assertEqual
(
resp
.
status_code
,
302
)
def
test_unpermitted_template_access_revoke
(
self
):
c
=
Client
()
self
.
login
(
c
,
self
.
u2
)
tmpl
=
InstanceTemplate
.
objects
.
get
(
id
=
1
)
tmpl
.
set_level
(
self
.
u1
,
"user"
)
resp
=
c
.
post
(
"/dashboard/template/1/acl/"
,
{
'remove-u-
%
d'
%
self
.
u1
.
pk
:
""
,
'perm-new-name'
:
""
,
'perm-new'
:
""
,
})
self
.
assertTrue
((
self
.
u1
,
"user"
)
in
tmpl
.
get_users_with_level
())
self
.
assertEqual
(
resp
.
status_code
,
403
)
def
test_template_original_owner_access_revoke
(
self
):
c
=
Client
()
self
.
login
(
c
,
self
.
u1
)
tmpl
=
InstanceTemplate
.
objects
.
get
(
id
=
1
)
tmpl
.
set_level
(
self
.
u1
,
"owner"
)
tmpl
.
set_level
(
self
.
ut
,
"owner"
)
resp
=
c
.
post
(
"/dashboard/template/1/acl/"
,
{
'remove-u-
%
d'
%
self
.
ut
.
pk
:
""
,
'perm-new-name'
:
""
,
'perm-new'
:
""
,
})
self
.
assertEqual
(
self
.
ut
,
InstanceTemplate
.
objects
.
get
(
id
=
1
)
.
owner
)
self
.
assertTrue
((
self
.
ut
,
"owner"
)
in
tmpl
.
get_users_with_level
())
self
.
assertEqual
(
resp
.
status_code
,
302
)
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