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
@@ -0,0 +1,226 @@
1
+ import synapse.exc as s_exc
2
+ import synapse.tests.utils as s_test
3
+
4
+ def printlines(mesgs):
5
+ return [part for m in mesgs if m[0] == 'print' for part in m[1]['mesg'].split('\n')]
6
+
7
+ class TabularTest(s_test.SynTest):
8
+
9
+ async def test_stormlib_tabular(self):
10
+
11
+ async with self.getTestCore() as core:
12
+
13
+ opts = {
14
+ 'vars': {
15
+ 'rows': [
16
+ (1973, 'Issac Asimov', 'The Gods Themselves'),
17
+ (1974, 'Arthur C. Clarke', 'Rendezvous with Rama'),
18
+ (1975, 'Ursula K. Le Guin', 'The Dispossessed'),
19
+ (1976, 'Joe Haldeman', 'The Forever War'),
20
+ ],
21
+ },
22
+ }
23
+
24
+ # get schema
25
+
26
+ mesgs = await core.stormlist('$lib.print($lib.yaml.save($lib.tabular.schema()))')
27
+ self.stormHasNoWarnErr(mesgs)
28
+ self.stormIsInPrint('column:outline', mesgs)
29
+
30
+ # single line defaults
31
+
32
+ mesgs = await core.stormlist('''
33
+ $printer = $lib.tabular.printer(({
34
+ "columns": [
35
+ {"name": "Year", "width": 6, "justify": "right"},
36
+ {"name": "Author", "width": 20, "justify": "center"},
37
+ {"name": "Title", "width": 12},
38
+ ]
39
+ }))
40
+
41
+ $lib.print($printer.header())
42
+ for $row in $rows {
43
+ $lib.print($printer.row($row))
44
+ }
45
+ ''', opts=opts)
46
+ self.stormHasNoWarnErr(mesgs)
47
+ self.eq([
48
+ ' Year | Author | Title ',
49
+ '========|======================|==============',
50
+ ' 1973 | Issac Asimov | The Gods ... ',
51
+ '--------|----------------------|--------------',
52
+ ' 1974 | Arthur C. Clarke | Rendezvou... ',
53
+ '--------|----------------------|--------------',
54
+ ' 1975 | Ursula K. Le Guin | The Dispo... ',
55
+ '--------|----------------------|--------------',
56
+ ' 1976 | Joe Haldeman | The Forev... ',
57
+ ], printlines(mesgs))
58
+
59
+ # custom separators
60
+
61
+ mesgs = await core.stormlist('''
62
+ $printer = $lib.tabular.printer(({
63
+ "separators": {
64
+ "row:outline": true,
65
+ "column:outline": true,
66
+ "header:row": "#",
67
+ "data:row": "*",
68
+ "column": "+",
69
+ },
70
+ "columns": [
71
+ {"name": "Year", "width": 6, "justify": "right"},
72
+ {"name": "Author", "width": 20, "justify": "center"},
73
+ {"name": "Title", "width": 12},
74
+ ]
75
+ }))
76
+
77
+ $lib.print($printer.header())
78
+ for $row in $rows {
79
+ $lib.print($printer.row($row))
80
+ }
81
+ ''', opts=opts)
82
+ self.stormHasNoWarnErr(mesgs)
83
+ self.eq([
84
+ '+########+######################+##############+',
85
+ '+ Year + Author + Title +',
86
+ '+########+######################+##############+',
87
+ '+ 1973 + Issac Asimov + The Gods ... +',
88
+ '+********+**********************+**************+',
89
+ '+ 1974 + Arthur C. Clarke + Rendezvou... +',
90
+ '+********+**********************+**************+',
91
+ '+ 1975 + Ursula K. Le Guin + The Dispo... +',
92
+ '+********+**********************+**************+',
93
+ '+ 1976 + Joe Haldeman + The Forev... +',
94
+ '+********+**********************+**************+',
95
+ ], printlines(mesgs))
96
+
97
+ # no col separators or end width
98
+
99
+ mesgs = await core.stormlist('''
100
+ $printer = $lib.tabular.printer(({
101
+ "separators": {
102
+ "header:row": "",
103
+ "data:row": "",
104
+ "column": "",
105
+ },
106
+ "columns": [
107
+ {"name": "Year", "width": 6, "justify": "right"},
108
+ {"name": "Author", "width": 20, "justify": "center"},
109
+ {"name": "Title"},
110
+ ]
111
+ }))
112
+
113
+ $lib.print($printer.header())
114
+ for $row in $rows {
115
+ $lib.print($printer.row($row))
116
+ }
117
+ ''', opts=opts)
118
+ self.stormHasNoWarnErr(mesgs)
119
+ self.eq([
120
+ ' Year Author Title ',
121
+ ' 1973 Issac Asimov The Gods Themselves ',
122
+ ' 1974 Arthur C. Clarke Rendezvous with Rama ',
123
+ ' 1975 Ursula K. Le Guin The Dispossessed ',
124
+ ' 1976 Joe Haldeman The Forever War ',
125
+ ], printlines(mesgs))
126
+
127
+ # wraps
128
+
129
+ mesgs = await core.stormlist('''
130
+ $printer = $lib.tabular.printer(({
131
+ "columns": [
132
+ {"name": "Year", "width": 6, "justify": "right"},
133
+ {"name": "Author", "width": 10, "justify": "center", "overflow": "wrap"},
134
+ {"name": "Title", "width": 10, "overflow": "wrap"},
135
+ ]
136
+ }))
137
+
138
+ $lib.print($printer.header())
139
+ for $row in $rows {
140
+ $lib.print($printer.row($row))
141
+ }
142
+ ''', opts=opts)
143
+ self.stormHasNoWarnErr(mesgs)
144
+ self.eq([
145
+ ' Year | Author | Title ',
146
+ '========|============|============',
147
+ ' 1973 | Issac | The Gods ',
148
+ ' | Asimov | Themselves ',
149
+ '--------|------------|------------',
150
+ ' 1974 | Arthur C. | Rendezvous ',
151
+ ' | Clarke | with Rama ',
152
+ '--------|------------|------------',
153
+ ' 1975 | Ursula K. | The Dispos ',
154
+ ' | Le Guin | sessed ',
155
+ '--------|------------|------------',
156
+ ' 1976 | Joe | The ',
157
+ ' | Haldeman | Forever ',
158
+ ' | | War ',
159
+ ], printlines(mesgs))
160
+
161
+ # newlines
162
+
163
+ mesgs = await core.stormlist('''
164
+ $printer = $lib.tabular.printer(({
165
+ "columns": [
166
+ {"name": "Foo", "width": 10},
167
+ {"name": "Bar", "width": 10, "newlines": "split"},
168
+ {"name": "Baz", "newlines": "split"},
169
+ ],
170
+ }))
171
+
172
+ $lib.print($printer.header())
173
+ $lib.print($printer.row(("aaa\\nbbb", "ccc\\nddd", "eee\\nfff")))
174
+ $lib.print($printer.row(("a", "dummy", "row")))
175
+ ''', opts=opts)
176
+ self.stormHasNoWarnErr(mesgs)
177
+ self.eq([
178
+ ' Foo | Bar | Baz ',
179
+ '============|============|=====',
180
+ ' aaa bbb | ccc ddd | eee ',
181
+ ' | | fff ',
182
+ '------------|------------|-----',
183
+ ' a | dummy | row ',
184
+ ], printlines(mesgs))
185
+
186
+ # reprs
187
+
188
+ mesgs = await core.stormlist('''
189
+ $printer = $lib.tabular.printer(({
190
+ "separators": {"header:row": "", "data:row": ""},
191
+ "columns": [{"name": "Foo", "width": 20}],
192
+ }))
193
+
194
+ $lib.print($printer.row(($lib.null,)))
195
+ $lib.print($printer.row((({"bar": "baz"}),)))
196
+ $lib.print($printer.row((${ps:name=cool},)))
197
+ ''', opts=opts)
198
+ self.stormHasNoWarnErr(mesgs)
199
+ self.eq([
200
+ " ",
201
+ " {'bar': 'baz'} ",
202
+ " ps:name=cool ",
203
+ ], printlines(mesgs))
204
+
205
+ # sad
206
+
207
+ with self.raises(s_exc.SchemaViolation):
208
+ await core.nodes('$lib.tabular.printer(({"columns": [{"name": "newp", "width": -43}]}))')
209
+
210
+ with self.raises(s_exc.BadArg) as ecm:
211
+ await core.nodes('''
212
+ $printer = $lib.tabular.printer(({
213
+ "columns": [{"name": "Foo", "width": 20}],
214
+ }))
215
+ $printer.row(({"yeah": "no"}))
216
+ ''')
217
+ self.eq('tabular:printer row() requires a list argument', ecm.exception.errinfo['mesg'])
218
+
219
+ with self.raises(s_exc.BadArg) as ecm:
220
+ await core.nodes('''
221
+ $printer = $lib.tabular.printer(({
222
+ "columns": [{"name": "Foo", "width": 20}],
223
+ }))
224
+ $printer.row((too, many, items))
225
+ ''')
226
+ self.eq('tabular:printer row() requires data length to equal column count', ecm.exception.errinfo['mesg'])
@@ -419,13 +419,16 @@ class StormSvcTest(s_test.SynTest):
419
419
  self.stormIsInPrint(f'List the storm services configured in the cortex.', msgs)
