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
@@ -23,6 +23,7 @@ import synapse.cortex as s_cortex
23
23
  import synapse.daemon as s_daemon
24
24
  import synapse.telepath as s_telepath
25
25
 
26
+ import synapse.lib.auth as s_auth
26
27
  import synapse.lib.base as s_base
27
28
  import synapse.lib.cell as s_cell
28
29
  import synapse.lib.coro as s_coro
@@ -31,7 +32,6 @@ import synapse.lib.nexus as s_nexus
31
32
  import synapse.lib.certdir as s_certdir
32
33
  import synapse.lib.msgpack as s_msgpack
33
34
  import synapse.lib.version as s_version
34
- import synapse.lib.hiveauth as s_hiveauth
35
35
  import synapse.lib.lmdbslab as s_lmdbslab
36
36
  import synapse.lib.crypto.passwd as s_passwd
37
37
  import synapse.lib.platforms.linux as s_linux
@@ -133,7 +133,27 @@ async def altAuthCtor(cell):
133
133
  authconf = cell.conf.get('auth:conf')
134
134
  assert authconf['foo'] == 'bar'
135
135
  authconf['baz'] = 'faz'
136
- return await s_cell.Cell._initCellHiveAuth(cell)
136
+
137
+ maxusers = cell.conf.get('max:users')
138
+
139
+ seed = s_common.guid((cell.iden, 'hive', 'auth'))
140
+
141
+ auth = await s_auth.Auth.anit(
142
+ cell.slab,
143
+ 'auth',
144
+ seed=seed,
145
+ nexsroot=cell.getCellNexsRoot(),
146
+ maxusers=maxusers
147
+ )
148
+
149
+ auth.link(cell.dist)
150
+
151
+ def finilink():
152
+ auth.unlink(cell.dist)
153
+
154
+ cell.onfini(finilink)
155
+ cell.onfini(auth.fini)
156
+ return auth
137
157
 
138
158
  class CellTest(s_t_utils.SynTest):
139
159
 
@@ -417,8 +437,6 @@ class CellTest(s_t_utils.SynTest):
417
437
  # Ensure the cell and its auth have been fini'd
418
438
  self.true(echo.isfini)
419
439
  self.true(echo.auth.isfini)
420
- root = await echo.auth.getUserByName('root')
421
- self.true(root.isfini)
422
440
 
423
441
  async def test_cell_userapi(self):
424
442
 
@@ -617,7 +635,6 @@ class CellTest(s_t_utils.SynTest):
617
635
  async with self.getTestCell(s_cell.Cell, dirn=dir0, conf=conf) as cell00, \
618
636
  cell00.getLocalProxy() as prox00:
619
637
 
620
- self.true(cell00.nexsroot.map_async)
621
638
  self.true(cell00.nexsroot.donexslog)
622
639
 
623
640
  await prox00.addUser('test')
@@ -914,7 +931,7 @@ class CellTest(s_t_utils.SynTest):
914
931
  pass
915
932
  stream.seek(0)
916
933
  buf = stream.read()
917
- self.isin(f'...cell API (telepath): cell://root@{dirn}:*', buf)
934
+ self.isin(f'...cell API (telepath): tcp://0.0.0.0:27492', buf)
918
935
  self.isin('...cell API (https): disabled', buf)
919
936
 
920
937
  async def test_cell_initargv_conf(self):
@@ -936,11 +953,11 @@ class CellTest(s_t_utils.SynTest):
936
953
  # 1) cmdline
937
954
  # 2) envars
938
955
  # 3) cell.yaml
939
- self.true(cell.conf.reqConfValu('nexslog:en'))
940
- self.true(cell.conf.reqConfValu('nexslog:async'))
941
- self.none(cell.conf.reqConfValu('dmon:listen'))
942
- self.none(cell.conf.reqConfValu('https:port'))
943
- self.eq(cell.conf.reqConfValu('aha:name'), 'some:cell')
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')
944
961
  root = cell.auth.rootuser
945
962
  self.true(await root.tryPasswd('secret'))
946
963
 
@@ -948,7 +965,7 @@ class CellTest(s_t_utils.SynTest):
948
965
  with self.getTestDir() as dirn:
949
966
  s_common.yamlsave({'nexslog:en': False}, dirn, 'cell.mods.yaml')
950
967
  async with await s_cell.Cell.initFromArgv([dirn]) as cell:
