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
e34471aa
authored
Jun 23, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add tests
parent
3ef0bd43
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
0 deletions
+59
-0
circle/dashboard/tests/test_views.py
+59
-0
No files found.
circle/dashboard/tests/test_views.py
View file @
e34471aa
...
@@ -32,6 +32,7 @@ from ..views import VmRenewView
...
@@ -32,6 +32,7 @@ from ..views import VmRenewView
from
storage.models
import
Disk
from
storage.models
import
Disk
from
firewall.models
import
Vlan
,
Host
,
VlanGroup
from
firewall.models
import
Vlan
,
Host
,
VlanGroup
from
mock
import
Mock
,
patch
from
mock
import
Mock
,
patch
from
django_sshkey.models
import
UserKey
import
django.conf
import
django.conf
settings
=
django
.
conf
.
settings
.
FIREWALL_SETTINGS
settings
=
django
.
conf
.
settings
.
FIREWALL_SETTINGS
...
@@ -1959,3 +1960,61 @@ class VmListTest(LoginMixin, TestCase):
...
@@ -1959,3 +1960,61 @@ class VmListTest(LoginMixin, TestCase):
's'
:
"A:B:C:D:"
's'
:
"A:B:C:D:"
})
})
self
.
assertEqual
(
200
,
resp
.
status_code
)
self
.
assertEqual
(
200
,
resp
.
status_code
)
class
SshKeyTest
(
LoginMixin
,
TestCase
):
def
setUp
(
self
):
self
.
u1
=
User
.
objects
.
create
(
username
=
'user1'
)
self
.
u1
.
set_password
(
'password'
)
self
.
u1
.
save
()
self
.
u2
=
User
.
objects
.
create
(
username
=
'user2'
)
self
.
u2
.
set_password
(
'password'
)
self
.
u2
.
save
()
self
.
k1
=
UserKey
(
key
=
'ssh-rsa AAAAB3NzaC1yc2EC asd'
,
user
=
self
.
u1
)
self
.
k1
.
save
()
def
tearDown
(
self
):
super
(
SshKeyTest
,
self
)
.
tearDown
()
self
.
k1
.
delete
()
self
.
u1
.
delete
()
def
test_permitted_edit
(
self
):
c
=
Client
()
self
.
login
(
c
,
self
.
u1
)
resp
=
c
.
post
(
"/dashboard/sshkey/1/"
,
{
'key'
:
'ssh-rsa AAAAB3NzaC1yc2EC'
})
self
.
assertEqual
(
UserKey
.
objects
.
get
(
id
=
1
)
.
user
,
self
.
u1
)
self
.
assertEqual
(
200
,
resp
.
status_code
)
def
test_unpermitted_edit
(
self
):
c
=
Client
()
self
.
login
(
c
,
self
.
u2
)
resp
=
c
.
post
(
"/dashboard/sshkey/1/"
,
{
'key'
:
'ssh-rsa AAAAB3NzaC1yc2EC'
})
self
.
assertEqual
(
UserKey
.
objects
.
get
(
id
=
1
)
.
user
,
self
.
u1
)
self
.
assertEqual
(
403
,
resp
.
status_code
)
def
test_permitted_add
(
self
):
c
=
Client
()
self
.
login
(
c
,
self
.
u1
)
resp
=
c
.
post
(
"/dashboard/sshkey/create/"
,
{
'name'
:
'asd'
,
'key'
:
'ssh-rsa AAAAB3NzaC1yc2EC'
})
self
.
assertEqual
(
UserKey
.
objects
.
get
(
id
=
2
)
.
user
,
self
.
u1
)
self
.
assertEqual
(
302
,
resp
.
status_code
)
def
test_permitted_delete
(
self
):
c
=
Client
()
self
.
login
(
c
,
self
.
u1
)
resp
=
c
.
post
(
"/dashboard/sshkey/delete/1/"
)
self
.
assertEqual
(
302
,
resp
.
status_code
)
def
test_unpermitted_delete
(
self
):
c
=
Client
()
self
.
login
(
c
,
self
.
u2
)
resp
=
c
.
post
(
"/dashboard/sshkey/delete/1/"
)
self
.
assertEqual
(
403
,
resp
.
status_code
)
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