synapse 2.176.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.

Files changed (95) hide show
  1. synapse/axon.py +24 -9
  2. synapse/cortex.py +337 -172
  3. synapse/cryotank.py +46 -37
  4. synapse/datamodel.py +17 -4
  5. synapse/exc.py +19 -0
  6. synapse/lib/agenda.py +7 -13
  7. synapse/lib/aha.py +361 -88
  8. synapse/lib/auth.py +1520 -0
  9. synapse/lib/base.py +27 -9
  10. synapse/lib/cell.py +422 -163
  11. synapse/lib/config.py +15 -11
  12. synapse/lib/coro.py +13 -0
  13. synapse/lib/grammar.py +5 -0
  14. synapse/lib/hive.py +24 -3
  15. synapse/lib/hiveauth.py +6 -32
  16. synapse/lib/layer.py +7 -9
  17. synapse/lib/link.py +22 -18
  18. synapse/lib/lmdbslab.py +152 -3
  19. synapse/lib/modelrev.py +1 -1
  20. synapse/lib/nexus.py +24 -12
  21. synapse/lib/schemas.py +136 -0
  22. synapse/lib/storm.py +61 -29
  23. synapse/lib/stormlib/aha.py +1 -1
  24. synapse/lib/stormlib/auth.py +185 -10
  25. synapse/lib/stormlib/cortex.py +16 -5
  26. synapse/lib/stormlib/gen.py +80 -0
  27. synapse/lib/stormlib/imap.py +6 -2
  28. synapse/lib/stormlib/model.py +55 -0
  29. synapse/lib/stormlib/modelext.py +60 -0
  30. synapse/lib/stormlib/smtp.py +12 -2
  31. synapse/lib/stormlib/tabular.py +212 -0
  32. synapse/lib/stormtypes.py +14 -1
  33. synapse/lib/trigger.py +1 -1
  34. synapse/lib/version.py +2 -2
  35. synapse/lib/view.py +55 -28
  36. synapse/models/base.py +7 -0
  37. synapse/models/biz.py +4 -0
  38. synapse/models/files.py +8 -1
  39. synapse/models/inet.py +8 -0
  40. synapse/telepath.py +32 -17
  41. synapse/tests/files/aha/certs/cas/synapse.crt +28 -0
  42. synapse/tests/files/aha/certs/cas/synapse.key +51 -0
  43. synapse/tests/files/aha/certs/hosts/00.aha.loop.vertex.link.crt +30 -0
  44. synapse/tests/files/aha/certs/hosts/00.aha.loop.vertex.link.key +51 -0
  45. synapse/tests/files/aha/certs/users/root@synapse.crt +29 -0
  46. synapse/tests/files/aha/certs/users/root@synapse.key +51 -0
  47. synapse/tests/files/changelog/model_2.176.0_16ee721a6b7221344eaf946c3ab4602dda546b1a.yaml.gz +0 -0
  48. synapse/tests/files/changelog/model_2.176.0_2a25c58bbd344716cd7cbc3f4304d8925b0f4ef2.yaml.gz +0 -0
  49. synapse/tests/files/rstorm/testsvc.py +1 -1
  50. synapse/tests/test_axon.py +8 -5
  51. synapse/tests/test_cortex.py +149 -141
  52. synapse/tests/test_cryotank.py +4 -4
  53. synapse/tests/test_datamodel.py +7 -0
  54. synapse/tests/test_lib_agenda.py +10 -3
  55. synapse/tests/test_lib_aha.py +336 -490
  56. synapse/tests/{test_lib_hiveauth.py → test_lib_auth.py} +314 -11
  57. synapse/tests/test_lib_base.py +20 -0
  58. synapse/tests/test_lib_cell.py +210 -30
  59. synapse/tests/test_lib_config.py +4 -3
  60. synapse/tests/test_lib_httpapi.py +18 -14
  61. synapse/tests/test_lib_layer.py +33 -33
  62. synapse/tests/test_lib_link.py +42 -1
  63. synapse/tests/test_lib_lmdbslab.py +68 -0
  64. synapse/tests/test_lib_nexus.py +12 -4
  65. synapse/tests/test_lib_node.py +0 -7
  66. synapse/tests/test_lib_storm.py +45 -0
  67. synapse/tests/test_lib_stormlib_aha.py +35 -36
  68. synapse/tests/test_lib_stormlib_auth.py +21 -0
  69. synapse/tests/test_lib_stormlib_cell.py +4 -15
  70. synapse/tests/test_lib_stormlib_cortex.py +12 -12
  71. synapse/tests/test_lib_stormlib_gen.py +99 -0
  72. synapse/tests/test_lib_stormlib_imap.py +14 -3
  73. synapse/tests/test_lib_stormlib_model.py +108 -0
  74. synapse/tests/test_lib_stormlib_modelext.py +64 -0
  75. synapse/tests/test_lib_stormlib_smtp.py +51 -0
  76. synapse/tests/test_lib_stormlib_tabular.py +226 -0
  77. synapse/tests/test_lib_stormsvc.py +4 -1
  78. synapse/tests/test_lib_stormtypes.py +10 -0
  79. synapse/tests/test_model_base.py +3 -0
  80. synapse/tests/test_model_biz.py +3 -0
  81. synapse/tests/test_model_files.py +12 -2
  82. synapse/tests/test_model_inet.py +24 -0
  83. synapse/tests/test_tools_aha.py +78 -101
  84. synapse/tests/test_tools_changelog.py +196 -0
  85. synapse/tests/test_tools_healthcheck.py +4 -3
  86. synapse/tests/utils.py +87 -121
  87. synapse/tools/aha/clone.py +50 -0
  88. synapse/tools/aha/enroll.py +2 -1
  89. synapse/tools/backup.py +2 -2
  90. synapse/tools/changelog.py +776 -15
  91. {synapse-2.176.0.dist-info → synapse-2.178.0.dist-info}/METADATA +48 -48
  92. {synapse-2.176.0.dist-info → synapse-2.178.0.dist-info}/RECORD +95 -82
  93. {synapse-2.176.0.dist-info → synapse-2.178.0.dist-info}/WHEEL +1 -1
  94. {synapse-2.176.0.dist-info → synapse-2.178.0.dist-info}/LICENSE +0 -0
  95. {synapse-2.176.0.dist-info → synapse-2.178.0.dist-info}/top_level.txt +0 -0