951
- self.false(cell.conf.reqConfValu('nexslog:en'))
968
+ self.false(cell.conf.req('nexslog:en'))
952
969
  # We can remove the valu from the overrides file with the pop API
953
970
  # This is NOT reactive API which causes the whole behavior
954
971
  # of the cell to suddenly change. This is intended to be used with
@@ -1020,6 +1037,7 @@ class CellTest(s_t_utils.SynTest):
1020
1037
  errinfo = info.get('lastexception')
1021
1038
  laststart1 = info['laststart']
1022
1039
  self.eq(errinfo['err'], 'SynErr')
1040
+ self.eq(errinfo['errinfo']['mesg'], 'backup subprocess start timed out')
1023
1041
 
1024
1042
  # Test runners can take an unusually long time to spawn a process
1025
1043
  with mock.patch.object(s_cell.Cell, 'BACKUP_SPAWN_TIMEOUT', 8.0):
@@ -1032,15 +1050,17 @@ class CellTest(s_t_utils.SynTest):
1032
1050
  self.ne(laststart1, laststart2)
1033
1051
  errinfo = info.get('lastexception')
1034
1052
  self.eq(errinfo['err'], 'SynErr')
1053
+ self.eq(errinfo['errinfo']['mesg'], 'backup subprocess start timed out')
1035
1054
 
1036
- with mock.patch.object(s_cell.Cell, '_backupProc', staticmethod(_exiterProc)):
1037
- await self.asyncraises(s_exc.SpawnExit, proxy.runBackup('_exiterProc'))
1055
+ with mock.patch.object(s_cell.Cell, '_backupProc', staticmethod(_exiterProc)):
1056
+ await self.asyncraises(s_exc.SpawnExit, proxy.runBackup('_exiterProc'))
1038
1057
 
1039
- info = await proxy.getBackupInfo()
1040
- laststart3 = info['laststart']
1041
- self.ne(laststart2, laststart3)
1042
- errinfo = info.get('lastexception')
1043
- self.eq(errinfo['err'], 'SpawnExit')
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)
1044
1064
 
1045
1065
  # Create rando slabs inside cell dir
1046
1066
  slabpath = s_common.genpath(coredirn, 'randoslab')
@@ -1189,6 +1209,7 @@ class CellTest(s_t_utils.SynTest):
1189
1209
  async with await s_cell.Cell.anit(dirn, conf=conf) as cell:
1190
1210
  self.eq('faz', cell.conf.get('auth:conf')['baz'])
1191
1211
  await cell.auth.addUser('visi')
1212
+ await cell._storCellAuthMigration()
1192
1213
 
1193
1214
  async def test_cell_auth_userlimit(self):
1194
1215
  maxusers = 3
@@ -1237,7 +1258,8 @@ class CellTest(s_t_utils.SynTest):
1237
1258
 
1238
1259
  with self.setTstEnvars(SYN_CELL_MAX_USERS=str(maxusers)):
1239
1260
  with self.getTestDir() as dirn:
1240
- async with await s_cell.Cell.initFromArgv([dirn]) as cell:
1261
+ argv = [dirn, '--https', '0', '--telepath', 'tcp://0.0.0.0:0']
1262
+ async with await s_cell.Cell.initFromArgv(argv) as cell:
1241
1263
  await cell.auth.addUser('visi1')
1242
1264
  await cell.auth.addUser('visi2')
1243
1265
  await cell.auth.addUser('visi3')
@@ -1597,7 +1619,7 @@ class CellTest(s_t_utils.SynTest):
1597
1619
 
1598
1620
  async with self.getTestCell(s_cell.Cell, conf=conf) as cell: # type: s_cell.Cell
1599
1621
  iden = s_common.guid((cell.iden, 'auth', 'user', 'foo@bar.mynet.com'))
1600
- user = cell.auth.user(iden) # type: s_hiveauth.HiveUser
1622
+ user = cell.auth.user(iden) # type: s_auth.User
1601
1623
  self.eq(user.name, 'foo@bar.mynet.com')
1602
1624
  self.eq(user.pack().get('email'), 'foo@barcorp.com')
1603
1625
  self.false(user.isAdmin())
@@ -1607,7 +1629,7 @@ class CellTest(s_t_utils.SynTest):
1607
1629
  self.false(user.allowed(('newp', 'secret')))
1608
1630
 
1609
1631
  iden = s_common.guid((cell.iden, 'auth', 'user', 'sally@bar.mynet.com'))
