synapse 2.177.0__py311-none-any.whl → 2.178.0__py311-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of synapse might be problematic. Click here for more details.
- synapse/cortex.py +8 -4
- synapse/lib/aha.py +361 -88
- synapse/lib/base.py +27 -9
- synapse/lib/cell.py +167 -110
- synapse/lib/config.py +15 -11
- synapse/lib/coro.py +13 -0
- synapse/lib/layer.py +0 -5
- synapse/lib/link.py +1 -1
- synapse/lib/lmdbslab.py +3 -3
- synapse/lib/nexus.py +24 -12
- synapse/lib/stormlib/imap.py +6 -2
- synapse/lib/stormlib/smtp.py +12 -2
- synapse/lib/version.py +2 -2
- synapse/telepath.py +32 -17
- synapse/tests/files/aha/certs/cas/synapse.crt +28 -0
- synapse/tests/files/aha/certs/cas/synapse.key +51 -0
- synapse/tests/files/aha/certs/hosts/00.aha.loop.vertex.link.crt +30 -0
- synapse/tests/files/aha/certs/hosts/00.aha.loop.vertex.link.key +51 -0
- synapse/tests/files/aha/certs/users/root@synapse.crt +29 -0
- synapse/tests/files/aha/certs/users/root@synapse.key +51 -0
- synapse/tests/files/rstorm/testsvc.py +1 -1
- synapse/tests/test_axon.py +1 -1
- synapse/tests/test_cortex.py +22 -59
- synapse/tests/test_lib_agenda.py +3 -3
- synapse/tests/test_lib_aha.py +336 -490
- synapse/tests/test_lib_base.py +20 -0
- synapse/tests/test_lib_cell.py +49 -22
- synapse/tests/test_lib_config.py +4 -3
- synapse/tests/test_lib_nexus.py +8 -0
- synapse/tests/test_lib_stormlib_aha.py +35 -35
- synapse/tests/test_lib_stormlib_cell.py +4 -15
- synapse/tests/test_lib_stormlib_imap.py +14 -3
- synapse/tests/test_lib_stormlib_smtp.py +51 -0
- synapse/tests/test_tools_aha.py +78 -101
- synapse/tests/utils.py +86 -120
- synapse/tools/aha/clone.py +50 -0
- synapse/tools/aha/enroll.py +2 -1
- synapse/tools/backup.py +2 -2
- synapse/tools/changelog.py +3 -1
- {synapse-2.177.0.dist-info → synapse-2.178.0.dist-info}/METADATA +48 -48
- {synapse-2.177.0.dist-info → synapse-2.178.0.dist-info}/RECORD +44 -37
- {synapse-2.177.0.dist-info → synapse-2.178.0.dist-info}/LICENSE +0 -0
- {synapse-2.177.0.dist-info → synapse-2.178.0.dist-info}/WHEEL +0 -0
- {synapse-2.177.0.dist-info → synapse-2.178.0.dist-info}/top_level.txt +0 -0
synapse/tests/test_lib_aha.py
CHANGED
|
@@ -14,7 +14,6 @@ import synapse.lib.base as s_base
|
|
|
14
14
|
import synapse.lib.cell as s_cell
|
|
15
15
|
|
|
16
16
|
import synapse.tools.aha.list as s_a_list
|
|
17
|
-
import synapse.tools.backup as s_tools_backup
|
|
18
17
|
|
|
19
18
|
import synapse.tools.aha.enroll as s_tools_enroll
|
|
20
19
|
import synapse.tools.aha.provision.user as s_tools_provision_user
|
|
@@ -44,30 +43,40 @@ class ExecTeleCaller(s_cell.Cell):
|
|
|
44
43
|
|
|
45
44
|
class AhaTest(s_test.SynTest):
|
|
46
45
|
|
|
47
|
-
async def
|
|
46
|
+
async def test_lib_aha_clone(self):
|
|
47
|
+
|
|
48
|
+
zoinks = 'zoinks.aha.loop.vertex.link'
|
|
48
49
|
|
|
49
50
|
with self.getTestDir() as dirn:
|
|
51
|
+
|
|
50
52
|
dir0 = s_common.gendir(dirn, 'aha0')
|
|
51
53
|
dir1 = s_common.gendir(dirn, 'aha1')
|
|
52
54
|
|
|
53
|
-
|
|
55
|
+
async with self.getTestAha(dirn=dir0) as aha0:
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
ahacount = len(await aha0.getAhaUrls())
|
|
58
|
+
async with aha0.getLocalProxy() as proxy0:
|
|
59
|
+
self.len(ahacount, await proxy0.getAhaUrls())
|
|
60
|
+
self.len(ahacount, await proxy0.getAhaServers())
|
|
58
61
|
|
|
59
|
-
|
|
62
|
+
purl = await proxy0.addAhaClone(zoinks)
|
|
60
63
|
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
conf1 = {'clone': purl}
|
|
65
|
+
async with self.getTestAha(conf=conf1, dirn=dir1) as aha1:
|
|
63
66
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
await aha1.sync()
|
|
68
|
+
|
|
69
|
+
self.eq(aha0.iden, aha1.iden)
|
|
70
|
+
self.nn(aha1.conf.get('mirror'))
|
|
71
|
+
|
|
72
|
+
serv0 = await aha0.getAhaServers()
|
|
73
|
+
serv1 = await aha1.getAhaServers()
|
|
74
|
+
|
|
75
|
+
self.len(ahacount + 1, serv0)
|
|
76
|
+
self.eq(serv0, serv1)
|
|
77
|
+
|
|
78
|
+
# ensure some basic functionality is being properly mirrored
|
|
68
79
|
|
|
69
|
-
async with self.getTestAha(conf=mirrorconf, dirn=dir1) as aha1:
|
|
70
|
-
# CA is nexus-fied
|
|
71
80
|
cabyts = await aha0.genCaCert('mirrorca')
|
|
72
81
|
await aha1.sync()
|
|
73
82
|
mirbyts = await aha1.genCaCert('mirrorca')
|
|
@@ -82,55 +91,74 @@ class AhaTest(s_test.SynTest):
|
|
|
82
91
|
mnfo = await aha1.getAhaSvc('test.example.net')
|
|
83
92
|
self.eq(mnfo.get('name'), 'test.example.net')
|
|
84
93
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
self.isin(len(await wait00.wait(timeout=6)), (1, 2))
|
|
94
|
+
async with aha0.waiter(1, 'aha:svcdown', timeout=6):
|
|
95
|
+
await aha0.setAhaSvcDown('test', iden, network='example.net')
|
|
88
96
|
|
|
89
97
|
await aha1.sync()
|
|
98
|
+
|
|
90
99
|
mnfo = await aha1.getAhaSvc('test.example.net')
|
|
91
100
|
self.notin('online', mnfo)
|
|
92
101
|
|
|
93
102
|
await aha0.delAhaSvc('test', network='example.net')
|
|
94
103
|
await aha1.sync()
|
|
104
|
+
|
|
95
105
|
mnfo = await aha1.getAhaSvc('test.example.net')
|
|
96
106
|
self.none(mnfo)
|
|
97
107
|
|
|
108
|
+
self.true(aha0.isactive)
|
|
109
|
+
self.false(aha1.isactive)
|
|
110
|
+
|
|
111
|
+
async with aha1.getLocalProxy() as proxy:
|
|
112
|
+
await proxy.promote(graceful=True)
|
|
113
|
+
|
|
114
|
+
self.false(aha0.isactive)
|
|
115
|
+
self.true(aha1.isactive)
|
|
116
|
+
|
|
117
|
+
# Remove 00.aha.loop.vertex.link since we're done with him + coverage
|
|
118
|
+
async with self.getTestAha(conf={'dns:name': zoinks}, dirn=dir1) as aha1:
|
|
119
|
+
async with aha1.getLocalProxy() as proxy1:
|
|
120
|
+
srvs = await proxy1.getAhaServers()
|
|
121
|
+
self.len(2, srvs)
|
|
122
|
+
aha00 = [info for info in srvs if info.get('host') == '00.aha.loop.vertex.link'][0]
|
|
123
|
+
data = await proxy1.delAhaServer(aha00.get('host'), aha00.get('port'))
|
|
124
|
+
self.eq(data.get('host'), aha00.get('host'))
|
|
125
|
+
self.eq(data.get('port'), aha00.get('port'))
|
|
126
|
+
|
|
127
|
+
srvs = await proxy1.getAhaServers()
|
|
128
|
+
self.len(1, srvs)
|
|
129
|
+
urls = await proxy1.getAhaUrls()
|
|
130
|
+
self.len(1, urls)
|
|
131
|
+
|
|
98
132
|
async def test_lib_aha_offon(self):
|
|
99
133
|
with self.getTestDir() as dirn:
|
|
100
134
|
cryo0_dirn = s_common.gendir(dirn, 'cryo0')
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
host, port = await aha.dmon.listen('tcp://127.0.0.1:0')
|
|
135
|
+
async with self.getTestAha(dirn=dirn) as aha:
|
|
136
|
+
purl = await aha.addAhaSvcProv('0.cryo')
|
|
104
137
|
|
|
105
138
|
wait00 = aha.waiter(1, 'aha:svcadd')
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
'aha:registry': f'tcp://root:secret@127.0.0.1:{port}',
|
|
110
|
-
'dmon:listen': 'tcp://0.0.0.0:0/',
|
|
111
|
-
}
|
|
112
|
-
async with self.getTestCryo(dirn=cryo0_dirn, conf=cryo_conf) as cryo:
|
|
139
|
+
|
|
140
|
+
conf = {'aha:provision': purl}
|
|
141
|
+
async with self.getTestCryo(dirn=cryo0_dirn, conf=conf) as cryo:
|
|
113
142
|
self.isin(len(await wait00.wait(timeout=6)), (1, 2))
|
|
114
143
|
|
|
115
|
-
svc = await aha.getAhaSvc('0.cryo
|
|
144
|
+
svc = await aha.getAhaSvc('0.cryo...')
|
|
116
145
|
linkiden = svc.get('svcinfo', {}).get('online')
|
|
117
|
-
self.nn(linkiden)
|
|
118
146
|
|
|
119
147
|
# Tear down the Aha cell.
|
|
120
148
|
await aha.__aexit__(None, None, None)
|
|
121
149
|
|
|
122
|
-
async with self.getTestAha(
|
|
150
|
+
async with self.getTestAha(dirn=dirn) as aha:
|
|
123
151
|
wait01 = aha.waiter(1, 'aha:svcdown')
|
|
124
152
|
await wait01.wait(timeout=6)
|
|
125
|
-
svc = await aha.getAhaSvc('0.cryo
|
|
153
|
+
svc = await aha.getAhaSvc('0.cryo...')
|
|
126
154
|
self.notin('online', svc.get('svcinfo'))
|
|
127
155
|
|
|
128
156
|
# Try setting something down a second time
|
|
129
|
-
await aha.setAhaSvcDown('0.cryo
|
|
130
|
-
svc = await aha.getAhaSvc('0.cryo
|
|
157
|
+
await aha.setAhaSvcDown('0.cryo', linkiden, network='synapse')
|
|
158
|
+
svc = await aha.getAhaSvc('0.cryo...')
|
|
131
159
|
self.notin('online', svc.get('svcinfo'))
|
|
132
160
|
|
|
133
|
-
async def
|
|
161
|
+
async def test_lib_aha_basics(self):
|
|
134
162
|
|
|
135
163
|
with self.raises(s_exc.NoSuchName):
|
|
136
164
|
await s_telepath.getAhaProxy({})
|
|
@@ -158,121 +186,84 @@ class AhaTest(s_test.SynTest):
|
|
|
158
186
|
|
|
159
187
|
cryo0_dirn = s_common.gendir(aha.dirn, 'cryo0')
|
|
160
188
|
|
|
161
|
-
|
|
162
|
-
await aha.auth.rootuser.setPasswd('hehehaha')
|
|
189
|
+
ahaurls = await aha.getAhaUrls()
|
|
163
190
|
|
|
164
191
|
wait00 = aha.waiter(1, 'aha:svcadd')
|
|
165
|
-
conf = {
|
|
166
|
-
'aha:name': '0.cryo.mynet',
|
|
167
|
-
'aha:leader': 'cryo.mynet',
|
|
168
|
-
'aha:admin': 'root@cryo.mynet',
|
|
169
|
-
'aha:registry': [f'tcp://root:hehehaha@127.0.0.1:{port}',
|
|
170
|
-
f'tcp://root:hehehaha@127.0.0.1:{port}'],
|
|
171
|
-
'dmon:listen': 'tcp://0.0.0.0:0/',
|
|
172
|
-
}
|
|
173
|
-
async with self.getTestCryo(dirn=cryo0_dirn, conf=conf) as cryo:
|
|
174
192
|
|
|
175
|
-
|
|
193
|
+
replaymult = 1
|
|
194
|
+
if s_common.envbool('SYNDEV_NEXUS_REPLAY'):
|
|
195
|
+
replaymult = 2
|
|
176
196
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
self.true(ahaadmin.isAdmin())
|
|
197
|
+
conf = {'aha:provision': await aha.addAhaSvcProv('0.cryo')}
|
|
198
|
+
async with self.getTestCryo(dirn=cryo0_dirn, conf=conf) as cryo:
|
|
180
199
|
|
|
181
200
|
await wait00.wait(timeout=2)
|
|
182
201
|
|
|
183
202
|
with self.raises(s_exc.NoSuchName):
|
|
184
203
|
await s_telepath.getAhaProxy({'host': 'hehe.haha'})
|
|
185
204
|
|
|
186
|
-
async with await s_telepath.openurl('aha://
|
|
205
|
+
async with await s_telepath.openurl('aha://cryo...') as proxy:
|
|
187
206
|
self.nn(await proxy.getCellIden())
|
|
188
207
|
|
|
189
208
|
with self.raises(s_exc.BadArg):
|
|
190
209
|
_proxy = await cryo.ahaclient.proxy(timeout=2)
|
|
191
|
-
await _proxy.modAhaSvcInfo('cryo
|
|
210
|
+
await _proxy.modAhaSvcInfo('cryo...', {'newp': 'newp'})
|
|
192
211
|
|
|
193
|
-
async with await s_telepath.openurl('aha://
|
|
212
|
+
async with await s_telepath.openurl('aha://0.cryo...') as proxy:
|
|
194
213
|
self.nn(await proxy.getCellIden())
|
|
195
214
|
|
|
196
215
|
# force a reconnect...
|
|
197
|
-
waiter = aha.waiter(1, 'aha:svcadd')
|
|
198
216
|
proxy = await cryo.ahaclient.proxy(timeout=2)
|
|
199
|
-
|
|
200
|
-
|
|
217
|
+
async with aha.waiter(2 * replaymult, 'aha:svcadd'):
|
|
218
|
+
await proxy.fini()
|
|
201
219
|
|
|
202
|
-
async with await s_telepath.openurl('aha://
|
|
220
|
+
async with await s_telepath.openurl('aha://cryo...') as proxy:
|
|
203
221
|
self.nn(await proxy.getCellIden())
|
|
204
222
|
|
|
205
|
-
waiter = aha.waiter(1, 'aha:svcadd')
|
|
206
223
|
# force the service into passive mode...
|
|
207
|
-
|
|
224
|
+
async with aha.waiter(3 * replaymult, 'aha:svcdown', 'aha:svcadd', timeout=6):
|
|
225
|
+
await cryo.setCellActive(False)
|
|
208
226
|
|
|
209
227
|
with self.raises(s_exc.NoSuchName):
|
|
210
|
-
async with await s_telepath.openurl('aha://
|
|
228
|
+
async with await s_telepath.openurl('aha://cryo...') as proxy:
|
|
211
229
|
pass
|
|
212
230
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
async with await s_telepath.openurl('aha://root:secret@0.cryo.mynet') as proxy:
|
|
231
|
+
async with await s_telepath.openurl('aha://0.cryo...') as proxy:
|
|
216
232
|
self.nn(await proxy.getCellIden())
|
|
217
233
|
|
|
218
|
-
|
|
234
|
+
async with aha.waiter(1 * replaymult, 'aha:svcadd', timeout=6):
|
|
235
|
+
await cryo.setCellActive(True)
|
|
219
236
|
|
|
220
|
-
async with await s_telepath.openurl('aha://
|
|
237
|
+
async with await s_telepath.openurl('aha://cryo...') as proxy:
|
|
221
238
|
self.nn(await proxy.getCellIden())
|
|
222
239
|
|
|
223
|
-
|
|
224
|
-
cryo.conf.pop('aha:leader', None)
|
|
225
|
-
await cryo.setCellActive(False)
|
|
226
|
-
|
|
227
|
-
# lock the aha:admin account so we can confirm it is unlocked upon restart
|
|
228
|
-
# remove the admin flag from the account.
|
|
229
|
-
self.false(ahaadmin.isLocked())
|
|
230
|
-
await ahaadmin.setLocked(True, logged=False)
|
|
231
|
-
self.true(ahaadmin.isLocked())
|
|
232
|
-
# remove the admin status so we can confirm its an admin upon restart
|
|
233
|
-
await ahaadmin.setAdmin(False, logged=False)
|
|
234
|
-
self.false(ahaadmin.isAdmin())
|
|
240
|
+
wait01 = aha.waiter(2 * replaymult, 'aha:svcadd')
|
|
235
241
|
|
|
236
|
-
|
|
237
|
-
ahaadmin = await cryo.auth.getUserByName('root@cryo.mynet')
|
|
238
|
-
# And we should be unlocked and admin now
|
|
239
|
-
self.false(ahaadmin.isLocked())
|
|
240
|
-
self.true(ahaadmin.isAdmin())
|
|
241
|
-
|
|
242
|
-
wait01 = aha.waiter(1, 'aha:svcadd')
|
|
243
|
-
conf = {
|
|
244
|
-
'aha:name': '0.cryo',
|
|
245
|
-
'aha:leader': 'cryo',
|
|
246
|
-
'aha:network': 'foo',
|
|
247
|
-
'aha:registry': f'tcp://root:hehehaha@127.0.0.1:{port}',
|
|
248
|
-
'dmon:listen': 'tcp://0.0.0.0:0/',
|
|
249
|
-
}
|
|
242
|
+
conf = {'aha:provision': await aha.addAhaSvcProv('0.cryo')}
|
|
250
243
|
async with self.getTestCryo(conf=conf) as cryo:
|
|
251
244
|
|
|
252
245
|
info = await cryo.getCellInfo()
|
|
253
|
-
cnfo = info.get('cell')
|
|
254
|
-
anfo = cnfo.get('aha')
|
|
255
|
-
self.eq(cnfo.get('aha'), {'name': '0.cryo', 'leader': 'cryo', 'network': 'foo'})
|
|
256
246
|
|
|
257
|
-
|
|
247
|
+
self.eq(info['cell']['aha'], {'name': '0.cryo', 'leader': 'cryo', 'network': 'synapse'})
|
|
258
248
|
|
|
259
249
|
await wait01.wait(timeout=2)
|
|
260
250
|
|
|
261
|
-
async with await s_telepath.openurl('aha://
|
|
251
|
+
async with await s_telepath.openurl('aha://cryo.synapse') as proxy:
|
|
262
252
|
self.nn(await proxy.getCellIden())
|
|
263
253
|
|
|
264
|
-
async with await s_telepath.openurl('aha://
|
|
254
|
+
async with await s_telepath.openurl('aha://0.cryo.synapse') as proxy:
|
|
265
255
|
self.nn(await proxy.getCellIden())
|
|
266
256
|
await proxy.puts('hehe', ('hehe', 'haha'))
|
|
267
257
|
|
|
268
|
-
async with await s_telepath.openurl('aha://
|
|
258
|
+
async with await s_telepath.openurl('aha://0.cryo.synapse/*/hehe') as proxy:
|
|
269
259
|
self.nn(await proxy.iden())
|
|
270
260
|
|
|
271
|
-
async with
|
|
272
|
-
|
|
261
|
+
async with aha.getLocalProxy() as ahaproxy:
|
|
262
|
+
|
|
263
|
+
svcs = [x async for x in ahaproxy.getAhaSvcs('synapse')]
|
|
273
264
|
self.len(2, svcs)
|
|
274
265
|
names = [s['name'] for s in svcs]
|
|
275
|
-
self.sorteq(('cryo.
|
|
266
|
+
self.sorteq(('cryo.synapse', '0.cryo.synapse'), names)
|
|
276
267
|
|
|
277
268
|
self.none(await ahaproxy.getCaCert('vertex.link'))
|
|
278
269
|
cacert0 = await ahaproxy.genCaCert('vertex.link')
|
|
@@ -299,20 +290,10 @@ class AhaTest(s_test.SynTest):
|
|
|
299
290
|
self.nn(usercert01)
|
|
300
291
|
self.ne(usercert00, usercert01)
|
|
301
292
|
|
|
302
|
-
async with await s_telepath.openurl(f'tcp://root:hehehaha@127.0.0.1:{port}') as ahaproxy:
|
|
303
|
-
await ahaproxy.delAhaSvc('cryo', network='foo')
|
|
304
|
-
await ahaproxy.delAhaSvc('0.cryo', network='foo')
|
|
305
|
-
self.none(await ahaproxy.getAhaSvc('cryo.foo'))
|
|
306
|
-
self.none(await ahaproxy.getAhaSvc('0.cryo.foo'))
|
|
307
|
-
self.len(2, [s async for s in ahaproxy.getAhaSvcs()])
|
|
308
|
-
|
|
309
|
-
with self.raises(s_exc.BadArg):
|
|
310
|
-
info = {'urlinfo': {'host': '127.0.0.1', 'port': 8080, 'scheme': 'tcp'}}
|
|
311
|
-
await ahaproxy.addAhaSvc('newp', info, network=None)
|
|
312
|
-
|
|
313
293
|
# We can use HTTP API to get the registered services
|
|
314
294
|
await aha.addUser('lowuser', passwd='lowuser')
|
|
315
295
|
await aha.auth.rootuser.setPasswd('secret')
|
|
296
|
+
|
|
316
297
|
host, httpsport = await aha.addHttpsPort(0)
|
|
317
298
|
svcsurl = f'https://localhost:{httpsport}/api/v1/aha/services'
|
|
318
299
|
|
|
@@ -322,15 +303,16 @@ class AhaTest(s_test.SynTest):
|
|
|
322
303
|
self.eq(info.get('status'), 'ok')
|
|
323
304
|
result = info.get('result')
|
|
324
305
|
self.len(2, result)
|
|
325
|
-
self.eq({'0.cryo.
|
|
306
|
+
self.eq({'0.cryo.synapse', 'cryo.synapse'},
|
|
326
307
|
{svcinfo.get('name') for svcinfo in result})
|
|
327
308
|
|
|
328
|
-
async with sess.get(svcsurl, json={'network': '
|
|
309
|
+
async with sess.get(svcsurl, json={'network': 'synapse'}) as resp:
|
|
329
310
|
info = await resp.json()
|
|
330
311
|
self.eq(info.get('status'), 'ok')
|
|
331
312
|
result = info.get('result')
|
|
332
|
-
self.len(
|
|
333
|
-
self.eq('cryo.
|
|
313
|
+
self.len(2, result)
|
|
314
|
+
self.eq({'0.cryo.synapse', 'cryo.synapse'},
|
|
315
|
+
{svcinfo.get('name') for svcinfo in result})
|
|
334
316
|
|
|
335
317
|
async with sess.get(svcsurl, json={'network': 'newp'}) as resp:
|
|
336
318
|
info = await resp.json()
|
|
@@ -356,36 +338,42 @@ class AhaTest(s_test.SynTest):
|
|
|
356
338
|
self.eq(info.get('status'), 'err')
|
|
357
339
|
self.eq(info.get('code'), 'AuthDeny')
|
|
358
340
|
|
|
359
|
-
# The aha service can also be configured with a set of URLs that could represent itself.
|
|
360
|
-
urls = ('cell://home0', 'cell://home1')
|
|
361
|
-
conf = {'aha:urls': urls}
|
|
362
|
-
async with self.getTestAha(conf=conf) as aha:
|
|
363
341
|
async with aha.getLocalProxy() as ahaproxy:
|
|
364
|
-
|
|
365
|
-
|
|
342
|
+
await ahaproxy.delAhaSvc('cryo', network='synapse')
|
|
343
|
+
await ahaproxy.delAhaSvc('0.cryo', network='synapse')
|
|
344
|
+
self.none(await ahaproxy.getAhaSvc('cryo.synapse'))
|
|
345
|
+
self.none(await ahaproxy.getAhaSvc('0.cryo.synapse'))
|
|
346
|
+
self.len(0, [s async for s in ahaproxy.getAhaSvcs()])
|
|
366
347
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
self.
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
self.
|
|
387
|
-
|
|
388
|
-
|
|
348
|
+
with self.raises(s_exc.BadArg):
|
|
349
|
+
info = {'urlinfo': {'host': '127.0.0.1', 'port': 8080, 'scheme': 'tcp'}}
|
|
350
|
+
await ahaproxy.addAhaSvc('newp', info, network=None)
|
|
351
|
+
|
|
352
|
+
# test that services get updated aha server list
|
|
353
|
+
with self.getTestDir() as dirn:
|
|
354
|
+
|
|
355
|
+
conf = {'aha:provision': await aha.addAhaSvcProv('00.cell')}
|
|
356
|
+
|
|
357
|
+
# can't assume just one due to enterprise tests with raft...
|
|
358
|
+
ahacount = len(await aha.getAhaUrls())
|
|
359
|
+
|
|
360
|
+
async with self.getTestCell(s_cell.Cell, conf=conf, dirn=dirn) as cell:
|
|
361
|
+
self.len(ahacount, cell.conf.get('aha:registry'))
|
|
362
|
+
|
|
363
|
+
await aha.addAhaServer({'host': 'zoinks.aha.loop.vertex.link'})
|
|
364
|
+
|
|
365
|
+
self.len(ahacount + 1, await aha.getAhaServers())
|
|
366
|
+
|
|
367
|
+
async with self.getTestCell(s_cell.Cell, conf=conf, dirn=dirn) as cell:
|
|
368
|
+
await cell.ahaclient.proxy()
|
|
369
|
+
self.len(ahacount + 1, cell.conf.get('aha:registry'))
|
|
370
|
+
|
|
371
|
+
self.nn(await aha.delAhaServer('zoinks.aha.loop.vertex.link', 27492))
|
|
372
|
+
self.len(ahacount, await aha.getAhaServers())
|
|
373
|
+
|
|
374
|
+
async with self.getTestCell(s_cell.Cell, conf=conf, dirn=dirn) as cell:
|
|
375
|
+
await cell.ahaclient.proxy()
|
|
376
|
+
self.len(ahacount, cell.conf.get('aha:registry'))
|
|
389
377
|
|
|
390
378
|
async def test_lib_aha_loadenv(self):
|
|
391
379
|
|
|
@@ -430,53 +418,25 @@ class AhaTest(s_test.SynTest):
|
|
|
430
418
|
|
|
431
419
|
async with self.getTestAha() as aha:
|
|
432
420
|
|
|
433
|
-
cryo0_dirn = s_common.gendir(aha.dirn, 'cryo0')
|
|
434
|
-
|
|
435
|
-
host, port = await aha.dmon.listen('tcp://127.0.0.1:0')
|
|
436
|
-
await aha.auth.rootuser.setPasswd('hehehaha')
|
|
437
|
-
|
|
438
|
-
aharegistry = [f'tcp://root:hehehaha@127.0.0.1:{port}',
|
|
439
|
-
f'tcp://root:hehehaha@127.0.0.1:{port}']
|
|
440
|
-
atup = tuple(aharegistry)
|
|
441
|
-
|
|
442
421
|
wait00 = aha.waiter(1, 'aha:svcadd')
|
|
443
|
-
conf = {
|
|
444
|
-
'aha:name': '0.cryo.mynet',
|
|
445
|
-
'aha:admin': 'root@cryo.mynet',
|
|
446
|
-
'aha:registry': aharegistry,
|
|
447
|
-
'dmon:listen': 'tcp://0.0.0.0:0/',
|
|
448
|
-
}
|
|
449
|
-
async with self.getTestCryo(dirn=cryo0_dirn, conf=conf) as cryo:
|
|
450
|
-
|
|
451
|
-
await cryo.auth.rootuser.setPasswd('secret')
|
|
422
|
+
conf = {'aha:provision': await aha.addAhaSvcProv('0.cryo')}
|
|
452
423
|
|
|
453
|
-
|
|
454
|
-
self.nn(ahaadmin)
|
|
455
|
-
self.true(ahaadmin.isAdmin())
|
|
456
|
-
|
|
457
|
-
await wait00.wait(timeout=2)
|
|
424
|
+
async with self.getTestCryo(conf=conf) as cryo:
|
|
458
425
|
|
|
459
|
-
self.
|
|
426
|
+
self.true(await wait00.wait(timeout=2))
|
|
460
427
|
|
|
461
|
-
async with await s_telepath.openurl('aha://
|
|
428
|
+
async with await s_telepath.openurl('aha://0.cryo...') as proxy:
|
|
462
429
|
self.nn(await proxy.getCellIden())
|
|
463
430
|
|
|
464
|
-
|
|
465
|
-
_aprx = await _ahaclient.proxy()
|
|
431
|
+
proxy = await cryo.ahaclient.proxy()
|
|
466
432
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
orig = s_telepath.Client.proxy
|
|
472
|
-
async def quickproxy(self, timeout):
|
|
473
|
-
return await orig(self, timeout=0.1)
|
|
474
|
-
|
|
475
|
-
with mock.patch('synapse.telepath.Client.proxy', quickproxy):
|
|
476
|
-
with self.raises(asyncio.TimeoutError):
|
|
433
|
+
# avoid race to notify client...
|
|
434
|
+
async with cryo.ahaclient.waiter(1, 'tele:client:linkloop', timeout=2):
|
|
435
|
+
await aha.fini()
|
|
436
|
+
self.true(await proxy.waitfini(timeout=10))
|
|
477
437
|
|
|
478
|
-
|
|
479
|
-
|
|
438
|
+
with self.raises(asyncio.TimeoutError):
|
|
439
|
+
await cryo.ahaclient.proxy(timeout=0.1)
|
|
480
440
|
|
|
481
441
|
async def test_lib_aha_onlink_fail(self):
|
|
482
442
|
|
|
@@ -484,27 +444,14 @@ class AhaTest(s_test.SynTest):
|
|
|
484
444
|
|
|
485
445
|
async with self.getTestAha() as aha:
|
|
486
446
|
|
|
487
|
-
cryo0_dirn = s_common.gendir(aha.dirn, 'cryo0')
|
|
488
|
-
|
|
489
|
-
host, port = await aha.dmon.listen('tcp://127.0.0.1:0')
|
|
490
|
-
await aha.auth.rootuser.setPasswd('secret')
|
|
491
|
-
|
|
492
447
|
aha.testerr = True
|
|
493
|
-
|
|
494
448
|
wait00 = aha.waiter(1, 'aha:svcadd')
|
|
495
|
-
conf = {
|
|
496
|
-
|
|
497
|
-
'aha:admin': 'root@cryo.mynet',
|
|
498
|
-
'aha:registry': f'tcp://root:secret@127.0.0.1:{port}',
|
|
499
|
-
'dmon:listen': 'tcp://0.0.0.0:0/',
|
|
500
|
-
}
|
|
501
|
-
async with self.getTestCryo(dirn=cryo0_dirn, conf=conf) as cryo:
|
|
502
|
-
|
|
503
|
-
await cryo.auth.rootuser.setPasswd('secret')
|
|
449
|
+
conf = {'aha:provision': await aha.addAhaSvcProv('0.cryo')}
|
|
450
|
+
async with self.getTestCryo(conf=conf) as cryo:
|
|
504
451
|
|
|
505
452
|
self.none(await wait00.wait(timeout=2))
|
|
506
453
|
|
|
507
|
-
svc = await aha.getAhaSvc('0.cryo
|
|
454
|
+
svc = await aha.getAhaSvc('0.cryo...')
|
|
508
455
|
self.none(svc)
|
|
509
456
|
|
|
510
457
|
wait01 = aha.waiter(1, 'aha:svcadd')
|
|
@@ -512,11 +459,11 @@ class AhaTest(s_test.SynTest):
|
|
|
512
459
|
|
|
513
460
|
self.nn(await wait01.wait(timeout=2))
|
|
514
461
|
|
|
515
|
-
svc = await aha.getAhaSvc('0.cryo
|
|
462
|
+
svc = await aha.getAhaSvc('0.cryo...')
|
|
516
463
|
self.nn(svc)
|
|
517
464
|
self.nn(svc.get('svcinfo', {}).get('online'))
|
|
518
465
|
|
|
519
|
-
async with await s_telepath.openurl('aha://
|
|
466
|
+
async with await s_telepath.openurl('aha://0.cryo...') as proxy:
|
|
520
467
|
self.nn(await proxy.getCellIden())
|
|
521
468
|
|
|
522
469
|
async def test_lib_aha_bootstrap(self):
|
|
@@ -532,12 +479,12 @@ class AhaTest(s_test.SynTest):
|
|
|
532
479
|
}
|
|
533
480
|
|
|
534
481
|
async with self.getTestAha(dirn=dirn, conf=conf) as aha:
|
|
535
|
-
self.true(os.path.isfile(os.path.join(dirn, 'certs', 'cas', 'do.vertex.link.crt')))
|
|
536
|
-
self.true(os.path.isfile(os.path.join(dirn, 'certs', 'cas', 'do.vertex.link.key')))
|
|
537
|
-
self.true(os.path.isfile(os.path.join(dirn, 'certs', 'hosts', 'aha.do.vertex.link.crt')))
|
|
538
|
-
self.true(os.path.isfile(os.path.join(dirn, 'certs', 'hosts', 'aha.do.vertex.link.key')))
|
|
539
|
-
self.true(os.path.isfile(os.path.join(dirn, 'certs', 'users', 'root@do.vertex.link.crt')))
|
|
540
|
-
self.true(os.path.isfile(os.path.join(dirn, 'certs', 'users', 'root@do.vertex.link.key')))
|
|
482
|
+
self.true(os.path.isfile(os.path.join(aha.dirn, 'certs', 'cas', 'do.vertex.link.crt')))
|
|
483
|
+
self.true(os.path.isfile(os.path.join(aha.dirn, 'certs', 'cas', 'do.vertex.link.key')))
|
|
484
|
+
self.true(os.path.isfile(os.path.join(aha.dirn, 'certs', 'hosts', 'aha.do.vertex.link.crt')))
|
|
485
|
+
self.true(os.path.isfile(os.path.join(aha.dirn, 'certs', 'hosts', 'aha.do.vertex.link.key')))
|
|
486
|
+
self.true(os.path.isfile(os.path.join(aha.dirn, 'certs', 'users', 'root@do.vertex.link.crt')))
|
|
487
|
+
self.true(os.path.isfile(os.path.join(aha.dirn, 'certs', 'users', 'root@do.vertex.link.key')))
|
|
541
488
|
|
|
542
489
|
host, port = await aha.dmon.listen('ssl://127.0.0.1:0?hostname=aha.do.vertex.link&ca=do.vertex.link')
|
|
543
490
|
|
|
@@ -546,7 +493,8 @@ class AhaTest(s_test.SynTest):
|
|
|
546
493
|
|
|
547
494
|
async def test_lib_aha_noconf(self):
|
|
548
495
|
|
|
549
|
-
|
|
496
|
+
conf = {'dns:name': None}
|
|
497
|
+
async with self.getTestAha(conf=conf) as aha:
|
|
550
498
|
|
|
551
499
|
with self.raises(s_exc.NeedConfValu):
|
|
552
500
|
await aha.addAhaSvcProv('hehe')
|
|
@@ -559,35 +507,17 @@ class AhaTest(s_test.SynTest):
|
|
|
559
507
|
with self.raises(s_exc.NeedConfValu):
|
|
560
508
|
await aha.addAhaUserEnroll('hehe')
|
|
561
509
|
|
|
562
|
-
aha.conf['provision:listen'] = 'tcp://127.0.0.1:27272'
|
|
563
|
-
|
|
564
|
-
with self.raises(s_exc.NeedConfValu):
|
|
565
|
-
await aha.addAhaSvcProv('hehe')
|
|
566
|
-
|
|
567
510
|
with self.raises(s_exc.NeedConfValu):
|
|
568
511
|
await aha.addAhaUserEnroll('hehe')
|
|
569
512
|
|
|
570
|
-
aha.conf['aha:network'] = 'haha'
|
|
571
|
-
await aha.addAhaSvcProv('hehe')
|
|
572
|
-
|
|
573
513
|
async def test_lib_aha_provision(self):
|
|
574
514
|
|
|
575
515
|
with self.getTestDir() as dirn:
|
|
576
516
|
|
|
577
|
-
conf = {
|
|
578
|
-
'aha:name': 'aha',
|
|
579
|
-
'aha:network': 'loop.vertex.link',
|
|
580
|
-
'provision:listen': 'ssl://aha.loop.vertex.link:0'
|
|
581
|
-
}
|
|
517
|
+
conf = {'dns:name': 'aha.loop.vertex.link'}
|
|
582
518
|
async with self.getTestAha(dirn=dirn, conf=conf) as aha:
|
|
583
519
|
|
|
584
|
-
|
|
585
|
-
# update the config to reflect the dynamically bound port
|
|
586
|
-
aha.conf['provision:listen'] = f'ssl://aha.loop.vertex.link:{port}'
|
|
587
|
-
|
|
588
|
-
# do this config ex-post-facto due to port binding...
|
|
589
|
-
host, ahaport = await aha.dmon.listen('ssl://0.0.0.0:0?hostname=aha.loop.vertex.link&ca=loop.vertex.link')
|
|
590
|
-
aha.conf['aha:urls'] = f'ssl://aha.loop.vertex.link:{ahaport}'
|
|
520
|
+
ahaport = aha.sockaddr[1]
|
|
591
521
|
|
|
592
522
|
url = aha.getLocalUrl()
|
|
593
523
|
|
|
@@ -655,19 +585,20 @@ class AhaTest(s_test.SynTest):
|
|
|
655
585
|
self.none(await axon.auth.getUserByName('axon@loop.vertex.link'))
|
|
656
586
|
|
|
657
587
|
self.true(os.path.isfile(s_common.genpath(axon.dirn, 'prov.done')))
|
|
658
|
-
self.true(os.path.isfile(s_common.genpath(axon.dirn, 'certs', 'cas', '
|
|
659
|
-
self.true(os.path.isfile(s_common.genpath(axon.dirn, 'certs', 'hosts', '00.axon.
|
|
660
|
-
self.true(os.path.isfile(s_common.genpath(axon.dirn, 'certs', 'hosts', '00.axon.
|
|
661
|
-
self.true(os.path.isfile(s_common.genpath(axon.dirn, 'certs', 'users', 'root@
|
|
662
|
-
self.true(os.path.isfile(s_common.genpath(axon.dirn, 'certs', 'users', 'root@
|
|
588
|
+
self.true(os.path.isfile(s_common.genpath(axon.dirn, 'certs', 'cas', 'synapse.crt')))
|
|
589
|
+
self.true(os.path.isfile(s_common.genpath(axon.dirn, 'certs', 'hosts', '00.axon.synapse.crt')))
|
|
590
|
+
self.true(os.path.isfile(s_common.genpath(axon.dirn, 'certs', 'hosts', '00.axon.synapse.key')))
|
|
591
|
+
self.true(os.path.isfile(s_common.genpath(axon.dirn, 'certs', 'users', 'root@synapse.crt')))
|
|
592
|
+
self.true(os.path.isfile(s_common.genpath(axon.dirn, 'certs', 'users', 'root@synapse.key')))
|
|
663
593
|
|
|
664
594
|
yamlconf = s_common.yamlload(axon.dirn, 'cell.yaml')
|
|
665
595
|
self.eq('axon', yamlconf.get('aha:leader'))
|
|
666
596
|
self.eq('00.axon', yamlconf.get('aha:name'))
|
|
667
|
-
self.eq('
|
|
597
|
+
self.eq('synapse', yamlconf.get('aha:network'))
|
|
668
598
|
self.none(yamlconf.get('aha:admin'))
|
|
669
|
-
|
|
670
|
-
self.eq(
|
|
599
|
+
|
|
600
|
+
self.eq(await aha.getAhaUrls(), yamlconf.get('aha:registry'))
|
|
601
|
+
self.eq(f'ssl://0.0.0.0:0?hostname=00.axon.synapse&ca=synapse', yamlconf.get('dmon:listen'))
|
|
671
602
|
|
|
672
603
|
unfo = await axon.addUser('visi')
|
|
673
604
|
|
|
@@ -678,9 +609,9 @@ class AhaTest(s_test.SynTest):
|
|
|
678
609
|
provurl = str(outp).split(':', 1)[1].strip()
|
|
679
610
|
with self.getTestSynDir() as syndir:
|
|
680
611
|
|
|
681
|
-
capath = s_common.genpath(syndir, 'certs', 'cas', '
|
|
682
|
-
crtpath = s_common.genpath(syndir, 'certs', 'users', 'visi@
|
|
683
|
-
keypath = s_common.genpath(syndir, 'certs', 'users', 'visi@
|
|
612
|
+
capath = s_common.genpath(syndir, 'certs', 'cas', 'synapse.crt')
|
|
613
|
+
crtpath = s_common.genpath(syndir, 'certs', 'users', 'visi@synapse.crt')
|
|
614
|
+
keypath = s_common.genpath(syndir, 'certs', 'users', 'visi@synapse.key')
|
|
684
615
|
|
|
685
616
|
for path in (capath, crtpath, keypath):
|
|
686
617
|
s_common.genfile(path)
|
|
@@ -693,7 +624,7 @@ class AhaTest(s_test.SynTest):
|
|
|
693
624
|
|
|
694
625
|
teleyaml = s_common.yamlload(syndir, 'telepath.yaml')
|
|
695
626
|
self.eq(teleyaml.get('version'), 1)
|
|
696
|
-
self.
|
|
627
|
+
self.sorteq(teleyaml.get('aha:servers'), await aha.getAhaUrls(user='visi'))
|
|
697
628
|
|
|
698
629
|
certdir = s_telepath.s_certdir.CertDir(os.path.join(syndir, 'certs'))
|
|
699
630
|
async with await s_telepath.openurl('aha://visi@axon...', certdir=certdir) as prox:
|
|
@@ -776,7 +707,7 @@ class AhaTest(s_test.SynTest):
|
|
|
776
707
|
await axon2.sync()
|
|
777
708
|
self.true(axon.isactive)
|
|
778
709
|
self.false(axon2.isactive)
|
|
779
|
-
self.eq('aha://root@axon
|
|
710
|
+
self.eq('aha://root@axon...', axon2.conf.get('mirror'))
|
|
780
711
|
|
|
781
712
|
with s_common.genfile(axn2path, 'prov.done') as fd:
|
|
782
713
|
axon2providen = fd.read().decode().strip()
|
|
@@ -787,7 +718,7 @@ class AhaTest(s_test.SynTest):
|
|
|
787
718
|
await axon2.sync()
|
|
788
719
|
self.true(axon.isactive)
|
|
789
720
|
self.false(axon2.isactive)
|
|
790
|
-
self.eq('aha://root@axon
|
|
721
|
+
self.eq('aha://root@axon...', axon2.conf.get('mirror'))
|
|
791
722
|
|
|
792
723
|
# Provision a mirror using aha:provision in the mirror cell.yaml as well.
|
|
793
724
|
# This is similar to the previous test block.
|
|
@@ -815,7 +746,7 @@ class AhaTest(s_test.SynTest):
|
|
|
815
746
|
await axon03.sync()
|
|
816
747
|
self.true(axon.isactive)
|
|
817
748
|
self.false(axon03.isactive)
|
|
818
|
-
self.eq('aha://root@axon
|
|
749
|
+
self.eq('aha://root@axon...', axon03.conf.get('mirror'))
|
|
819
750
|
|
|
820
751
|
with s_common.genfile(axn3path, 'prov.done') as fd:
|
|
821
752
|
axon3providen = fd.read().decode().strip()
|
|
@@ -831,15 +762,15 @@ class AhaTest(s_test.SynTest):
|
|
|
831
762
|
await axon3.sync()
|
|
832
763
|
self.true(axon.isactive)
|
|
833
764
|
self.false(axon3.isactive)
|
|
834
|
-
self.eq('aha://root@axon
|
|
765
|
+
self.eq('aha://root@axon...', axon03.conf.get('mirror'))
|
|
835
766
|
|
|
836
767
|
retn, outp = await self.execToolMain(s_a_list._main, [aha.getLocalUrl()])
|
|
837
768
|
self.eq(retn, 0)
|
|
838
769
|
outp.expect('Service network leader')
|
|
839
|
-
outp.expect('00.axon
|
|
840
|
-
outp.expect('01.axon
|
|
841
|
-
outp.expect('02.axon
|
|
842
|
-
outp.expect('axon
|
|
770
|
+
outp.expect('00.axon synapse True')
|
|
771
|
+
outp.expect('01.axon synapse False')
|
|
772
|
+
outp.expect('02.axon synapse False')
|
|
773
|
+
outp.expect('axon synapse True')
|
|
843
774
|
|
|
844
775
|
# Ensure we can provision a service on a given listening ports
|
|
845
776
|
outp.clear()
|
|
@@ -854,14 +785,6 @@ class AhaTest(s_test.SynTest):
|
|
|
854
785
|
outp.expect('ERROR: Invalid HTTPS port: 123456')
|
|
855
786
|
self.eq(1, ret)
|
|
856
787
|
|
|
857
|
-
outp.clear()
|
|
858
|
-
bad_conf_path = s_common.genpath(dirn, 'badconf.yaml')
|
|
859
|
-
s_common.yamlsave({'aha:network': 'aha.newp.net'}, bad_conf_path)
|
|
860
|
-
args = ('--url', aha.getLocalUrl(), 'bazfaz', '--cellyaml', bad_conf_path)
|
|
861
|
-
ret = await s_tools_provision_service.main(args, outp=outp)
|
|
862
|
-
outp.expect('ERROR: Provisioning aha:network must be equal to the Aha servers network')
|
|
863
|
-
self.eq(1, ret)
|
|
864
|
-
|
|
865
788
|
outp = self.getTestOutp()
|
|
866
789
|
argv = ('--url', aha.getLocalUrl(), 'bazfaz', '--dmon-port', '1234', '--https-port', '443')
|
|
867
790
|
await s_tools_provision_service.main(argv, outp=outp)
|
|
@@ -876,27 +799,21 @@ class AhaTest(s_test.SynTest):
|
|
|
876
799
|
https_port = conf.get('https:port')
|
|
877
800
|
self.eq(https_port, 443)
|
|
878
801
|
|
|
879
|
-
# provisioning against a network that differs from the aha network fails.
|
|
880
|
-
bad_netw = 'stuff.goes.beep'
|
|
881
|
-
provinfo = {'conf': {'aha:network': bad_netw}}
|
|
882
|
-
with self.raises(s_exc.BadConfValu) as cm:
|
|
883
|
-
async with self.addSvcToAha(aha, '00.exec', ExecTeleCaller,
|
|
884
|
-
provinfo=provinfo) as conn:
|
|
885
|
-
pass
|
|
886
|
-
self.isin('Provisioning aha:network must be equal to the Aha servers network',
|
|
887
|
-
cm.exception.get('mesg'))
|
|
888
|
-
|
|
889
802
|
# We can generate urls and then drop them en-mass. They will not usable.
|
|
890
803
|
provurls = []
|
|
891
804
|
enrlursl = []
|
|
805
|
+
clonurls = []
|
|
892
806
|
async with aha.getLocalProxy() as proxy:
|
|
893
807
|
provurls.append(await proxy.addAhaSvcProv('00.cell'))
|
|
894
808
|
provurls.append(await proxy.addAhaSvcProv('01.cell', {'mirror': 'cell'}))
|
|
895
809
|
enrlursl.append(await proxy.addAhaUserEnroll('bob'))
|
|
896
810
|
enrlursl.append(await proxy.addAhaUserEnroll('alice'))
|
|
811
|
+
clonurls.append(await proxy.addAhaClone('hehe.haha.com'))
|
|
812
|
+
clonurls.append(await proxy.addAhaClone('wow.haha.com', port='12345'))
|
|
897
813
|
|
|
898
814
|
await proxy.clearAhaSvcProvs()
|
|
899
815
|
await proxy.clearAhaUserEnrolls()
|
|
816
|
+
await proxy.clearAhaClones()
|
|
900
817
|
|
|
901
818
|
for url in provurls:
|
|
902
819
|
with self.raises(s_exc.NoSuchName) as cm:
|
|
@@ -906,24 +823,16 @@ class AhaTest(s_test.SynTest):
|
|
|
906
823
|
with self.raises(s_exc.NoSuchName) as cm:
|
|
907
824
|
async with await s_telepath.openurl(url) as prox:
|
|
908
825
|
self.fail(f'Connected to an expired enrollment URL {url}') # pragma: no cover
|
|
826
|
+
for url in clonurls:
|
|
827
|
+
with self.raises(s_exc.NoSuchName) as cm:
|
|
828
|
+
async with await s_telepath.openurl(url) as prox:
|
|
829
|
+
self.fail(f'Connected to an expired clone URL {url}') # pragma: no cover
|
|
909
830
|
|
|
910
831
|
async def test_aha_httpapi(self):
|
|
911
832
|
|
|
912
|
-
|
|
913
|
-
'aha:name': 'aha',
|
|
914
|
-
'aha:network': 'loop.vertex.link',
|
|
915
|
-
'provision:listen': 'ssl://aha.loop.vertex.link:0'
|
|
916
|
-
}
|
|
917
|
-
async with self.getTestAha(conf=conf) as aha:
|
|
918
|
-
await aha.auth.rootuser.setPasswd('secret')
|
|
919
|
-
|
|
920
|
-
addr, port = aha.provdmon.addr
|
|
921
|
-
# update the config to reflect the dynamically bound port
|
|
922
|
-
aha.conf['provision:listen'] = f'ssl://aha.loop.vertex.link:{port}'
|
|
833
|
+
async with self.getTestAha() as aha:
|
|
923
834
|
|
|
924
|
-
|
|
925
|
-
host, ahaport = await aha.dmon.listen('ssl://0.0.0.0:0?hostname=aha.loop.vertex.link&ca=loop.vertex.link')
|
|
926
|
-
aha.conf['aha:urls'] = f'ssl://aha.loop.vertex.link:{ahaport}'
|
|
835
|
+
await aha.auth.rootuser.setPasswd('secret')
|
|
927
836
|
|
|
928
837
|
host, httpsport = await aha.addHttpsPort(0)
|
|
929
838
|
url = f'https://localhost:{httpsport}/api/v1/aha/provision/service'
|
|
@@ -997,13 +906,6 @@ class AhaTest(s_test.SynTest):
|
|
|
997
906
|
self.eq(info.get('status'), 'err')
|
|
998
907
|
self.eq(info.get('code'), 'SchemaViolation')
|
|
999
908
|
|
|
1000
|
-
# Break the Aha cell - not will provision after this.
|
|
1001
|
-
_network = aha.conf.pop('aha:network')
|
|
1002
|
-
async with sess.post(url, json={'name': '00.newp'}) as resp:
|
|
1003
|
-
info = await resp.json()
|
|
1004
|
-
self.eq(info.get('status'), 'err')
|
|
1005
|
-
self.eq(info.get('code'), 'NeedConfValu')
|
|
1006
|
-
|
|
1007
909
|
# Not an admin
|
|
1008
910
|
await aha.addUser('lowuser', passwd='lowuser')
|
|
1009
911
|
async with self.getHttpSess(auth=('lowuser', 'lowuser'), port=httpsport) as sess:
|
|
@@ -1013,15 +915,11 @@ class AhaTest(s_test.SynTest):
|
|
|
1013
915
|
self.eq(info.get('code'), 'AuthDeny')
|
|
1014
916
|
|
|
1015
917
|
async def test_aha_connect_back(self):
|
|
1016
|
-
async with self.getTestAhaProv() as aha: # type: s_aha.AhaCell
|
|
1017
|
-
|
|
1018
|
-
async with self.addSvcToAha(aha, '00.exec', ExecTeleCaller) as conn:
|
|
1019
918
|
|
|
1020
|
-
|
|
1021
|
-
ahaurl = s_telepath.modurl(ahaurl, user='root')
|
|
919
|
+
async with self.getTestAha() as aha: # type: s_aha.AhaCell
|
|
1022
920
|
|
|
1023
|
-
|
|
1024
|
-
|
|
921
|
+
async with self.addSvcToAha(aha, '00.exec', ExecTeleCaller) as conn:
|
|
922
|
+
ahaurl = aha.getMyUrl()
|
|
1025
923
|
await conn.exectelecall(ahaurl, 'getNexsIndx')
|
|
1026
924
|
|
|
1027
925
|
self.true(conn.ahaclient.isfini)
|
|
@@ -1029,26 +927,7 @@ class AhaTest(s_test.SynTest):
|
|
|
1029
927
|
async def test_aha_util_helpers(self):
|
|
1030
928
|
|
|
1031
929
|
# Mainly for test helper coverage.
|
|
1032
|
-
|
|
1033
|
-
async with self.getTestAhaProv(conf={'auth:passwd': 'secret'}) as aha: # type: s_aha.AhaCell
|
|
1034
|
-
root = await aha.auth.getUserByName('root')
|
|
1035
|
-
self.true(await root.tryPasswd('secret'))
|
|
1036
|
-
|
|
1037
|
-
import synapse.cortex as s_cortex
|
|
1038
|
-
|
|
1039
|
-
with self.getTestDir() as dirn:
|
|
1040
|
-
cdr0 = s_common.genpath(dirn, 'core00')
|
|
1041
|
-
cdr1 = s_common.genpath(dirn, 'core01')
|
|
1042
|
-
|
|
1043
|
-
async with self.addSvcToAha(aha, '00.core', s_cortex.Cortex, dirn=cdr0) as core00:
|
|
1044
|
-
async with self.addSvcToAha(aha, '01.core', s_cortex.Cortex, dirn=cdr1,
|
|
1045
|
-
provinfo={'mirror': 'core'}) as core01:
|
|
1046
|
-
self.len(1, await core00.nodes('[inet:asn=0]'))
|
|
1047
|
-
await core01.sync()
|
|
1048
|
-
self.len(1, await core01.nodes('inet:asn=0'))
|
|
1049
|
-
|
|
1050
|
-
# Simple test setups should work without issue
|
|
1051
|
-
async with self.getTestAhaProv() as aha:
|
|
930
|
+
async with self.getTestAha() as aha:
|
|
1052
931
|
async with self.addSvcToAha(aha, '00.cell', s_cell.Cell) as cell00: # type: s_cell.Cell
|
|
1053
932
|
async with self.addSvcToAha(aha, '01.cell', s_cell.Cell,
|
|
1054
933
|
provinfo={'mirror': 'cell'}) as cell01: # type: s_cell.Cell
|
|
@@ -1056,96 +935,53 @@ class AhaTest(s_test.SynTest):
|
|
|
1056
935
|
# This should teardown cleanly.
|
|
1057
936
|
|
|
1058
937
|
async def test_aha_restart(self):
|
|
1059
|
-
with self.withNexusReplay() as stack:
|
|
1060
938
|
|
|
1061
|
-
|
|
1062
|
-
ahadirn = s_common.gendir(dirn, 'aha')
|
|
1063
|
-
svc0dirn = s_common.gendir(dirn, 'svc00')
|
|
1064
|
-
svc1dirn = s_common.gendir(dirn, 'svc01')
|
|
1065
|
-
async with await s_base.Base.anit() as cm:
|
|
1066
|
-
aconf = {
|
|
1067
|
-
'aha:name': 'aha',
|
|
1068
|
-
'aha:network': 'loop.vertex.link',
|
|
1069
|
-
'provision:listen': 'ssl://aha.loop.vertex.link:0'
|
|
1070
|
-
}
|
|
1071
|
-
name = aconf.get('aha:name')
|
|
1072
|
-
netw = aconf.get('aha:network')
|
|
1073
|
-
dnsname = f'{name}.{netw}'
|
|
939
|
+
with self.getTestDir() as dirn:
|
|
1074
940
|
|
|
1075
|
-
|
|
1076
|
-
|
|
941
|
+
ahadirn = s_common.gendir(dirn, 'aha')
|
|
942
|
+
svc0dirn = s_common.gendir(dirn, 'svc00')
|
|
943
|
+
svc1dirn = s_common.gendir(dirn, 'svc01')
|
|
1077
944
|
|
|
1078
|
-
|
|
1079
|
-
# update the config to reflect the dynamically bound port
|
|
1080
|
-
aha.conf['provision:listen'] = f'ssl://{dnsname}:{port}'
|
|
945
|
+
async with await s_base.Base.anit() as cm:
|
|
1081
946
|
|
|
1082
|
-
|
|
1083
|
-
host, ahaport = await aha.dmon.listen(f'ssl://0.0.0.0:0?hostname={dnsname}&ca={netw}')
|
|
1084
|
-
aha.conf['aha:urls'] = (f'ssl://{dnsname}:{ahaport}',)
|
|
947
|
+
async with self.getTestAha(dirn=ahadirn) as aha:
|
|
1085
948
|
|
|
1086
|
-
|
|
1087
|
-
sconf = {'aha:provision': onetime}
|
|
1088
|
-
s_common.yamlsave(sconf, svc0dirn, 'cell.yaml')
|
|
1089
|
-
svc0 = await s_cell.Cell.anit(svc0dirn, conf=sconf)
|
|
1090
|
-
await cm.enter_context(svc0)
|
|
949
|
+
async with aha.waiter(3, 'aha:svcadd', timeout=10):
|
|
1091
950
|
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
951
|
+
onetime = await aha.addAhaSvcProv('00.svc', provinfo=None)
|
|
952
|
+
conf = {'aha:provision': onetime}
|
|
953
|
+
svc0 = await cm.enter_context(self.getTestCell(conf=conf))
|
|
954
|
+
|
|
955
|
+
onetime = await aha.addAhaSvcProv('01.svc', provinfo={'mirror': 'svc'})
|
|
956
|
+
conf = {'aha:provision': onetime}
|
|
957
|
+
svc1 = await cm.enter_context(self.getTestCell(conf=conf))
|
|
1097
958
|
|
|
1098
959
|
# Ensure that services have connected
|
|
1099
960
|
await asyncio.wait_for(svc1.nexsroot._mirready.wait(), timeout=6)
|
|
1100
961
|
await svc1.sync()
|
|
1101
962
|
|
|
1102
963
|
# Get Aha services
|
|
1103
|
-
snfo = await aha.getAhaSvc('01.svc
|
|
1104
|
-
|
|
1105
|
-
ready = svcinfo.get('ready')
|
|
1106
|
-
self.true(ready)
|
|
964
|
+
snfo = await aha.getAhaSvc('01.svc...')
|
|
965
|
+
self.true(snfo['svcinfo']['ready'])
|
|
1107
966
|
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
# Reuse our listening port we just deployed services with
|
|
1112
|
-
aconf = {
|
|
1113
|
-
'aha:name': 'aha',
|
|
1114
|
-
'aha:network': 'loop.vertex.link',
|
|
1115
|
-
'provision:listen': 'ssl://aha.loop.vertex.link:0', # we do not care about provisioning
|
|
1116
|
-
'dmon:listen': f'ssl://{dnsname}:{ahaport}?hostname={dnsname}&ca={netw}'
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
# Restart aha
|
|
1120
|
-
aha = await s_aha.AhaCell.anit(ahadirn, conf=aconf)
|
|
1121
|
-
await cm.enter_context(aha)
|
|
1122
|
-
|
|
1123
|
-
# services are cleared
|
|
1124
|
-
snfo = await aha.getAhaSvc('01.svc.loop.vertex.link')
|
|
1125
|
-
svcinfo = snfo.get('svcinfo')
|
|
1126
|
-
ready = svcinfo.get('ready')
|
|
1127
|
-
online = svcinfo.get('online')
|
|
1128
|
-
self.none(online)
|
|
1129
|
-
self.false(ready) # Ready is cleared upon restart / setting service down.
|
|
967
|
+
online = snfo['svcinfo']['online']
|
|
968
|
+
self.nn(online)
|
|
1130
969
|
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
n = n * 2
|
|
970
|
+
# Restart aha
|
|
971
|
+
async with self.getTestAha(dirn=ahadirn) as aha:
|
|
1134
972
|
|
|
1135
|
-
|
|
1136
|
-
self.
|
|
973
|
+
snfo = await aha._waitAhaSvcDown('01.svc...', timeout=10)
|
|
974
|
+
self.none(snfo['svcinfo'].get('online'))
|
|
975
|
+
self.false(snfo['svcinfo']['ready'])
|
|
1137
976
|
|
|
1138
977
|
# svc01 has reconnected and the ready state has been re-registered
|
|
1139
|
-
snfo = await aha.
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
online = svcinfo.get('online')
|
|
1143
|
-
self.nn(online)
|
|
1144
|
-
self.true(ready)
|
|
978
|
+
snfo = await aha._waitAhaSvcOnline('01.svc...', timeout=10)
|
|
979
|
+
self.nn(snfo['svcinfo']['online'])
|
|
980
|
+
self.true(snfo['svcinfo']['ready'])
|
|
1145
981
|
|
|
1146
982
|
async def test_aha_service_pools(self):
|
|
1147
983
|
|
|
1148
|
-
async with self.
|
|
984
|
+
async with self.getTestAha() as aha:
|
|
1149
985
|
|
|
1150
986
|
async with await s_base.Base.anit() as base:
|
|
1151
987
|
|
|
@@ -1166,18 +1002,17 @@ class AhaTest(s_test.SynTest):
|
|
|
1166
1002
|
|
|
1167
1003
|
msgs = await core00.stormlist('aha.pool.add pool00...')
|
|
1168
1004
|
self.stormHasNoWarnErr(msgs)
|
|
1169
|
-
self.stormIsInPrint('Created AHA service pool: pool00.
|
|
1005
|
+
self.stormIsInPrint('Created AHA service pool: pool00.synapse', msgs)
|
|
1170
1006
|
|
|
1171
1007
|
# Pool has no members....
|
|
1172
1008
|
pool = await s_telepath.open('aha://pool00...')
|
|
1173
1009
|
self.eq(0, pool.size())
|
|
1174
|
-
waiter = pool.waiter(0, 'svc:add')
|
|
1175
1010
|
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1011
|
+
async with pool.waiter(1, 'svc:add', timeout=12):
|
|
1012
|
+
msgs = await core00.stormlist('aha.pool.svc.add pool00... 00...')
|
|
1013
|
+
self.stormHasNoWarnErr(msgs)
|
|
1014
|
+
self.stormIsInPrint('AHA service (00...) added to service pool (pool00.synapse)', msgs)
|
|
1179
1015
|
|
|
1180
|
-
self.len(1, await waiter.wait(timeout=12))
|
|
1181
1016
|
prox = await pool.proxy(timeout=12)
|
|
1182
1017
|
info = await prox.getCellInfo()
|
|
1183
1018
|
self.eq('00', info.get('cell').get('aha').get('name'))
|
|
@@ -1190,40 +1025,38 @@ class AhaTest(s_test.SynTest):
|
|
|
1190
1025
|
self.len(1, poolinfo['services'])
|
|
1191
1026
|
|
|
1192
1027
|
msgs = await core00.stormlist('aha.pool.list')
|
|
1193
|
-
self.stormIsInPrint('Pool: pool00.
|
|
1194
|
-
self.stormIsInPrint(' 00.
|
|
1028
|
+
self.stormIsInPrint('Pool: pool00.synapse', msgs)
|
|
1029
|
+
self.stormIsInPrint(' 00.synapse', msgs)
|
|
1195
1030
|
self.stormIsInPrint('1 pools', msgs)
|
|
1196
1031
|
|
|
1197
|
-
msgs = await core00.stormlist('$lib.print($lib.aha.pool.get(pool00.
|
|
1198
|
-
self.stormIsInPrint('aha:pool: pool00.
|
|
1032
|
+
msgs = await core00.stormlist('$lib.print($lib.aha.pool.get(pool00.synapse))')
|
|
1033
|
+
self.stormIsInPrint('aha:pool: pool00.synapse', msgs)
|
|
1199
1034
|
|
|
1200
1035
|
async with await s_telepath.open('aha://pool00...') as pool:
|
|
1201
1036
|
|
|
1202
1037
|
replay = s_common.envbool('SYNDEV_NEXUS_REPLAY')
|
|
1203
1038
|
nevents = 5 if replay else 3
|
|
1204
1039
|
|
|
1205
|
-
|
|
1040
|
+
async with pool.waiter(nevents, 'svc:add', timeout=3):
|
|
1206
1041
|
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1042
|
+
msgs = await core00.stormlist('aha.pool.svc.add pool00... 01...')
|
|
1043
|
+
self.stormHasNoWarnErr(msgs)
|
|
1044
|
+
self.stormIsInPrint('AHA service (01...) added to service pool (pool00.synapse)', msgs)
|
|
1210
1045
|
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
await waiter.wait(timeout=3)
|
|
1046
|
+
msgs = await core00.stormlist('aha.pool.svc.add pool00... 01...')
|
|
1047
|
+
self.stormHasNoWarnErr(msgs)
|
|
1048
|
+
self.stormIsInPrint('AHA service (01...) added to service pool (pool00.synapse)', msgs)
|
|
1216
1049
|
|
|
1217
1050
|
poolinfo = await aha.getAhaPool('pool00...')
|
|
1218
1051
|
self.len(2, poolinfo['services'])
|
|
1219
1052
|
|
|
1220
1053
|
self.nn(poolinfo['created'])
|
|
1221
|
-
self.nn(poolinfo['services']['00.
|
|
1222
|
-
self.nn(poolinfo['services']['01.
|
|
1054
|
+
self.nn(poolinfo['services']['00.synapse']['created'])
|
|
1055
|
+
self.nn(poolinfo['services']['01.synapse']['created'])
|
|
1223
1056
|
|
|
1224
1057
|
self.eq(core00.auth.rootuser.iden, poolinfo['creator'])
|
|
1225
|
-
self.eq(core00.auth.rootuser.iden, poolinfo['services']['00.
|
|
1226
|
-
self.eq(core00.auth.rootuser.iden, poolinfo['services']['01.
|
|
1058
|
+
self.eq(core00.auth.rootuser.iden, poolinfo['services']['00.synapse']['creator'])
|
|
1059
|
+
self.eq(core00.auth.rootuser.iden, poolinfo['services']['01.synapse']['creator'])
|
|
1227
1060
|
|
|
1228
1061
|
for client in pool.clients.values():
|
|
1229
1062
|
await client.proxy(timeout=3)
|
|
@@ -1235,24 +1068,21 @@ class AhaTest(s_test.SynTest):
|
|
|
1235
1068
|
|
|
1236
1069
|
waiter = pool.waiter(1, 'pool:reset')
|
|
1237
1070
|
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
await waiter.wait(timeout=3)
|
|
1071
|
+
async with pool.waiter(1, 'pool:reset', timeout=3):
|
|
1072
|
+
ahaproxy = await pool.aha.proxy()
|
|
1073
|
+
await ahaproxy.fini()
|
|
1242
1074
|
|
|
1243
1075
|
# wait for the pool to be notified of the topology change
|
|
1244
|
-
|
|
1076
|
+
async with pool.waiter(1, 'svc:del', timeout=10):
|
|
1245
1077
|
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
msgs)
|
|
1078
|
+
msgs = await core00.stormlist('aha.pool.svc.del pool00... 00...')
|
|
1079
|
+
self.stormHasNoWarnErr(msgs)
|
|
1080
|
+
self.stormIsInPrint('AHA service (00.synapse) removed from service pool (pool00.synapse)', msgs)
|
|
1250
1081
|
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1082
|
+
msgs = await core00.stormlist('aha.pool.svc.del pool00... 00...')
|
|
1083
|
+
self.stormHasNoWarnErr(msgs)
|
|
1084
|
+
self.stormIsInPrint('Did not remove (00...) from the service pool.', msgs)
|
|
1254
1085
|
|
|
1255
|
-
await waiter.wait(timeout=3)
|
|
1256
1086
|
run00 = await (await pool.proxy(timeout=3)).getCellRunId()
|
|
1257
1087
|
self.eq(run00, await (await pool.proxy(timeout=3)).getCellRunId())
|
|
1258
1088
|
|
|
@@ -1261,104 +1091,60 @@ class AhaTest(s_test.SynTest):
|
|
|
1261
1091
|
|
|
1262
1092
|
msgs = await core00.stormlist('aha.pool.del pool00...')
|
|
1263
1093
|
self.stormHasNoWarnErr(msgs)
|
|
1264
|
-
self.stormIsInPrint('Removed AHA service pool: pool00.
|
|
1094
|
+
self.stormIsInPrint('Removed AHA service pool: pool00.synapse', msgs)
|
|
1265
1095
|
|
|
1266
1096
|
async def test_aha_reprovision(self):
|
|
1097
|
+
|
|
1267
1098
|
with self.withNexusReplay() as stack:
|
|
1268
1099
|
with self.getTestDir() as dirn:
|
|
1100
|
+
|
|
1269
1101
|
aha00dirn = s_common.gendir(dirn, 'aha00')
|
|
1270
1102
|
aha01dirn = s_common.gendir(dirn, 'aha01')
|
|
1271
1103
|
svc0dirn = s_common.gendir(dirn, 'svc00')
|
|
1272
1104
|
svc1dirn = s_common.gendir(dirn, 'svc01')
|
|
1273
|
-
async with await s_base.Base.anit() as cm:
|
|
1274
|
-
aconf = {
|
|
1275
|
-
'aha:name': 'aha',
|
|
1276
|
-
'aha:network': 'loop.vertex.link',
|
|
1277
|
-
'provision:listen': 'ssl://aha.loop.vertex.link:0'
|
|
1278
|
-
}
|
|
1279
|
-
name = aconf.get('aha:name')
|
|
1280
|
-
netw = aconf.get('aha:network')
|
|
1281
|
-
dnsname = f'{name}.{netw}'
|
|
1282
1105
|
|
|
1283
|
-
|
|
1284
|
-
await cm.enter_context(aha)
|
|
1285
|
-
|
|
1286
|
-
addr, port = aha.provdmon.addr
|
|
1287
|
-
# update the config to reflect the dynamically bound port
|
|
1288
|
-
aha.conf['provision:listen'] = f'ssl://{dnsname}:{port}'
|
|
1106
|
+
async with await s_base.Base.anit() as cm:
|
|
1289
1107
|
|
|
1290
|
-
|
|
1291
|
-
host, ahaport = await aha.dmon.listen(f'ssl://0.0.0.0:0?hostname={dnsname}&ca={netw}')
|
|
1292
|
-
aha.conf['aha:urls'] = (f'ssl://{dnsname}:{ahaport}',)
|
|
1108
|
+
aha = await cm.enter_context(self.getTestAha(dirn=aha00dirn))
|
|
1293
1109
|
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
await cm.enter_context(svc0)
|
|
1110
|
+
async with aha.waiter(2, 'aha:svcadd', timeout=6):
|
|
1111
|
+
purl = await aha.addAhaSvcProv('00.svc')
|
|
1112
|
+
svc0 = await s_cell.Cell.anit(svc0dirn, conf={'aha:provision': purl})
|
|
1113
|
+
await cm.enter_context(svc0)
|
|
1299
1114
|
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
await cm.enter_context(svc1)
|
|
1115
|
+
async with aha.waiter(1, 'aha:svcadd', timeout=6):
|
|
1116
|
+
purl = await aha.addAhaSvcProv('01.svc', provinfo={'mirror': 'svc'})
|
|
1117
|
+
svc1 = await s_cell.Cell.anit(svc1dirn, conf={'aha:provision': purl})
|
|
1118
|
+
await cm.enter_context(svc1)
|
|
1305
1119
|
|
|
1306
|
-
# Ensure that services have connected
|
|
1307
1120
|
await asyncio.wait_for(svc1.nexsroot._mirready.wait(), timeout=6)
|
|
1308
1121
|
await svc1.sync()
|
|
1309
1122
|
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
svcinfo = snfo.get('svcinfo')
|
|
1313
|
-
ready = svcinfo.get('ready')
|
|
1314
|
-
self.true(ready)
|
|
1315
|
-
|
|
1316
|
-
await aha.fini()
|
|
1123
|
+
snfo = self.nn(await aha.getAhaSvc('01.svc...'))
|
|
1124
|
+
self.true(snfo['svcinfo']['ready'])
|
|
1317
1125
|
|
|
1318
1126
|
# Now re-deploy the AHA Service and re-provision the two cells
|
|
1319
1127
|
# with the same AHA configuration
|
|
1320
1128
|
async with await s_base.Base.anit() as cm:
|
|
1321
|
-
aconf = {
|
|
1322
|
-
'aha:name': 'aha',
|
|
1323
|
-
'aha:network': 'loop.vertex.link',
|
|
1324
|
-
'provision:listen': 'ssl://aha.loop.vertex.link:0'
|
|
1325
|
-
}
|
|
1326
|
-
name = aconf.get('aha:name')
|
|
1327
|
-
netw = aconf.get('aha:network')
|
|
1328
|
-
dnsname = f'{name}.{netw}'
|
|
1329
|
-
|
|
1330
|
-
aha = await s_aha.AhaCell.anit(aha01dirn, conf=aconf)
|
|
1331
|
-
await cm.enter_context(aha)
|
|
1332
|
-
|
|
1333
|
-
addr, port = aha.provdmon.addr
|
|
1334
|
-
# update the config to reflect the dynamically bound port
|
|
1335
|
-
aha.conf['provision:listen'] = f'ssl://{dnsname}:{port}'
|
|
1336
1129
|
|
|
1337
|
-
|
|
1338
|
-
host, ahaport = await aha.dmon.listen(f'ssl://0.0.0.0:0?hostname={dnsname}&ca={netw}')
|
|
1339
|
-
aha.conf['aha:urls'] = (f'ssl://{dnsname}:{ahaport}',)
|
|
1130
|
+
aha = await cm.enter_context(self.getTestAha(dirn=aha01dirn))
|
|
1340
1131
|
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
await cm.enter_context(svc0)
|
|
1132
|
+
async with aha.waiter(2, 'aha:svcadd', timeout=6):
|
|
1133
|
+
purl = await aha.addAhaSvcProv('00.svc')
|
|
1134
|
+
svc0 = await s_cell.Cell.anit(svc0dirn, conf={'aha:provision': purl})
|
|
1135
|
+
await cm.enter_context(svc0)
|
|
1346
1136
|
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
await cm.enter_context(svc1)
|
|
1137
|
+
async with aha.waiter(1, 'aha:svcadd', timeout=6):
|
|
1138
|
+
purl = await aha.addAhaSvcProv('01.svc', provinfo={'mirror': 'svc'})
|
|
1139
|
+
svc1 = await s_cell.Cell.anit(svc1dirn, conf={'aha:provision': purl})
|
|
1140
|
+
await cm.enter_context(svc1)
|
|
1352
1141
|
|
|
1353
|
-
# Ensure that services have connected
|
|
1354
1142
|
await asyncio.wait_for(svc1.nexsroot._mirready.wait(), timeout=6)
|
|
1355
1143
|
await svc1.sync()
|
|
1356
1144
|
|
|
1357
1145
|
# Get Aha services
|
|
1358
|
-
snfo = await aha.getAhaSvc('01.svc
|
|
1359
|
-
|
|
1360
|
-
ready = svcinfo.get('ready')
|
|
1361
|
-
self.true(ready)
|
|
1146
|
+
snfo = self.nn(await aha.getAhaSvc('01.svc...'))
|
|
1147
|
+
self.true(snfo['svcinfo']['ready'])
|
|
1362
1148
|
|
|
1363
1149
|
async def test_aha_provision_longname(self):
|
|
1364
1150
|
# Run a long network name and try provisioning with values that would exceed CSR
|
|
@@ -1446,3 +1232,63 @@ class AhaTest(s_test.SynTest):
|
|
|
1446
1232
|
with self.raises(s_exc.CryptoErr) as errcm:
|
|
1447
1233
|
await s_aha.AhaCell.anit(aha00dirn, conf=aconf)
|
|
1448
1234
|
self.isin('Certificate name values must be between 1-64 characters', errcm.exception.get('mesg'))
|
|
1235
|
+
|
|
1236
|
+
async def test_aha_prov_with_user(self):
|
|
1237
|
+
|
|
1238
|
+
async with self.getTestAha() as aha:
|
|
1239
|
+
async with await s_base.Base.anit() as base:
|
|
1240
|
+
with self.getTestDir() as dirn:
|
|
1241
|
+
user = 'synuser'
|
|
1242
|
+
dirn00 = s_common.genpath(dirn, 'cell00')
|
|
1243
|
+
dirn01 = s_common.genpath(dirn, 'cell01')
|
|
1244
|
+
|
|
1245
|
+
axon00 = await base.enter_context(self.addSvcToAha(aha, '00.axon', s_axon.Axon, dirn=dirn00,
|
|
1246
|
+
provinfo={'conf': {'aha:user': user}}))
|
|
1247
|
+
self.eq(axon00.conf.get('aha:user'), user)
|
|
1248
|
+
core00 = await base.enter_context(self.addSvcToAha(aha, '00.core', s_cortex.Cortex, dirn=dirn01,
|
|
1249
|
+
conf={'axon': 'aha://axon...'},
|
|
1250
|
+
provinfo={'conf': {'aha:user': user}}))
|
|
1251
|
+
self.eq(core00.conf.get('aha:user'), user)
|
|
1252
|
+
# Svc to svc connections use the hinted aha:user value
|
|
1253
|
+
prox = self.nn(await asyncio.wait_for(core00.axon.proxy(), timeout=12))
|
|
1254
|
+
unfo = await prox.getCellUser()
|
|
1255
|
+
self.eq(unfo.get('name'), user)
|
|
1256
|
+
|
|
1257
|
+
async def test_aha_cell_with_tcp(self):
|
|
1258
|
+
# It's an older code, sir, but it checks out.
|
|
1259
|
+
# This should be removed in Synapse v3.0.0
|
|
1260
|
+
|
|
1261
|
+
with self.getTestDir() as dirn:
|
|
1262
|
+
ahadir = s_common.gendir(dirn, 'aha')
|
|
1263
|
+
clldir = s_common.gendir(dirn, 'cell')
|
|
1264
|
+
ahaconf = {
|
|
1265
|
+
'aha:name': '00.aha',
|
|
1266
|
+
'aha:network': 'loop.vertex.link',
|
|
1267
|
+
'dmon:listen': 'tcp://127.0.0.1:0/',
|
|
1268
|
+
'auth:passwd': 'secret',
|
|
1269
|
+
}
|
|
1270
|
+
async with await s_aha.AhaCell.anit(dirn=ahadir, conf=ahaconf) as aha:
|
|
1271
|
+
urls = await aha.getAhaUrls()
|
|
1272
|
+
self.len(1, urls)
|
|
1273
|
+
self.true(urls[0].startswith('ssl://'))
|
|
1274
|
+
ahaurl = f'tcp://root:secret@127.0.0.1:{aha.sockaddr[1]}/'
|
|
1275
|
+
cllconf = {
|
|
1276
|
+
'aha:name': '00.cell',
|
|
1277
|
+
'aha:network': 'loop.vertex.link',
|
|
1278
|
+
'aha:registry': ahaurl,
|
|
1279
|
+
'dmon:listen': None,
|
|
1280
|
+
}
|
|
1281
|
+
async with await s_cell.Cell.anit(dirn=clldir, conf=cllconf) as cell:
|
|
1282
|
+
self.none(await cell.ahaclient.waitready(timeout=12))
|
|
1283
|
+
self.eq(cell.conf.get('aha:registry'), ahaurl)
|
|
1284
|
+
|
|
1285
|
+
prox = await cell.ahaclient.proxy()
|
|
1286
|
+
await prox.fini()
|
|
1287
|
+
self.false(cell.ahaclient._t_ready.is_set())
|
|
1288
|
+
|
|
1289
|
+
self.none(await cell.ahaclient.waitready(timeout=12))
|
|
1290
|
+
|
|
1291
|
+
# No change when restarting
|
|
1292
|
+
async with await s_cell.Cell.anit(dirn=clldir, conf=cllconf) as cell:
|
|
1293
|
+
self.none(await cell.ahaclient.waitready(timeout=12))
|
|
1294
|
+
self.eq(cell.conf.get('aha:registry'), ahaurl)
|