@@ -63,10 +63,15 @@ class LinkTest(s_test.SynTest):
63
63
  host, port = serv.sockets[0].getsockname()
64
64
 
65
65
  link = await s_link.connect(host, port)
66
-
66
+ info = link.getAddrInfo()
67
+ self.eq(info.get('family'), 'tcp')
68
+ self.eq(info.get('ipver'), 'ipv4')
67
69
  await link.send(b'visi')
68
70
  self.eq(b'vert', await link.recvsize(4))
69
71
  self.none(await link.recvsize(1))
72
+ await link.fini()
73
+ # We can still get the info after we've closed the socket / fini'd the link.
74
+ self.eq(info, link.getAddrInfo())
70
75
 
71
76
  async def test_link_tx_sadpath(self):
72
77
 
@@ -295,3 +300,39 @@ class LinkTest(s_test.SynTest):
295
300
  await s_link.connect(hostname, port=port, ssl=sslctx)
296
301
  finally:
297
302
  server.close()
303
+
304
+ # Ensure we can talk to a TLS link though.
305
+ async def func(link: s_link.Link):
306
+ self.eq(b'go', await link.recv(2))
307
+ await link.tx(link.getAddrInfo())
308
+ await link.fini()
309
+
310
+ srv_sslctx = certdir.getServerSSLContext(hostname) # type: ssl.SSLContext
311
+ server = await s_link.listen(hostname, lport, onlink=func, ssl=srv_sslctx)
312
+ sslctx = certdir.getClientSSLContext() # type: ssl.SSLContext
313
+ _, port = server.sockets[0].getsockname()
314
+ print(f'listening on port {port=}')
315
+ async with await s_link.connect(hostname, port=port, ssl=sslctx) as link:
316
+ await link.send(b'go')
317
+ item = await link.rx()
318
+ self.eq(link.getAddrInfo().get('family'), 'tls')
319
+ self.eq(item.get('family'), 'tls')
320
+ server.close()
321
+
322
+ async def test_link_unix(self):
323
+ with self.getTestDir() as dirn:
324
+
325
+ async def func(link: s_link.Link):
326
+ self.eq(b'go', await link.recv(2))
327
+ await link.tx(link.getAddrInfo())
328
+ await link.fini()
329
+ fp = s_common.genpath(dirn, 'sock')
330
+ server = await s_link.unixlisten(fp, onlink=func)
331
+
332
+ async with await s_link.unixconnect(fp) as link:
333
+ await link.send(b'go')
334
+ item = await link.rx()
335
+ self.eq(link.getAddrInfo().get('family'), 'unix')
336
+ self.eq(item.get('addr'), fp)
337
+ self.eq(item.get('family'), 'unix')
338
+ server.close()
@@ -1528,6 +1528,74 @@ class LmdbSlabTest(s_t_utils.SynTest):
1528
1528
 
