synapse 2.193.0__py311-none-any.whl → 2.195.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 +9 -7
- synapse/datamodel.py +9 -6
- synapse/exc.py +1 -1
- synapse/lib/agenda.py +17 -4
- synapse/lib/ast.py +217 -86
- synapse/lib/auth.py +5 -2
- synapse/lib/link.py +33 -19
- synapse/lib/modelrev.py +6 -1
- synapse/lib/parser.py +4 -0
- synapse/lib/scrape.py +18 -1
- synapse/lib/snap.py +40 -11
- synapse/lib/storm.lark +16 -1
- synapse/lib/storm.py +6 -4
- synapse/lib/storm_format.py +1 -0
- synapse/lib/stormctrl.py +88 -6
- synapse/lib/stormlib/auth.py +15 -1
- synapse/lib/stormlib/cache.py +6 -2
- synapse/lib/stormlib/cell.py +11 -0
- synapse/lib/stormlib/infosec.py +2 -0
- synapse/lib/stormlib/scrape.py +1 -1
- synapse/lib/stormlib/stix.py +8 -8
- synapse/lib/stormtypes.py +13 -5
- synapse/lib/version.py +2 -2
- synapse/lib/view.py +20 -3
- synapse/models/geopol.py +1 -0
- synapse/models/geospace.py +53 -10
- synapse/models/inet.py +3 -0
- synapse/models/infotech.py +12 -5
- synapse/models/material.py +67 -8
- synapse/models/orgs.py +11 -3
- synapse/models/person.py +28 -17
- synapse/models/risk.py +4 -1
- synapse/models/syn.py +3 -0
- synapse/models/telco.py +10 -3
- synapse/models/transport.py +382 -49
- synapse/tests/test_axon.py +6 -6
- synapse/tests/test_cortex.py +134 -12
- synapse/tests/test_exc.py +1 -0
- synapse/tests/test_lib_agenda.py +125 -1
- synapse/tests/test_lib_aha.py +13 -6
- synapse/tests/test_lib_ast.py +258 -9
- synapse/tests/test_lib_auth.py +6 -7
- synapse/tests/test_lib_cell.py +10 -0
- synapse/tests/test_lib_grammar.py +14 -0
- synapse/tests/test_lib_layer.py +1 -1
- synapse/tests/test_lib_link.py +6 -1
- synapse/tests/test_lib_lmdbslab.py +3 -3
- synapse/tests/test_lib_modelrev.py +7 -0
- synapse/tests/test_lib_scrape.py +8 -0
- synapse/tests/test_lib_storm.py +201 -25
- synapse/tests/test_lib_stormctrl.py +65 -0
- synapse/tests/test_lib_stormhttp.py +5 -5
- synapse/tests/test_lib_stormlib_auth.py +31 -5
- synapse/tests/test_lib_stormlib_cache.py +38 -6
- synapse/tests/test_lib_stormlib_cell.py +3 -0
- synapse/tests/test_lib_stormlib_modelext.py +3 -3
- synapse/tests/test_lib_stormlib_scrape.py +4 -4
- synapse/tests/test_lib_stormlib_spooled.py +1 -1
- synapse/tests/test_lib_stormlib_xml.py +5 -5
- synapse/tests/test_lib_stormtypes.py +54 -57
- synapse/tests/test_lib_view.py +1 -1
- synapse/tests/test_model_base.py +1 -2
- synapse/tests/test_model_geopol.py +4 -0
- synapse/tests/test_model_geospace.py +43 -4
- synapse/tests/test_model_inet.py +3 -0
- synapse/tests/test_model_infotech.py +31 -4
- synapse/tests/test_model_material.py +18 -0
- synapse/tests/test_model_orgs.py +25 -3
- synapse/tests/test_model_person.py +26 -1
- synapse/tests/test_model_risk.py +11 -0
- synapse/tests/test_model_syn.py +9 -3
- synapse/tests/test_model_transport.py +168 -0
- synapse/tests/test_telepath.py +24 -5
- synapse/tests/test_tools_healthcheck.py +4 -4
- synapse/tests/test_utils.py +17 -18
- synapse/tests/utils.py +0 -35
- synapse/tools/changelog.py +14 -5
- synapse/tools/storm.py +1 -1
- {synapse-2.193.0.dist-info → synapse-2.195.0.dist-info}/METADATA +5 -5
- {synapse-2.193.0.dist-info → synapse-2.195.0.dist-info}/RECORD +83 -82
- {synapse-2.193.0.dist-info → synapse-2.195.0.dist-info}/WHEEL +1 -1
- {synapse-2.193.0.dist-info → synapse-2.195.0.dist-info}/LICENSE +0 -0
- {synapse-2.193.0.dist-info → synapse-2.195.0.dist-info}/top_level.txt +0 -0
synapse/tests/test_cortex.py
CHANGED
|
@@ -440,7 +440,7 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
440
440
|
'interfaces': ['lookup'],
|
|
441
441
|
'storm': '''
|
|
442
442
|
function lookup(tokens) {
|
|
443
|
-
$looks =
|
|
443
|
+
$looks = ()
|
|
444
444
|
for $token in $tokens { $looks.append( (inet:fqdn, $token) ) }
|
|
445
445
|
return($looks)
|
|
446
446
|
}
|
|
@@ -679,7 +679,7 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
679
679
|
# functions that don't return a generator
|
|
680
680
|
storm = '''
|
|
681
681
|
function x() {
|
|
682
|
-
$lst =
|
|
682
|
+
$lst = ()
|
|
683
683
|
[ ou:org=* ou:org=* +#cat ]
|
|
684
684
|
$lst.append($node)
|
|
685
685
|
fini { return($lst) }
|
|
@@ -692,7 +692,7 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
692
692
|
|
|
693
693
|
storm = '''
|
|
694
694
|
function x() {
|
|
695
|
-
$lst =
|
|
695
|
+
$lst = ()
|
|
696
696
|
[ ou:org=* ou:org=* +#dog ]
|
|
697
697
|
$lst.append($node)
|
|
698
698
|
fini { return($lst) }
|
|
@@ -974,7 +974,7 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
974
974
|
await core.nodes('media:news -(refs)> $(10)')
|
|
975
975
|
|
|
976
976
|
self.eq(1, await core.callStorm('''
|
|
977
|
-
$list =
|
|
977
|
+
$list = ()
|
|
978
978
|
for $edge in $lib.view.get().getEdges() { $list.append($edge) }
|
|
979
979
|
return($list.size())
|
|
980
980
|
'''))
|
|
@@ -982,7 +982,7 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
982
982
|
# check that auto-deleting a node's edges works
|
|
983
983
|
await core.nodes('media:news | delnode')
|
|
984
984
|
self.eq(0, await core.callStorm('''
|
|
985
|
-
$list =
|
|
985
|
+
$list = ()
|
|
986
986
|
for $edge in $lib.view.get().getEdges() { $list.append($edge) }
|
|
987
987
|
return($list.size())
|
|
988
988
|
'''))
|
|
@@ -1017,7 +1017,7 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
1017
1017
|
self.eq(('1', '2'), retn)
|
|
1018
1018
|
|
|
1019
1019
|
with self.raises(s_exc.StormRuntimeError):
|
|
1020
|
-
q = '$foo
|
|
1020
|
+
q = '$foo=() $bar=$foo.index(10) return ( $bar )'
|
|
1021
1021
|
await proxy.callStorm(q)
|
|
1022
1022
|
|
|
1023
1023
|
with self.raises(s_exc.SynErr) as cm:
|
|
@@ -1033,6 +1033,26 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
1033
1033
|
self.eq(cm.exception.get('hehe'), 'haha')
|
|
1034
1034
|
self.eq(cm.exception.get('key'), 1)
|
|
1035
1035
|
|
|
1036
|
+
# We convert StormLoopCtrl and StormGenrCtrl into StormRuntimeError
|
|
1037
|
+
opts = {'vars': {'i': 2}}
|
|
1038
|
+
q = 'if ($i = 2) { break }'
|
|
1039
|
+
with self.raises(s_exc.StormRuntimeError) as cm:
|
|
1040
|
+
await core.callStorm(q, opts=opts)
|
|
1041
|
+
self.eq(cm.exception.get('mesg'),
|
|
1042
|
+
'Loop control statement "break" used outside of a loop.')
|
|
1043
|
+
|
|
1044
|
+
q = 'if ($i = 2) { continue }'
|
|
1045
|
+
with self.raises(s_exc.StormRuntimeError) as cm:
|
|
1046
|
+
await core.callStorm(q, opts=opts)
|
|
1047
|
+
self.eq(cm.exception.get('mesg'),
|
|
1048
|
+
'Loop control statement "continue" used outside of a loop.')
|
|
1049
|
+
|
|
1050
|
+
q = 'if ($i = 2) { stop }'
|
|
1051
|
+
with self.raises(s_exc.StormRuntimeError) as cm:
|
|
1052
|
+
await core.callStorm(q, opts=opts)
|
|
1053
|
+
self.eq(cm.exception.get('mesg'),
|
|
1054
|
+
'Generator control statement "stop" used outside of a generator function.')
|
|
1055
|
+
|
|
1036
1056
|
with self.getAsyncLoggerStream('synapse.lib.view', 'callStorm cancelled') as stream:
|
|
1037
1057
|
async with core.getLocalProxy() as proxy:
|
|
1038
1058
|
|
|
@@ -1069,7 +1089,7 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
1069
1089
|
self.eq('ok', retn.get('status'))
|
|
1070
1090
|
self.eq('asdf', retn['result'])
|
|
1071
1091
|
|
|
1072
|
-
body = {'query': '$foo
|
|
1092
|
+
body = {'query': '$foo=() $bar=$foo.index(10) return ( $bar )'}
|
|
1073
1093
|
async with sess.get(f'https://localhost:{port}/api/v1/storm/call', json=body) as resp:
|
|
1074
1094
|
retn = await resp.json()
|
|
1075
1095
|
self.eq('err', retn.get('status'))
|
|
@@ -1081,7 +1101,7 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
1081
1101
|
retn = await resp.json()
|
|
1082
1102
|
self.eq('err', retn.get('status'))
|
|
1083
1103
|
self.eq('StormExit', retn.get('code'))
|
|
1084
|
-
self.eq('', retn.get('mesg'))
|
|
1104
|
+
self.eq('StormExit: ', retn.get('mesg'))
|
|
1085
1105
|
|
|
1086
1106
|
# No body
|
|
1087
1107
|
async with sess.get(f'https://localhost:{port}/api/v1/storm/call') as resp:
|
|
@@ -1760,7 +1780,7 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
1760
1780
|
self.len(1, nodes)
|
|
1761
1781
|
self.eq(set(nodes[0].tags.keys()), {'foo', 'bar', 'bar.baz'})
|
|
1762
1782
|
|
|
1763
|
-
nodes = await wcore.nodes('$foo
|
|
1783
|
+
nodes = await wcore.nodes('$foo=(["foo", "bar.baz"]) [test:int=4 +#$foo]')
|
|
1764
1784
|
self.len(1, nodes)
|
|
1765
1785
|
self.eq(set(nodes[0].tags.keys()), {'foo', 'bar', 'bar.baz'})
|
|
1766
1786
|
|
|
@@ -3028,7 +3048,7 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
3028
3048
|
|
|
3029
3049
|
depr = [x for x in coreinfo['stormdocs']['libraries'] if x['path'] == ('lib', 'infosec', 'cvss')]
|
|
3030
3050
|
self.len(1, depr)
|
|
3031
|
-
self.len(
|
|
3051
|
+
self.len(4, [x for x in depr[0]['locals'] if x.get('deprecated')])
|
|
3032
3052
|
|
|
3033
3053
|
async def test_cortex_model_dict(self):
|
|
3034
3054
|
|
|
@@ -3087,6 +3107,9 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
3087
3107
|
self.nn(model['univs'].get('.created'))
|
|
3088
3108
|
self.nn(model['univs'].get('.seen'))
|
|
3089
3109
|
|
|
3110
|
+
self.true(model['types']['edge']['info'].get('deprecated'))
|
|
3111
|
+
self.true(model['types']['timeedge']['info'].get('deprecated'))
|
|
3112
|
+
|
|
3090
3113
|
async def test_storm_graph(self):
|
|
3091
3114
|
|
|
3092
3115
|
async with self.getTestCoreAndProxy() as (core, prox):
|
|
@@ -3499,6 +3522,97 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
3499
3522
|
for node in nodes:
|
|
3500
3523
|
self.nn(node.getTag('hehe'))
|
|
3501
3524
|
|
|
3525
|
+
# Break and Continue cannot cross function boundaries and will instead raise a catchable StormRuntimeError
|
|
3526
|
+
keywords = ('break', 'continue')
|
|
3527
|
+
base_func_q = '''
|
|
3528
|
+
function inner(v) {
|
|
3529
|
+
if ( $v = 2 ) {
|
|
3530
|
+
KEYWORD
|
|
3531
|
+
}
|
|
3532
|
+
return ( $v )
|
|
3533
|
+
}
|
|
3534
|
+
$N = (5)
|
|
3535
|
+
|
|
3536
|
+
for $valu in $lib.range($N) {
|
|
3537
|
+
$lib.print(`{$inner($valu)}/{$N}`)
|
|
3538
|
+
}
|
|
3539
|
+
'''
|
|
3540
|
+
func_catch_q = '''
|
|
3541
|
+
function inner(v) {
|
|
3542
|
+
if ( $v = 2 ) {
|
|
3543
|
+
KEYWORD
|
|
3544
|
+
}
|
|
3545
|
+
return ( $v )
|
|
3546
|
+
}
|
|
3547
|
+
$N = (5)
|
|
3548
|
+
try {
|
|
3549
|
+
for $valu in $lib.range($N) {
|
|
3550
|
+
$lib.print(`{$inner($valu)}/{$N}`)
|
|
3551
|
+
}
|
|
3552
|
+
} catch StormRuntimeError as err {
|
|
3553
|
+
$lib.print(`caught: {$err.mesg}`)
|
|
3554
|
+
}
|
|
3555
|
+
'''
|
|
3556
|
+
for keyword in keywords:
|
|
3557
|
+
q = base_func_q.replace('KEYWORD', keyword)
|
|
3558
|
+
msgs = await core.stormlist(q)
|
|
3559
|
+
self.stormIsInPrint('1/5', msgs)
|
|
3560
|
+
self.stormNotInPrint('2/5', msgs)
|
|
3561
|
+
self.stormIsInErr(f'function inner - Loop control statement "{keyword}" used outside of a loop.',
|
|
3562
|
+
msgs)
|
|
3563
|
+
|
|
3564
|
+
q = func_catch_q.replace('KEYWORD', keyword)
|
|
3565
|
+
msgs = await core.stormlist(q)
|
|
3566
|
+
self.stormIsInPrint('1/5', msgs)
|
|
3567
|
+
self.stormNotInPrint('2/5', msgs)
|
|
3568
|
+
self.stormIsInPrint(f'function inner - Loop control statement "{keyword}" used outside of a loop.',
|
|
3569
|
+
msgs)
|
|
3570
|
+
|
|
3571
|
+
# The toplevel use of the keywords will convert them into StormRuntimeError in the message stream
|
|
3572
|
+
# but prevent them from being caught.
|
|
3573
|
+
base_top_q = '''
|
|
3574
|
+
$N = (5)
|
|
3575
|
+
for $j in $lib.range($N) {
|
|
3576
|
+
if ($j = 2) { break }
|
|
3577
|
+
$lib.print(`{$j}/{$N}`)
|
|
3578
|
+
}
|
|
3579
|
+
if ($j = 2) {
|
|
3580
|
+
KEYWORD
|
|
3581
|
+
}
|
|
3582
|
+
'''
|
|
3583
|
+
top_catch_q = '''
|
|
3584
|
+
$N = (5)
|
|
3585
|
+
for $j in $lib.range($N) {
|
|
3586
|
+
if ($j = 2) { break }
|
|
3587
|
+
$lib.print(`{$j}/{$N}`)
|
|
3588
|
+
}
|
|
3589
|
+
try {
|
|
3590
|
+
if ($j = 2) {
|
|
3591
|
+
KEYWORD
|
|
3592
|
+
}
|
|
3593
|
+
} catch StormRuntimeError as err {
|
|
3594
|
+
$lib.print(`caught: {$err.mesg}`)
|
|
3595
|
+
}
|
|
3596
|
+
'''
|
|
3597
|
+
for keyword in keywords:
|
|
3598
|
+
q = base_top_q.replace('KEYWORD', keyword)
|
|
3599
|
+
msgs = await core.stormlist(q)
|
|
3600
|
+
self.stormIsInPrint('1/5', msgs)
|
|
3601
|
+
self.stormNotInPrint('2/5', msgs)
|
|
3602
|
+
self.stormIsInErr(f'Loop control statement "{keyword}" used outside of a loop.',
|
|
3603
|
+
msgs)
|
|
3604
|
+
errname = [m[1][0] for m in msgs if m[0] == 'err'][0]
|
|
3605
|
+
self.eq(errname, 'StormRuntimeError')
|
|
3606
|
+
|
|
3607
|
+
q = top_catch_q.replace('KEYWORD', keyword)
|
|
3608
|
+
msgs = await core.stormlist(q)
|
|
3609
|
+
self.stormIsInPrint('1/5', msgs)
|
|
3610
|
+
self.stormNotInPrint('2/5', msgs)
|
|
3611
|
+
self.stormIsInErr(f'Loop control statement "{keyword}" used outside of a loop.',
|
|
3612
|
+
msgs)
|
|
3613
|
+
errname = [m[1][0] for m in msgs if m[0] == 'err'][0]
|
|
3614
|
+
self.eq(errname, 'StormRuntimeError')
|
|
3615
|
+
|
|
3502
3616
|
async def test_storm_varcall(self):
|
|
3503
3617
|
|
|
3504
3618
|
async with self.getTestCore() as core:
|
|
@@ -5119,6 +5233,14 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
5119
5233
|
self.eq(('inet:fqdn', 'nest.com'), nodes[0].ndef)
|
|
5120
5234
|
self.eq(('inet:fqdn', 'nest.com'), nodes[1].ndef)
|
|
5121
5235
|
|
|
5236
|
+
with self.raises(s_exc.StormRuntimeError) as err:
|
|
5237
|
+
await core.nodes('[ it:dev:int=1 ] for $n in $node.value() { }')
|
|
5238
|
+
self.isin("'int' object is not iterable: 1", err.exception.errinfo.get('mesg'))
|
|
5239
|
+
|
|
5240
|
+
with self.raises(s_exc.StormRuntimeError) as err:
|
|
5241
|
+
await core.nodes('for $n in { .created return($node) } { }')
|
|
5242
|
+
self.isin("'node' object is not iterable", err.exception.errinfo.get('mesg'))
|
|
5243
|
+
|
|
5122
5244
|
async def test_storm_whileloop(self):
|
|
5123
5245
|
|
|
5124
5246
|
async with self.getTestCore() as core:
|
|
@@ -5460,7 +5582,7 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
5460
5582
|
self.len(1, nodes)
|
|
5461
5583
|
|
|
5462
5584
|
async def test_storm_order(self):
|
|
5463
|
-
q = '''[test:str=foo :hehe=bar] $tvar
|
|
5585
|
+
q = '''[test:str=foo :hehe=bar] $tvar=() $tvar.append(1) $tvar.append(:hehe) $lib.print($lib.str.join('', $tvar)) '''
|
|
5464
5586
|
async with self.getTestCore() as core:
|
|
5465
5587
|
mesgs = await core.stormlist(q)
|
|
5466
5588
|
self.stormIsInPrint('1bar', mesgs)
|
|
@@ -5684,7 +5806,7 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
5684
5806
|
|
|
5685
5807
|
url02 = core02.getLocalUrl()
|
|
5686
5808
|
opts = {'vars': {'url01': url01, 'url02': url02}}
|
|
5687
|
-
strim = 'return($lib.cell.trimNexsLog(consumers
|
|
5809
|
+
strim = 'return($lib.cell.trimNexsLog(consumers=($url01, $url02), timeout=$lib.null))'
|
|
5688
5810
|
|
|
5689
5811
|
await core00.nodes('[ inet:ipv4=11.0.0.0/28 ]')
|
|
5690
5812
|
ips00 = await core00.count('inet:ipv4')
|
synapse/tests/test_exc.py
CHANGED
|
@@ -16,6 +16,7 @@ class ExcTest(s_t_utils.SynTest):
|
|
|
16
16
|
def test_basic(self):
|
|
17
17
|
e = s_exc.SynErr(mesg='words', foo='bar')
|
|
18
18
|
self.eq(e.get('foo'), 'bar')
|
|
19
|
+
self.eq(e.items(), {'mesg': 'words', 'foo': 'bar'})
|
|
19
20
|
self.eq("SynErr: foo='bar' mesg='words'", str(e))
|
|
20
21
|
e.set('hehe', 1234)
|
|
21
22
|
e.set('foo', 'words')
|
synapse/tests/test_lib_agenda.py
CHANGED
|
@@ -441,7 +441,7 @@ class AgendaTest(s_t_utils.SynTest):
|
|
|
441
441
|
await self.asyncraises(s_exc.DupIden, core.addCronJob(cdef))
|
|
442
442
|
await core.delCronJob(viewiden)
|
|
443
443
|
|
|
444
|
-
self.nn(core.getAuthGate(viewiden))
|
|
444
|
+
self.nn(await core.getAuthGate(viewiden))
|
|
445
445
|
|
|
446
446
|
async def test_agenda_persistence(self):
|
|
447
447
|
''' Test we can make/change/delete appointments and they are persisted to storage '''
|
|
@@ -1097,3 +1097,127 @@ class AgendaTest(s_t_utils.SynTest):
|
|
|
1097
1097
|
self.eq(cdef01.get('lastresult'), 'cancelled')
|
|
1098
1098
|
self.gt(cdef00['laststarttime'], 0)
|
|
1099
1099
|
self.eq(cdef00['laststarttime'], cdef01['laststarttime'])
|
|
1100
|
+
|
|
1101
|
+
async def test_agenda_graceful_promotion_with_running_cron(self):
|
|
1102
|
+
|
|
1103
|
+
async with self.getTestAha() as aha:
|
|
1104
|
+
|
|
1105
|
+
conf00 = {
|
|
1106
|
+
'aha:provision': await aha.addAhaSvcProv('00.cortex')
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
async with self.getTestCore(conf=conf00) as core00:
|
|
1110
|
+
self.false(core00.conf.get('mirror'))
|
|
1111
|
+
|
|
1112
|
+
q = '''
|
|
1113
|
+
while((true)) {
|
|
1114
|
+
$lib.log.error('I AM A ERROR LOG MESSAGE')
|
|
1115
|
+
$lib.time.sleep(6)
|
|
1116
|
+
}
|
|
1117
|
+
'''
|
|
1118
|
+
msgs = await core00.stormlist('cron.at --now $q', opts={'vars': {'q': q}})
|
|
1119
|
+
self.stormHasNoWarnErr(msgs)
|
|
1120
|
+
|
|
1121
|
+
crons00 = await core00.callStorm('return($lib.cron.list())')
|
|
1122
|
+
self.len(1, crons00)
|
|
1123
|
+
|
|
1124
|
+
prov01 = {'mirror': '00.cortex'}
|
|
1125
|
+
conf01 = {
|
|
1126
|
+
'aha:provision': await aha.addAhaSvcProv('01.cortex', provinfo=prov01),
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
async with self.getTestCore(conf=conf01) as core01:
|
|
1130
|
+
|
|
1131
|
+
with self.getAsyncLoggerStream('synapse.storm.log', 'I AM A ERROR LOG MESSAGE') as stream:
|
|
1132
|
+
self.true(await stream.wait(timeout=6))
|
|
1133
|
+
|
|
1134
|
+
cron = await core00.callStorm('return($lib.cron.list())')
|
|
1135
|
+
self.len(1, cron)
|
|
1136
|
+
self.true(cron[0].get('isrunning'))
|
|
1137
|
+
|
|
1138
|
+
await core01.promote(graceful=True)
|
|
1139
|
+
|
|
1140
|
+
self.false(core00.isactive)
|
|
1141
|
+
self.true(core01.isactive)
|
|
1142
|
+
|
|
1143
|
+
await core00.sync()
|
|
1144
|
+
|
|
1145
|
+
cron00 = await core00.callStorm('return($lib.cron.list())')
|
|
1146
|
+
self.len(1, cron00)
|
|
1147
|
+
self.false(cron00[0].get('isrunning'))
|
|
1148
|
+
self.eq(cron00[0].get('lasterrs')[0], 'aborted')
|
|
1149
|
+
|
|
1150
|
+
cron01 = await core01.callStorm('return($lib.cron.list())')
|
|
1151
|
+
self.len(1, cron01)
|
|
1152
|
+
self.false(cron01[0].get('isrunning'))
|
|
1153
|
+
self.eq(cron01[0].get('lasterrs')[0], 'aborted')
|
|
1154
|
+
|
|
1155
|
+
async def test_agenda_force_promotion_with_running_cron(self):
|
|
1156
|
+
|
|
1157
|
+
async with self.getTestAha() as aha:
|
|
1158
|
+
|
|
1159
|
+
conf00 = {
|
|
1160
|
+
'aha:provision': await aha.addAhaSvcProv('00.cortex')
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
async with self.getTestCore(conf=conf00) as core00:
|
|
1164
|
+
self.false(core00.conf.get('mirror'))
|
|
1165
|
+
|
|
1166
|
+
q = '''
|
|
1167
|
+
while((true)) {
|
|
1168
|
+
$lib.log.error('I AM A ERROR LOG MESSAGE')
|
|
1169
|
+
$lib.time.sleep(6)
|
|
1170
|
+
}
|
|
1171
|
+
'''
|
|
1172
|
+
msgs = await core00.stormlist('cron.at --now $q', opts={'vars': {'q': q}})
|
|
1173
|
+
self.stormHasNoWarnErr(msgs)
|
|
1174
|
+
|
|
1175
|
+
crons00 = await core00.callStorm('return($lib.cron.list())')
|
|
1176
|
+
self.len(1, crons00)
|
|
1177
|
+
|
|
1178
|
+
prov01 = {'mirror': '00.cortex'}
|
|
1179
|
+
conf01 = {
|
|
1180
|
+
'aha:provision': await aha.addAhaSvcProv('01.cortex', provinfo=prov01),
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
async with self.getTestCore(conf=conf01) as core01:
|
|
1184
|
+
|
|
1185
|
+
cron = await core00.callStorm('return($lib.cron.list())')
|
|
1186
|
+
self.len(1, cron)
|
|
1187
|
+
self.true(cron[0].get('isrunning'))
|
|
1188
|
+
|
|
1189
|
+
await core01.promote(graceful=False)
|
|
1190
|
+
|
|
1191
|
+
self.true(core00.isactive)
|
|
1192
|
+
self.true(core01.isactive)
|
|
1193
|
+
|
|
1194
|
+
cron01 = await core01.callStorm('return($lib.cron.list())')
|
|
1195
|
+
self.len(1, cron01)
|
|
1196
|
+
self.false(cron01[0].get('isrunning'))
|
|
1197
|
+
self.eq(cron01[0].get('lasterrs')[0], 'aborted')
|
|
1198
|
+
|
|
1199
|
+
async def test_agenda_clear_running_none_nexttime(self):
|
|
1200
|
+
|
|
1201
|
+
async with self.getTestCore() as core:
|
|
1202
|
+
|
|
1203
|
+
cdef = {
|
|
1204
|
+
'creator': core.auth.rootuser.iden,
|
|
1205
|
+
'iden': s_common.guid(),
|
|
1206
|
+
'storm': '$lib.log.info("test")',
|
|
1207
|
+
'reqs': {},
|
|
1208
|
+
'incunit': 'minute',
|
|
1209
|
+
'incvals': 1
|
|
1210
|
+
}
|
|
1211
|
+
await core.addCronJob(cdef)
|
|
1212
|
+
|
|
1213
|
+
appt = core.agenda.appts[cdef['iden']]
|
|
1214
|
+
self.true(appt in core.agenda.apptheap)
|
|
1215
|
+
|
|
1216
|
+
appt.isrunning = True
|
|
1217
|
+
appt.nexttime = None
|
|
1218
|
+
|
|
1219
|
+
await core.agenda.clearRunningStatus()
|
|
1220
|
+
self.false(appt in core.agenda.apptheap)
|
|
1221
|
+
|
|
1222
|
+
crons = await core.callStorm('return($lib.cron.list())')
|
|
1223
|
+
self.len(1, crons)
|
synapse/tests/test_lib_aha.py
CHANGED
|
@@ -59,7 +59,7 @@ class AhaTest(s_test.SynTest):
|
|
|
59
59
|
self.len(ahacount, await proxy0.getAhaUrls())
|
|
60
60
|
self.len(ahacount, await proxy0.getAhaServers())
|
|
61
61
|
|
|
62
|
-
purl = await proxy0.addAhaClone(zoinks)
|
|
62
|
+
purl = await proxy0.addAhaClone(zoinks, port=0)
|
|
63
63
|
|
|
64
64
|
conf1 = {'clone': purl}
|
|
65
65
|
async with self.getTestAha(conf=conf1, dirn=dir1) as aha1:
|
|
@@ -574,7 +574,7 @@ class AhaTest(s_test.SynTest):
|
|
|
574
574
|
}
|
|
575
575
|
s_common.yamlsave(axonconf, axonpath, 'cell.yaml')
|
|
576
576
|
|
|
577
|
-
argv = (axonpath, '--auth-passwd', 'rootbeer')
|
|
577
|
+
argv = (axonpath, '--auth-passwd', 'rootbeer', '--https', '0')
|
|
578
578
|
async with await s_axon.Axon.initFromArgv(argv) as axon:
|
|
579
579
|
|
|
580
580
|
# opts were copied through successfully
|
|
@@ -1161,7 +1161,8 @@ class AhaTest(s_test.SynTest):
|
|
|
1161
1161
|
aconf = {
|
|
1162
1162
|
'aha:name': 'aha',
|
|
1163
1163
|
'aha:network': networkname,
|
|
1164
|
-
'
|
|
1164
|
+
'dmon:listen': f'ssl://aha.{networkname}:0',
|
|
1165
|
+
'provision:listen': f'ssl://aha.{networkname}:0',
|
|
1165
1166
|
}
|
|
1166
1167
|
name = aconf.get('aha:name')
|
|
1167
1168
|
netw = aconf.get('aha:network')
|
|
@@ -1300,11 +1301,17 @@ class AhaTest(s_test.SynTest):
|
|
|
1300
1301
|
conf = {
|
|
1301
1302
|
'aha:network': 'synapse',
|
|
1302
1303
|
'dns:name': 'here.loop.vertex.link',
|
|
1304
|
+
'dmon:listen': 'ssl://0.0.0.0:0?hostname=here.loop.vertex.link&ca=synapse',
|
|
1303
1305
|
}
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
+
|
|
1307
|
+
orig = s_aha.AhaCell._getProvListen
|
|
1308
|
+
def _getProvListen(_self):
|
|
1309
|
+
ret = orig(_self)
|
|
1310
|
+
self.eq(ret, 'ssl://0.0.0.0:27272?hostname=here.loop.vertex.link')
|
|
1311
|
+
return 'ssl://0.0.0.0:0?hostname=here.loop.vertex.link'
|
|
1312
|
+
|
|
1313
|
+
with mock.patch('synapse.lib.aha.AhaCell._getProvListen', _getProvListen):
|
|
1306
1314
|
async with self.getTestCell(s_aha.AhaCell, conf=conf) as aha:
|
|
1307
|
-
self.true(await stream.wait(timeout=6))
|
|
1308
1315
|
# And the URL works with our listener :)
|
|
1309
1316
|
provurl = await aha.addAhaUserEnroll('bob.grey')
|
|
1310
1317
|
async with await s_telepath.openurl(provurl) as prox:
|