1610
- user = cell.auth.user(iden) # type: s_hiveauth.HiveUser
1632
+ user = cell.auth.user(iden) # type: s_auth.User
1611
1633
  self.eq(user.name, 'sally@bar.mynet.com')
1612
1634
  self.true(user.isAdmin())
1613
1635
 
@@ -1721,7 +1743,7 @@ class CellTest(s_t_utils.SynTest):
1721
1743
  'has different iden') as stream:
1722
1744
  async with self.getTestCell(s_cell.Cell, dirn=path01, conf=conf01) as cell01:
1723
1745
  await stream.wait(timeout=2)
1724
- self.true(await cell01.waitfini(6))
1746
+ self.true(await cell01.nexsroot.waitfini(6))
1725
1747
 
1726
1748
  async def test_backup_restore_base(self):
1727
1749
 
@@ -1816,15 +1838,42 @@ class CellTest(s_t_utils.SynTest):
1816
1838
  self.true(s_common.isguid(second_doneiden))
1817
1839
  self.ne(doneiden, second_doneiden)
1818
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
+
1819
1870
  async def test_backup_restore_aha(self):
1820
1871
  # do a mirror provisioning of a Cell
1821
1872
  # promote the mirror to being a leader
1822
1873
  # ensure the mirror has a
1823
1874
  # backup the mirror
1824
1875
  # restore the backup
1825
- async with self.getTestAhaProv(conf={'auth:passwd': 'secret'}) as aha: # type: s_aha.AhaCell
1826
- root = await aha.auth.getUserByName('root')
1827
- self.true(await root.tryPasswd('secret'))
1876
+ async with self.getTestAha() as aha: # type: s_aha.AhaCell
1828
1877
 
1829
1878
  with self.getTestDir() as dirn:
1830
1879
  cdr0 = s_common.genpath(dirn, 'core00')
@@ -1907,9 +1956,7 @@ class CellTest(s_t_utils.SynTest):
1907
1956
  # ensure the mirror has a
1908
1957
  # backup the mirror
1909
1958
  # restore the backup
1910
- async with self.getTestAhaProv(conf={'auth:passwd': 'secret'}) as aha: # type: s_aha.AhaCell
1911
- root = await aha.auth.getUserByName('root')
1912
- self.true(await root.tryPasswd('secret'))
1959
+ async with self.getTestAha() as aha: # type: s_aha.AhaCell
1913
1960
 
1914
1961
  with self.getTestDir() as dirn:
1915
1962
  cdr0 = s_common.genpath(dirn, 'core00')
@@ -2036,6 +2083,23 @@ class CellTest(s_t_utils.SynTest):
2036
2083
  self.true(await user.tryPasswd('hehe'))
2037
2084
  self.false(await user.tryPasswd('secret1234'))
2038
2085
 
2086
+ # Password policies do not prevent live migration of an existing password
2087
+ with self.getRegrDir('cells', 'passwd-2.109.0') as dirn:
2088
+ policy = {'complexity': {'length': 5}}
2089
+ conf = {'auth:passwd:policy': policy}
2090
+ async with self.getTestCell(s_cell.Cell, conf=conf, dirn=dirn) as cell: # type: s_cell.Cell
2091
+ root = await cell.auth.getUserByName('root')
2092
+ shadow = root.info.get('passwd')
2093
+ self.isinstance(shadow, tuple)
2094
+ self.len(2, shadow)
2095
+
2096
+ # Old password works and is migrated to the new password scheme
2097
+ self.false(await root.tryPasswd('newp'))
2098
+ self.true(await root.tryPasswd('root'))
2099
+ shadow = root.info.get('passwd')
2100
+ self.isinstance(shadow, dict)
2101
+ self.eq(shadow.get('type'), s_passwd.DEFAULT_PTYP)
2102
+
2039
2103
  # Pre-nexus changes of root via auth:passwd work too.
2040
2104
  with self.getRegrDir('cells', 'passwd-2.109.0') as dirn:
2041
2105
  conf = {'auth:passwd': 'supersecretpassword'}
@@ -2625,6 +2689,122 @@ class CellTest(s_t_utils.SynTest):
2625
2689
  with self.raises(s_exc.NoSuchIden):
2626
2690
  await cell.delUserApiKey(newp)
2627
2691
 