1529
1529
  self.eq(3, slab.count(b'foo', db=dupsdb))
1530
1530
 
1531
+ async def test_safekeyval(self):
1532
+ with self.getTestDir() as dirn:
1533
+
1534
+ path = os.path.join(dirn, 'test.lmdb')
1535
+
1536
+ async with await s_lmdbslab.Slab.anit(path) as slab:
1537
+
1538
+ safekv = slab.getSafeKeyVal('test')
1539
+
1540
+ subkv1 = safekv.getSubKeyVal('pref1')
1541
+ subkv2 = subkv1.getSubKeyVal('pref2')
1542
+
1543
+ self.eq(subkv2.prefix, 'pref1pref2')
1544
+
1545
+ subkv2.set('foo', 'bar')
1546
+ subkv2.set('baz', 'faz')
1547
+
1548
+ self.eq(list(subkv2.keys()), ['baz', 'foo'])
1549
+ self.eq(list(safekv.keys()), ['pref1pref2baz', 'pref1pref2foo'])
1550
+ self.eq(list(safekv.values()), ['faz', 'bar'])
1551
+
1552
+ await safekv.truncate()
1553
+ self.len(0, safekv.items())
1554
+
1555
+ subkv2.set('wow', 'guys')
1556
+
1557
+ newp = 'a' * 512
1558
+
1559
+ with self.raises(s_exc.BadArg):
1560
+ safekv.getSubKeyVal(newp)
1561
+
1562
+ with self.raises(s_exc.BadArg):
1563
+ safekv.get(newp)
1564
+
1565
+ with self.raises(s_exc.BadArg):
1566
+ safekv.set(newp, 'newp')
1567
+
1568
+ with self.raises(s_exc.BadArg):
1569
+ safekv.pop(newp)
1570
+
1571
+ with self.raises(s_exc.BadArg):
1572
+ safekv.delete(newp)
1573
+
1574
+ with self.raises(s_exc.BadArg):
1575
+ list(safekv.keys(pref=newp))
1576
+
1577
+ with self.raises(s_exc.BadArg):
1578
+ list(safekv.items(pref=newp))
1579
+
1580
+ with self.raises(s_exc.BadArg):
1581
+ list(safekv.values(pref=newp))
1582
+
1583
+ with self.raises(s_exc.BadArg):
1584
+ await safekv.truncate(pref=newp)
1585
+
1586
+ with self.raises(s_exc.BadArg):
1587
+ safekv.getSubKeyVal('')
1588
+
1589
+ with self.raises(s_exc.BadArg):
1590
+ slab.getSafeKeyVal('newp', create=False)
1591
+
1592
+ async with await s_lmdbslab.Slab.anit(path) as slab:
1593
+ safekv = slab.getSafeKeyVal('test', create=False)
1594
+ subkv1 = safekv.getSubKeyVal('pref1')
1595
+ subkv2 = subkv1.getSubKeyVal('pref2')
1596
+ self.eq(list(subkv2.keys()), ['wow'])
1597
+
1598
+
1531
1599
  class LmdbSlabMemLockTest(s_t_utils.SynTest):
