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_base.py
CHANGED
|
@@ -60,6 +60,21 @@ class BaseTest(s_t_utils.SynTest):
|
|
|
60
60
|
event = await base.fire('woot', x=3, y=5, ret=[])
|
|
61
61
|
self.eq(event[1]['ret'], 8)
|
|
62
62
|
|
|
63
|
+
base00 = await s_base.Base.anit()
|
|
64
|
+
base01 = await s_base.Base.anit()
|
|
65
|
+
data = {}
|
|
66
|
+
async def onfini():
|
|
67
|
+
data['woot'] = True
|
|
68
|
+
|
|
69
|
+
await base00.fini()
|
|
70
|
+
base00.onfini(onfini)
|
|
71
|
+
await asyncio.sleep(0)
|
|
72
|
+
self.true(data.get('woot'))
|
|
73
|
+
|
|
74
|
+
base00.onfini(base01)
|
|
75
|
+
await asyncio.sleep(0)
|
|
76
|
+
self.true(base01.isfini)
|
|
77
|
+
|
|
63
78
|
async def test_base_anit(self):
|
|
64
79
|
|
|
65
80
|
afoo = await Hehe.anit(20)
|
|
@@ -201,6 +216,7 @@ class BaseTest(s_t_utils.SynTest):
|
|
|
201
216
|
self.eq(data['count'], 1)
|
|
202
217
|
|
|
203
218
|
async def test_base_waiter(self):
|
|
219
|
+
|
|
204
220
|
base0 = await s_base.Base.anit()
|
|
205
221
|
|
|
206
222
|
wait0 = base0.waiter(3, 'foo:bar')
|
|
@@ -224,6 +240,10 @@ class BaseTest(s_t_utils.SynTest):
|
|
|
224
240
|
evts = await wait2.wait(1)
|
|
225
241
|
self.len(2, evts)
|
|
226
242
|
|
|
243
|
+
with self.raises(s_exc.TimeOut):
|
|
244
|
+
async with base0.waiter(1, 'newp', 'nuuh', timeout=0.01):
|
|
245
|
+
pass
|
|
246
|
+
|
|
227
247
|
async def test_baseref(self):
|
|
228
248
|
|
|
229
249
|
bref = await s_base.BaseRef.anit()
|
synapse/tests/test_lib_cell.py
CHANGED
|
@@ -635,7 +635,6 @@ class CellTest(s_t_utils.SynTest):
|
|
|
635
635
|
async with self.getTestCell(s_cell.Cell, dirn=dir0, conf=conf) as cell00, \
|
|
636
636
|
cell00.getLocalProxy() as prox00:
|
|
637
637
|
|
|
638
|
-
self.true(cell00.nexsroot.map_async)
|
|
639
638
|
self.true(cell00.nexsroot.donexslog)
|
|
640
639
|
|
|
641
640
|
await prox00.addUser('test')
|
|
@@ -932,7 +931,7 @@ class CellTest(s_t_utils.SynTest):
|
|
|
932
931
|
pass
|
|
933
932
|
stream.seek(0)
|
|
934
933
|
buf = stream.read()
|
|
935
|
-
self.isin(f'...cell API (telepath):
|
|
934
|
+
self.isin(f'...cell API (telepath): tcp://0.0.0.0:27492', buf)
|
|
936
935
|
self.isin('...cell API (https): disabled', buf)
|
|
937
936
|
|
|
938
937
|
async def test_cell_initargv_conf(self):
|
|
@@ -954,11 +953,11 @@ class CellTest(s_t_utils.SynTest):
|
|
|
954
953
|
# 1) cmdline
|
|
955
954
|
# 2) envars
|
|
956
955
|
# 3) cell.yaml
|
|
957
|
-
self.true(cell.conf.
|
|
958
|
-
self.true(cell.conf.
|
|
959
|
-
self.none(cell.conf.
|
|
960
|
-
self.none(cell.conf.
|
|
961
|
-
self.eq(cell.conf.
|
|
956
|
+
self.true(cell.conf.req('nexslog:en'))
|
|
957
|
+
self.true(cell.conf.req('nexslog:async'))
|
|
958
|
+
self.none(cell.conf.req('dmon:listen'))
|
|
959
|
+
self.none(cell.conf.req('https:port'))
|
|
960
|
+
self.eq(cell.conf.req('aha:name'), 'some:cell')
|
|
962
961
|
root = cell.auth.rootuser
|
|
963
962
|
self.true(await root.tryPasswd('secret'))
|
|
964
963
|
|
|
@@ -966,7 +965,7 @@ class CellTest(s_t_utils.SynTest):
|
|
|
966
965
|
with self.getTestDir() as dirn:
|
|
967
966
|
s_common.yamlsave({'nexslog:en': False}, dirn, 'cell.mods.yaml')
|
|
968
967
|
async with await s_cell.Cell.initFromArgv([dirn]) as cell:
|
|
969
|
-
self.false(cell.conf.
|
|
968
|
+
self.false(cell.conf.req('nexslog:en'))
|
|
970
969
|
# We can remove the valu from the overrides file with the pop API
|
|
971
970
|
# This is NOT reactive API which causes the whole behavior
|
|
972
971
|
# of the cell to suddenly change. This is intended to be used with
|
|
@@ -1038,6 +1037,7 @@ class CellTest(s_t_utils.SynTest):
|
|
|
1038
1037
|
errinfo = info.get('lastexception')
|
|
1039
1038
|
laststart1 = info['laststart']
|
|
1040
1039
|
self.eq(errinfo['err'], 'SynErr')
|
|
1040
|
+
self.eq(errinfo['errinfo']['mesg'], 'backup subprocess start timed out')
|
|
1041
1041
|
|
|
1042
1042
|
# Test runners can take an unusually long time to spawn a process
|
|
1043
1043
|
with mock.patch.object(s_cell.Cell, 'BACKUP_SPAWN_TIMEOUT', 8.0):
|
|
@@ -1050,15 +1050,17 @@ class CellTest(s_t_utils.SynTest):
|
|
|
1050
1050
|
self.ne(laststart1, laststart2)
|
|
1051
1051
|
errinfo = info.get('lastexception')
|
|
1052
1052
|
self.eq(errinfo['err'], 'SynErr')
|
|
1053
|
+
self.eq(errinfo['errinfo']['mesg'], 'backup subprocess start timed out')
|
|
1053
1054
|
|
|
1054
|
-
|
|
1055
|
-
|
|
1055
|
+
with mock.patch.object(s_cell.Cell, '_backupProc', staticmethod(_exiterProc)):
|
|
1056
|
+
await self.asyncraises(s_exc.SpawnExit, proxy.runBackup('_exiterProc'))
|
|
1056
1057
|
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1058
|
+
info = await proxy.getBackupInfo()
|
|
1059
|
+
laststart3 = info['laststart']
|
|
1060
|
+
self.ne(laststart2, laststart3)
|
|
1061
|
+
errinfo = info.get('lastexception')
|
|
1062
|
+
self.eq(errinfo['err'], 'SpawnExit')
|
|
1063
|
+
self.eq(errinfo['errinfo']['code'], 1)
|
|
1062
1064
|
|
|
1063
1065
|
# Create rando slabs inside cell dir
|
|
1064
1066
|
slabpath = s_common.genpath(coredirn, 'randoslab')
|
|
@@ -1741,7 +1743,7 @@ class CellTest(s_t_utils.SynTest):
|
|
|
1741
1743
|
'has different iden') as stream:
|
|
1742
1744
|
async with self.getTestCell(s_cell.Cell, dirn=path01, conf=conf01) as cell01:
|
|
1743
1745
|
await stream.wait(timeout=2)
|
|
1744
|
-
self.true(await cell01.waitfini(6))
|
|
1746
|
+
self.true(await cell01.nexsroot.waitfini(6))
|
|
1745
1747
|
|
|
1746
1748
|
async def test_backup_restore_base(self):
|
|
1747
1749
|
|
|
@@ -1836,15 +1838,42 @@ class CellTest(s_t_utils.SynTest):
|
|
|
1836
1838
|
self.true(s_common.isguid(second_doneiden))
|
|
1837
1839
|
self.ne(doneiden, second_doneiden)
|
|
1838
1840
|
|
|
1841
|
+
async def test_cell_mirrorboot_failure(self):
|
|
1842
|
+
async with self.getTestAha() as aha: # type: s_aha.AhaCell
|
|
1843
|
+
|
|
1844
|
+
with self.getTestDir() as dirn:
|
|
1845
|
+
cdr0 = s_common.genpath(dirn, 'cell00')
|
|
1846
|
+
cdr1 = s_common.genpath(dirn, 'cell01')
|
|
1847
|
+
|
|
1848
|
+
async with self.addSvcToAha(aha, '00.cell', s_cell.Cell, dirn=cdr0) as cell00:
|
|
1849
|
+
|
|
1850
|
+
conf = {'mirror': 'aha://cell...'}
|
|
1851
|
+
with self.raises(s_exc.FatalErr) as cm:
|
|
1852
|
+
async with self.getTestCell(conf=conf, dirn=cdr1) as cell01:
|
|
1853
|
+
self.fail('Cell01 should never boot')
|
|
1854
|
+
self.isin('No aha:provision configuration has been provided to allow the service to bootstrap',
|
|
1855
|
+
cm.exception.get('mesg'))
|
|
1856
|
+
|
|
1857
|
+
provurl = await aha.addAhaSvcProv('01.cell', provinfo={'mirror': 'cell'})
|
|
1858
|
+
conf = self.getCellConf({'aha:provision': provurl})
|
|
1859
|
+
async with self.getTestCell(conf=conf, dirn=cdr1) as cell01:
|
|
1860
|
+
await cell01.sync()
|
|
1861
|
+
os.unlink(s_common.genpath(cdr1, 'cell.guid'))
|
|
1862
|
+
|
|
1863
|
+
conf = self.getCellConf({'aha:provision': provurl})
|
|
1864
|
+
with self.raises(s_exc.FatalErr) as cm:
|
|
1865
|
+
async with self.getTestCell(conf=conf, dirn=cdr1) as cell01:
|
|
1866
|
+
self.fail('Cell01 should never boot')
|
|
1867
|
+
self.isin('The aha:provision URL guid matches the service prov.done guid',
|
|
1868
|
+
cm.exception.get('mesg'))
|
|
1869
|
+
|
|
1839
1870
|
async def test_backup_restore_aha(self):
|
|
1840
1871
|
# do a mirror provisioning of a Cell
|
|
1841
1872
|
# promote the mirror to being a leader
|
|
1842
1873
|
# ensure the mirror has a
|
|
1843
1874
|
# backup the mirror
|
|
1844
1875
|
# restore the backup
|
|
1845
|
-
async with self.
|
|
1846
|
-
root = await aha.auth.getUserByName('root')
|
|
1847
|
-
self.true(await root.tryPasswd('secret'))
|
|
1876
|
+
async with self.getTestAha() as aha: # type: s_aha.AhaCell
|
|
1848
1877
|
|
|
1849
1878
|
with self.getTestDir() as dirn:
|
|
1850
1879
|
cdr0 = s_common.genpath(dirn, 'core00')
|
|
@@ -1927,9 +1956,7 @@ class CellTest(s_t_utils.SynTest):
|
|
|
1927
1956
|
# ensure the mirror has a
|
|
1928
1957
|
# backup the mirror
|
|
1929
1958
|
# restore the backup
|
|
1930
|
-
async with self.
|
|
1931
|
-
root = await aha.auth.getUserByName('root')
|
|
1932
|
-
self.true(await root.tryPasswd('secret'))
|
|
1959
|
+
async with self.getTestAha() as aha: # type: s_aha.AhaCell
|
|
1933
1960
|
|
|
1934
1961
|
with self.getTestDir() as dirn:
|
|
1935
1962
|
cdr0 = s_common.genpath(dirn, 'core00')
|
synapse/tests/test_lib_config.py
CHANGED
|
@@ -31,7 +31,7 @@ class SchemaCell(s_cell.Cell):
|
|
|
31
31
|
await s_cell.Cell.__anit__(self, dirn, conf, readonly, *args, **kwargs)
|
|
32
32
|
# This captures a design pattern that reduces boilerplate
|
|
33
33
|
# code used by Cell implementators.
|
|
34
|
-
self.conf.
|
|
34
|
+
self.conf.req('apikey')
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
class ConfTest(s_test.SynTest):
|
|
@@ -162,7 +162,7 @@ class ConfTest(s_test.SynTest):
|
|
|
162
162
|
})
|
|
163
163
|
|
|
164
164
|
# We can ensure that certain vars are loaded
|
|
165
|
-
self.eq('Funky string time!', conf.
|
|
165
|
+
self.eq('Funky string time!', conf.req('key:string'))
|
|
166
166
|
# And throw if they are not, or if the requested key isn't even schema valid
|
|
167
167
|
self.raises(s_exc.NeedConfValu, conf.reqConfValu, 'key:bool:nodefval')
|
|
168
168
|
self.raises(s_exc.BadArg, conf.reqConfValu, 'key:newp')
|
|
@@ -286,7 +286,8 @@ class ConfTest(s_test.SynTest):
|
|
|
286
286
|
# Trying to make a cell with a missing key it wants fails
|
|
287
287
|
async with await SchemaCell.anit(dirn, conf={}) as cell:
|
|
288
288
|
pass
|
|
289
|
-
|
|
289
|
+
|
|
290
|
+
self.eq(cm.exception.get('name'), 'apikey')
|
|
290
291
|
|
|
291
292
|
def test_hideconf(self):
|
|
292
293
|
hide_schema = {
|
synapse/tests/test_lib_nexus.py
CHANGED
|
@@ -111,6 +111,14 @@ class NexusTest(s_t_utils.SynTest):
|
|
|
111
111
|
stream.seek(0)
|
|
112
112
|
self.isin('while replaying log', stream.read())
|
|
113
113
|
|
|
114
|
+
async def test_nexus_modroot(self):
|
|
115
|
+
|
|
116
|
+
async with self.getTestCell() as cell:
|
|
117
|
+
await cell.sync()
|
|
118
|
+
async with cell.nexslock:
|
|
119
|
+
await cell.modNexsRoot(cell._ctorNexsRoot)
|
|
120
|
+
await cell.sync()
|
|
121
|
+
|
|
114
122
|
async def test_nexus_mixin(self):
|
|
115
123
|
with self.getTestDir() as dirn:
|
|
116
124
|
dir1 = s_common.genpath(dirn, 'nexus1')
|
|
@@ -10,7 +10,7 @@ class AhaLibTest(s_test.SynTest):
|
|
|
10
10
|
|
|
11
11
|
async def test_stormlib_aha_basics(self):
|
|
12
12
|
|
|
13
|
-
async with self.
|
|
13
|
+
async with self.getTestAha() as aha:
|
|
14
14
|
|
|
15
15
|
with self.getTestDir() as dirn:
|
|
16
16
|
|
|
@@ -36,24 +36,24 @@ class AhaLibTest(s_test.SynTest):
|
|
|
36
36
|
self.len(5, svcs)
|
|
37
37
|
|
|
38
38
|
svc = await core00.callStorm('return( $lib.aha.get(core...) )')
|
|
39
|
-
self.eq('core.
|
|
40
|
-
svc = await core00.callStorm('return( $lib.aha.get(core.
|
|
41
|
-
self.eq('core.
|
|
39
|
+
self.eq('core.synapse', svc.get('name'))
|
|
40
|
+
svc = await core00.callStorm('return( $lib.aha.get(core.synapse))')
|
|
41
|
+
self.eq('core.synapse', svc.get('name'))
|
|
42
42
|
svc = await core00.callStorm('return( $lib.aha.get(00.cell...))')
|
|
43
|
-
self.eq('00.cell.
|
|
43
|
+
self.eq('00.cell.synapse', svc.get('name'))
|
|
44
44
|
svc = await core00.callStorm('return( $lib.aha.get(cell...))')
|
|
45
|
-
self.eq('cell.
|
|
45
|
+
self.eq('cell.synapse', svc.get('name'))
|
|
46
46
|
svc = await core00.callStorm('$f=({"mirror": (true)}) return( $lib.aha.get(cell..., filters=$f))')
|
|
47
|
-
self.eq('01.cell.
|
|
47
|
+
self.eq('01.cell.synapse', svc.get('name'))
|
|
48
48
|
|
|
49
49
|
# List the aha services available
|
|
50
50
|
msgs = await core00.stormlist('aha.svc.list --nexus')
|
|
51
51
|
self.stormIsInPrint('Nexus', msgs)
|
|
52
|
-
self.stormIsInPrint('00.cell.
|
|
53
|
-
self.stormIsInPrint('01.cell.
|
|
54
|
-
self.stormIsInPrint('cell.
|
|
55
|
-
self.stormIsInPrint('core.
|
|
56
|
-
self.stormIsInPrint('mysvc.
|
|
52
|
+
self.stormIsInPrint('00.cell.synapse true true true', msgs, whitespace=False)
|
|
53
|
+
self.stormIsInPrint('01.cell.synapse false true true', msgs, whitespace=False)
|
|
54
|
+
self.stormIsInPrint('cell.synapse true true true', msgs, whitespace=False)
|
|
55
|
+
self.stormIsInPrint('core.synapse null true true', msgs, whitespace=False)
|
|
56
|
+
self.stormIsInPrint('mysvc.synapse null true true', msgs, whitespace=False)
|
|
57
57
|
|
|
58
58
|
msgs = await core00.stormlist('aha.svc.list')
|
|
59
59
|
self.stormNotInPrint('Nexus', msgs)
|
|
@@ -63,24 +63,24 @@ class AhaLibTest(s_test.SynTest):
|
|
|
63
63
|
# Omit checking part of that.
|
|
64
64
|
emsg = '''Resolved cell... to an AHA Service.
|
|
65
65
|
|
|
66
|
-
Name: cell.
|
|
66
|
+
Name: cell.synapse
|
|
67
67
|
Online: true
|
|
68
68
|
Ready: true
|
|
69
69
|
Run iden: ********************************
|
|
70
70
|
Cell iden: ********************************
|
|
71
71
|
Leader: cell
|
|
72
72
|
Connection information:
|
|
73
|
-
ca:
|
|
73
|
+
ca: synapse
|
|
74
74
|
'''
|
|
75
75
|
self.stormIsInPrint(emsg, msgs, deguid=True)
|
|
76
|
-
self.stormIsInPrint(' hostname: 00.cell.
|
|
76
|
+
self.stormIsInPrint(' hostname: 00.cell.synapse', msgs)
|
|
77
77
|
self.stormIsInPrint(' scheme: ssl', msgs)
|
|
78
78
|
self.stormIsInPrint(' user: root', msgs)
|
|
79
79
|
|
|
80
80
|
msgs = await core00.stormlist('aha.svc.stat --nexus cell...')
|
|
81
81
|
emsg = '''Resolved cell... to an AHA Service.
|
|
82
82
|
|
|
83
|
-
Name: cell.
|
|
83
|
+
Name: cell.synapse
|
|
84
84
|
Online: true
|
|
85
85
|
Ready: true
|
|
86
86
|
Run iden: ********************************
|
|
@@ -88,14 +88,14 @@ Cell iden: ********************************
|
|
|
88
88
|
Leader: cell
|
|
89
89
|
Nexus: 1
|
|
90
90
|
Connection information:
|
|
91
|
-
ca:
|
|
91
|
+
ca: synapse
|
|
92
92
|
'''
|
|
93
93
|
self.stormIsInPrint(emsg, msgs, deguid=True)
|
|
94
94
|
|
|
95
95
|
msgs = await core00.stormlist('aha.svc.stat --nexus 01.cell...')
|
|
96
96
|
emsg = '''Resolved 01.cell... to an AHA Service.
|
|
97
97
|
|
|
98
|
-
Name: 01.cell.
|
|
98
|
+
Name: 01.cell.synapse
|
|
99
99
|
Online: true
|
|
100
100
|
Ready: true
|
|
101
101
|
Run iden: ********************************
|
|
@@ -103,15 +103,15 @@ Cell iden: ********************************
|
|
|
103
103
|
Leader: cell
|
|
104
104
|
Nexus: 1
|
|
105
105
|
Connection information:
|
|
106
|
-
ca:
|
|
106
|
+
ca: synapse
|
|
107
107
|
'''
|
|
108
108
|
self.stormIsInPrint(emsg, msgs, deguid=True)
|
|
109
109
|
|
|
110
110
|
# Full name works
|
|
111
|
-
msgs = await core00.stormlist('aha.svc.stat 01.cell.
|
|
112
|
-
emsg = '''Resolved 01.cell.
|
|
111
|
+
msgs = await core00.stormlist('aha.svc.stat 01.cell.synapse')
|
|
112
|
+
emsg = '''Resolved 01.cell.synapse to an AHA Service.
|
|
113
113
|
|
|
114
|
-
Name: 01.cell.
|
|
114
|
+
Name: 01.cell.synapse
|
|
115
115
|
'''
|
|
116
116
|
self.stormIsInPrint(emsg, msgs, deguid=True)
|
|
117
117
|
|
|
@@ -128,8 +128,8 @@ Name: 01.cell.loop.vertex.link
|
|
|
128
128
|
emsg = '''Resolved pool00... to an AHA Pool.
|
|
129
129
|
|
|
130
130
|
The pool currently has 1 members.
|
|
131
|
-
AHA Pool: pool00.
|
|
132
|
-
Member: 00.cell.
|
|
131
|
+
AHA Pool: pool00.synapse
|
|
132
|
+
Member: 00.cell.synapse'''
|
|
133
133
|
self.stormIsInPrint(emsg, msgs)
|
|
134
134
|
|
|
135
135
|
# Shut down a service
|
|
@@ -139,15 +139,15 @@ Member: 00.cell.loop.vertex.link'''
|
|
|
139
139
|
self.len(nevents, await waiter.wait(timeout=12))
|
|
140
140
|
|
|
141
141
|
msgs = await core00.stormlist('aha.svc.list')
|
|
142
|
-
self.stormIsInPrint('01.cell.
|
|
142
|
+
self.stormIsInPrint('01.cell.synapse false false false', msgs, whitespace=False)
|
|
143
143
|
|
|
144
144
|
# Fake a record
|
|
145
145
|
await aha.addAhaSvc('00.newp', info={'urlinfo': {'scheme': 'tcp', 'host': '0.0.0.0', 'port': '3030'}},
|
|
146
|
-
network='
|
|
146
|
+
network='synapse')
|
|
147
147
|
|
|
148
148
|
msgs = await core00.stormlist('aha.svc.list --nexus')
|
|
149
|
-
emsg = '00.newp.
|
|
150
|
-
self.stormIsInPrint(emsg, msgs)
|
|
149
|
+
emsg = '00.newp.synapse null false null 0.0.0.0 3030 <offline>'
|
|
150
|
+
self.stormIsInPrint(emsg, msgs, whitespace=False)
|
|
151
151
|
|
|
152
152
|
self.none(await core00.callStorm('return($lib.aha.del(00.newp...))'))
|
|
153
153
|
msgs = await core00.stormlist('aha.svc.list')
|
|
@@ -160,22 +160,22 @@ Member: 00.cell.loop.vertex.link'''
|
|
|
160
160
|
'port': '3030'},
|
|
161
161
|
'online': guid,
|
|
162
162
|
},
|
|
163
|
-
network='
|
|
163
|
+
network='synapse')
|
|
164
164
|
msgs = await core00.stormlist('aha.svc.list --nexus')
|
|
165
|
-
emsg = '00.newp.
|
|
166
|
-
'Failed to connect to Telepath service: "aha://00.newp.
|
|
167
|
-
self.stormIsInPrint(emsg, msgs)
|
|
165
|
+
emsg = '00.newp.synapse null true null 0.0.0.0 3030 ' \
|
|
166
|
+
'Failed to connect to Telepath service: "aha://00.newp.synapse/" error:'
|
|
167
|
+
self.stormIsInPrint(emsg, msgs, whitespace=False)
|
|
168
168
|
|
|
169
169
|
msgs = await core00.stormlist('aha.svc.stat --nexus 00.newp...')
|
|
170
170
|
emsg = '''Resolved 00.newp... to an AHA Service.
|
|
171
171
|
|
|
172
|
-
Name: 00.newp.
|
|
172
|
+
Name: 00.newp.synapse
|
|
173
173
|
Online: true
|
|
174
174
|
Ready: null
|
|
175
175
|
Run iden: $lib.null
|
|
176
176
|
Cell iden: $lib.null
|
|
177
177
|
Leader: Service did not register itself with a leader name.
|
|
178
|
-
Nexus: Failed to connect to Telepath service: "aha://00.newp.
|
|
178
|
+
Nexus: Failed to connect to Telepath service: "aha://00.newp.synapse/" error: [Errno 111] Connect call failed ('0.0.0.0', 3030)
|
|
179
179
|
Connection information:
|
|
180
180
|
host: 0.0.0.0
|
|
181
181
|
port: 3030
|
|
@@ -184,7 +184,7 @@ Connection information:
|
|
|
184
184
|
self.stormIsInPrint(emsg, msgs)
|
|
185
185
|
|
|
186
186
|
# Delete the fake service with its full service name
|
|
187
|
-
self.none(await core00.callStorm('return($lib.aha.del(00.newp.
|
|
187
|
+
self.none(await core00.callStorm('return($lib.aha.del(00.newp.synapse))'))
|
|
188
188
|
self.none(await core00.callStorm('return($lib.aha.get(00.newp...))'))
|
|
189
189
|
|
|
190
190
|
# Coverage for sad paths
|
|
@@ -76,18 +76,7 @@ class StormCellTest(s_test.SynTest):
|
|
|
76
76
|
|
|
77
77
|
async def test_stormlib_cell_getmirrors(self):
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
'aha:name': 'aha',
|
|
81
|
-
'aha:network': 'mynet',
|
|
82
|
-
'provision:listen': 'tcp://127.0.0.1:0',
|
|
83
|
-
}
|
|
84
|
-
async with self.getTestCell(s_aha.AhaCell, conf=conf) as aha:
|
|
85
|
-
|
|
86
|
-
provaddr, provport = aha.provdmon.addr
|
|
87
|
-
aha.conf['provision:listen'] = f'tcp://127.0.0.1:{provport}'
|
|
88
|
-
|
|
89
|
-
ahahost, ahaport = await aha.dmon.listen('ssl://127.0.0.1:0?hostname=aha.mynet&ca=mynet')
|
|
90
|
-
aha.conf['aha:urls'] = (f'ssl://127.0.0.1:{ahaport}?hostname=aha.mynet',)
|
|
79
|
+
async with self.getTestAha() as aha:
|
|
91
80
|
|
|
92
81
|
provurl = await aha.addAhaSvcProv('00.cortex')
|
|
93
82
|
coreconf = {'aha:provision': provurl}
|
|
@@ -116,7 +105,7 @@ class StormCellTest(s_test.SynTest):
|
|
|
116
105
|
await core01.nodes('[ inet:ipv4=1.2.3.4 ]')
|
|
117
106
|
self.len(1, await core00.nodes('inet:ipv4=1.2.3.4'))
|
|
118
107
|
|
|
119
|
-
expurls = ['aha://01.cortex.
|
|
108
|
+
expurls = ['aha://01.cortex.synapse']
|
|
120
109
|
|
|
121
110
|
self.eq(expurls, await core00.callStorm('return($lib.cell.getMirrorUrls())'))
|
|
122
111
|
self.eq(expurls, await core01.callStorm('return($lib.cell.getMirrorUrls())'))
|
|
@@ -148,11 +137,11 @@ class StormCellTest(s_test.SynTest):
|
|
|
148
137
|
|
|
149
138
|
await svc01.sync()
|
|
150
139
|
|
|
151
|
-
expurls = ('aha://01.testsvc.
|
|
140
|
+
expurls = ('aha://01.testsvc.synapse',)
|
|
152
141
|
|
|
153
142
|
self.eq(expurls, await core00.callStorm('return($lib.cell.getMirrorUrls(name=testsvc))'))
|
|
154
143
|
|
|
155
|
-
await aha.delAhaSvc('00.testsvc.
|
|
144
|
+
await aha.delAhaSvc('00.testsvc.synapse')
|
|
156
145
|
|
|
157
146
|
with self.raises(s_exc.NoSuchName):
|
|
158
147
|
await core00.callStorm('return($lib.cell.getMirrorUrls(name=testsvc))')
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import ssl
|
|
1
2
|
import asyncio
|
|
2
3
|
|
|
3
4
|
from unittest import mock
|
|
@@ -124,8 +125,13 @@ class ImapTest(s_test.SynTest):
|
|
|
124
125
|
|
|
125
126
|
async def test_storm_imap(self):
|
|
126
127
|
|
|
127
|
-
|
|
128
|
-
|
|
128
|
+
client_args = []
|
|
129
|
+
def client_mock(*args, **kwargs):
|
|
130
|
+
client_args.append((args, kwargs))
|
|
131
|
+
return mock_create_client(*args, **kwargs)
|
|
132
|
+
|
|
133
|
+
with mock.patch('aioimaplib.IMAP4.create_client', client_mock), \
|
|
134
|
+
mock.patch('aioimaplib.IMAP4_SSL.create_client', client_mock):
|
|
129
135
|
|
|
130
136
|
async with self.getTestCore() as core:
|
|
131
137
|
|
|
@@ -137,16 +143,20 @@ class ImapTest(s_test.SynTest):
|
|
|
137
143
|
'''
|
|
138
144
|
retn = await core.callStorm(scmd)
|
|
139
145
|
self.eq((True, ('INBOX',)), retn)
|
|
146
|
+
ctx = self.nn(client_args[-1][0][5]) # type: ssl.SSLContext
|
|
147
|
+
self.eq(ctx.verify_mode, ssl.CERT_REQUIRED)
|
|
140
148
|
|
|
141
149
|
# search for UIDs
|
|
142
150
|
scmd = '''
|
|
143
|
-
$server = $lib.inet.imap.connect(hello)
|
|
151
|
+
$server = $lib.inet.imap.connect(hello, ssl_verify=(false))
|
|
144
152
|
$server.login("vtx@email.com", "secret")
|
|
145
153
|
$server.select("INBOX")
|
|
146
154
|
return($server.search("FROM", "foo@mail.com"))
|
|
147
155
|
'''
|
|
148
156
|
retn = await core.callStorm(scmd)
|
|
149
157
|
self.eq((True, ('8181', '8192', '8194')), retn)
|
|
158
|
+
ctx = self.nn(client_args[-1][0][5]) # type: ssl.SSLContext
|
|
159
|
+
self.eq(ctx.verify_mode, ssl.CERT_NONE)
|
|
150
160
|
|
|
151
161
|
# search for UIDs with specific charset
|
|
152
162
|
scmd = '''
|
|
@@ -186,6 +196,7 @@ class ImapTest(s_test.SynTest):
|
|
|
186
196
|
'''
|
|
187
197
|
retn = await core.callStorm(scmd)
|
|
188
198
|
self.eq((True, None), retn)
|
|
199
|
+
self.none(client_args[-1][0][5])
|
|
189
200
|
|
|
190
201
|
# delete
|
|
191
202
|
scmd = '''
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import ssl
|
|
2
|
+
import email.mime.multipart as e_muiltipart
|
|
3
|
+
|
|
1
4
|
from unittest import mock
|
|
2
5
|
import synapse.tests.utils as s_test
|
|
3
6
|
|
|
@@ -5,7 +8,9 @@ class SmtpTest(s_test.SynTest):
|
|
|
5
8
|
|
|
6
9
|
async def test_storm_smtp(self):
|
|
7
10
|
|
|
11
|
+
called_args = []
|
|
8
12
|
async def send(*args, **kwargs):
|
|
13
|
+
called_args.append((args, kwargs))
|
|
9
14
|
return
|
|
10
15
|
|
|
11
16
|
with mock.patch('aiosmtplib.send', send):
|
|
@@ -14,6 +19,9 @@ class SmtpTest(s_test.SynTest):
|
|
|
14
19
|
|
|
15
20
|
retn = await core.callStorm('return($lib.inet.smtp.message().send(127.0.0.1))')
|
|
16
21
|
self.false(retn[0])
|
|
22
|
+
self.eq(retn[1].get('err'), 'StormRuntimeError')
|
|
23
|
+
self.isin('The inet:smtp:message has no HTML or text body.', retn[1].get('errmsg'))
|
|
24
|
+
self.len(0, called_args)
|
|
17
25
|
|
|
18
26
|
retn = await core.callStorm('''
|
|
19
27
|
$message = $lib.inet.smtp.message()
|
|
@@ -31,6 +39,49 @@ class SmtpTest(s_test.SynTest):
|
|
|
31
39
|
return($message.send('smtp.gmail.com', port=465, usetls=true))
|
|
32
40
|
''')
|
|
33
41
|
self.eq(retn, (True, {}))
|
|
42
|
+
mesg = called_args[-1][0][0] # type: e_muiltipart.MIMEMultipart
|
|
43
|
+
self.eq(mesg.get_all('subject'), ['woot'])
|
|
44
|
+
payload = mesg.get_payload()
|
|
45
|
+
self.len(2, payload)
|
|
46
|
+
self.eq([pl.get_content_type() for pl in payload],
|
|
47
|
+
['text/plain', 'text/html'])
|
|
48
|
+
ctx = self.nn(called_args[-1][1].get('tls_context')) # type: ssl.SSLContext
|
|
49
|
+
self.eq(ctx.verify_mode, ssl.CERT_REQUIRED)
|
|
50
|
+
self.eq(called_args[-1][1].get('port'), 465)
|
|
51
|
+
self.true(called_args[-1][1].get('use_tls'))
|
|
52
|
+
self.false(called_args[-1][1].get('start_tls'))
|
|
53
|
+
|
|
54
|
+
retn = await core.callStorm('''
|
|
55
|
+
$message = $lib.inet.smtp.message()
|
|
56
|
+
$message.text = "HELLO WORLD"
|
|
57
|
+
$message.sender = visi@vertex.link
|
|
58
|
+
$message.headers.Subject = woot
|
|
59
|
+
$message.recipients.append(visi@vertex.link)
|
|
60
|
+
return($message.send('smtp.gmail.com', port=465, starttls=true, ssl_verify=(false)))
|
|
61
|
+
''')
|
|
62
|
+
self.eq(retn, (True, {}))
|
|
63
|
+
mesg = called_args[-1][0][0] # type: e_muiltipart.MIMEMultipart
|
|
64
|
+
payload = mesg.get_payload()
|
|
65
|
+
self.len(1, payload)
|
|
66
|
+
self.eq([pl.get_content_type() for pl in payload], ['text/plain'])
|
|
67
|
+
ctx = self.nn(called_args[-1][1].get('tls_context')) # type: ssl.SSLContext
|
|
68
|
+
self.eq(ctx.verify_mode, ssl.CERT_NONE)
|
|
69
|
+
self.false(called_args[-1][1].get('use_tls'))
|
|
70
|
+
self.true(called_args[-1][1].get('start_tls'))
|
|
71
|
+
|
|
72
|
+
retn = await core.callStorm('''
|
|
73
|
+
$message = $lib.inet.smtp.message()
|
|
74
|
+
$message.text = "HELLO WORLD"
|
|
75
|
+
$message.sender = visi@vertex.link
|
|
76
|
+
$message.headers.Subject = woot
|
|
77
|
+
$message.recipients.append(visi@vertex.link)
|
|
78
|
+
return($message.send('smtp.gmail.com', port=25))
|
|
79
|
+
''')
|
|
80
|
+
self.eq(retn, (True, {}))
|
|
81
|
+
self.none(called_args[-1][1].get('tls_context')) # type: ssl.SSLContext
|
|
82
|
+
self.eq(called_args[-1][1].get('port'), 25)
|
|
83
|
+
self.false(called_args[-1][1].get('use_tls'))
|
|
84
|
+
self.false(called_args[-1][1].get('start_tls'))
|
|
34
85
|
|
|
35
86
|
isok, info = await core.callStorm('''
|
|
36
87
|
$message = $lib.inet.smtp.message()
|