blob: 6baa7c266c5388ad506688ded853fb68ef0c62ac [file] [log] [blame]
rajalakshmi-ganesanefc8bd72012-05-30 17:52:11 +05301# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2012 OpenStack, LLC
4# All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License. You may obtain
8# a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15# License for the specific language governing permissions and limitations
16# under the License.
17
Jay Pipes444c3e62012-10-04 19:26:35 -040018import nose
rajalakshmi-ganesanefc8bd72012-05-30 17:52:11 +053019
rajalakshmi-ganesanefc8bd72012-05-30 17:52:11 +053020from tempest.common.utils.data_utils import rand_name
Matthew Treinisha83a16e2012-12-07 13:44:02 -050021from tempest import exceptions
Vincent Hou6b8a7b72012-08-25 01:24:33 +080022from tempest.tests.identity import base
rajalakshmi-ganesanefc8bd72012-05-30 17:52:11 +053023
24
Vincent Hou6b8a7b72012-08-25 01:24:33 +080025class ServicesTestBase(object):
rajalakshmi-ganesanefc8bd72012-05-30 17:52:11 +053026
27 def test_create_get_delete_service(self):
28 """GET Service"""
29 try:
30 #Creating a Service
31 name = rand_name('service-')
32 type = rand_name('type--')
33 description = rand_name('description-')
34 resp, service_data = \
35 self.client.create_service(name, type, description=description)
36 self.assertTrue(resp['status'].startswith('2'))
37 #Verifying response body of create service
38 self.assertTrue('id' in service_data)
39 self.assertFalse(service_data['id'] is None)
40 self.assertTrue('name' in service_data)
41 self.assertEqual(name, service_data['name'])
42 self.assertTrue('type' in service_data)
43 self.assertEqual(type, service_data['type'])
44 self.assertTrue('description' in service_data)
45 self.assertEqual(description, service_data['description'])
46 #Get service
47 resp, fetched_service = self.client.get_service(service_data['id'])
48 self.assertTrue(resp['status'].startswith('2'))
49 #verifying the existence of service created
50 self.assertTrue('id' in fetched_service)
51 self.assertEquals(fetched_service['id'], service_data['id'])
52 self.assertTrue('name' in fetched_service)
53 self.assertEqual(fetched_service['name'], service_data['name'])
54 self.assertTrue('type' in fetched_service)
55 self.assertEqual(fetched_service['type'], service_data['type'])
56 self.assertTrue('description' in fetched_service)
57 self.assertEqual(fetched_service['description'],
58 service_data['description'])
59 finally:
60 #Deleting the service created in this method
61 resp, _ = self.client.delete_service(service_data['id'])
62 self.assertTrue(resp['status'].startswith('2'))
63 #Checking whether service is deleted successfully
64 self.assertRaises(exceptions.NotFound, self.client.get_service,
65 service_data['id'])
Vincent Hou6b8a7b72012-08-25 01:24:33 +080066
67
Zhongyue Luo79d8d362012-09-25 13:49:27 +080068class ServicesTestJSON(base.BaseIdentityAdminTestJSON, ServicesTestBase):
Vincent Hou6b8a7b72012-08-25 01:24:33 +080069 @classmethod
70 def setUpClass(cls):
71 super(ServicesTestJSON, cls).setUpClass()
72
73
74class ServicesTestXML(base.BaseIdentityAdminTestXML,
75 ServicesTestBase):
76 @classmethod
77 def setUpClass(cls):
78 super(ServicesTestXML, cls).setUpClass()
Jay Pipes444c3e62012-10-04 19:26:35 -040079 raise nose.SkipTest("Skipping until Bug #1061738 resolved")