Add security groups extension to API samples test.

Change-Id: Ie7635cacf96e0bafbd412ff40d7912aa0da4677d
Signed-off-by: Matthew Treinish <treinish@linux.vnet.ibm.com>
This commit is contained in:
Matthew Treinish 2012-09-12 15:50:17 -04:00
parent 114109dbf4
commit 0e0d46353e
29 changed files with 327 additions and 0 deletions

View File

@ -0,0 +1,6 @@
{
"security_group": {
"name": "json-test",
"description": "description"
}
}

View File

@ -0,0 +1,5 @@
<security_group name="xml-test">
<description>
description
</description>
</security_group>

View File

@ -0,0 +1,9 @@
{
"security_group": {
"description": "description",
"id": 2,
"name": "json-test",
"rules": [],
"tenant_id": "openstack"
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<security_group xmlns="http://docs.openstack.org/compute/api/v1.1" tenant_id="openstack" id="2" name="xml-test">
<description>
description
</description>
<rules/>
</security_group>

View File

@ -0,0 +1,9 @@
{
"security_group": {
"description": "default",
"id": 1,
"name": "default",
"rules": [],
"tenant_id": "openstack"
}
}

View File

@ -0,0 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<security_group xmlns="http://docs.openstack.org/compute/api/v1.1" tenant_id="openstack" id="1" name="default">
<description>default</description>
<rules/>
</security_group>

View File

@ -0,0 +1,11 @@
{
"security_groups": [
{
"description": "default",
"id": 1,
"name": "default",
"rules": [],
"tenant_id": "openstack"
}
]
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<security_groups xmlns="http://docs.openstack.org/compute/api/v1.1">
<security_group tenant_id="openstack" id="1" name="default">
<description>default</description>
<rules/>
</security_group>
</security_groups>

View File

@ -0,0 +1,16 @@
{
"server" : {
"name" : "new-server-test",
"imageRef" : "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b",
"flavorRef" : "http://openstack.example.com/openstack/flavors/1",
"metadata" : {
"My Server Name" : "Apache1"
},
"personality" : [
{
"path" : "/etc/banner.txt",
"contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA=="
}
]
}
}

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<server xmlns="http://docs.openstack.org/compute/api/v1.1" imageRef="http://openstack.example.com/ openstack/images/70a599e0-31e7-49b7-b260-868f441e862b" flavorRef="http://openstack.example.com/openstack/flavors/1" name="new-server-test">
<metadata>
<meta key="My Server Name">Apache1</meta>
</metadata>
<personality>
<file path="/etc/banner.txt">
ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp
dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k
IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs
c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g
QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo
ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv
dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy
c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6
b25zLiINCg0KLVJpY2hhcmQgQmFjaA==
</file>
</personality>
</server>

View File

@ -0,0 +1,21 @@
{
"server": {
"adminPass": "QmKpgBk7izBM",
"id": "3ad37a3a-d5c4-40ab-9bff-af5b66a0e35b",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/servers/3ad37a3a-d5c4-40ab-9bff-af5b66a0e35b",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/servers/3ad37a3a-d5c4-40ab-9bff-af5b66a0e35b",
"rel": "bookmark"
}
],
"security_groups": [
{
"name": "default"
}
]
}
}

View File

@ -0,0 +1,9 @@
<?xml version='1.0' encoding='UTF-8'?>
<server xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" id="d324fb9c-c7b6-49ef-9f52-e7cca5ac1b23" adminPass="2oTyCGxjDu8p">
<metadata/>
<atom:link href="http://openstack.example.com/v2/openstack/servers/d324fb9c-c7b6-49ef-9f52-e7cca5ac1b23" rel="self"/>
<atom:link href="http://openstack.example.com/openstack/servers/d324fb9c-c7b6-49ef-9f52-e7cca5ac1b23" rel="bookmark"/>
<security_groups>
<security_group name="default"/>
</security_groups>
</server>

View File

@ -0,0 +1,11 @@
{
"security_groups": [
{
"description": "default",
"id": 1,
"name": "default",
"rules": [],
"tenant_id": "openstack"
}
]
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<security_groups xmlns="http://docs.openstack.org/compute/api/v1.1">
<security_group tenant_id="openstack" id="1" name="default">
<description>default</description>
<rules/>
</security_group>
</security_groups>

View File

@ -0,0 +1,6 @@
{
"security_group": {
"name": "%(group_name)s",
"description": "description"
}
}

View File

@ -0,0 +1,5 @@
<security_group name="%(group_name)s">
<description>
description
</description>
</security_group>

View File

@ -0,0 +1,9 @@
{
"security_group": {
"description": "description",
"id": 2,
"name": "%(group_name)s",
"rules": [],
"tenant_id": "openstack"
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<security_group xmlns="http://docs.openstack.org/compute/api/v1.1" tenant_id="openstack" id="2" name="%(group_name)s">
<description>
description
</description>
<rules/>
</security_group>

View File

@ -0,0 +1,9 @@
{
"security_group": {
"description": "default",
"id": 1,
"name": "default",
"rules": [],
"tenant_id": "openstack"
}
}

View File

@ -0,0 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<security_group xmlns="http://docs.openstack.org/compute/api/v1.1" tenant_id="openstack" id="1" name="default">
<description>default</description>
<rules/>
</security_group>

View File

@ -0,0 +1,11 @@
{
"security_groups": [
{
"description": "default",
"id": 1,
"name": "default",
"rules": [],
"tenant_id": "openstack"
}
]
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<security_groups xmlns="http://docs.openstack.org/compute/api/v1.1">
<security_group tenant_id="openstack" id="1" name="default">
<description>default</description>
<rules/>
</security_group>
</security_groups>

View File

@ -0,0 +1,16 @@
{
"server" : {
"name" : "new-server-test",
"imageRef" : "%(host)s/openstack/images/%(image_id)s",
"flavorRef" : "%(host)s/openstack/flavors/1",
"metadata" : {
"My Server Name" : "Apache1"
},
"personality" : [
{
"path" : "/etc/banner.txt",
"contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA=="
}
]
}
}

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<server xmlns="http://docs.openstack.org/compute/api/v1.1" imageRef="%(host)s/ openstack/images/%(image_id)s" flavorRef="%(host)s/openstack/flavors/1" name="new-server-test">
<metadata>
<meta key="My Server Name">Apache1</meta>
</metadata>
<personality>
<file path="/etc/banner.txt">
ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp
dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k
IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs
c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g
QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo
ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv
dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy
c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6
b25zLiINCg0KLVJpY2hhcmQgQmFjaA==
</file>
</personality>
</server>

View File

@ -0,0 +1,21 @@
{
"server": {
"adminPass": "%(password)s",
"id": "%(id)s",
"links": [
{
"href": "%(host)s/v2/openstack/servers/%(uuid)s",
"rel": "self"
},
{
"href": "%(host)s/openstack/servers/%(uuid)s",
"rel": "bookmark"
}
],
"security_groups": [
{
"name": "default"
}
]
}
}

View File

@ -0,0 +1,9 @@
<?xml version='1.0' encoding='UTF-8'?>
<server xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" id="%(id)s" adminPass="%(password)s">
<metadata/>
<atom:link href="%(host)s/v2/openstack/servers/%(uuid)s" rel="self"/>
<atom:link href="%(host)s/openstack/servers/%(uuid)s" rel="bookmark"/>
<security_groups>
<security_group name="default"/>
</security_groups>
</server>

View File

@ -0,0 +1,11 @@
{
"security_groups": [
{
"description": "default",
"id": 1,
"name": "default",
"rules": [],
"tenant_id": "openstack"
}
]
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<security_groups xmlns="http://docs.openstack.org/compute/api/v1.1">
<security_group tenant_id="openstack" id="1" name="default">
<description>default</description>
<rules/>
</security_group>
</security_groups>

View File

@ -553,3 +553,46 @@ class FlavorsExtraDataJsonTest(ApiSampleTestBase):
class FlavorsExtraDataXmlTest(FlavorsExtraDataJsonTest):
ctype = 'xml'
class SecurityGroupsSampleJsonTest(ServersSampleBase):
extension_name = "nova.api.openstack.compute.contrib" + \
".security_groups.Security_groups"
def test_security_group_create(self):
name = self.ctype + '-test'
subs = {
'group_name': name,
"description": "description",
}
response = self._do_post('os-security-groups',
'security-group-post-req', subs)
self.assertEqual(response.status, 200)
self._verify_response('security-groups-create-resp', subs, response)
def test_security_groups_list(self):
"""Get api sample of security groups get list request"""
response = self._do_get('os-security-groups')
subs = self._get_regexes()
return self._verify_response('security-groups-list-get-resp',
subs, response)
def test_security_groups_get(self):
"""Get api sample of security groups get request"""
security_group_id = '1'
response = self._do_get('os-security-groups/%s' % security_group_id)
subs = self._get_regexes()
return self._verify_response('security-groups-get-resp',
subs, response)
def test_security_groups_list_server(self):
"""Get api sample of security groups for a specific server."""
uuid = self._post_server()
response = self._do_get('servers/%s/os-security-groups' % uuid)
subs = self._get_regexes()
return self._verify_response('server-security-groups-list-resp',
subs, response)
class SecurityGroupsSampleXmlTest(SecurityGroupsSampleJsonTest):
ctype = 'xml'