@@ -25,12 +25,17 @@ class IdentityTests(test.TestCase):
2525 PROJECT_FIELDS = ['enabled' , 'id' , 'name' , 'description' , 'domain_id' ]
2626 TOKEN_FIELDS = ['expires' , 'id' , 'project_id' , 'user_id' ]
2727 ROLE_FIELDS = ['id' , 'name' , 'links' ]
28+ SERVICE_FIELDS = ['id' , 'enabled' , 'name' , 'type' , 'description' ]
29+ ENDPOINT_FIELDS = ['id' , 'region' , 'service_id' , 'service_name' ,
30+ 'service_type' , 'enabled' , 'publicurl' ,
31+ 'adminurl' , 'internalurl' ]
2832
2933 EC2_CREDENTIALS_FIELDS = ['access' , 'project_id' , 'secret' ,
3034 'trust_id' , 'user_id' ]
3135 EC2_CREDENTIALS_LIST_HEADERS = ['Access' , 'Secret' ,
3236 'Project ID' , 'User ID' ]
3337 CATALOG_LIST_HEADERS = ['Name' , 'Type' , 'Endpoints' ]
38+ ENDPOINT_LIST_HEADERS = ['ID' , 'Region' , 'Service Name' , 'Service Type' ]
3439
3540 @classmethod
3641 def setUpClass (cls ):
@@ -127,3 +132,48 @@ def _create_dummy_token(self, add_clean_up=True):
127132 self .addCleanup (self .openstack ,
128133 'token revoke %s' % token ['id' ])
129134 return token ['id' ]
135+
136+ def _create_dummy_service (self , add_clean_up = True ):
137+ service_name = data_utils .rand_name ('TestService' )
138+ description = data_utils .rand_name ('description' )
139+ type_name = data_utils .rand_name ('TestType' )
140+ raw_output = self .openstack (
141+ 'service create '
142+ '--name %(name)s '
143+ '--description %(description)s '
144+ '%(type)s' % {'name' : service_name ,
145+ 'description' : description ,
146+ 'type' : type_name })
147+ items = self .parse_show (raw_output )
148+ self .assert_show_fields (items , self .SERVICE_FIELDS )
149+ if add_clean_up :
150+ service = self .parse_show_as_object (raw_output )
151+ self .addCleanup (self .openstack ,
152+ 'service delete %s' % service ['id' ])
153+ return service_name
154+
155+ def _create_dummy_endpoint (self , add_clean_up = True ):
156+ region_id = data_utils .rand_name ('TestRegion' )
157+ service_name = self ._create_dummy_service ()
158+ public_url = data_utils .rand_url ()
159+ admin_url = data_utils .rand_url ()
160+ internal_url = data_utils .rand_url ()
161+ raw_output = self .openstack (
162+ 'endpoint create '
163+ '--publicurl %(publicurl)s '
164+ '--adminurl %(adminurl)s '
165+ '--internalurl %(internalurl)s '
166+ '--region %(region)s '
167+ '%(service)s' % {'publicurl' : public_url ,
168+ 'adminurl' : admin_url ,
169+ 'internalurl' : internal_url ,
170+ 'region' : region_id ,
171+ 'service' : service_name })
172+ items = self .parse_show (raw_output )
173+ self .assert_show_fields (items , self .ENDPOINT_FIELDS )
174+ endpoint = self .parse_show_as_object (raw_output )
175+ if add_clean_up :
176+ self .addCleanup (
177+ self .openstack ,
178+ 'endpoint delete %s' % endpoint ['id' ])
179+ return endpoint ['id' ]
0 commit comments