2692
+ async def test_cell_iter_slab_data(self):
2693
+ async with self.getTestCell(s_cell.Cell) as cell:
2694
+ data = await s_t_utils.alist(cell.iterSlabData('cell:info'))
2695
+ self.eq(data, (
2696
+ ('cell:version', s_version.version),
2697
+ ('nexus:version', s_cell.NEXUS_VERSION),
2698
+ ('synapse:version', s_version.version)
2699
+ ))
2700
+ with self.raises(s_exc.BadArg):
2701
+ await s_t_utils.alist(cell.iterSlabData('newp'))
2702
+
2703
+ sfkv = cell.slab.getSafeKeyVal('hehe', prefix='yup')
2704
+ sfkv.set('wow', 'yes')
2705
+ data = await s_t_utils.alist(cell.iterSlabData('hehe'))
2706
+ self.eq(data, [('yupwow', 'yes')])
2707
+ data = await s_t_utils.alist(cell.iterSlabData('hehe', prefix='yup'))
2708
+ self.eq(data, [('wow', 'yes')])
2709
+
2710
+ async def test_cell_nexus_compat(self):
2711
+ with mock.patch('synapse.lib.cell.NEXUS_VERSION', (0, 0)):
2712
+ async with self.getRegrCore('hive-migration') as core0:
2713
+ with mock.patch('synapse.lib.cell.NEXUS_VERSION', (2, 177)):
2714
+ conf = {'mirror': core0.getLocalUrl()}
2715
+ async with self.getRegrCore('hive-migration', conf=conf) as core1:
2716
+ await core1.sync()
2717
+
2718
+ await core1.nodes('$lib.user.vars.set(foo, bar)')
2719
+ self.eq('bar', await core0.callStorm('return($lib.user.vars.get(foo))'))
2720
+
2721
+ await core1.nodes('$lib.user.vars.pop(foo)')
2722
+ self.none(await core0.callStorm('return($lib.user.vars.get(foo))'))
2723
+
2724
+ await core1.nodes('$lib.user.profile.set(bar, baz)')
2725
+ self.eq('baz', await core0.callStorm('return($lib.user.profile.get(bar))'))
2726
+
2727
+ await core1.nodes('$lib.user.profile.pop(bar)')
2728
+ self.none(await core0.callStorm('return($lib.user.profile.get(bar))'))
2729
+
2730
+ self.eq((0, 0), core1.nexsvers)
2731
+ await core0.setNexsVers((2, 177))
2732
+ await core1.sync()
2733
+ self.eq((2, 177), core1.nexsvers)
2734
+
2735
+ await core1.nodes('$lib.user.vars.set(foo, bar)')
2736
+ self.eq('bar', await core0.callStorm('return($lib.user.vars.get(foo))'))
2737
+
2738
+ await core1.nodes('$lib.user.vars.pop(foo)')
2739
+ self.none(await core0.callStorm('return($lib.user.vars.get(foo))'))
2740
+
2741
+ await core1.nodes('$lib.user.profile.set(bar, baz)')
2742
+ self.eq('baz', await core0.callStorm('return($lib.user.profile.get(bar))'))
2743
+
2744
+ await core1.nodes('$lib.user.profile.pop(bar)')
2745
+ self.none(await core0.callStorm('return($lib.user.profile.get(bar))'))
2746
+
2747
+ async def test_cell_hive_migration(self):
2748
+
2749
+ with self.getAsyncLoggerStream('synapse.lib.cell') as stream:
2750
+
2751
+ async with self.getRegrCore('hive-migration') as core:
2752
+ visi = await core.auth.getUserByName('visi')
2753
+ asvisi = {'user': visi.iden}
2754
+
2755
+ valu = await core.callStorm('return($lib.user.vars.get(foovar))', opts=asvisi)
2756
+ self.eq('barvalu', valu)
2757
+
2758
+ valu = await core.callStorm('return($lib.user.profile.get(fooprof))', opts=asvisi)
2759
+ self.eq('barprof', valu)
2760
+
2761
+ msgs = await core.stormlist('cron.list')
2762
+ self.stormIsInPrint('visi 8437c35a', msgs)
2763
+ self.stormIsInPrint('[tel:mob:telem=*]', msgs)
2764
+
2765
+ msgs = await core.stormlist('dmon.list')
2766
+ self.stormIsInPrint('0973342044469bc40b577969028c5079: (foodmon ): running', msgs)
2767
+
2768
+ msgs = await core.stormlist('trigger.list')
2769
+ self.stormIsInPrint('visi 27f5dc524e7c3ee8685816ddf6ca1326', msgs)
2770
+ self.stormIsInPrint('[ +#count test:str=$tag ]', msgs)
2771
+
2772
+ msgs = await core.stormlist('testcmd0 foo')
2773
+ self.stormIsInPrint('foo haha', msgs)
2774
+
2775
+ msgs = await core.stormlist('testcmd1')
2776
+ self.stormIsInPrint('hello', msgs)
2777
+
2778
+ msgs = await core.stormlist('model.deprecated.locks')
2779
+ self.stormIsInPrint('ou:hasalias', msgs)
2780
+
2781
+ nodes = await core.nodes('_visi:int')
2782
+ self.len(1, nodes)
2783
+ node = nodes[0]
2784
+ self.eq(node.get('tick'), 1577836800000,)
2785
+ self.eq(node.get('._woot'), 5)
2786
+ self.nn(node.getTagProp('test', 'score'), 6)
2787
+
2788
+ roles = s_t_utils.deguidify('[{"type": "role", "iden": "e1ef725990aa62ae3c4b98be8736d89f", "name": "all", "rules": [], "authgates": {"46cfde2c1682566602860f8df7d0cc83": {"rules": [[true, ["layer", "read"]]]}, "4d50eb257549436414643a71e057091a": {"rules": [[true, ["view", "read"]]]}}}]')
2789
+ users = s_t_utils.deguidify('[{"type": "user", "iden": "a357138db50780b62093a6ce0d057fd8", "name": "root", "rules": [], "roles": [], "admin": true, "email": null, "locked": false, "archived": false, "authgates": {"46cfde2c1682566602860f8df7d0cc83": {"admin": true}, "4d50eb257549436414643a71e057091a": {"admin": true}}}, {"type": "user", "iden": "f77ac6744671a845c27e571071877827", "name": "visi", "rules": [[true, ["cron", "add"]], [true, ["dmon", "add"]], [true, ["trigger", "add"]]], "roles": [{"type": "role", "iden": "e1ef725990aa62ae3c4b98be8736d89f", "name": "all", "rules": [], "authgates": {"46cfde2c1682566602860f8df7d0cc83": {"rules": [[true, ["layer", "read"]]]}, "4d50eb257549436414643a71e057091a": {"rules": [[true, ["view", "read"]]]}}}], "admin": false, "email": null, "locked": false, "archived": false, "authgates": {"f21b7ae79c2dacb89484929a8409e5d8": {"admin": true}, "d7d0380dd4e743e35af31a20d014ed48": {"admin": true}}}]')
2790
+ gates = s_t_utils.deguidify('[{"iden": "46cfde2c1682566602860f8df7d0cc83", "type": "layer", "users": [{"iden": "a357138db50780b62093a6ce0d057fd8", "rules": [], "admin": true}], "roles": [{"iden": "e1ef725990aa62ae3c4b98be8736d89f", "rules": [[true, ["layer", "read"]]], "admin": false}]}, {"iden": "d7d0380dd4e743e35af31a20d014ed48", "type": "trigger", "users": [{"iden": "f77ac6744671a845c27e571071877827", "rules": [], "admin": true}], "roles": []}, {"iden": "f21b7ae79c2dacb89484929a8409e5d8", "type": "cronjob", "users": [{"iden": "f77ac6744671a845c27e571071877827", "rules": [], "admin": true}], "roles": []}, {"iden": "4d50eb257549436414643a71e057091a", "type": "view", "users": [{"iden": "a357138db50780b62093a6ce0d057fd8", "rules": [], "admin": true}], "roles": [{"iden": "e1ef725990aa62ae3c4b98be8736d89f", "rules": [[true, ["view", "read"]]], "admin": false}]}, {"iden": "cortex", "type": "cortex", "users": [], "roles": []}]')
2791
+
2792
+ self.eq(roles, s_t_utils.deguidify(json.dumps(await core.callStorm('return($lib.auth.roles.list())'))))
2793
+ self.eq(users, s_t_utils.deguidify(json.dumps(await core.callStorm('return($lib.auth.users.list())'))))
2794
+ self.eq(gates, s_t_utils.deguidify(json.dumps(await core.callStorm('return($lib.auth.gates.list())'))))
2795
+
2796
+ with self.raises(s_exc.BadTag):
2797
+ await core.nodes('[ it:dev:str=foo +#test.newp ]')
2798
+
2799
+ stream.seek(0)
2800
+ data = stream.getvalue()
2801
+ newprole = s_common.guid('newprole')
2802
+ newpuser = s_common.guid('newpuser')
2803
+
2804
+ self.isin(f'Unknown user {newpuser} on gate', data)
2805
+ self.isin(f'Unknown role {newprole} on gate', data)
2806
+ self.isin(f'Unknown role {newprole} on user', data)
2807
+
2628
2808
  async def test_cell_check_sysctl(self):