1532
1600
 
1533
1601
  async def test_lmdbslabmemlock(self):
@@ -4,9 +4,9 @@ from unittest import mock
4
4
  import synapse.exc as s_exc
5
5
  import synapse.common as s_common
6
6
 
7
+ import synapse.lib.auth as s_auth
7
8
  import synapse.lib.cell as s_cell
8
9
  import synapse.lib.nexus as s_nexus
9
- import synapse.lib.hiveauth as s_hiveauth
10
10
 
11
11
  import synapse.tests.utils as s_t_utils
12
12
 
@@ -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')
@@ -207,7 +215,7 @@ class NexusTest(s_t_utils.SynTest):
207
215
 
208
216
  async def test_nexus_safety(self):
209
217
 
210
- orig = s_hiveauth.Auth.reqUser
218
+ orig = s_auth.Auth.reqUser
211
219
  async def slowReq(self, iden):
212
220
  await asyncio.sleep(0.2)
213
221
  return await orig(self, iden)
@@ -215,7 +223,7 @@ class NexusTest(s_t_utils.SynTest):
215
223
  with self.getTestDir() as dirn:
216
224
  async with self.getTestCore(dirn=dirn) as core:
217
225
 
218
- with mock.patch('synapse.lib.hiveauth.Auth.reqUser', slowReq):
226
+ with mock.patch('synapse.lib.auth.Auth.reqUser', slowReq):
219
227
 
220
228
  vcnt = len(core.views)
221
229
  deflayr = (await core.getLayerDef()).get('iden')
@@ -245,7 +253,7 @@ class NexusTest(s_t_utils.SynTest):
245
253
  vcnt = len(core.views)
246
254
  strt = await core.nexsroot.index()
247
255
 
248
- with mock.patch('synapse.lib.hiveauth.Auth.reqUser', slowReq):
256
+ with mock.patch('synapse.lib.auth.Auth.reqUser', slowReq):
249
257
  for x in range(3):
250
258
  vdef = {'layers': (deflayr,), 'name': f'someview{x}'}
251
259
  with self.raises(TimeoutError):
@@ -174,13 +174,6 @@ class NodeTest(s_t_utils.SynTest):
174
174
  self.isin('tick', props)
175
175
  self.notin('newp', props)
176
176
 
177
- form = 'test:str'
178
- valu = 'cool'
179
- props = {'tick': 12345,
180
- 'hehe': 'hehe',
181
- }
182
- tval = (None, None)
183
-
184
177
  async with self.getTestCore() as core:
185
178
  await core.addTagProp('score', ('int', {}), {})
186
179
  await core.addTagProp('note', ('str', {'lower': True, 'strip': 'True'}), {})
@@ -955,6 +955,42 @@ class StormTest(s_t_utils.SynTest):
955
955
  | merge --apply