420
420
 
421
421
  msgs = await core.stormlist('service.add fake tcp://localhost:3333/foo')
422
- iden = core.getStormSvcs()[0].iden
422
+ ssvc = core.getStormSvcs()[0]
423
+ iden = ssvc.iden
423
424
  self.stormIsInPrint(f'added {iden} (fake): tcp://localhost:3333/foo', msgs)
424
425
 
425
426
  msgs = await core.stormlist('service.list')
426
427
  self.stormIsInPrint('Storm service list (iden, ready, name, service name, service version, url):', msgs)
427
428
  self.stormIsInPrint(f' {iden} false (fake) (Unknown @ Unknown): tcp://localhost:3333/foo', msgs)
428
429
 
430
+ self.eq(ssvc.sdef, await core._addStormSvc({'iden': iden}))
431
+
429
432
  msgs = await core.stormlist(f'service.del {iden[:4]}')
430
433
  self.stormIsInPrint(f'removed {iden} (fake): tcp://localhost:3333/foo', msgs)
431
434
 
@@ -3277,6 +3277,16 @@ class StormTypesTest(s_test.SynTest):
3277
3277
  self.eq(err[0], 'StormRuntimeError')
3278
3278
  self.isin('Error during base64 decoding - Incorrect padding', err[1].get('mesg'))
