synapse 2.224.0__py311-none-any.whl → 2.225.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/axon.py +10 -5
- synapse/lib/cell.py +1 -1
- synapse/lib/const.py +4 -0
- synapse/lib/multislabseqn.py +36 -1
- synapse/lib/nexus.py +67 -8
- synapse/lib/queue.py +4 -1
- synapse/lib/rstorm.py +2 -2
- synapse/lib/schemas.py +11 -1
- synapse/lib/slabseqn.py +28 -0
- synapse/lib/storm.py +5 -1
- synapse/lib/stormhttp.py +7 -1
- synapse/lib/version.py +2 -2
- synapse/models/inet.py +4 -0
- synapse/models/media.py +4 -0
- synapse/models/risk.py +3 -0
- synapse/tests/test_cortex.py +2 -2
- synapse/tests/test_lib_agenda.py +1 -1
- synapse/tests/test_lib_cell.py +1 -1
- synapse/tests/test_lib_certdir.py +1 -1
- synapse/tests/test_lib_httpapi.py +1 -1
- synapse/tests/test_lib_layer.py +1 -1
- synapse/tests/test_lib_multislabseqn.py +22 -0
- synapse/tests/test_lib_nexus.py +42 -1
- synapse/tests/test_lib_slabseqn.py +30 -1
- synapse/tests/test_lib_storm.py +59 -1
- synapse/tests/test_lib_stormhttp.py +16 -0
- synapse/tests/test_lib_stormlib_oauth.py +1 -1
- synapse/tests/test_lib_stormsvc.py +1 -1
- synapse/tests/test_lib_trigger.py +1 -1
- synapse/tests/test_model_inet.py +6 -0
- synapse/tests/test_model_media.py +4 -1
- synapse/tests/test_model_risk.py +2 -0
- synapse/tests/{test_tools_axon2axon.py → test_tools_axon_copy.py} +4 -4
- synapse/tests/{test_tools_pullfile.py → test_tools_axon_get.py} +4 -4
- synapse/tests/{test_tools_pushfile.py → test_tools_axon_put.py} +7 -7
- synapse/tests/{test_tools_csvtool.py → test_tools_cortex_csv.py} +12 -3
- synapse/tests/{test_tools_feed.py → test_tools_cortex_feed.py} +2 -2
- synapse/tests/{test_tools_apikey.py → test_tools_service_apikey.py} +1 -4
- synapse/tests/{test_tools_backup.py → test_tools_service_backup.py} +5 -5
- synapse/tests/{test_tools_demote.py → test_tools_service_demote.py} +1 -1
- synapse/tests/{test_tools_healthcheck.py → test_tools_service_healthcheck.py} +1 -1
- synapse/tests/{test_tools_livebackup.py → test_tools_service_livebackup.py} +1 -1
- synapse/tests/{test_tools_modrole.py → test_tools_service_modrole.py} +1 -1
- synapse/tests/{test_tools_moduser.py → test_tools_service_moduser.py} +1 -1
- synapse/tests/{test_tools_promote.py → test_tools_service_promote.py} +1 -1
- synapse/tests/{test_tools_reload.py → test_tools_service_reload.py} +1 -1
- synapse/tests/{test_tools_shutdown.py → test_tools_service_shutdown.py} +1 -1
- synapse/tests/{test_tools_snapshot.py → test_tools_service_snapshot.py} +1 -1
- synapse/tests/{test_tools_storm.py → test_tools_storm_cli.py} +1 -1
- synapse/tests/{test_tools_pkgs_gendocs.py → test_tools_storm_pkg_doc.py} +12 -3
- synapse/tests/{test_tools_genpkg.py → test_tools_storm_pkg_gen.py} +1 -1
- synapse/tests/{test_tools_autodoc.py → test_tools_utils_autodoc.py} +1 -1
- synapse/tests/test_tools_utils_changelog.py +454 -0
- synapse/tests/{test_tools_easycert.py → test_tools_utils_easycert.py} +48 -46
- synapse/tests/{test_tools_guid.py → test_tools_utils_guid.py} +3 -3
- synapse/tests/{test_tools_json2mpk.py → test_tools_utils_json2mpk.py} +3 -3
- synapse/tests/{test_tools_rstorm.py → test_tools_utils_rstorm.py} +6 -1
- synapse/tests/utils.py +3 -1
- synapse/tools/apikey.py +4 -83
- synapse/tools/autodoc.py +3 -1031
- synapse/tools/axon/copy.py +44 -0
- synapse/tools/axon/get.py +64 -0
- synapse/tools/axon/put.py +122 -0
- synapse/tools/axon2axon.py +3 -36
- synapse/tools/backup.py +6 -176
- synapse/tools/changelog.py +3 -1098
- synapse/tools/cortex/csv.py +236 -0
- synapse/tools/cortex/feed.py +151 -0
- synapse/tools/csvtool.py +3 -227
- synapse/tools/demote.py +4 -40
- synapse/tools/docker/validate.py +3 -3
- synapse/tools/easycert.py +4 -129
- synapse/tools/feed.py +3 -140
- synapse/tools/genpkg.py +3 -307
- synapse/tools/guid.py +7 -6
- synapse/tools/healthcheck.py +3 -101
- synapse/tools/json2mpk.py +6 -38
- synapse/tools/livebackup.py +4 -27
- synapse/tools/modrole.py +3 -108
- synapse/tools/moduser.py +3 -179
- synapse/tools/pkgs/gendocs.py +3 -164
- synapse/tools/promote.py +4 -41
- synapse/tools/pullfile.py +3 -56
- synapse/tools/pushfile.py +3 -114
- synapse/tools/reload.py +4 -61
- synapse/tools/rstorm.py +3 -26
- synapse/tools/service/__init__.py +0 -0
- synapse/tools/service/apikey.py +90 -0
- synapse/tools/service/backup.py +181 -0
- synapse/tools/service/demote.py +47 -0
- synapse/tools/service/healthcheck.py +109 -0
- synapse/tools/service/livebackup.py +34 -0
- synapse/tools/service/modrole.py +116 -0
- synapse/tools/service/moduser.py +184 -0
- synapse/tools/service/promote.py +48 -0
- synapse/tools/service/reload.py +68 -0
- synapse/tools/service/shutdown.py +51 -0
- synapse/tools/service/snapshot.py +64 -0
- synapse/tools/shutdown.py +5 -45
- synapse/tools/snapshot.py +4 -57
- synapse/tools/storm/__init__.py +0 -0
- synapse/tools/storm/__main__.py +5 -0
- synapse/tools/{storm.py → storm/_cli.py} +0 -3
- synapse/tools/storm/pkg/__init__.py +0 -0
- synapse/tools/{pkgs/pandoc_filter.py → storm/pkg/_pandoc_filter.py} +1 -1
- synapse/tools/storm/pkg/doc.py +176 -0
- synapse/tools/storm/pkg/gen.py +315 -0
- synapse/tools/utils/__init__.py +0 -0
- synapse/tools/utils/autodoc.py +1040 -0
- synapse/tools/utils/changelog.py +1124 -0
- synapse/tools/utils/easycert.py +136 -0
- synapse/tools/utils/guid.py +11 -0
- synapse/tools/utils/json2mpk.py +46 -0
- synapse/tools/utils/rstorm.py +35 -0
- {synapse-2.224.0.dist-info → synapse-2.225.0.dist-info}/METADATA +1 -1
- {synapse-2.224.0.dist-info → synapse-2.225.0.dist-info}/RECORD +120 -91
- synapse/tests/test_tools_changelog.py +0 -196
- /synapse/tests/{test_tools_axon.py → test_tools_axon_dump_load.py} +0 -0
- {synapse-2.224.0.dist-info → synapse-2.225.0.dist-info}/WHEEL +0 -0
- {synapse-2.224.0.dist-info → synapse-2.225.0.dist-info}/licenses/LICENSE +0 -0
- {synapse-2.224.0.dist-info → synapse-2.225.0.dist-info}/top_level.txt +0 -0
|
@@ -5,31 +5,31 @@ import os
|
|
|
5
5
|
import synapse.exc as s_exc
|
|
6
6
|
import synapse.common as s_common
|
|
7
7
|
import synapse.tests.utils as s_t_utils
|
|
8
|
-
import synapse.tools.easycert as s_easycert
|
|
8
|
+
import synapse.tools.utils.easycert as s_easycert
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class TestEasyCert(s_t_utils.SynTest):
|
|
12
12
|
|
|
13
|
-
def make_testca(self, path):
|
|
13
|
+
async def make_testca(self, path):
|
|
14
14
|
'''
|
|
15
15
|
Helper for making a testca named "testca"
|
|
16
16
|
'''
|
|
17
17
|
outp = self.getTestOutp()
|
|
18
18
|
argv = ['--ca', '--certdir', path, 'testca']
|
|
19
|
-
self.eq(s_easycert.main(argv, outp=outp), 0)
|
|
19
|
+
self.eq(await s_easycert.main(argv, outp=outp), 0)
|
|
20
20
|
self.true(outp.expect('key saved'))
|
|
21
21
|
self.true(outp.expect('testca.key'))
|
|
22
22
|
self.true(outp.expect('cert saved'))
|
|
23
23
|
self.true(outp.expect('testca.crt'))
|
|
24
24
|
|
|
25
|
-
def test_easycert_user_p12(self):
|
|
25
|
+
async def test_easycert_user_p12(self):
|
|
26
26
|
with self.getTestDir() as path:
|
|
27
27
|
|
|
28
|
-
self.make_testca(path)
|
|
28
|
+
await self.make_testca(path)
|
|
29
29
|
|
|
30
30
|
outp = self.getTestOutp()
|
|
31
31
|
argv = ['--certdir', path, '--signas', 'testca', 'user@test.com']
|
|
32
|
-
self.eq(s_easycert.main(argv, outp=outp), 0)
|
|
32
|
+
self.eq(await s_easycert.main(argv, outp=outp), 0)
|
|
33
33
|
self.true(outp.expect('key saved'))
|
|
34
34
|
self.true(outp.expect('user@test.com.key'))
|
|
35
35
|
self.true(outp.expect('cert saved'))
|
|
@@ -37,42 +37,42 @@ class TestEasyCert(s_t_utils.SynTest):
|
|
|
37
37
|
|
|
38
38
|
outp = self.getTestOutp()
|
|
39
39
|
argv = ['--certdir', path, '--p12', 'user@test.com']
|
|
40
|
-
self.eq(s_easycert.main(argv, outp=outp), 0)
|
|
40
|
+
self.eq(await s_easycert.main(argv, outp=outp), 0)
|
|
41
41
|
self.true(outp.expect('client cert saved'))
|
|
42
42
|
self.true(outp.expect('user@test.com.p12'))
|
|
43
43
|
|
|
44
|
-
def test_easycert_user_sign(self):
|
|
44
|
+
async def test_easycert_user_sign(self):
|
|
45
45
|
with self.getTestDir() as path:
|
|
46
46
|
|
|
47
|
-
self.make_testca(path)
|
|
47
|
+
await self.make_testca(path)
|
|
48
48
|
|
|
49
49
|
outp = self.getTestOutp()
|
|
50
50
|
argv = ['--certdir', path, '--signas', 'testca', 'user@test.com']
|
|
51
|
-
self.eq(s_easycert.main(argv, outp=outp), 0)
|
|
51
|
+
self.eq(await s_easycert.main(argv, outp=outp), 0)
|
|
52
52
|
self.true(outp.expect('key saved'))
|
|
53
53
|
self.true(outp.expect('user@test.com.key'))
|
|
54
54
|
self.true(outp.expect('cert saved'))
|
|
55
55
|
self.true(outp.expect('user@test.com.crt'))
|
|
56
56
|
|
|
57
|
-
def test_easycert_server_sign(self):
|
|
57
|
+
async def test_easycert_server_sign(self):
|
|
58
58
|
with self.getTestDir() as path:
|
|
59
59
|
|
|
60
|
-
self.make_testca(path)
|
|
60
|
+
await self.make_testca(path)
|
|
61
61
|
|
|
62
62
|
outp = self.getTestOutp()
|
|
63
63
|
argv = ['--certdir', path, '--signas', 'testca', '--server', 'test.vertex.link']
|
|
64
|
-
self.eq(s_easycert.main(argv, outp=outp), 0)
|
|
64
|
+
self.eq(await s_easycert.main(argv, outp=outp), 0)
|
|
65
65
|
self.true(outp.expect('key saved'))
|
|
66
66
|
self.true(outp.expect('test.vertex.link.key'))
|
|
67
67
|
self.true(outp.expect('cert saved'))
|
|
68
68
|
self.true(outp.expect('test.vertex.link.crt'))
|
|
69
69
|
|
|
70
|
-
def test_easycert_csr(self):
|
|
70
|
+
async def test_easycert_csr(self):
|
|
71
71
|
with self.getTestDir() as path:
|
|
72
72
|
|
|
73
73
|
outp = self.getTestOutp()
|
|
74
74
|
argv = ['--csr', '--certdir', path, 'user@test.com']
|
|
75
|
-
self.eq(s_easycert.main(argv, outp=outp), 0)
|
|
75
|
+
self.eq(await s_easycert.main(argv, outp=outp), 0)
|
|
76
76
|
self.true(outp.expect('key saved'))
|
|
77
77
|
self.true(outp.expect('user@test.com.key'))
|
|
78
78
|
self.true(outp.expect('csr saved'))
|
|
@@ -81,7 +81,7 @@ class TestEasyCert(s_t_utils.SynTest):
|
|
|
81
81
|
# Generate a server CSR
|
|
82
82
|
outp = self.getTestOutp()
|
|
83
83
|
argv = ['--csr', '--certdir', path, 'wwww.vertex.link', '--server']
|
|
84
|
-
self.eq(s_easycert.main(argv, outp=outp), 0)
|
|
84
|
+
self.eq(await s_easycert.main(argv, outp=outp), 0)
|
|
85
85
|
self.true(outp.expect('key saved'))
|
|
86
86
|
self.true(outp.expect('www.vertex.link.key'))
|
|
87
87
|
self.true(outp.expect('csr saved'))
|
|
@@ -89,22 +89,23 @@ class TestEasyCert(s_t_utils.SynTest):
|
|
|
89
89
|
|
|
90
90
|
outp = self.getTestOutp()
|
|
91
91
|
argv = ['--csr', '--certdir', path, 'intermed', '--ca']
|
|
92
|
-
self.raises(NotImplementedError
|
|
92
|
+
with self.raises(NotImplementedError):
|
|
93
|
+
await s_easycert.main(argv, outp=outp)
|
|
93
94
|
|
|
94
95
|
# Ensure that duplicate files won't be overwritten
|
|
95
96
|
outp = self.getTestOutp()
|
|
96
97
|
argv = ['--csr', '--certdir', path, 'user@test.com']
|
|
97
|
-
self.eq(s_easycert.main(argv, outp=outp), 1)
|
|
98
|
+
self.eq(await s_easycert.main(argv, outp=outp), 1)
|
|
98
99
|
self.true(outp.expect('file exists:'))
|
|
99
100
|
self.true(outp.expect('user@test.com.key'))
|
|
100
101
|
|
|
101
|
-
self.make_testca(path)
|
|
102
|
+
await self.make_testca(path)
|
|
102
103
|
|
|
103
104
|
# Sign the user csr
|
|
104
105
|
outp = self.getTestOutp()
|
|
105
106
|
csrpath = os.path.join(path, 'users', 'user@test.com.csr')
|
|
106
107
|
argv = ['--certdir', path, '--signas', 'testca', '--sign-csr', csrpath, ]
|
|
107
|
-
self.eq(s_easycert.main(argv, outp=outp), 0)
|
|
108
|
+
self.eq(await s_easycert.main(argv, outp=outp), 0)
|
|
108
109
|
self.true(outp.expect('cert saved:'))
|
|
109
110
|
self.true(outp.expect('user@test.com.crt'))
|
|
110
111
|
|
|
@@ -112,23 +113,23 @@ class TestEasyCert(s_t_utils.SynTest):
|
|
|
112
113
|
outp = self.getTestOutp()
|
|
113
114
|
csrpath = os.path.join(path, 'hosts', 'wwww.vertex.link.csr')
|
|
114
115
|
argv = ['--certdir', path, '--signas', 'testca', '--sign-csr', csrpath, '--server']
|
|
115
|
-
self.eq(s_easycert.main(argv, outp=outp), 0)
|
|
116
|
+
self.eq(await s_easycert.main(argv, outp=outp), 0)
|
|
116
117
|
self.true(outp.expect('cert saved:'))
|
|
117
118
|
self.true(outp.expect('www.vertex.link.crt'))
|
|
118
119
|
|
|
119
120
|
# test nonexistent csr
|
|
120
121
|
outp = self.getTestOutp()
|
|
121
122
|
argv = ['--certdir', path, '--signas', 'testca', '--sign-csr', 'lololol', ]
|
|
122
|
-
self.eq(s_easycert.main(argv, outp=outp), 1)
|
|
123
|
+
self.eq(await s_easycert.main(argv, outp=outp), 1)
|
|
123
124
|
self.true(outp.expect('csr not found: lololol'))
|
|
124
125
|
|
|
125
126
|
# Test bad input
|
|
126
127
|
outp = self.getTestOutp()
|
|
127
128
|
argv = ['--certdir', path, '--sign-csr', 'lololol', ]
|
|
128
|
-
self.eq(s_easycert.main(argv, outp=outp), 1)
|
|
129
|
+
self.eq(await s_easycert.main(argv, outp=outp), 1)
|
|
129
130
|
self.true(outp.expect('--sign-csr requires --signas'))
|
|
130
131
|
|
|
131
|
-
def test_easycert_importfile(self):
|
|
132
|
+
async def test_easycert_importfile(self):
|
|
132
133
|
with self.getTestDir() as tstpath:
|
|
133
134
|
|
|
134
135
|
outp = self.getTestOutp()
|
|
@@ -137,7 +138,7 @@ class TestEasyCert(s_t_utils.SynTest):
|
|
|
137
138
|
ftype = 'cas'
|
|
138
139
|
argv = ['--importfile', ftype, '--certdir', tstpath, srcpath]
|
|
139
140
|
with s_common.genfile(srcpath) as fd:
|
|
140
|
-
self.eq(s_easycert.main(argv, outp=outp), 0)
|
|
141
|
+
self.eq(await s_easycert.main(argv, outp=outp), 0)
|
|
141
142
|
|
|
142
143
|
outp = self.getTestOutp()
|
|
143
144
|
fname = 'pennywise@vertex.link.crt'
|
|
@@ -145,69 +146,70 @@ class TestEasyCert(s_t_utils.SynTest):
|
|
|
145
146
|
ftype = 'cas'
|
|
146
147
|
argv = ['--importfile', ftype, '--certdir', tstpath, srcpath]
|
|
147
148
|
with s_common.genfile(srcpath) as fd:
|
|
148
|
-
self.eq(s_easycert.main(argv, outp=outp), 0)
|
|
149
|
+
self.eq(await s_easycert.main(argv, outp=outp), 0)
|
|
149
150
|
|
|
150
151
|
outp = self.getTestOutp()
|
|
151
152
|
argv = ['--importfile', 'cas', '--certdir', tstpath, 'nope']
|
|
152
|
-
self.raises(s_exc.NoSuchFile
|
|
153
|
+
with self.raises(s_exc.NoSuchFile):
|
|
154
|
+
await s_easycert.main(argv, outp=outp)
|
|
153
155
|
|
|
154
|
-
def test_easycert_code(self):
|
|
156
|
+
async def test_easycert_code(self):
|
|
155
157
|
with self.getTestDir() as dirn:
|
|
156
158
|
outp = self.getTestOutp()
|
|
157
|
-
self.eq(0, s_easycert.main(('--certdir', dirn, '--ca', 'woot'), outp=outp))
|
|
159
|
+
self.eq(0, await s_easycert.main(('--certdir', dirn, '--ca', 'woot'), outp=outp))
|
|
158
160
|
|
|
159
161
|
outp.clear()
|
|
160
|
-
self.eq(0, s_easycert.main(('--certdir', dirn, '--code', 'wootpipe', '--signas', 'woot'), outp=outp))
|
|
162
|
+
self.eq(0, await s_easycert.main(('--certdir', dirn, '--code', 'wootpipe', '--signas', 'woot'), outp=outp))
|
|
161
163
|
outp.expect('code/wootpipe.crt')
|
|
162
164
|
|
|
163
165
|
outp.clear()
|
|
164
|
-
self.eq(0, s_easycert.main(('--certdir', dirn, '--code', 'selfpipe'), outp=outp))
|
|
166
|
+
self.eq(0, await s_easycert.main(('--certdir', dirn, '--code', 'selfpipe'), outp=outp))
|
|
165
167
|
outp.expect('code/selfpipe.crt')
|
|
166
168
|
|
|
167
|
-
def test_easycert_revokeas(self):
|
|
169
|
+
async def test_easycert_revokeas(self):
|
|
168
170
|
|
|
169
171
|
with self.getTestDir() as dirn:
|
|
170
172
|
outp = self.getTestOutp()
|
|
171
|
-
self.eq(0, s_easycert.main(('--certdir', dirn, '--ca', 'woot'), outp=outp))
|
|
173
|
+
self.eq(0, await s_easycert.main(('--certdir', dirn, '--ca', 'woot'), outp=outp))
|
|
172
174
|
|
|
173
175
|
outp.clear()
|
|
174
|
-
self.eq(0, s_easycert.main(('--certdir', dirn, '--ca', 'inner', '--signas', 'woot'), outp=outp))
|
|
176
|
+
self.eq(0, await s_easycert.main(('--certdir', dirn, '--ca', 'inner', '--signas', 'woot'), outp=outp))
|
|
175
177
|
|
|
176
178
|
outp.clear()
|
|
177
|
-
self.eq(0, s_easycert.main(('--certdir', dirn, '--crl', 'woot'), outp=outp))
|
|
179
|
+
self.eq(0, await s_easycert.main(('--certdir', dirn, '--crl', 'woot'), outp=outp))
|
|
178
180
|
outp.expect('CRL saved:')
|
|
179
181
|
|
|
180
182
|
outp.clear()
|
|
181
|
-
self.eq(0, s_easycert.main(('--certdir', dirn, '--signas', 'woot', 'newp@newp.newp'), outp=outp))
|
|
183
|
+
self.eq(0, await s_easycert.main(('--certdir', dirn, '--signas', 'woot', 'newp@newp.newp'), outp=outp))
|
|
182
184
|
|
|
183
185
|
outp.clear()
|
|
184
|
-
self.eq(0, s_easycert.main(('--certdir', dirn, '--signas', 'woot', '--code', 'testpipe'), outp=outp))
|
|
186
|
+
self.eq(0, await s_easycert.main(('--certdir', dirn, '--signas', 'woot', '--code', 'testpipe'), outp=outp))
|
|
185
187
|
|
|
186
188
|
outp.clear()
|
|
187
|
-
self.eq(0, s_easycert.main(('--certdir', dirn, '--signas', 'woot', '--server', 'newp.newp'), outp=outp))
|
|
189
|
+
self.eq(0, await s_easycert.main(('--certdir', dirn, '--signas', 'woot', '--server', 'newp.newp'), outp=outp))
|
|
188
190
|
|
|
189
191
|
outp.clear()
|
|
190
|
-
self.eq(0, s_easycert.main(('--certdir', dirn, '--revokeas', 'woot', 'newp@newp.newp'), outp=outp))
|
|
192
|
+
self.eq(0, await s_easycert.main(('--certdir', dirn, '--revokeas', 'woot', 'newp@newp.newp'), outp=outp))
|
|
191
193
|
|
|
192
194
|
outp.clear()
|
|
193
|
-
self.eq(0, s_easycert.main(('--certdir', dirn, '--revokeas', 'woot', '--server', 'newp.newp'), outp=outp))
|
|
195
|
+
self.eq(0, await s_easycert.main(('--certdir', dirn, '--revokeas', 'woot', '--server', 'newp.newp'), outp=outp))
|
|
194
196
|
|
|
195
197
|
outp.clear()
|
|
196
|
-
self.eq(0, s_easycert.main(('--certdir', dirn, '--revokeas', 'woot', '--ca', 'inner'), outp=outp))
|
|
198
|
+
self.eq(0, await s_easycert.main(('--certdir', dirn, '--revokeas', 'woot', '--ca', 'inner'), outp=outp))
|
|
197
199
|
|
|
198
200
|
outp.clear()
|
|
199
|
-
self.eq(0, s_easycert.main(('--certdir', dirn, '--revokeas', 'woot', '--code', 'testpipe'), outp=outp))
|
|
201
|
+
self.eq(0, await s_easycert.main(('--certdir', dirn, '--revokeas', 'woot', '--code', 'testpipe'), outp=outp))
|
|
200
202
|
|
|
201
203
|
outp.clear()
|
|
202
|
-
self.eq(1, s_easycert.main(('--certdir', dirn, '--revokeas', 'woot', 'noexist'), outp=outp))
|
|
204
|
+
self.eq(1, await s_easycert.main(('--certdir', dirn, '--revokeas', 'woot', 'noexist'), outp=outp))
|
|
203
205
|
outp.expect('Certificate not found: noexist')
|
|
204
206
|
|
|
205
207
|
outp.clear()
|
|
206
|
-
self.eq(0, s_easycert.main(('--certdir', dirn, '--ca', 'dude'), outp=outp))
|
|
208
|
+
self.eq(0, await s_easycert.main(('--certdir', dirn, '--ca', 'dude'), outp=outp))
|
|
207
209
|
|
|
208
210
|
outp.clear()
|
|
209
|
-
self.eq(0, s_easycert.main(('--certdir', dirn, '--signas', 'dude', 'giggle@dude.dude'), outp=outp))
|
|
211
|
+
self.eq(0, await s_easycert.main(('--certdir', dirn, '--signas', 'dude', 'giggle@dude.dude'), outp=outp))
|
|
210
212
|
|
|
211
213
|
outp.clear()
|
|
212
|
-
self.eq(1, s_easycert.main(('--certdir', dirn, '--revokeas', 'woot', 'giggle@dude.dude'), outp=outp))
|
|
214
|
+
self.eq(1, await s_easycert.main(('--certdir', dirn, '--revokeas', 'woot', 'giggle@dude.dude'), outp=outp))
|
|
213
215
|
outp.expect('Failed to validate that certificate was signed by woot')
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import synapse.common as s_common
|
|
2
2
|
|
|
3
3
|
import synapse.tests.utils as s_t_utils
|
|
4
|
-
import synapse.tools.guid as s_guid
|
|
4
|
+
import synapse.tools.utils.guid as s_guid
|
|
5
5
|
|
|
6
6
|
class TestGuid(s_t_utils.SynTest):
|
|
7
7
|
|
|
8
|
-
def test_tools_guid(self):
|
|
8
|
+
async def test_tools_guid(self):
|
|
9
9
|
argv = []
|
|
10
10
|
outp = self.getTestOutp()
|
|
11
|
-
s_guid.main(argv, outp=outp)
|
|
11
|
+
await s_guid.main(argv, outp=outp)
|
|
12
12
|
self.true(s_common.isguid(str(outp)))
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import os
|
|
2
2
|
|
|
3
|
-
import synapse.tools.json2mpk as s_json2mpk
|
|
3
|
+
import synapse.tools.utils.json2mpk as s_json2mpk
|
|
4
4
|
|
|
5
5
|
import synapse.tests.utils as s_t_utils
|
|
6
6
|
|
|
7
7
|
class Json2MpkTest(s_t_utils.SynTest):
|
|
8
8
|
|
|
9
|
-
def test_tools_json2mpk(self):
|
|
9
|
+
async def test_tools_json2mpk(self):
|
|
10
10
|
|
|
11
11
|
with self.getTestDir() as ndir:
|
|
12
12
|
|
|
@@ -25,7 +25,7 @@ class Json2MpkTest(s_t_utils.SynTest):
|
|
|
25
25
|
|
|
26
26
|
args = ['--rm', path, fake, html]
|
|
27
27
|
|
|
28
|
-
s_json2mpk.main(args, outp=outp)
|
|
28
|
+
await s_json2mpk.main(args, outp=outp)
|
|
29
29
|
|
|
30
30
|
with open(newp, 'rb') as fd:
|
|
31
31
|
self.eq(fd.read(), b'\x81\xa3foo\n\x81\xa3bar\x14')
|
|
@@ -2,7 +2,7 @@ import synapse.exc as s_exc
|
|
|
2
2
|
|
|
3
3
|
import synapse.common as s_common
|
|
4
4
|
|
|
5
|
-
import synapse.tools.rstorm as s_rstorm
|
|
5
|
+
import synapse.tools.utils.rstorm as s_rstorm
|
|
6
6
|
|
|
7
7
|
import synapse.tests.utils as s_test
|
|
8
8
|
import synapse.tests.test_lib_rstorm as s_test_rstorm
|
|
@@ -26,6 +26,11 @@ class RStormToolTest(s_test.SynTest):
|
|
|
26
26
|
|
|
27
27
|
self.eq(text, s_test_rstorm.rst_out)
|
|
28
28
|
|
|
29
|
+
outp = self.getTestOutp()
|
|
30
|
+
await s_rstorm.main((path,), outp=outp)
|
|
31
|
+
text = ''.join(outp.mesgs)
|
|
32
|
+
self.eq(text, s_test_rstorm.rst_out)
|
|
33
|
+
|
|
29
34
|
# debug output
|
|
30
35
|
path = s_common.genpath(dirn, 'test2.rst')
|
|
31
36
|
with s_common.genfile(path) as fd:
|
synapse/tests/utils.py
CHANGED
|
@@ -76,7 +76,7 @@ import synapse.lib.thishost as s_thishost
|
|
|
76
76
|
import synapse.lib.structlog as s_structlog
|
|
77
77
|
import synapse.lib.stormtypes as s_stormtypes
|
|
78
78
|
|
|
79
|
-
import synapse.tools.
|
|
79
|
+
import synapse.tools.storm.pkg.gen as s_genpkg
|
|
80
80
|
|
|
81
81
|
logger = logging.getLogger(__name__)
|
|
82
82
|
|
|
@@ -906,6 +906,8 @@ class HttpReflector(s_httpapi.Handler):
|
|
|
906
906
|
self.sendRestRetn(resp)
|
|
907
907
|
|
|
908
908
|
async def post(self):
|
|
909
|
+
self.set_header('Giant', 'x' * 64_000)
|
|
910
|
+
|
|
909
911
|
resp = {}
|
|
910
912
|
params = self._decode_params()
|
|
911
913
|
if params:
|
synapse/tools/apikey.py
CHANGED
|
@@ -1,90 +1,11 @@
|
|
|
1
|
-
import synapse.
|
|
2
|
-
import synapse.telepath as s_telepath
|
|
1
|
+
import synapse.common as s_common
|
|
3
2
|
|
|
4
3
|
import synapse.lib.cmd as s_cmd
|
|
5
|
-
import synapse.lib.time as s_time
|
|
6
|
-
import synapse.lib.output as s_output
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
Add, list, or delete user API keys from a Synapse service.
|
|
10
|
-
'''
|
|
5
|
+
from synapse.tools.service.apikey import main
|
|
11
6
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
name = info.get('name')
|
|
15
|
-
created = info.get('created')
|
|
16
|
-
updated = info.get('updated')
|
|
17
|
-
expires = info.get('expires')
|
|
18
|
-
|
|
19
|
-
outp.printf(f'Iden: {iden}')
|
|
20
|
-
if apikey:
|
|
21
|
-
outp.printf(f' API Key: {apikey}')
|
|
22
|
-
outp.printf(f' Name: {name}')
|
|
23
|
-
outp.printf(f' Created: {s_time.repr(created)}')
|
|
24
|
-
outp.printf(f' Updated: {s_time.repr(updated)}')
|
|
25
|
-
if expires:
|
|
26
|
-
outp.printf(f' Expires: {s_time.repr(expires)}')
|
|
27
|
-
|
|
28
|
-
outp.printf('')
|
|
29
|
-
|
|
30
|
-
async def main(argv, outp=s_output.stdout):
|
|
31
|
-
|
|
32
|
-
pars = s_cmd.Parser(prog='synapse.tools.apikey', outp=outp, description=descr)
|
|
33
|
-
pars.add_argument('--svcurl', default='cell:///vertex/storage', help='The telepath URL of the Synapse service.')
|
|
34
|
-
|
|
35
|
-
subpars = pars.add_subparsers(dest='action', required=True)
|
|
36
|
-
|
|
37
|
-
addp = subpars.add_parser('add', help='Add a user API key.')
|
|
38
|
-
addp.add_argument('-d', '--duration', type=int, help='The duration of the API key in seconds.')
|
|
39
|
-
addp.add_argument('-u', '--username', type=str, help='The username to add an API key to (restricted to admins).')
|
|
40
|
-
addp.add_argument('name', help='The name of the API key to add.')
|
|
41
|
-
|
|
42
|
-
listp = subpars.add_parser('list', help='List user API keys.')
|
|
43
|
-
listp.add_argument('-u', '--username', type=str, help='The username to list API keys for (restricted to admins).')
|
|
44
|
-
|
|
45
|
-
delp = subpars.add_parser('del', help='Delete a user API key.')
|
|
46
|
-
delp.add_argument('iden', help='The iden of the API key to delete.')
|
|
47
|
-
|
|
48
|
-
opts = pars.parse_args(argv)
|
|
49
|
-
|
|
50
|
-
async with s_telepath.withTeleEnv():
|
|
51
|
-
|
|
52
|
-
async with await s_telepath.openurl(opts.svcurl) as cell:
|
|
53
|
-
|
|
54
|
-
try:
|
|
55
|
-
useriden = None
|
|
56
|
-
if opts.action in ('add', 'list') and opts.username:
|
|
57
|
-
user = await cell.getUserInfo(opts.username)
|
|
58
|
-
useriden = user.get('iden')
|
|
59
|
-
|
|
60
|
-
if opts.action == 'add':
|
|
61
|
-
if (duration := opts.duration) is not None:
|
|
62
|
-
# Convert from seconds to milliseconds
|
|
63
|
-
duration *= 1000
|
|
64
|
-
|
|
65
|
-
apikey, info = await cell.addUserApiKey(opts.name, duration=duration, useriden=useriden)
|
|
66
|
-
outp.printf(f'Successfully added API key with name={opts.name}.')
|
|
67
|
-
printkey(outp, info, apikey)
|
|
68
|
-
|
|
69
|
-
elif opts.action == 'del':
|
|
70
|
-
await cell.delUserApiKey(opts.iden)
|
|
71
|
-
outp.printf(f'Successfully deleted API key with iden={opts.iden}.')
|
|
72
|
-
|
|
73
|
-
elif opts.action == 'list':
|
|
74
|
-
apikeys = await cell.listUserApiKeys(useriden=useriden)
|
|
75
|
-
if not apikeys:
|
|
76
|
-
outp.printf('No API keys found.')
|
|
77
|
-
return 0
|
|
78
|
-
|
|
79
|
-
for info in apikeys:
|
|
80
|
-
printkey(outp, info)
|
|
81
|
-
|
|
82
|
-
except s_exc.SynErr as exc:
|
|
83
|
-
mesg = exc.get('mesg')
|
|
84
|
-
outp.printf(f'ERROR: {exc.__class__.__name__}: {mesg}')
|
|
85
|
-
return 1
|
|
86
|
-
|
|
87
|
-
return 0
|
|
7
|
+
s_common.deprecated('synapse.tools.apikey is deprecated. Please use synapse.tools.service.apikey instead.',
|
|
8
|
+
curv='v2.225.0')
|
|
88
9
|
|
|
89
10
|
if __name__ == '__main__': # pragma: no cover
|
|
90
11
|
s_cmd.exitmain(main)
|