956
956
  ''', opts=opts)
957
957
 
958
+ # make a few more edits and merge some of them to test --wipe
959
+ await core.stormlist('[ inet:fqdn=hehehaha.com inet:fqdn=woottoow.com ]')
960
+
961
+ layrcount = len(core.layers.values())
962
+ await core.stormlist('[ inet:fqdn=hehehaha.com inet:fqdn=woottoow.com ]', opts=opts)
963
+ oldlayr = await core.callStorm('return($lib.view.get().layers.0.iden)', opts=opts)
964
+ msgs = await core.stormlist('inet:fqdn=hehehaha.com | merge --apply --wipe', opts=opts)
965
+ self.stormHasNoWarnErr(msgs)
966
+ newlayr = await core.callStorm('return($lib.view.get().layers.0.iden)', opts=opts)
967
+ self.ne(oldlayr, newlayr)
968
+ msgs = await core.stormlist('''
969
+ $layr = $lib.view.get().layers.0.iden
970
+ $user = $lib.auth.users.byname(visi)
971
+ $role = $lib.auth.roles.add(ninjas)
972
+
973
+ $user.grant($role.iden)
974
+
975
+ $user.setAdmin((true), gateiden=$layr)
976
+ $user.addRule(([true, ["foo", "bar"]]), gateiden=$layr)
977
+ $role.addRule(([true, ["baz", "faz"]]), gateiden=$layr)
978
+ ''', opts=opts)
979
+ self.stormHasNoWarnErr(msgs)
980
+ await core.callStorm('$lib.view.get().swapLayer()', opts=opts)
981
+ self.ne(newlayr, await core.callStorm('return($lib.view.get().layers.0.iden)', opts=opts))
982
+
983
+ self.true(await core.callStorm('''
984
+ $layr = $lib.view.get().layers.0.iden
985
+ return($lib.auth.users.byname(visi).allowed(foo.bar, gateiden=$layr))
986
+ ''', opts=opts))
987
+ self.true(await core.callStorm('''
988
+ $layr = $lib.view.get().layers.0.iden
989
+ return($lib.auth.users.byname(visi).allowed(baz.faz, gateiden=$layr))
990
+ ''', opts=opts))
991
+
992
+ self.len(0, await core.nodes('diff', opts=opts))
993
+
958
994
  self.len(0, await core.callStorm('''
959
995
  $list = $lib.list()
960
996
  for ($buid, $sode) in $lib.view.get().layers.0.getStorNodes() {
@@ -4235,6 +4271,15 @@ class StormTest(s_t_utils.SynTest):
4235
4271
  msgs = await core.stormlist(pushq, opts={'user': visi.iden, 'vars': varz})
4236
4272
  self.stormHasNoWarnErr(msgs)
4237
4273
 
4274
+ l1iden = l1.get('iden')
4275
+ pdef = list(core.getLayer(l1iden).layrinfo['pushs'].values())[0]
4276
+ self.none(await core.addLayrPush(l1iden, pdef))
4277
+ self.len(1, list(core.getLayer(l1iden).layrinfo['pushs'].values()))
4278
+
4279
+ pdef = list(core.getLayer(l1iden).layrinfo['pulls'].values())[0]
4280
+ self.none(await core.addLayrPull(l1iden, pdef))
4281
+ self.len(1, list(core.getLayer(l1iden).layrinfo['pulls'].values()))
4282
+
4238
4283
  async def test_storm_tagprune(self):
4239
4284
 
4240
4285
  async with self.getTestCore() as core:
@@ -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.getTestAhaProv() as aha:
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.loop.vertex.link', svc.get('name'))
40
- svc = await core00.callStorm('return( $lib.aha.get(core.loop.vertex.link))')
41
- self.eq('core.loop.vertex.link', svc.get('name'))
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.loop.vertex.link', svc.get('name'))
43
+ self.eq('00.cell.synapse', svc.get('name'))
44
44
  svc = await core00.callStorm('return( $lib.aha.get(cell...))')
45
- self.eq('cell.loop.vertex.link', svc.get('name'))
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.loop.vertex.link', svc.get('name'))
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.loop.vertex.link true true true', msgs)
53
- self.stormIsInPrint('01.cell.loop.vertex.link false true true', msgs)
54
- self.stormIsInPrint('cell.loop.vertex.link true true true', msgs)
55
- self.stormIsInPrint('core.loop.vertex.link null true true', msgs)
56
- self.stormIsInPrint('mysvc.loop.vertex.link null true true', msgs)
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.loop.vertex.link
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: loop.vertex.link
73
+ ca: synapse
74
74
  '''
75
75
  self.stormIsInPrint(emsg, msgs, deguid=True)
76
- self.stormIsInPrint(' hostname: 00.cell.loop.vertex.link', msgs)
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.loop.vertex.link
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: loop.vertex.link
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.loop.vertex.link
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: loop.vertex.link
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.loop.vertex.link')
112
- emsg = '''Resolved 01.cell.loop.vertex.link to an AHA Service.
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.loop.vertex.link
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.loop.vertex.link
132
- Member: 00.cell.loop.vertex.link'''
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,16 +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.loop.vertex.link false false false', msgs)
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='loop.vertex.link')
146
+ network='synapse')
147
147
 
148
148
  msgs = await core00.stormlist('aha.svc.list --nexus')
149
- emsg = '00.newp.loop.vertex.link null false null 0.0.0.0 3030 ' \
150
- 'Service is not online. Will not attempt to retrieve its nexus offset.'
151
- 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)
152
151
 
153
152
  self.none(await core00.callStorm('return($lib.aha.del(00.newp...))'))
154
153
  msgs = await core00.stormlist('aha.svc.list')
@@ -161,22 +160,22 @@ Member: 00.cell.loop.vertex.link'''
161
160
  'port': '3030'},