3279
3279
 
3280
+ opts = {'vars': {'bytes': None}}
3281
+ text = '[test:str=$lib.base64.decode($bytes)]'
3282
+ mesgs = await core.stormlist(text, opts=opts)
3283
+ errs = [m[1] for m in mesgs if m[0] == 'err']
3284
+ self.len(1, errs)
3285
+ err = errs[0]
3286
+ self.eq(err[0], 'StormRuntimeError')
3287
+ emsg = "Error during base64 decoding - argument should be a bytes-like object or ASCII string, not 'NoneType'"
3288
+ self.isin(emsg, err[1].get('mesg'))
3289
+
3280
3290
  async def test_storm_lib_vars(self):
3281
3291
 
3282
3292
  async with self.getTestCore() as core:
@@ -278,6 +278,7 @@ class BaseTest(s_t_utils.SynTest):
278
278
  [ meta:rule=*
279
279
  :created=20200202 :updated=20220401 :author=*
280
280
  :name=" My Rule" :desc="My cool rule"
281
+ :type=foo.bar
281
282
  :text="while TRUE { BAD }"
282
283
  :ext:id=WOOT-20 :url=https://vertex.link/rules/WOOT-20
283
284
  <(has)+ { meta:ruleset }
@@ -287,6 +288,7 @@ class BaseTest(s_t_utils.SynTest):
287
288
  self.len(1, nodes)
288
289
 
289
290
  self.nn(nodes[0].get('author'))
291
+ self.eq(nodes[0].get('type'), 'foo.bar.')
290
292
  self.eq(nodes[0].get('created'), 1580601600000)
291
293
  self.eq(nodes[0].get('updated'), 1648771200000)
292
294
  self.eq(nodes[0].get('name'), 'my rule')
@@ -296,6 +298,7 @@ class BaseTest(s_t_utils.SynTest):
296
298
  self.eq(nodes[0].get('ext:id'), 'WOOT-20')
297
299
 
298
300
  self.len(1, await core.nodes('meta:rule -> ps:contact'))
301
+ self.len(1, await core.nodes('meta:rule -> meta:rule:type:taxonomy'))
299
302
  self.len(1, await core.nodes('meta:ruleset -> ps:contact'))
300
303
  self.len(1, await core.nodes('meta:ruleset -(has)> meta:rule -(matches)> *'))
301
304
 
@@ -51,6 +51,7 @@ class BizModelTest(s_t_utils.SynTest):
51
51
  nodes = await core.nodes('''
52
52
  [ biz:deal=*
53
53
 
54
+ :id = " 12345 "
54
55
  :title = HeHeHaHa
55
56
  :type = baz.faz
56
57
  :status = foo.bar
@@ -74,6 +75,7 @@ class BizModelTest(s_t_utils.SynTest):
74
75
  ]
75
76
  ''')
76
77
  self.len(1, nodes)
78
+ self.eq(nodes[0].get('id'), '12345')
77
79
  self.eq(nodes[0].get('title'), 'HeHeHaHa')
78
80
  self.eq(nodes[0].get('type'), 'baz.faz.')
79
81
  self.eq(nodes[0].get('status'), 'foo.bar.')
@@ -128,6 +130,7 @@ class BizModelTest(s_t_utils.SynTest):
128
130
  self.nn(nodes[0].get('purchase'))
129
131
 
130
132
  self.len(1, await core.nodes('biz:bundle -> biz:deal'))
133
+ self.len(1, await core.nodes('biz:bundle -> biz:deal +:id=12345'))
131
134
  self.len(1, await core.nodes('biz:bundle -> econ:purchase'))
132
135
  self.len(1, await core.nodes('biz:bundle -> biz:product +:name=LoLoLoL'))
133
136
  self.len(1, await core.nodes('biz:bundle -> biz:service +:name=WoWoWoW'))
@@ -586,7 +586,7 @@ class FileTest(s_t_utils.SynTest):
586
586
  :entry:primary="c:\\some\\stuff\\prog~2\\cmd.exe"
587
587
  :entry:secondary="c:\\some\\stuff\program files\\cmd.exe"
588
588
  :entry:extended="c:\\some\\actual\\stuff\\I\\swear\\cmd.exe"
589
- :entry:localized="c:\\some\\actual\\stuff\\I\\swear\\cmd.exe"
589
+ :entry:localized="c:\\some\\actual\\archivos\\I\\swear\\cmd.exe"
590
590
  :entry:icon="%windir%\\system32\\notepad.exe"
591
591
 
592
592
  :environment:path="%windir%\\system32\\cmd.exe"
@@ -602,6 +602,10 @@ class FileTest(s_t_utils.SynTest):
602
602
  :target:created="2023/01/25 18:57:45.284"
603
603
  :target:accessed="2023/01/25 18:57:45.284"
604
604
  :target:written="2023/01/25 18:57:45.284"
605
+
606
+ :driveserial=0x6af54670
607
+ :machineid=stellarcollapse
608
+ :iconindex=1
605
609
  ]''')
606
610
  self.len(1, nodes)
607
611
  node = nodes[0]
@@ -609,7 +613,7 @@ class FileTest(s_t_utils.SynTest):
609
613
  self.eq(node.get('entry:primary'), 'c:/some/stuff/prog~2/cmd.exe')
610
614
  self.eq(node.get('entry:secondary'), 'c:/some/stuff/program files/cmd.exe')
611
615
  self.eq(node.get('entry:extended'), 'c:/some/actual/stuff/i/swear/cmd.exe')
612
- self.eq(node.get('entry:localized'), 'c:/some/actual/stuff/i/swear/cmd.exe')
616
+ self.eq(node.get('entry:localized'), 'c:/some/actual/archivos/i/swear/cmd.exe')
613
617
 
614
618
  self.eq(node.get('entry:icon'), '%windir%/system32/notepad.exe')
615
619
  self.eq(node.get('environment:path'), '%windir%/system32/cmd.exe')
@@ -628,3 +632,9 @@ class FileTest(s_t_utils.SynTest):
628
632
  self.eq(node.get('target:created'), time)
629
633
  self.eq(node.get('target:accessed'), time)
630
634
  self.eq(node.get('target:written'), time)
635
+
636
+ self.eq(node.get('driveserial'), 0x6af54670)
637
+ self.eq(node.get('machineid'), 'stellarcollapse')
638
+ self.eq(node.get('iconindex'), 1)
639
+
640
+ self.len(1, await core.nodes('file:mime:lnk -> it:hostname'))
@@ -3173,16 +3173,19 @@ class InetModelTest(s_t_utils.SynTest):
3173
3173
  q = '''
