Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
c9adb6d2
authored
Feb 27, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add VmDetailVncTest
parent
8820554f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
107 additions
and
1 deletions
+107
-1
circle/dashboard/fixtures/node.json
+72
-0
circle/dashboard/tests/test_views.py
+35
-1
No files found.
circle/dashboard/fixtures/node.json
0 → 100644
View file @
c9adb6d2
[
{
"pk"
:
1
,
"model"
:
"firewall.vlan"
,
"fields"
:
{
"comment"
:
""
,
"ipv6_template"
:
"2001:7:2:4031:%(b)d:%(c)d:%(d)d:0"
,
"domain"
:
1
,
"dhcp_pool"
:
""
,
"managed"
:
true
,
"name"
:
"pub"
,
"vid"
:
3066
,
"created_at"
:
"2014-02-19T17:00:17.358Z"
,
"modified_at"
:
"2014-02-19T17:00:17.358Z"
,
"owner"
:
null
,
"snat_ip"
:
null
,
"snat_to"
:
[],
"network6"
:
null
,
"network4"
:
"10.7.0.93/16"
,
"reverse_domain"
:
"%(d)d.%(c)d.%(b)d.%(a)d.in-addr.arpa"
,
"network_type"
:
"public"
,
"description"
:
""
}
},
{
"pk"
:
1
,
"model"
:
"firewall.host"
,
"fields"
:
{
"comment"
:
""
,
"vlan"
:
1
,
"reverse"
:
""
,
"created_at"
:
"2014-02-19T17:03:45.365Z"
,
"hostname"
:
"devenv"
,
"modified_at"
:
"2014-02-24T15:55:01.412Z"
,
"location"
:
""
,
"pub_ipv4"
:
null
,
"mac"
:
"11:22:33:44:55:66"
,
"shared_ip"
:
false
,
"ipv4"
:
"10.7.0.96"
,
"groups"
:
[],
"ipv6"
:
null
,
"owner"
:
1
,
"description"
:
""
}
},
{
"pk"
:
1
,
"model"
:
"firewall.domain"
,
"fields"
:
{
"description"
:
""
,
"created_at"
:
"2014-02-19T17:00:08.819Z"
,
"modified_at"
:
"2014-02-19T17:00:08.819Z"
,
"ttl"
:
600
,
"owner"
:
1
,
"name"
:
"test.ik.bme.hu"
}
},
{
"pk"
:
1
,
"model"
:
"vm.node"
,
"fields"
:
{
"name"
:
"devenv"
,
"created"
:
"2014-02-19T17:03:45.322Z"
,
"overcommit"
:
1.0
,
"enabled"
:
true
,
"modified"
:
"2014-02-19T21:11:34.671Z"
,
"priority"
:
1
,
"traits"
:
[],
"host"
:
1
}
}
]
circle/dashboard/tests/test_views.py
View file @
c9adb6d2
...
...
@@ -2,7 +2,7 @@ from django.test import TestCase
from
django.test.client
import
Client
from
django.contrib.auth.models
import
User
,
Group
from
vm.models
import
Instance
,
InstanceTemplate
,
Lease
from
vm.models
import
Instance
,
InstanceTemplate
,
Lease
,
Node
from
storage.models
import
Disk
from
firewall.models
import
Vlan
...
...
@@ -234,3 +234,37 @@ class VmDetailTest(TestCase):
response
=
c
.
get
(
"/dashboard/notifications/"
)
self
.
assertEqual
(
response
.
status_code
,
200
)
assert
self
.
u1
.
notification_set
.
get
()
.
status
==
'read'
class
VmDetailVncTest
(
TestCase
):
fixtures
=
[
'test-vm-fixture.json'
,
'node.json'
]
def
setUp
(
self
):
self
.
u1
=
User
.
objects
.
create
(
username
=
'user1'
)
self
.
u1
.
set_password
(
'password'
)
self
.
u1
.
save
()
def
login
(
self
,
client
,
username
,
password
=
'password'
):
response
=
client
.
post
(
'/accounts/login/'
,
{
'username'
:
username
,
'password'
:
password
})
self
.
assertNotEqual
(
response
.
status_code
,
403
)
def
test_permitted_vm_console
(
self
):
c
=
Client
()
self
.
login
(
c
,
'user1'
)
inst
=
Instance
.
objects
.
get
(
pk
=
1
)
inst
.
node
=
Node
.
objects
.
all
()[
0
]
inst
.
save
()
inst
.
set_level
(
self
.
u1
,
'operator'
)
response
=
c
.
get
(
'/dashboard/vm/1/vnctoken/'
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_not_permitted_vm_console
(
self
):
c
=
Client
()
self
.
login
(
c
,
'user1'
)
inst
=
Instance
.
objects
.
get
(
pk
=
1
)
inst
.
node
=
Node
.
objects
.
all
()[
0
]
inst
.
save
()
inst
.
set_level
(
self
.
u1
,
'user'
)
response
=
c
.
get
(
'/dashboard/vm/1/vnctoken/'
)
self
.
assertEqual
(
response
.
status_code
,
403
)
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