162
161
  'online': guid,
163
162
  },
164
- network='loop.vertex.link')
163
+ network='synapse')
165
164
  msgs = await core00.stormlist('aha.svc.list --nexus')
166
- emsg = '00.newp.loop.vertex.link null true null 0.0.0.0 3030 ' \
167
- 'Failed to connect to Telepath service: "aha://00.newp.loop.vertex.link/" error:'
168
- 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)
169
168
 
170
169
  msgs = await core00.stormlist('aha.svc.stat --nexus 00.newp...')
171
170
  emsg = '''Resolved 00.newp... to an AHA Service.
172
171
 
173
- Name: 00.newp.loop.vertex.link
172
+ Name: 00.newp.synapse
174
173
  Online: true
175
174
  Ready: null
176
175
  Run iden: $lib.null
177
176
  Cell iden: $lib.null
178
177
  Leader: Service did not register itself with a leader name.
179
- Nexus: Failed to connect to Telepath service: "aha://00.newp.loop.vertex.link/" error: [Errno 111] Connect call failed ('0.0.0.0', 3030)
178
+ Nexus: Failed to connect to Telepath service: "aha://00.newp.synapse/" error: [Errno 111] Connect call failed ('0.0.0.0', 3030)
180
179
  Connection information:
181
180
  host: 0.0.0.0
182
181
  port: 3030
@@ -185,7 +184,7 @@ Connection information:
185
184
  self.stormIsInPrint(emsg, msgs)
186
185
 
187
186
  # Delete the fake service with its full service name
188
- self.none(await core00.callStorm('return($lib.aha.del(00.newp.loop.vertex.link))'))
187
+ self.none(await core00.callStorm('return($lib.aha.del(00.newp.synapse))'))
189
188
  self.none(await core00.callStorm('return($lib.aha.get(00.newp...))'))
190
189
 
191
190
  # Coverage for sad paths
@@ -480,6 +480,9 @@ class StormLibAuthTest(s_test.SynTest):
480
480
 
481
481
  await core.callStorm('$lib.user.vars.set(foo, foovalu)', opts=asvisi)
482
482
 
483
+ msgs = await core.stormlist('for $valu in $lib.user.vars { $lib.print($valu) }', opts=asvisi)
484
+ self.stormIsInPrint("('foo', 'foovalu')", msgs)
485
+
483
486
  q = 'return($lib.auth.users.byname(visi).vars.foo)'
484
487
  self.eq('foovalu', await core.callStorm(q, opts=asvisi))
485
488
 
@@ -494,6 +497,24 @@ class StormLibAuthTest(s_test.SynTest):
494
497
  await core.callStorm('$lib.auth.users.byname(visi).vars.foo=$lib.undef')
495
498
  self.none(await core.callStorm('return($lib.auth.users.byname(visi).vars.foo)'))
496
499
 
500
+ with self.raises(s_exc.StormRuntimeError):
501
+ await core.callStorm('$lib.user.vars.set((1), newp)')
502
+
503
+ await core.callStorm('$lib.user.profile.set(bar, foovalu)', opts=asvisi)
504
+
505
+ self.eq('foovalu', await core.callStorm('return($lib.user.profile.get(bar))', opts=asvisi))
506
+
507
+ self.eq((('bar', 'foovalu'),), await core.callStorm('return($lib.user.profile.list())', opts=asvisi))
508
+
509
+ msgs = await core.stormlist('for $valu in $lib.user.profile { $lib.print($valu) }', opts=asvisi)
510
+ self.stormIsInPrint("('bar', 'foovalu')", msgs)
511
+
512
+ await core.callStorm('$lib.user.profile.pop(bar)', opts=asvisi)
513
+ self.none(await core.callStorm('return($lib.user.profile.get(bar))', opts=asvisi))
514
+
515
+ with self.raises(s_exc.StormRuntimeError):
516
+ await core.callStorm('$lib.user.profile.set((1), newp)')
517
+
497
518
  async def test_stormlib_auth_base(self):
498
519
 
499
520
  async with self.getTestCore() as core:
@@ -76,18 +76,7 @@ class StormCellTest(s_test.SynTest):
76
76
 
77
77
  async def test_stormlib_cell_getmirrors(self):
78
78
 
79
- conf = {
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.mynet']
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.mynet',)
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.mynet')
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))')
@@ -489,10 +489,10 @@ $request.reply(206, headers=$headers, body=({"no":"body"}))
489
489
  await core.callStorm(q, opts={'vars': {'iden': iden3}})
490
490
 
491
491
  msgs = await core.stormlist('cortex.httpapi.list')
492
- self.stormIsInPrint(f'0 {iden0}', msgs)
493
- self.stormIsInPrint(f'1 {iden1}', msgs)
494
- self.stormIsInPrint(f'2 {iden2}', msgs)
495
- self.stormIsInPrint(f'3 {iden3}', msgs)
492
+ self.stormIsInPrint(f'0 | {iden0}', msgs)
493
+ self.stormIsInPrint(f'1 | {iden1}', msgs)
494
+ self.stormIsInPrint(f'2 | {iden2}', msgs)
495
+ self.stormIsInPrint(f'3 | {iden3}', msgs)
496
496
 
497
497
  q = '''
