aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorhalcy <halcy@ARARAGI-KUN>2022-11-26 01:00:44 +0200
committerhalcy <halcy@ARARAGI-KUN>2022-11-26 01:00:44 +0200
commit7331f7774ae10d927e086318338989de6bc37cad (patch)
tree6444e7070e1f8e7fa1abdaae771c76bde8896892 /tests
parent0c731e968b652de7e90312b744277b33788d6ddd (diff)
downloadmastodon.py-7331f7774ae10d927e086318338989de6bc37cad.tar.gz
Add admin domain block tests, change some things about the admin domain blocks
Diffstat (limited to 'tests')
-rw-r--r--tests/cassettes/test_admin_domain_blocks.yaml366
-rw-r--r--tests/test_admin.py14
2 files changed, 380 insertions, 0 deletions
diff --git a/tests/cassettes/test_admin_domain_blocks.yaml b/tests/cassettes/test_admin_domain_blocks.yaml
new file mode 100644
index 0000000..742a8b0
--- /dev/null
+++ b/tests/cassettes/test_admin_domain_blocks.yaml
@@ -0,0 +1,366 @@
1interactions:
2- request:
3 body: domain=https%3A%2F%2Fchitter.xyz%2F&severity=suspend&public_comment=sicko+behaviour
4 headers:
5 Accept:
6 - '*/*'
7 Accept-Encoding:
8 - gzip, deflate
9 Authorization:
10 - Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2
11 Connection:
12 - keep-alive
13 Content-Length:
14 - '83'
15 Content-Type:
16 - application/x-www-form-urlencoded
17 User-Agent:
18 - tests/v311
19 method: POST
20 uri: http://localhost:3000/api/v1/admin/domain_blocks/
21 response:
22 body:
23 string: '{"id":"8","domain":"https:chitter.xyz","created_at":"2022-11-25T22:59:08.008Z","severity":"suspend","reject_media":false,"reject_reports":false,"private_comment":null,"public_comment":"sicko
24 behaviour","obfuscate":false}'
25 headers:
26 Cache-Control:
27 - no-store
28 Content-Security-Policy:
29 - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src
30 ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000;
31 style-src ''self'' http://localhost:3000 ''nonce-Imbtm+KUEpnqJvOJ45mutA=='';
32 media-src ''self'' https: data: http://localhost:3000; frame-src ''self''
33 https:; manifest-src ''self'' http://localhost:3000; connect-src ''self''
34 data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000
35 ws://localhost:3035 http://localhost:3035; script-src ''self'' ''unsafe-inline''
36 ''unsafe-eval'' http://localhost:3000; child-src ''self'' blob: http://localhost:3000;
37 worker-src ''self'' blob: http://localhost:3000'
38 Content-Type:
39 - application/json; charset=utf-8
40 ETag:
41 - W/"1db810d68fb2778f381897c8eb7c01b1"
42 Referrer-Policy:
43 - strict-origin-when-cross-origin
44 Transfer-Encoding:
45 - chunked
46 Vary:
47 - Accept, Origin
48 X-Content-Type-Options:
49 - nosniff
50 X-Download-Options:
51 - noopen
52 X-Frame-Options:
53 - SAMEORIGIN
54 X-Permitted-Cross-Domain-Policies:
55 - none
56 X-Request-Id:
57 - 2411dfa5-38f0-4e57-942c-1cd2673fe831
58 X-Runtime:
59 - '0.022290'
60 X-XSS-Protection:
61 - 1; mode=block
62 status:
63 code: 200
64 message: OK
65- request:
66 body: null
67 headers:
68 Accept:
69 - '*/*'
70 Accept-Encoding:
71 - gzip, deflate
72 Authorization:
73 - Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2
74 Connection:
75 - keep-alive
76 User-Agent:
77 - tests/v311
78 method: GET
79 uri: http://localhost:3000/api/v1/admin/domain_blocks/
80 response:
81 body:
82 string: '[{"id":"8","domain":"https:chitter.xyz","created_at":"2022-11-25T22:59:08.008Z","severity":"suspend","reject_media":false,"reject_reports":false,"private_comment":null,"public_comment":"sicko
83 behaviour","obfuscate":false}]'
84 headers:
85 Cache-Control:
86 - no-store
87 Content-Security-Policy:
88 - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src
89 ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000;
90 style-src ''self'' http://localhost:3000 ''nonce-cmboU6G0U/fNuxkj3razsg=='';
91 media-src ''self'' https: data: http://localhost:3000; frame-src ''self''
92 https:; manifest-src ''self'' http://localhost:3000; connect-src ''self''
93 data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000
94 ws://localhost:3035 http://localhost:3035; script-src ''self'' ''unsafe-inline''
95 ''unsafe-eval'' http://localhost:3000; child-src ''self'' blob: http://localhost:3000;
96 worker-src ''self'' blob: http://localhost:3000'
97 Content-Type:
98 - application/json; charset=utf-8
99 ETag:
100 - W/"e807730146b189a5a31148fb29e433da"
101 Link:
102 - <http://localhost:3000/api/v1/admin/domain_blocks?min_id=8>; rel="prev"
103 Referrer-Policy:
104 - strict-origin-when-cross-origin
105 Transfer-Encoding:
106 - chunked
107 Vary:
108 - Accept, Origin
109 X-Content-Type-Options:
110 - nosniff
111 X-Download-Options:
112 - noopen
113 X-Frame-Options:
114 - SAMEORIGIN
115 X-Permitted-Cross-Domain-Policies:
116 - none
117 X-Request-Id:
118 - c5bb9784-47fc-4e9a-ab37-5bdcadfdccc2
119 X-Runtime:
120 - '0.010368'
121 X-XSS-Protection:
122 - 1; mode=block
123 status:
124 code: 200
125 message: OK
126- request:
127 body: null
128 headers:
129 Accept:
130 - '*/*'
131 Accept-Encoding:
132 - gzip, deflate
133 Authorization:
134 - Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2
135 Connection:
136 - keep-alive
137 User-Agent:
138 - tests/v311
139 method: GET
140 uri: http://localhost:3000/api/v1/admin/domain_blocks/8
141 response:
142 body:
143 string: '{"id":"8","domain":"https:chitter.xyz","created_at":"2022-11-25T22:59:08.008Z","severity":"suspend","reject_media":false,"reject_reports":false,"private_comment":null,"public_comment":"sicko
144 behaviour","obfuscate":false}'
145 headers:
146 Cache-Control:
147 - no-store
148 Content-Security-Policy:
149 - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src
150 ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000;
151 style-src ''self'' http://localhost:3000 ''nonce-y+xczE/ywMzzq9Ae5Shj3A=='';
152 media-src ''self'' https: data: http://localhost:3000; frame-src ''self''
153 https:; manifest-src ''self'' http://localhost:3000; connect-src ''self''
154 data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000
155 ws://localhost:3035 http://localhost:3035; script-src ''self'' ''unsafe-inline''
156 ''unsafe-eval'' http://localhost:3000; child-src ''self'' blob: http://localhost:3000;
157 worker-src ''self'' blob: http://localhost:3000'
158 Content-Type:
159 - application/json; charset=utf-8
160 ETag:
161 - W/"1db810d68fb2778f381897c8eb7c01b1"
162 Referrer-Policy:
163 - strict-origin-when-cross-origin
164 Transfer-Encoding:
165 - chunked
166 Vary:
167 - Accept, Origin
168 X-Content-Type-Options:
169 - nosniff
170 X-Download-Options:
171 - noopen
172 X-Frame-Options:
173 - SAMEORIGIN
174 X-Permitted-Cross-Domain-Policies:
175 - none
176 X-Request-Id:
177 - ea5739bc-7ebd-40c8-9692-db2f4bbdbde4
178 X-Runtime:
179 - '0.009239'
180 X-XSS-Protection:
181 - 1; mode=block
182 status:
183 code: 200
184 message: OK
185- request:
186 body: severity=silence&private_comment=jk+ilu+%3C3
187 headers:
188 Accept:
189 - '*/*'
190 Accept-Encoding:
191 - gzip, deflate
192 Authorization:
193 - Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2
194 Connection:
195 - keep-alive
196 Content-Length:
197 - '44'
198 Content-Type:
199 - application/x-www-form-urlencoded
200 User-Agent:
201 - tests/v311
202 method: PUT
203 uri: http://localhost:3000/api/v1/admin/domain_blocks/8
204 response:
205 body:
206 string: '{"id":"8","domain":"https:chitter.xyz","created_at":"2022-11-25T22:59:08.008Z","severity":"silence","reject_media":false,"reject_reports":false,"private_comment":"jk
207 ilu \u003c3","public_comment":"sicko behaviour","obfuscate":false}'
208 headers:
209 Cache-Control:
210 - no-store
211 Content-Security-Policy:
212 - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src
213 ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000;
214 style-src ''self'' http://localhost:3000 ''nonce-MH0zeyGASxwMnqSQO8XnVw=='';
215 media-src ''self'' https: data: http://localhost:3000; frame-src ''self''
216 https:; manifest-src ''self'' http://localhost:3000; connect-src ''self''
217 data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000
218 ws://localhost:3035 http://localhost:3035; script-src ''self'' ''unsafe-inline''
219 ''unsafe-eval'' http://localhost:3000; child-src ''self'' blob: http://localhost:3000;
220 worker-src ''self'' blob: http://localhost:3000'
221 Content-Type:
222 - application/json; charset=utf-8
223 ETag:
224 - W/"56e34924f74cdfe16875883a46f8959b"
225 Referrer-Policy:
226 - strict-origin-when-cross-origin
227 Transfer-Encoding:
228 - chunked
229 Vary:
230 - Accept, Origin
231 X-Content-Type-Options:
232 - nosniff
233 X-Download-Options:
234 - noopen
235 X-Frame-Options:
236 - SAMEORIGIN
237 X-Permitted-Cross-Domain-Policies:
238 - none
239 X-Request-Id:
240 - cb8d039e-d10c-403d-a1e7-6e43c3ac3f6d
241 X-Runtime:
242 - '0.019215'
243 X-XSS-Protection:
244 - 1; mode=block
245 status:
246 code: 200
247 message: OK
248- request:
249 body: null
250 headers:
251 Accept:
252 - '*/*'
253 Accept-Encoding:
254 - gzip, deflate
255 Authorization:
256 - Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2
257 Connection:
258 - keep-alive
259 Content-Length:
260 - '0'
261 User-Agent:
262 - tests/v311
263 method: DELETE
264 uri: http://localhost:3000/api/v1/admin/domain_blocks/8
265 response:
266 body:
267 string: '{}'
268 headers:
269 Cache-Control:
270 - no-store
271 Content-Security-Policy:
272 - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src
273 ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000;
274 style-src ''self'' http://localhost:3000 ''nonce-ICuLgest9NO+qhP7YVWYXw=='';
275 media-src ''self'' https: data: http://localhost:3000; frame-src ''self''
276 https:; manifest-src ''self'' http://localhost:3000; connect-src ''self''
277 data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000
278 ws://localhost:3035 http://localhost:3035; script-src ''self'' ''unsafe-inline''
279 ''unsafe-eval'' http://localhost:3000; child-src ''self'' blob: http://localhost:3000;
280 worker-src ''self'' blob: http://localhost:3000'
281 Content-Type:
282 - application/json; charset=utf-8
283 ETag:
284 - W/"44136fa355b3678a1146ad16f7e8649e"
285 Referrer-Policy:
286 - strict-origin-when-cross-origin
287 Transfer-Encoding:
288 - chunked
289 Vary:
290 - Accept, Origin
291 X-Content-Type-Options:
292 - nosniff
293 X-Download-Options:
294 - noopen
295 X-Frame-Options:
296 - SAMEORIGIN
297 X-Permitted-Cross-Domain-Policies:
298 - none
299 X-Request-Id:
300 - 299ea94d-2646-42c4-8bde-def40fd3858a
301 X-Runtime:
302 - '0.017753'
303 X-XSS-Protection:
304 - 1; mode=block
305 status:
306 code: 200
307 message: OK
308- request:
309 body: null
310 headers:
311 Accept:
312 - '*/*'
313 Accept-Encoding:
314 - gzip, deflate
315 Authorization:
316 - Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2
317 Connection:
318 - keep-alive
319 User-Agent:
320 - tests/v311
321 method: GET
322 uri: http://localhost:3000/api/v1/admin/domain_blocks/
323 response:
324 body:
325 string: '[]'
326 headers:
327 Cache-Control:
328 - no-store
329 Content-Security-Policy:
330 - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src
331 ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000;
332 style-src ''self'' http://localhost:3000 ''nonce-f4x2CzcoPSq9zb0LNrS1pA=='';
333 media-src ''self'' https: data: http://localhost:3000; frame-src ''self''
334 https:; manifest-src ''self'' http://localhost:3000; connect-src ''self''
335 data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000
336 ws://localhost:3035 http://localhost:3035; script-src ''self'' ''unsafe-inline''
337 ''unsafe-eval'' http://localhost:3000; child-src ''self'' blob: http://localhost:3000;
338 worker-src ''self'' blob: http://localhost:3000'
339 Content-Type:
340 - application/json; charset=utf-8
341 ETag:
342 - W/"4f53cda18c2baa0c0354bb5f9a3ecbe5"
343 Referrer-Policy:
344 - strict-origin-when-cross-origin
345 Transfer-Encoding:
346 - chunked
347 Vary:
348 - Accept, Origin
349 X-Content-Type-Options:
350 - nosniff
351 X-Download-Options:
352 - noopen
353 X-Frame-Options:
354 - SAMEORIGIN
355 X-Permitted-Cross-Domain-Policies:
356 - none
357 X-Request-Id:
358 - 1f76071e-2199-4c73-8744-e1d87cadc4d7
359 X-Runtime:
360 - '0.009019'
361 X-XSS-Protection:
362 - 1; mode=block
363 status:
364 code: 200
365 message: OK
366version: 1
diff --git a/tests/test_admin.py b/tests/test_admin.py
index 6a72ed7..887ed14 100644
--- a/tests/test_admin.py
+++ b/tests/test_admin.py
@@ -120,3 +120,17 @@ def test_admin_trends(api2):
120def test_admin_accountrequests(api2): 120def test_admin_accountrequests(api2):
121 pass 121 pass
122 122
123@pytest.mark.vcr()
124def test_admin_domain_blocks(api2):
125 block = api2.admin_create_domain_block(domain = "https://chitter.xyz/", public_comment="sicko behaviour", severity="suspend")
126 assert isinstance(api2.admin_domain_blocks(), list)
127 block2 = api2.admin_domain_blocks(block)
128 assert block.severity == "suspend"
129 assert block.public_comment == "sicko behaviour"
130 assert block.severity == block2.severity
131 block3 = api2.admin_update_domain_block(block, severity="silence", private_comment="jk ilu <3")
132 assert block3.severity == "silence"
133 assert block3.public_comment == "sicko behaviour"
134 assert block3.private_comment == "jk ilu <3"
135 api2.admin_delete_domain_block(block2)
136 assert not block3.id in map(lambda x: x.id, api2.admin_domain_blocks())
Powered by cgit v1.2.3 (git 2.41.0)