2629
2809
  sysctls = s_linux.getSysctls()
2630
2810
 
@@ -2640,7 +2820,7 @@ class CellTest(s_t_utils.SynTest):
2640
2820
 
2641
2821
  stream.seek(0)
2642
2822
  data = stream.getvalue()
2643
- raw_mesgs = [m for m in data.split('\\n') if m]
2823
+ raw_mesgs = [m for m in data.split('\n') if m]
2644
2824
  msgs = [json.loads(m) for m in raw_mesgs]
2645
2825
 
2646
2826
  self.len(1, msgs)
@@ -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.reqConfValu('apikey')
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.reqConfValu('key:string'))
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
- self.eq(cm.exception.get('key'), 'apikey')
289
+
290
+ self.eq(cm.exception.get('name'), 'apikey')
290
291
 
291
292
  def test_hideconf(self):
292
293
  hide_schema = {
@@ -525,7 +525,7 @@ class HttpApiTest(s_tests.SynTest):
525
525
 
526
526
  async with self.getHttpSess() as noobsess:
527
527
  info = {'user': 'noob', 'passwd': 'nooblet'}
528
- async with sess.post(f'https://localhost:{port}/api/v1/login', json=info) as resp:
528
+ async with noobsess.post(f'https://localhost:{port}/api/v1/login', json=info) as resp:
529
529
  item = await resp.json()
530
530
  self.eq('AuthDeny', item.get('code'))
531
531
 
@@ -1136,6 +1136,11 @@ class HttpApiTest(s_tests.SynTest):
1136
1136
  self.len(1, data['gates'])
1137
1137
  self.eq(data['gates'][0]['iden'], 'cortex')
1138
1138
 
1139
+ deflayr, defview = await core.callStorm('''
1140
+ $view = $lib.view.get()
1141
+ return(($view.layers.0.iden, $view.iden))
1142
+ ''')
1143
+
1139
1144
  # user add. couple of messages fall out from it
1140
1145
  await core.callStorm('auth.user.add beep --email beep@vertex.link')
1141
1146
  mesg = await sock.receive_json()
@@ -1151,18 +1156,6 @@ class HttpApiTest(s_tests.SynTest):
1151
1156
  mesg = await sock.receive_json()
1152
1157
  data = mesg['data']
1153
1158
  self.eq(data['event'], 'user:info')
1154
- self.eq(data['info']['name'], 'email')
1155
- self.eq(data['info']['valu'], 'beep@vertex.link')
1156
- self.gt(data['offset'], base)
1157
- base = data['offset']
1158
-
1159
- mesg = await sock.receive_json()
1160
- data = mesg['data']
1161
- deflayr, defview = await core.callStorm('''
1162
- $view = $lib.view.get()
1163
- return(($view.layers.0.iden, $view.iden))
1164
- ''')
1165
- self.eq(data['event'], 'user:info')
1166
1159
  self.eq(data['info']['name'], 'role:grant')
1167
1160
  self.eq(data['info']['iden'], beepiden)
1168
1161
  self.eq(data['info']['role']['iden'], rall.iden)
@@ -1174,6 +1167,14 @@ class HttpApiTest(s_tests.SynTest):
1174
1167
  self.gt(data['offset'], base)
1175
1168
  base = data['offset']
1176
1169
 
1170
+ mesg = await sock.receive_json()
1171
+ data = mesg['data']
1172
+ self.eq(data['event'], 'user:info')
1173
+ self.eq(data['info']['name'], 'email')
1174
+ self.eq(data['info']['valu'], 'beep@vertex.link')
1175
+ self.gt(data['offset'], base)
1176
+ base = data['offset']
1177
+
1177
1178
  # set password
1178
1179
  await core.callStorm('$lib.auth.users.byname("beep").setPasswd("plzdontdothis")')
1179
1180
  mesg = await sock.receive_json()
@@ -1893,7 +1894,10 @@ class HttpApiTest(s_tests.SynTest):
1893
1894
  self.eq(roles, {'all', 'ninjas'})
1894
1895
 
1895
1896
  # Remove the role from the Auth subsystem.
1896
- core.auth.rolesbyiden.pop(ninjas.get('iden'))
1897
+ core.auth.roledefs.delete(ninjas.get('iden'))
1898
+ core.auth.roleidenbyname.delete('ninjas')
1899
+ core.auth.rolebyidencache.pop(ninjas.get('iden'))
1900
+ core.auth.roleidenbynamecache.pop('ninjas')
1897
1901
 
1898
1902
  async with self.getHttpSess() as sess:
1899
1903
  async with sess.post(f'https://localhost:{port}/api/v1/login',
@@ -7,11 +7,11 @@ import synapse.common as s_common
7
7
  import synapse.cortex as s_cortex
8
8
  import synapse.telepath as s_telepath
9
9
 
10
+ import synapse.lib.auth as s_auth
10
11
  import synapse.lib.time as s_time
11
12
  import synapse.lib.layer as s_layer
12
13
  import synapse.lib.msgpack as s_msgpack
13
14
  import synapse.lib.spooled as s_spooled
14
- import synapse.lib.hiveauth as s_hiveauth
15
15
 
16
16
  import synapse.tools.backup as s_tools_backup
17
17
 
@@ -1369,6 +1369,8 @@ class LayerTest(s_t_utils.SynTest):
1369
1369
  readlayr = core.getLayer(readlayrinfo.get('iden'))
1370
1370
  self.true(readlayr.readonly)
1371
1371
 
1372
+ self.none(await core._cloneLayer(readlayrinfo['iden'], readlayrinfo, None))
1373
+
1372
1374
  async def test_layer_ro(self):
1373
1375
  with self.getTestDir() as dirn:
1374
1376
  async with self.getTestCore(dirn=dirn) as core:
@@ -1966,7 +1968,7 @@ class LayerTest(s_t_utils.SynTest):
1966
1968
  parent = core.view.layers[0]
1967
1969
 
1968
1970
  seen.clear()
1969
- with mock.patch.object(s_hiveauth.HiveUser, 'confirm', confirm):
1971
+ with mock.patch.object(s_auth.User, 'confirm', confirm):
1970
1972
  with mock.patch.object(s_cortex.Cortex, 'confirmPropSet', confirmPropSet):
1971
1973
  with mock.patch.object(s_cortex.Cortex, 'confirmPropDel', confirmPropDel):
1972
1974
  await layr.confirmLayerEditPerms(user, parent.iden)
@@ -2015,7 +2017,7 @@ class LayerTest(s_t_utils.SynTest):
2015
2017
  ''', opts=opts)
2016
2018
 
2017
2019
  seen.clear()
2018
- with mock.patch.object(s_hiveauth.HiveUser, 'confirm', confirm):
2020
+ with mock.patch.object(s_auth.User, 'confirm', confirm):
2019
2021
  with mock.patch.object(s_cortex.Cortex, 'confirmPropSet', confirmPropSet):
2020
2022
  with mock.patch.object(s_cortex.Cortex, 'confirmPropDel', confirmPropDel):
2021
2023
  await layr.confirmLayerEditPerms(user, parent.iden)
@@ -2046,7 +2048,7 @@ class LayerTest(s_t_utils.SynTest):
2046
2048
  })
2047
2049
 
2048
2050
  seen.clear()
2049
- with mock.patch.object(s_hiveauth.HiveUser, 'confirm', confirm):
2051
+ with mock.patch.object(s_auth.User, 'confirm', confirm):
2050
2052
  with mock.patch.object(s_cortex.Cortex, 'confirmPropSet', confirmPropSet):
2051
2053
  with mock.patch.object(s_cortex.Cortex, 'confirmPropDel', confirmPropDel):
2052
2054
  await layr.confirmLayerEditPerms(user, layr.iden, delete=True)
@@ -2107,7 +2109,7 @@ class LayerTest(s_t_utils.SynTest):
2107
2109
  parent = core.view.layers[0]
2108
2110
 
2109
2111
  seen.clear()
2110
- with mock.patch.object(s_hiveauth.HiveUser, 'confirm', confirm):
2112
+ with mock.patch.object(s_auth.User, 'confirm', confirm):
2111
2113
  with mock.patch.object(s_cortex.Cortex, 'confirmPropSet', confirmPropSet):
2112
2114
  with mock.patch.object(s_cortex.Cortex, 'confirmPropDel', confirmPropDel):
2113
2115
  await layr.confirmLayerEditPerms(user, parent.iden)
@@ -2122,7 +2124,7 @@ class LayerTest(s_t_utils.SynTest):
2122
2124
  await user.delRule((False, ('node', 'data', 'set', 'hehe')))
2123
2125
 
2124
2126
  seen.clear()
2125
- with mock.patch.object(s_hiveauth.HiveUser, 'confirm', confirm):
2127
+ with mock.patch.object(s_auth.User, 'confirm', confirm):
2126
2128
  with mock.patch.object(s_cortex.Cortex, 'confirmPropSet', confirmPropSet):
2127
2129
  with mock.patch.object(s_cortex.Cortex, 'confirmPropDel', confirmPropDel):
2128
2130
  await layr.confirmLayerEditPerms(user, parent.iden)
@@ -2189,30 +2191,28 @@ class LayerTest(s_t_utils.SynTest):
2189
2191
 
2190
2192
  async def test_push_pull_default_migration(self):
2191
2193
  async with self.getRegrCore('2.159.0-layr-pdefs') as core:
2192
- def_tree = await core.saveHiveTree(('cortex', 'layers', '507ebf7e6ec7aadc47ace6f1f8f77954'))
2193
- dst_tree = await core.saveHiveTree(('cortex', 'layers', '9bf7a3adbf69bd16832529ab1fcd1c83'))
2194
-
2195
- epulls = {'value':
2196
- {'28cb757e9e390a234822f55b922f3295':
2197
- {'chunk:size': 1000,
2198
- 'iden': '28cb757e9e390a234822f55b922f3295',
2199
- 'offs': 0,
2200
- 'queue:size': 10000,
2201
- 'time': 1703781215891,
2202
- 'url': 'cell://./cells/pdefmigr00:*/layer/9bf7a3adbf69bd16832529ab1fcd1c83',
2203
- 'user': '1d8e6e87a2931f8d27690ff408debdab'}}}
2204
- epushs = {'value':
2205
- {'e112f93f09e43f3a10ae945b84721778':
2206
- {'chunk:size': 1000,
2207
- 'iden': 'e112f93f09e43f3a10ae945b84721778',
2208
- 'offs': 0,
2209
- 'queue:size': 10000,
2210
- 'time': 1703781208684,
2211
- 'url': 'cell://./cells/pdefmigr00:*/layer/9bf7a3adbf69bd16832529ab1fcd1c83',
2212
- 'user': '1d8e6e87a2931f8d27690ff408debdab'}}}
2213
-
2214
- self.eq(def_tree.get('kids').get('pulls'), epulls)
2215
- self.eq(def_tree.get('kids').get('pushs'), epushs)
2216
-
2217
- self.notin('pulls', dst_tree.get('kids'))
2218
- self.notin('pushs', dst_tree.get('kids'))
2194
+ def_tree = core.getLayer('507ebf7e6ec7aadc47ace6f1f8f77954').layrinfo
2195
+ dst_tree = core.getLayer('9bf7a3adbf69bd16832529ab1fcd1c83').layrinfo
2196
+
2197
+ epulls = {'28cb757e9e390a234822f55b922f3295':
2198
+ {'chunk:size': 1000,
2199
+ 'iden': '28cb757e9e390a234822f55b922f3295',
2200
+ 'offs': 0,
2201
+ 'queue:size': 10000,
2202
+ 'time': 1703781215891,
2203
+ 'url': 'cell://./cells/pdefmigr00:*/layer/9bf7a3adbf69bd16832529ab1fcd1c83',
2204
+ 'user': '1d8e6e87a2931f8d27690ff408debdab'}}
2205
+ epushs = {'e112f93f09e43f3a10ae945b84721778':
2206
+ {'chunk:size': 1000,
2207
+ 'iden': 'e112f93f09e43f3a10ae945b84721778',
2208
+ 'offs': 0,
2209
+ 'queue:size': 10000,
2210
+ 'time': 1703781208684,
2211
+ 'url': 'cell://./cells/pdefmigr00:*/layer/9bf7a3adbf69bd16832529ab1fcd1c83',
2212
+ 'user': '1d8e6e87a2931f8d27690ff408debdab'}}
2213
+
2214
+ self.eq(def_tree.get('pulls'), epulls)
2215
+ self.eq(def_tree.get('pushs'), epushs)
2216
+
2217
+ self.notin('pulls', dst_tree)
2218
+ self.notin('pushs', dst_tree)