498
498
  $ret = $lib.null $api = $lib.cortex.httpapi.getByPath($path)
@@ -528,10 +528,10 @@ $request.reply(206, headers=$headers, body=({"no":"body"}))
528
528
  self.eq(iden0, await core.callStorm(q, opts={'vars': {'path': 'hehe/ohmy'}}))
529
529
 
530
530
  msgs = await core.stormlist('cortex.httpapi.list')
531
- self.stormIsInPrint(f'0 {iden1}', msgs)
532
- self.stormIsInPrint(f'1 {iden0}', msgs)
533
- self.stormIsInPrint(f'2 {iden2}', msgs)
534
- self.stormIsInPrint(f'3 {iden3}', msgs)
531
+ self.stormIsInPrint(f'0 | {iden1}', msgs)
532
+ self.stormIsInPrint(f'1 | {iden0}', msgs)
533
+ self.stormIsInPrint(f'2 | {iden2}', msgs)
534
+ self.stormIsInPrint(f'3 | {iden3}', msgs)
535
535
 
536
536
  # The wildcard handler does not match the more specific request as a result of the new order
537
537
  async with self.getHttpSess(auth=('root', 'root'), port=hport) as sess:
@@ -569,10 +569,10 @@ $request.reply(206, headers=$headers, body=({"no":"body"}))
569
569
  self.stormIsInPrint(f'Set HTTP API {iden0} to index 3', msgs)
570
570
 
571
571
  msgs = await core.stormlist('cortex.httpapi.list')
572
- self.stormIsInPrint(f'0 {iden1}', msgs)
573
- self.stormIsInPrint(f'1 {iden2}', msgs)
574
- self.stormIsInPrint(f'2 {iden3}', msgs)
575
- self.stormIsInPrint(f'3 {iden0}', msgs)
572
+ self.stormIsInPrint(f'0 | {iden1}', msgs)
573
+ self.stormIsInPrint(f'1 | {iden2}', msgs)
574
+ self.stormIsInPrint(f'2 | {iden3}', msgs)
575
+ self.stormIsInPrint(f'3 | {iden0}', msgs)
576
576
 
577
577
  # iden Prefix + name matching
578
578
  msgs = await core.stormlist('cortex.httpapi.index $iden 0', opts={'vars': {'iden': iden1[:6]}})