aboutsummaryrefslogtreecommitdiff
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
parent0c731e968b652de7e90312b744277b33788d6ddd (diff)
downloadmastodon.py-7331f7774ae10d927e086318338989de6bc37cad.tar.gz
Add admin domain block tests, change some things about the admin domain blocks
-rw-r--r--docs/index.rst5
-rw-r--r--mastodon/Mastodon.py61
-rw-r--r--tests/cassettes/test_admin_domain_blocks.yaml366
-rw-r--r--tests/test_admin.py14
4 files changed, 419 insertions, 27 deletions
diff --git a/docs/index.rst b/docs/index.rst
index bb6e5b1..95ae0aa 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -884,9 +884,10 @@ Admin account dicts
884 884
885Admin domain block dicts 885Admin domain block dicts
886~~~~~~~~~~~~~~~~~~~~~~~~ 886~~~~~~~~~~~~~~~~~~~~~~~~
887.. _domain dicts 887.. _admin domain block dict:
888 888
889.. code-block::python 889.. code-block::python
890
890 mastodon.domain_blocks(id=1) 891 mastodon.domain_blocks(id=1)
891 #Returns the following dictionary: 892 #Returns the following dictionary:
892 { 893 {
@@ -1466,7 +1467,7 @@ have admin: scopes attached with a lot of care, but be extra careful with those
1466.. automethod:: Mastodon.admin_trending_statuses 1467.. automethod:: Mastodon.admin_trending_statuses
1467.. automethod:: Mastodon.admin_trending_links 1468.. automethod:: Mastodon.admin_trending_links
1468.. automethod:: Mastodon.admin_domain_blocks 1469.. automethod:: Mastodon.admin_domain_blocks
1469.. automethod:: Mastodon.admin_domain_block 1470.. automethod:: Mastodon.admin_create_domain_block
1470.. automethod:: Mastodon.admin_update_domain_block 1471.. automethod:: Mastodon.admin_update_domain_block
1471.. automethod:: Mastodon.admin_delete_domain_block 1472.. automethod:: Mastodon.admin_delete_domain_block
1472 1473
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index c519a0d..82e058c 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -210,10 +210,20 @@ class Mastodon:
210 'admin:read': [ 210 'admin:read': [
211 'admin:read:accounts', 211 'admin:read:accounts',
212 'admin:read:reports', 212 'admin:read:reports',
213 'admin:read:domain_allows',
214 'admin:read:domain_blocks',
215 'admin:read:ip_blocks',
216 'admin:read:email_domain_blocks',
217 'admin:read:canonical_email_blocks',
213 ], 218 ],
214 'admin:write': [ 219 'admin:write': [
215 'admin:write:accounts', 220 'admin:write:accounts',
216 'admin:write:reports', 221 'admin:write:reports',
222 'admin:write:domain_allows',
223 'admin:write:domain_blocks',
224 'admin:write:ip_blocks',
225 'admin:write:email_domain_blocks',
226 'admin:write:canonical_email_blocks',
217 ], 227 ],
218 } 228 }
219 __VALID_SCOPES = ['read', 'write', 'follow', 'push', 'admin:read', 'admin:write'] + \ 229 __VALID_SCOPES = ['read', 'write', 'follow', 'push', 'admin:read', 'admin:write'] + \
@@ -253,6 +263,7 @@ class Mastodon:
253 __DICT_VERSION_REACTION = "3.1.0" 263 __DICT_VERSION_REACTION = "3.1.0"
254 __DICT_VERSION_ANNOUNCEMENT = bigger_version("3.1.0", __DICT_VERSION_REACTION) 264 __DICT_VERSION_ANNOUNCEMENT = bigger_version("3.1.0", __DICT_VERSION_REACTION)
255 __DICT_VERSION_STATUS_EDIT = "3.5.0" 265 __DICT_VERSION_STATUS_EDIT = "3.5.0"
266 __DICT_VERSION_ADMIN_DOMAIN_BLOCK = "4.0.0"
256 267
257 ### 268 ###
258 # Registering apps 269 # Registering apps
@@ -3363,26 +3374,26 @@ class Mastodon:
3363 params = self.__generate_params(locals()) 3374 params = self.__generate_params(locals())
3364 return self.__api_request('GET', '/api/v1/admin/trends/links', params) 3375 return self.__api_request('GET', '/api/v1/admin/trends/links', params)
3365 3376
3366 @api_version("4.0.0","4.0.0","4.0.0") 3377 @api_version("4.0.0", "4.0.0", __DICT_VERSION_ADMIN_DOMAIN_BLOCK)
3367 def admin_domain_blocks(self, id:str=None, limit:int=None): 3378 def admin_domain_blocks(self, id=None, limit:int=None):
3368 """ 3379 """
3369 Fetches a list of blocked domains. Requires scope `admin:read:domain_blocks`. 3380 Fetches a list of blocked domains. Requires scope `admin:read:domain_blocks`.
3370 3381
3371 Provide an `id` to fetch a specific domain block based on its database id. 3382 Provide an `id` to fetch a specific domain block based on its database id.
3372 3383
3373 Returns a list of `domain dicts`_, or 404 if a domain is queried for and not found. 3384 Returns a list of `admin domain block dicts`_, raises a `MastodonAPIError` if the specified block does not exist.
3374 """ 3385 """
3375 id = self.__unpack_id(id)
3376 if id is not None: 3386 if id is not None:
3387 id = self.__unpack_id(id)
3377 return self.__api_request('GET', '/api/v1/admin/domain_blocks/{0}'.format(id)) 3388 return self.__api_request('GET', '/api/v1/admin/domain_blocks/{0}'.format(id))
3378 else: 3389 else:
3379 params = self.__generate_params(locals(),['limit']) 3390 params = self.__generate_params(locals(),['limit'])
3380 return self.__api_request('GET', '/api/v1/admin/domain_blocks/', params) 3391 return self.__api_request('GET', '/api/v1/admin/domain_blocks/', params)
3381 3392
3382 @api_version("4.0.0","4.0.0","4.0.0") 3393 @api_version("4.0.0", "4.0.0", __DICT_VERSION_ADMIN_DOMAIN_BLOCK)
3383 def admin_domain_block(self, domain:str, severity:str=None, reject_media:bool=None, reject_reports:bool=None, private_comment:str=None, public_comment:str=None, obfuscate:bool=None): 3394 def admin_create_domain_block(self, domain:str, severity:str=None, reject_media:bool=None, reject_reports:bool=None, private_comment:str=None, public_comment:str=None, obfuscate:bool=None):
3384 """ 3395 """
3385 Perform a moderation action on a domain. 3396 Perform a moderation action on a domain. Requires scope `admin:write:domain_blocks`.
3386 3397
3387 Valid severities are: 3398 Valid severities are:
3388 * "silence" - hide all posts from federated timelines and do not show notifications to local users from the remote instance's users unless they are following the remote user. 3399 * "silence" - hide all posts from federated timelines and do not show notifications to local users from the remote instance's users unless they are following the remote user.
@@ -3395,20 +3406,19 @@ class Mastodon:
3395 `reject_reports` ignores all reports from the remote instance. 3406 `reject_reports` ignores all reports from the remote instance.
3396 `private_comment` sets a private admin comment for the domain. 3407 `private_comment` sets a private admin comment for the domain.
3397 `public_comment` sets a publicly available comment for this domain, which will be available to local users and may be available to everyone depending on your settings. 3408 `public_comment` sets a publicly available comment for this domain, which will be available to local users and may be available to everyone depending on your settings.
3398 `obfuscate` sensors some part of the domain name. Useful if the domain name contains unwanted words like slurs. 3409 `obfuscate` censors some part of the domain name. Useful if the domain name contains unwanted words like slurs.
3410
3411 Returns the new domain block as an `admin domain block dict`_.
3399 """ 3412 """
3400 if domain is None: 3413 if domain is None:
3401 raise AttributeError("Must provide a domain to block a domain") 3414 raise AttributeError("Must provide a domain to block a domain")
3402
3403 params = self.__generate_params(locals()) 3415 params = self.__generate_params(locals())
3416 return self.__api_request('POST', '/api/v1/admin/domain_blocks/', params)
3404 3417
3405 3418 @api_version("4.0.0", "4.0.0", __DICT_VERSION_ADMIN_DOMAIN_BLOCK)
3406 self.__api_request('POST', '/api/v1/admin/domain_blocks/', params) 3419 def admin_update_domain_block(self, id, severity:str=None, reject_media:bool=None, reject_reports:bool=None, private_comment:str=None, public_comment:str=None, obfuscate:bool=None):
3407
3408 @api_version("4.0.0","4.0.0","4.0.0")
3409 def admin_update_domain_block(self, id:str, severity:str=None, reject_media:bool=None, reject_reports:bool=None, private_comment:str=None, public_comment:str=None, obfuscate:bool=None):
3410 """ 3420 """
3411 Modify existing moderation action on a domain. 3421 Modify existing moderation action on a domain. Requires scope `admin:write:domain_blocks`.
3412 3422
3413 Valid severities are: 3423 Valid severities are:
3414 * "silence" - hide all posts from federated timelines and do not show notifications to local users from the remote instance's users unless they are following the remote user. 3424 * "silence" - hide all posts from federated timelines and do not show notifications to local users from the remote instance's users unless they are following the remote user.
@@ -3421,27 +3431,28 @@ class Mastodon:
3421 `reject_reports` ignores all reports from the remote instance. 3431 `reject_reports` ignores all reports from the remote instance.
3422 `private_comment` sets a private admin comment for the domain. 3432 `private_comment` sets a private admin comment for the domain.
3423 `public_comment` sets a publicly available comment for this domain, which will be available to local users and may be available to everyone depending on your settings. 3433 `public_comment` sets a publicly available comment for this domain, which will be available to local users and may be available to everyone depending on your settings.
3424 `obfuscate` sensors some part of the domain name. Useful if the domain name contains unwanted words like slurs. 3434 `obfuscate` censors some part of the domain name. Useful if the domain name contains unwanted words like slurs.
3435
3436 Returns the modified domain block as an `admin domain block dict`_, raises a `MastodonAPIError` if the specified block does not exist.
3425 """ 3437 """
3426 if id is None: 3438 if id is None:
3427 raise AttributeError("Must provide an id to modify the existing moderation actions on a given domain.") 3439 raise AttributeError("Must provide an id to modify the existing moderation actions on a given domain.")
3440 id = self.__unpack_id(id)
3441 params = self.__generate_params(locals(), ["id"])
3442 return self.__api_request('PUT', '/api/v1/admin/domain_blocks/{0}'.format(id), params)
3428 3443
3429 params = self.__generate_params(locals()) 3444 @api_version("4.0.0", "4.0.0", __DICT_VERSION_ADMIN_DOMAIN_BLOCK)
3430 3445 def admin_delete_domain_block(self, id=None):
3431 self.__api_request('PUT', '/api/v1/admin/domain_blocks/', params)
3432
3433 @api_version("4.0.0","4.0.0","4.0.0")
3434 def admin_delete_domain_blocks(self, id:str=None):
3435 """ 3446 """
3436 Removes moderation action against a given domain. Requires scope `admin:write:domain_blocks`. 3447 Removes moderation action against a given domain. Requires scope `admin:write:domain_blocks`.
3437 3448
3438 Provide an `id` to remove a specific domain block based on its database id. 3449 Provide an `id` to remove a specific domain block based on its database id.
3439 3450
3440 Returns 200 OK if successful. 3451 Raises a `MastodonAPIError` if the specified block does not exist.
3441 """ 3452 """
3442 id = self.__unpack_id(id)
3443 if id is not None: 3453 if id is not None:
3444 return self.__api_request('DELETE', '/api/v1/admin/domain_blocks/{0}'.format(id)) 3454 id = self.__unpack_id(id)
3455 self.__api_request('DELETE', '/api/v1/admin/domain_blocks/{0}'.format(id))
3445 else: 3456 else:
3446 raise AttributeError("You must provide an id of an existing domain block to remove it.") 3457 raise AttributeError("You must provide an id of an existing domain block to remove it.")
3447 3458
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)