1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 """Identity API v3 Test (Services/Endpoints)"""
18
19
20 import hashlib
21 import os
22 import sys
23 import tempfile
24
25 from yakumo.smoketest import *
26 from yakumo import utils
27
28
30
31
32 if c._session.config[u'identity_api_version'] != '3':
33 return
34
35 LOG.info("Create Service #1")
36 name = get_random_str('service')
37 with c.service.create(name=name,
38 type='type1',
39 description='service 1',
40 is_enabled=False) as s:
41
42 test("Service #1: name is %s" % name, s.name == name)
43 test("Service #1: type is 'type1'", s.type == 'type1')
44 test("Service #1: description is 'service 1'",
45 s.description == 'service 1')
46 test("Service #1: is disabled", not s.is_enabled)
47
48 LOG.info("Update service properties")
49 name = get_random_str('service')
50 s.update(name=name, type='type2', description='service 2',
51 is_enabled=True)
52
53 test("Service #1: name is %s" % name, s.name == name)
54 test("Service #1: type is 'type1'", s.type == 'type2')
55 test("Service #1: description is 'service 2'",
56 s.description == 'service 2')
57 test("Service #1: is enabled", s.is_enabled)
58
59 LOG.info("Create Region #1")
60 region_id = get_random_str('region')
61 with c.region.create(id=region_id, description='region 1') as r:
62
63 test("Region #1: id is %s" % region_id, r.id == region_id)
64 test("Region #1: description is 'region 1'",
65 r.description == 'region 1')
66
67 LOG.info("Update region properties")
68 r.update(description='region 2')
69
70 test("Region #1: description is 'region 2'",
71 r.description == 'region 2')
72
73 LOG.info("Create Endpoints")
74 name = get_random_str('endpoint')
75 url = 'http://%s/v1/public' % name
76 with c.endpoint.create(url=url,
77 interface='public',
78 region=r,
79 service=s) as e:
80
81 test("Endpoints #1: service is %s" % s.name, e.service == s)
82 test("Endpoints #1: region is %s" % r.id, e.region == r)
83 test("Endpoints #1: url is %s" % url, e.url == url)
84 test("Endpoints #1: interface is public",
85 e.interface == 'public')
86
87 LOG.info("Update endpoint properties")
88 name = get_random_str('endpoint')
89 url = 'http://%s/v1/internal' % name
90 e.update(url=url, interface='internal')
91
92 test("Endpoints #1: url is %s" % url, e.url == url)
93 test("Endpoints #1: interface is internal",
94 e.interface == 'internal')
95
96
97 if __name__ == '__main__':
98 c = utils.get_client()
99 if c._session.config[u'identity_api_version'] != '3':
100 sys.exit(0)
101
102 LOG.debug("list services: %s", [_.name for _ in c.service.list()])
103 LOG.debug("list endpoints: %s", c.endpoint.list())
104 main(c)
105 LOG.debug("list service: %s", [_.name for _ in c.service.list()])
106 LOG.debug("list endpoints: %s", c.endpoint.list())
107
108 show_test_summary()
109