3174
3174
  [
3175
3175
  (inet:service:message=(blackout, developers, 1715856900000, vertex, slack)
3176
+ :type=chat.group
3176
3177
  :group=$devsiden
3177
3178
  :public=$lib.false
3178
3179
  )
3179
3180
 
3180
3181
  (inet:service:message=(blackout, visi, 1715856900000, vertex, slack)
3182
+ :type=chat.direct
3181
3183
  :to=$visiiden
3182
3184
  :public=$lib.false
3183
3185
  )
3184
3186
 
3185
3187
  (inet:service:message=(blackout, general, 1715856900000, vertex, slack)
3188
+ :type=chat.channel
3186
3189
  :channel=$gnrliden
3187
3190
  :public=$lib.true
3188
3191
  )
@@ -3224,12 +3227,33 @@ class InetModelTest(s_t_utils.SynTest):
3224
3227
 
3225
3228
  self.eq(nodes[0].get('group'), devsgrp.ndef[1])
3226
3229
  self.false(nodes[0].get('public'))
3230
+ self.eq(nodes[0].get('type'), 'chat.group.')
3227
3231
 
3228
3232
  self.eq(nodes[1].get('to'), visiacct.ndef[1])
3229
3233
  self.false(nodes[1].get('public'))
3234
+ self.eq(nodes[1].get('type'), 'chat.direct.')
3230
3235
 
3231
3236
  self.eq(nodes[2].get('channel'), gnrlchan.ndef[1])
3232
3237
  self.true(nodes[2].get('public'))
3238
+ self.eq(nodes[2].get('type'), 'chat.channel.')
3239
+
3240
+ svcmsgs = await core.nodes('inet:service:message:type:taxonomy -> inet:service:message')
3241
+ self.len(3, svcmsgs)
3242
+ self.sorteq(
3243
+ [k.ndef for k in svcmsgs],
3244
+ [k.ndef for k in nodes],
3245
+ )
3246
+
3247
+ nodes = await core.nodes('inet:service:message:type:taxonomy')
3248
+ self.len(4, nodes)
3249
+ self.sorteq(
3250
+ [k.ndef[1] for k in nodes],
3251
+ ('chat.', 'chat.channel.', 'chat.direct.', 'chat.group.'),
3252
+ )
3253
+
3254
+ nodes = await core.nodes('inet:service:message:type:taxonomy=chat.channel -> inet:service:message')
3255
+ self.len(1, nodes)
3256
+ self.eq(nodes[0].ndef, ('inet:service:message', 'c0d64c559e2f42d57b37b558458c068b'))
3233
3257
 
3234
3258
  q = '''
3235
3259
  [ inet:service:resource=(web, api, vertex, slack)
@@ -9,6 +9,7 @@ import synapse.lib.cell as s_cell
9
9
  import synapse.tests.utils as s_t_utils
10
10
 
11
11
  import synapse.tools.aha.list as s_a_list
12
+ import synapse.tools.aha.clone as s_a_clone
12
13
  import synapse.tools.aha.enroll as s_a_enroll
13
14
  import synapse.tools.aha.easycert as s_a_easycert
14
15
  import synapse.tools.aha.provision.user as s_a_provision_user
@@ -17,40 +18,37 @@ class AhaToolsTest(s_t_utils.SynTest):
17
18
 
18
19
  async def test_aha_list(self):
19
20
 
20
- ephemeral_address = 'tcp://0.0.0.0:0/'
21
- async with self.getTestAha(conf={'auth:passwd': 'root',
22
- 'dmon:listen': ephemeral_address}) as aha:
23
- _, port = aha.sockaddr
24
- ahaurl = f'tcp://root:root@127.0.0.1:{port}'
25
- conf0 = {
26
- 'aha:registry': ahaurl,
27
- 'aha:name': 'cell0',
28
- 'aha:network': 'demo.net',
29
- 'dmon:listen': ephemeral_address,
30
- }
31
- conf1 = {
32
- 'aha:registry': ahaurl,
33
- 'aha:name': 'cell1',
34
- 'aha:network': 'example.net',
35
- 'dmon:listen': ephemeral_address,
36
- }
21
+ async with self.getTestAha() as aha:
22
+
37
23
  waiter = aha.waiter(2, 'aha:svcadd')
24
+ conf0 = {'aha:provision': await aha.addAhaSvcProv('cell0')}
25
+
26
+ provinfo = {'aha:network': 'example.net'}
27
+ conf1 = {'aha:provision': await aha.addAhaSvcProv('cell1', provinfo=provinfo)}
28
+
29
+ ahaurl = aha.getLocalUrl()
30
+
38
31
  async with self.getTestCell(s_cell.Cell, conf=conf0) as cell0:
32
+
39
33
  async with self.getTestCell(s_cell.Cell, conf=conf1) as cell1:
34
+
40
35
  self.true(await waiter.wait(timeout=6))
36
+
41
37
  argv = [ahaurl]
42
38
  retn, outp = await self.execToolMain(s_a_list._main, argv)
43
39
  self.eq(retn, 0)
44
- outp.expect('Service network leader')
45
- outp.expect('cell0 demo.net None')
46
- outp.expect('cell1 example.net None')
40
+
41
+ outp.expect('''
42
+ Service network leader
43
+ cell0 synapse None
44
+ cell1 example.net None
45
+ ''', whitespace=False)
47
46
 
48
47
  argv = [ahaurl, 'demo.net']
49
48
  retn, outp = await self.execToolMain(s_a_list._main, argv)
50
49
  self.eq(retn, 0)
51
- outp.expect('Service network')
52
- outp.expect('cell0 demo.net')
53
- self.false(outp.expect('cell1 example.net', throw=False))
50
+ outp.expect('Service network', whitespace=False)
51
+ outp.expect('cell0 demo.net', whitespace=False)
54
52
 
55
53
  async with self.getTestCore() as core:
56
54
  curl = core.getLocalUrl()
@@ -94,102 +92,81 @@ class AhaToolsTest(s_t_utils.SynTest):
94
92
 
95
93
  async def test_aha_enroll(self):
96
94
 
97
- with self.getTestDir() as dirn:
98
-
99
- conf = {
100
- 'aha:name': 'aha',
101
- 'aha:network': 'loop.vertex.link',
102
- 'provision:listen': 'ssl://aha.loop.vertex.link:0',
103
- 'dmon:listen': 'tcp://0.0.0.0:0'
104
- }
105
- async with self.getTestAha(dirn=dirn, conf=conf) as aha:
106
-
107
- addr, port = aha.provdmon.addr
108
- aha.conf['provision:listen'] = f'ssl://aha.loop.vertex.link:{port}'
109
-
110
- host_, ahaport = aha.sockaddr
111
- self.eq(aha._getAhaUrls(), [f'ssl://aha.loop.vertex.link:{ahaport}'])
95
+ async with self.getTestAha() as aha:
112
96
 
113
- argv = ['--url', aha.getLocalUrl(), 'visi']
114
- retn, outp = await self.execToolMain(s_a_provision_user.main, argv)
115
- self.isin('one-time use URL:', str(outp))
116
-
117
- provurl = str(outp).split(':', 1)[1].strip()
118
- with self.getTestSynDir() as syndir:
97
+ argv = ['--url', aha.getLocalUrl(), '01.aha.loop.vertex.link']
98
+ retn, outp = await self.execToolMain(s_a_clone.main, argv)
99
+ self.eq(retn, 0)
100
+ self.isin('one-time use URL:', str(outp))
119
101
 
120
- capath = s_common.genpath(syndir, 'certs', 'cas', 'loop.vertex.link.crt')
121
- crtpath = s_common.genpath(syndir, 'certs', 'users', 'visi@loop.vertex.link.crt')
122
- keypath = s_common.genpath(syndir, 'certs', 'users', 'visi@loop.vertex.link.key')
102
+ argv = ['--url', aha.getLocalUrl(), '01.aha.loop.vertex.link', '--only-url']
103
+ retn, outp = await self.execToolMain(s_a_clone.main, argv)
104
+ self.eq(retn, 0)
105
+ self.notin('one-time use URL:', str(outp))
123
106
 
124
- for path in (capath, crtpath, keypath):
125
- s_common.genfile(path)
107
+ argv = ['--url', 'newp://1.2.3.4', '01.aha.loop.vertex.link']
108
+ retn, outp = await self.execToolMain(s_a_clone.main, argv)
109
+ self.eq(retn, 1)
110
+ self.isin('ERROR: Invalid URL scheme: newp', str(outp))
126
111
 
127
- yamlpath = s_common.genpath(syndir, 'telepath.yaml')
128
- s_common.yamlsave({'aha:servers': 'cell://aha'}, yamlpath)
112
+ argv = ['--url', aha.getLocalUrl(), 'visi']
113
+ retn, outp = await self.execToolMain(s_a_provision_user.main, argv)
114
+ self.isin('one-time use URL:', str(outp))
129
115
 
130
- retn, outp = await self.execToolMain(s_a_enroll.main, (provurl,))
131
- self.eq(0, retn)
116
+ provurl = str(outp).split(':', 1)[1].strip()
117
+ with self.getTestSynDir() as syndir:
132
118
 
133
- for path in (capath, crtpath, keypath):
134
- self.gt(os.path.getsize(path), 0)
119
+ capath = s_common.genpath(syndir, 'certs', 'cas', 'synapse.crt')
120
+ crtpath = s_common.genpath(syndir, 'certs', 'users', 'visi@synapse.crt')
121
+ keypath = s_common.genpath(syndir, 'certs', 'users', 'visi@synapse.crt')
135
122
 
136
- teleyaml = s_common.yamlload(syndir, 'telepath.yaml')
137
- self.eq(teleyaml.get('version'), 1)
138
- self.eq(teleyaml.get('aha:servers'), ('cell://aha', f'ssl://visi@aha.loop.vertex.link:{ahaport}'))
123
+ retn, outp = await self.execToolMain(s_a_enroll.main, (provurl,))
124
+ self.eq(0, retn)
139
125
 
140
- shutil.rmtree(s_common.genpath(syndir, 'certs'))
126
+ for path in (capath, crtpath, keypath):
127
+ self.true(os.path.isfile(path))
128
+ self.gt(os.path.getsize(path), 0)
141
129
 
142
- def _strUrl(self):
143
- return 'ssl://aha.loop.vertex.link'
130
+ teleyaml = s_common.yamlload(syndir, 'telepath.yaml')
131
+ self.eq(teleyaml.get('version'), 1)
132
+ self.len(1, teleyaml.get('aha:servers'))
144
133
 
145
- with mock.patch('synapse.lib.aha.AhaCell._getAhaUrls', _strUrl):
134
+ shutil.rmtree(s_common.genpath(syndir, 'certs'))
146
135
 
147
- argv = ['--again', '--url', aha.getLocalUrl(), 'visi']
148
- retn, outp = await self.execToolMain(s_a_provision_user.main, argv)
149
- self.eq(retn, 0)
150
- self.isin('one-time use URL:', str(outp))
151
-
152
- provurl = str(outp).split(':', 1)[1].strip()
153
-
154
- retn, outp = await self.execToolMain(s_a_enroll.main, (provurl,))
155
-
156
- servers = ['cell://aha',
157
- 'ssl://visi@aha.loop.vertex.link',
158
- f'ssl://visi@aha.loop.vertex.link:{ahaport}']
136
+ argv = ['--again', '--url', aha.getLocalUrl(), 'visi']
137
+ retn, outp = await self.execToolMain(s_a_provision_user.main, argv)
138
+ self.eq(retn, 0)
139
+ self.isin('one-time use URL:', str(outp))
159
140
 
160
- teleyaml = s_common.yamlload(syndir, 'telepath.yaml')
161
- self.sorteq(teleyaml.get('aha:servers'), servers)
141
+ provurl = str(outp).split(':', 1)[1].strip()
162
142
 
163
- # Just return the URL
164
- retn, outp = await self.execToolMain(s_a_provision_user.main, argv + ['--only-url'])
165
- self.eq(retn, 0)
166
- self.notin('one-time use URL:', str(outp))
167
- self.isin('ssl://', str(outp))
143
+ retn, outp = await self.execToolMain(s_a_enroll.main, (provurl,))
168
144
 
169
- with self.getTestSynDir() as syndir:
145
+ # Just return the URL
146
+ retn, outp = await self.execToolMain(s_a_provision_user.main, argv + ['--only-url'])
147
+ self.eq(retn, 0)
148
+ self.notin('one-time use URL:', str(outp))
149
+ self.isin('ssl://', str(outp))
170
150
 
171
- argv = ['--again', '--url', aha.getLocalUrl(), 'visi']
172
- retn, outp = await self.execToolMain(s_a_provision_user.main, argv)
173
- self.eq(retn, 0)
174
- provurl = str(outp).split(':', 1)[1].strip()
151
+ with self.getTestSynDir() as syndir:
175
152
 
176
- capath = s_common.genpath(syndir, 'certs', 'cas', 'loop.vertex.link.crt')
177
- crtpath = s_common.genpath(syndir, 'certs', 'users', 'visi@loop.vertex.link.crt')
178
- keypath = s_common.genpath(syndir, 'certs', 'users', 'visi@loop.vertex.link.key')
153
+ argv = ['--again', '--url', aha.getLocalUrl(), 'visi']
154
+ retn, outp = await self.execToolMain(s_a_provision_user.main, argv)
155
+ self.eq(retn, 0)
156
+ provurl = str(outp).split(':', 1)[1].strip()
179
157
 
180
- for path in (capath, crtpath, keypath):
181
- s_common.genfile(path)
158
+ capath = s_common.genpath(syndir, 'certs', 'cas', 'synapse.crt')
159
+ crtpath = s_common.genpath(syndir, 'certs', 'users', 'visi@synapse.crt')
160
+ keypath = s_common.genpath(syndir, 'certs', 'users', 'visi@synapse.key')
182
161
 
183
- yamlpath = s_common.genpath(syndir, 'telepath.yaml')
184
- s_common.yamlsave({'aha:servers': ['cell://aha', 'cell://foo', ['cell://bar']]}, yamlpath)
162
+ for path in (capath, crtpath, keypath):
163
+ s_common.genfile(path)
185
164
 
186
- retn, outp = await self.execToolMain(s_a_enroll.main, (provurl,))
187
- self.eq(0, retn)
165
+ retn, outp = await self.execToolMain(s_a_enroll.main, (provurl,))
166
+ self.eq(0, retn)
188
167
 
189
- for path in (capath, crtpath, keypath):
190
- self.gt(os.path.getsize(path), 0)
168
+ for path in (capath, crtpath, keypath):
169
+ self.gt(os.path.getsize(path), 0)
191
170
 
192
- teleyaml = s_common.yamlload(syndir, 'telepath.yaml')
193
- self.eq(teleyaml.get('version'), 1)
194
- self.eq(teleyaml.get('aha:servers'), ('cell://aha', 'cell://foo', ('cell://bar',),
195
- f'ssl://visi@aha.loop.vertex.link:{ahaport}'))
171
+ teleyaml = s_common.yamlload(syndir, 'telepath.yaml')
172
+ self.eq(teleyaml.get('version'), 1)