aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/cassettes/test_admin_accounts.yaml85
-rw-r--r--tests/cassettes/test_admin_moderation.yaml365
-rw-r--r--tests/setup.sql4
-rw-r--r--tests/test_admin.py46
4 files changed, 498 insertions, 2 deletions
diff --git a/tests/cassettes/test_admin_accounts.yaml b/tests/cassettes/test_admin_accounts.yaml
new file mode 100644
index 0000000..9cf0e25
--- /dev/null
+++ b/tests/cassettes/test_admin_accounts.yaml
@@ -0,0 +1,85 @@
1interactions:
2- request:
3 body: null
4 headers:
5 Accept: ['*/*']
6 Accept-Encoding: ['gzip, deflate']
7 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
8 Connection: [keep-alive]
9 User-Agent: [python-requests/2.18.4]
10 method: GET
11 uri: http://localhost:3000/api/v1/admin/accounts?active=True
12 response:
13 body: {string: '[{"id":"1234567890123456","username":"mastodonpy_test","domain":null,"created_at":"2019-06-22T22:15:59.914Z","email":"mastodonpy_test@localhost:3000","ip":null,"role":"user","confirmed":true,"suspended":false,"silenced":false,"disabled":false,"approved":true,"locale":"ja","invite_request":null,"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-06-22T22:15:59.914Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"emojis":[],"fields":[]}},{"id":"2","username":"coolguy42187","domain":null,"created_at":"2019-06-22T13:02:57.324Z","email":"email@localhost42187","ip":null,"role":"user","confirmed":false,"suspended":false,"silenced":false,"disabled":false,"approved":true,"locale":"en","invite_request":null,"created_by_application_id":"2","account":{"id":"2","username":"coolguy42187","acct":"coolguy42187","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T13:02:57.324Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@coolguy42187","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"emojis":[],"fields":[]}},{"id":"1","username":"admin","domain":null,"created_at":"2019-06-22T12:42:50.096Z","email":"admin@localhost","ip":"127.0.0.1","role":"admin","confirmed":true,"suspended":false,"silenced":false,"disabled":false,"approved":true,"locale":null,"invite_request":null,"account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T12:42:50.096Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@admin","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":1,"following_count":0,"statuses_count":7,"emojis":[],"fields":[]}}]'}
14 headers:
15 Cache-Control: ['no-cache, no-store']
16 Content-Type: [application/json; charset=utf-8]
17 Link: ['<http://localhost:3000/api/v1/admin/accounts?active=True&min_id=1234567890123456>;
18 rel="prev"']
19 Referrer-Policy: [strict-origin-when-cross-origin]
20 Transfer-Encoding: [chunked]
21 Vary: ['Accept-Encoding, Origin']
22 X-Content-Type-Options: [nosniff]
23 X-Download-Options: [noopen]
24 X-Frame-Options: [SAMEORIGIN]
25 X-Permitted-Cross-Domain-Policies: [none]
26 X-Request-Id: [058a0579-6d84-4c48-a16b-5bdae0b74ac6]
27 X-Runtime: ['0.074321']
28 X-XSS-Protection: [1; mode=block]
29 content-length: ['2526']
30 status: {code: 200, message: OK}
31- request:
32 body: null
33 headers:
34 Accept: ['*/*']
35 Accept-Encoding: ['gzip, deflate']
36 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
37 Connection: [keep-alive]
38 User-Agent: [python-requests/2.18.4]
39 method: GET
40 uri: http://localhost:3000/api/v1/accounts/verify_credentials
41 response:
42 body: {string: '{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T12:42:50.096Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@admin","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":1,"following_count":0,"statuses_count":7,"source":{"privacy":"public","sensitive":false,"language":null,"note":"","fields":[]},"emojis":[],"fields":[]}'}
43 headers:
44 Cache-Control: ['no-cache, no-store']
45 Content-Type: [application/json; charset=utf-8]
46 Referrer-Policy: [strict-origin-when-cross-origin]
47 Transfer-Encoding: [chunked]
48 Vary: ['Accept-Encoding, Origin']
49 X-Content-Type-Options: [nosniff]
50 X-Download-Options: [noopen]
51 X-Frame-Options: [SAMEORIGIN]
52 X-Permitted-Cross-Domain-Policies: [none]
53 X-Request-Id: [4f0a2ed4-b4ee-4d79-a0a2-24253670a629]
54 X-Runtime: ['0.023701']
55 X-XSS-Protection: [1; mode=block]
56 content-length: ['609']
57 status: {code: 200, message: OK}
58- request:
59 body: null
60 headers:
61 Accept: ['*/*']
62 Accept-Encoding: ['gzip, deflate']
63 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
64 Connection: [keep-alive]
65 User-Agent: [python-requests/2.18.4]
66 method: GET
67 uri: http://localhost:3000/api/v1/admin/accounts/1
68 response:
69 body: {string: '{"id":"1","username":"admin","domain":null,"created_at":"2019-06-22T12:42:50.096Z","email":"admin@localhost","ip":"127.0.0.1","role":"admin","confirmed":true,"suspended":false,"silenced":false,"disabled":false,"approved":true,"locale":null,"invite_request":null,"account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T12:42:50.096Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@admin","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":1,"following_count":0,"statuses_count":7,"emojis":[],"fields":[]}}'}
70 headers:
71 Cache-Control: ['no-cache, no-store']
72 Content-Type: [application/json; charset=utf-8]
73 Referrer-Policy: [strict-origin-when-cross-origin]
74 Transfer-Encoding: [chunked]
75 Vary: ['Accept-Encoding, Origin']
76 X-Content-Type-Options: [nosniff]
77 X-Download-Options: [noopen]
78 X-Frame-Options: [SAMEORIGIN]
79 X-Permitted-Cross-Domain-Policies: [none]
80 X-Request-Id: [76cc4636-f5f7-4149-941a-071443f4e0c0]
81 X-Runtime: ['0.023539']
82 X-XSS-Protection: [1; mode=block]
83 content-length: ['796']
84 status: {code: 200, message: OK}
85version: 1
diff --git a/tests/cassettes/test_admin_moderation.yaml b/tests/cassettes/test_admin_moderation.yaml
new file mode 100644
index 0000000..58cb23c
--- /dev/null
+++ b/tests/cassettes/test_admin_moderation.yaml
@@ -0,0 +1,365 @@
1interactions:
2- request:
3 body: null
4 headers:
5 Accept: ['*/*']
6 Accept-Encoding: ['gzip, deflate']
7 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
8 Connection: [keep-alive]
9 User-Agent: [python-requests/2.18.4]
10 method: GET
11 uri: http://localhost:3000/api/v1/accounts/verify_credentials
12 response:
13 body: {string: '{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-06-22T22:24:48.478Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"source":{"privacy":"public","sensitive":false,"language":null,"note":"","fields":[]},"emojis":[],"fields":[]}'}
14 headers:
15 Cache-Control: ['no-cache, no-store']
16 Content-Type: [application/json; charset=utf-8]
17 Referrer-Policy: [strict-origin-when-cross-origin]
18 Transfer-Encoding: [chunked]
19 Vary: ['Accept-Encoding, Origin']
20 X-Content-Type-Options: [nosniff]
21 X-Download-Options: [noopen]
22 X-Frame-Options: [SAMEORIGIN]
23 X-Permitted-Cross-Domain-Policies: [none]
24 X-Request-Id: [aa064dd7-6f49-4308-ab68-17130de204b1]
25 X-Runtime: ['0.033881']
26 X-XSS-Protection: [1; mode=block]
27 content-length: ['653']
28 status: {code: 200, message: OK}
29- request:
30 body: send_email_notification=1&type=disable
31 headers:
32 Accept: ['*/*']
33 Accept-Encoding: ['gzip, deflate']
34 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
35 Connection: [keep-alive]
36 Content-Length: ['38']
37 Content-Type: [application/x-www-form-urlencoded]
38 User-Agent: [python-requests/2.18.4]
39 method: POST
40 uri: http://localhost:3000/api/v1/admin/accounts/1234567890123456/action
41 response:
42 body: {string: '{}'}
43 headers:
44 Cache-Control: ['no-cache, no-store']
45 Content-Type: [application/json; charset=utf-8]
46 Referrer-Policy: [strict-origin-when-cross-origin]
47 Transfer-Encoding: [chunked]
48 Vary: ['Accept-Encoding, Origin']
49 X-Content-Type-Options: [nosniff]
50 X-Download-Options: [noopen]
51 X-Frame-Options: [SAMEORIGIN]
52 X-Permitted-Cross-Domain-Policies: [none]
53 X-Request-Id: [12eb6f99-0b79-47b9-a61b-2c01939b2eef]
54 X-Runtime: ['0.038479']
55 X-XSS-Protection: [1; mode=block]
56 content-length: ['2']
57 status: {code: 200, message: OK}
58- request:
59 body: null
60 headers:
61 Accept: ['*/*']
62 Accept-Encoding: ['gzip, deflate']
63 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
64 Connection: [keep-alive]
65 User-Agent: [python-requests/2.18.4]
66 method: GET
67 uri: http://localhost:3000/api/v1/admin/accounts/1234567890123456
68 response:
69 body: {string: '{"id":"1234567890123456","username":"mastodonpy_test","domain":null,"created_at":"2019-06-22T22:24:48.478Z","email":"mastodonpy_test@localhost:3000","ip":"127.0.0.1","role":"user","confirmed":true,"suspended":false,"silenced":false,"disabled":true,"approved":true,"locale":"ja","invite_request":null,"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-06-22T22:24:48.478Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"emojis":[],"fields":[]}}'}
70 headers:
71 Cache-Control: ['no-cache, no-store']
72 Content-Type: [application/json; charset=utf-8]
73 Referrer-Policy: [strict-origin-when-cross-origin]
74 Transfer-Encoding: [chunked]
75 Vary: ['Accept-Encoding, Origin']
76 X-Content-Type-Options: [nosniff]
77 X-Download-Options: [noopen]
78 X-Frame-Options: [SAMEORIGIN]
79 X-Permitted-Cross-Domain-Policies: [none]
80 X-Request-Id: [3cb9e402-a36b-4bb3-9e85-f8e55b58924c]
81 X-Runtime: ['0.052556']
82 X-XSS-Protection: [1; mode=block]
83 content-length: ['878']
84 status: {code: 200, message: OK}
85- request:
86 body: null
87 headers:
88 Accept: ['*/*']
89 Accept-Encoding: ['gzip, deflate']
90 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
91 Connection: [keep-alive]
92 Content-Length: ['0']
93 User-Agent: [python-requests/2.18.4]
94 method: POST
95 uri: http://localhost:3000/api/v1/admin/accounts/1234567890123456/enable
96 response:
97 body: {string: '{"id":"1234567890123456","username":"mastodonpy_test","domain":null,"created_at":"2019-06-22T22:24:48.478Z","email":"mastodonpy_test@localhost:3000","ip":"127.0.0.1","role":"user","confirmed":true,"suspended":false,"silenced":false,"disabled":false,"approved":true,"locale":"ja","invite_request":null,"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-06-22T22:24:48.478Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"emojis":[],"fields":[]}}'}
98 headers:
99 Cache-Control: ['no-cache, no-store']
100 Content-Type: [application/json; charset=utf-8]
101 Referrer-Policy: [strict-origin-when-cross-origin]
102 Transfer-Encoding: [chunked]
103 Vary: ['Accept-Encoding, Origin']
104 X-Content-Type-Options: [nosniff]
105 X-Download-Options: [noopen]
106 X-Frame-Options: [SAMEORIGIN]
107 X-Permitted-Cross-Domain-Policies: [none]
108 X-Request-Id: [fbc1c872-c78d-4737-9ffd-aab6ac569727]
109 X-Runtime: ['0.072257']
110 X-XSS-Protection: [1; mode=block]
111 content-length: ['879']
112 status: {code: 200, message: OK}
113- request:
114 body: send_email_notification=1&type=silence
115 headers:
116 Accept: ['*/*']
117 Accept-Encoding: ['gzip, deflate']
118 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
119 Connection: [keep-alive]
120 Content-Length: ['38']
121 Content-Type: [application/x-www-form-urlencoded]
122 User-Agent: [python-requests/2.18.4]
123 method: POST
124 uri: http://localhost:3000/api/v1/admin/accounts/1234567890123456/action
125 response:
126 body: {string: '{}'}
127 headers:
128 Cache-Control: ['no-cache, no-store']
129 Content-Type: [application/json; charset=utf-8]
130 Referrer-Policy: [strict-origin-when-cross-origin]
131 Transfer-Encoding: [chunked]
132 Vary: ['Accept-Encoding, Origin']
133 X-Content-Type-Options: [nosniff]
134 X-Download-Options: [noopen]
135 X-Frame-Options: [SAMEORIGIN]
136 X-Permitted-Cross-Domain-Policies: [none]
137 X-Request-Id: [5eb4cb13-617b-4c0f-a8b1-b77ca412e5e1]
138 X-Runtime: ['0.059976']
139 X-XSS-Protection: [1; mode=block]
140 content-length: ['2']
141 status: {code: 200, message: OK}
142- request:
143 body: null
144 headers:
145 Accept: ['*/*']
146 Accept-Encoding: ['gzip, deflate']
147 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
148 Connection: [keep-alive]
149 User-Agent: [python-requests/2.18.4]
150 method: GET
151 uri: http://localhost:3000/api/v1/admin/accounts/1234567890123456
152 response:
153 body: {string: '{"id":"1234567890123456","username":"mastodonpy_test","domain":null,"created_at":"2019-06-22T22:24:48.478Z","email":"mastodonpy_test@localhost:3000","ip":"127.0.0.1","role":"user","confirmed":true,"suspended":false,"silenced":true,"disabled":false,"approved":true,"locale":"ja","invite_request":null,"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-06-22T22:24:48.478Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"emojis":[],"fields":[]}}'}
154 headers:
155 Cache-Control: ['no-cache, no-store']
156 Content-Type: [application/json; charset=utf-8]
157 Referrer-Policy: [strict-origin-when-cross-origin]
158 Transfer-Encoding: [chunked]
159 Vary: ['Accept-Encoding, Origin']
160 X-Content-Type-Options: [nosniff]
161 X-Download-Options: [noopen]
162 X-Frame-Options: [SAMEORIGIN]
163 X-Permitted-Cross-Domain-Policies: [none]
164 X-Request-Id: [bd1d95a4-ca94-4757-ba95-d6e605c1a078]
165 X-Runtime: ['0.046756']
166 X-XSS-Protection: [1; mode=block]
167 content-length: ['878']
168 status: {code: 200, message: OK}
169- request:
170 body: null
171 headers:
172 Accept: ['*/*']
173 Accept-Encoding: ['gzip, deflate']
174 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
175 Connection: [keep-alive]
176 Content-Length: ['0']
177 User-Agent: [python-requests/2.18.4]
178 method: POST
179 uri: http://localhost:3000/api/v1/admin/accounts/1234567890123456/unsilence
180 response:
181 body: {string: '{"id":"1234567890123456","username":"mastodonpy_test","domain":null,"created_at":"2019-06-22T22:24:48.478Z","email":"mastodonpy_test@localhost:3000","ip":"127.0.0.1","role":"user","confirmed":true,"suspended":false,"silenced":false,"disabled":false,"approved":true,"locale":"ja","invite_request":null,"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-06-22T22:24:48.478Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"emojis":[],"fields":[]}}'}
182 headers:
183 Cache-Control: ['no-cache, no-store']
184 Content-Type: [application/json; charset=utf-8]
185 Referrer-Policy: [strict-origin-when-cross-origin]
186 Transfer-Encoding: [chunked]
187 Vary: ['Accept-Encoding, Origin']
188 X-Content-Type-Options: [nosniff]
189 X-Download-Options: [noopen]
190 X-Frame-Options: [SAMEORIGIN]
191 X-Permitted-Cross-Domain-Policies: [none]
192 X-Request-Id: [b9098809-599c-408a-8148-d9fd3362628b]
193 X-Runtime: ['0.082879']
194 X-XSS-Protection: [1; mode=block]
195 content-length: ['879']
196 status: {code: 200, message: OK}
197- request:
198 body: send_email_notification=1&type=suspend
199 headers:
200 Accept: ['*/*']
201 Accept-Encoding: ['gzip, deflate']
202 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
203 Connection: [keep-alive]
204 Content-Length: ['38']
205 Content-Type: [application/x-www-form-urlencoded]
206 User-Agent: [python-requests/2.18.4]
207 method: POST
208 uri: http://localhost:3000/api/v1/admin/accounts/1234567890123456/action
209 response:
210 body: {string: '{}'}
211 headers:
212 Cache-Control: ['no-cache, no-store']
213 Content-Type: [application/json; charset=utf-8]
214 Referrer-Policy: [strict-origin-when-cross-origin]
215 Transfer-Encoding: [chunked]
216 Vary: ['Accept-Encoding, Origin']
217 X-Content-Type-Options: [nosniff]
218 X-Download-Options: [noopen]
219 X-Frame-Options: [SAMEORIGIN]
220 X-Permitted-Cross-Domain-Policies: [none]
221 X-Request-Id: [82c35ecb-8a86-4110-b314-0b325960ec32]
222 X-Runtime: ['0.077761']
223 X-XSS-Protection: [1; mode=block]
224 content-length: ['2']
225 status: {code: 200, message: OK}
226- request:
227 body: null
228 headers:
229 Accept: ['*/*']
230 Accept-Encoding: ['gzip, deflate']
231 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
232 Connection: [keep-alive]
233 User-Agent: [python-requests/2.18.4]
234 method: GET
235 uri: http://localhost:3000/api/v1/admin/accounts/1234567890123456
236 response:
237 body: {string: '{"id":"1234567890123456","username":"mastodonpy_test","domain":null,"created_at":"2019-06-22T22:24:48.478Z","email":"mastodonpy_test@localhost:3000","ip":"127.0.0.1","role":"user","confirmed":true,"suspended":true,"silenced":false,"disabled":true,"approved":true,"locale":"ja","invite_request":null,"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-06-22T22:24:48.478Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"emojis":[],"fields":[]}}'}
238 headers:
239 Cache-Control: ['no-cache, no-store']
240 Content-Type: [application/json; charset=utf-8]
241 Referrer-Policy: [strict-origin-when-cross-origin]
242 Transfer-Encoding: [chunked]
243 Vary: ['Accept-Encoding, Origin']
244 X-Content-Type-Options: [nosniff]
245 X-Download-Options: [noopen]
246 X-Frame-Options: [SAMEORIGIN]
247 X-Permitted-Cross-Domain-Policies: [none]
248 X-Request-Id: [412e8231-2367-4988-88b6-f427b2017d52]
249 X-Runtime: ['0.055886']
250 X-XSS-Protection: [1; mode=block]
251 content-length: ['877']
252 status: {code: 200, message: OK}
253- request:
254 body: null
255 headers:
256 Accept: ['*/*']
257 Accept-Encoding: ['gzip, deflate']
258 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
259 Connection: [keep-alive]
260 Content-Length: ['0']
261 User-Agent: [python-requests/2.18.4]
262 method: POST
263 uri: http://localhost:3000/api/v1/admin/accounts/1234567890123456/unsuspend
264 response:
265 body: {string: '{"id":"1234567890123456","username":"mastodonpy_test","domain":null,"created_at":"2019-06-22T22:24:48.478Z","email":"mastodonpy_test@localhost:3000","ip":"127.0.0.1","role":"user","confirmed":true,"suspended":false,"silenced":false,"disabled":false,"approved":true,"locale":"ja","invite_request":null,"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-06-22T22:24:48.478Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"emojis":[],"fields":[]}}'}
266 headers:
267 Cache-Control: ['no-cache, no-store']
268 Content-Type: [application/json; charset=utf-8]
269 Referrer-Policy: [strict-origin-when-cross-origin]
270 Transfer-Encoding: [chunked]
271 Vary: ['Accept-Encoding, Origin']
272 X-Content-Type-Options: [nosniff]
273 X-Download-Options: [noopen]
274 X-Frame-Options: [SAMEORIGIN]
275 X-Permitted-Cross-Domain-Policies: [none]
276 X-Request-Id: [a82b647c-4f22-4037-9a85-df9dc29554cf]
277 X-Runtime: ['0.107695']
278 X-XSS-Protection: [1; mode=block]
279 content-length: ['879']
280 status: {code: 200, message: OK}
281- request:
282 body: null
283 headers:
284 Accept: ['*/*']
285 Accept-Encoding: ['gzip, deflate']
286 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
287 Connection: [keep-alive]
288 Content-Length: ['0']
289 User-Agent: [python-requests/2.18.4]
290 method: POST
291 uri: http://localhost:3000/api/v1/admin/accounts/1234567890123456/unsuspend
292 response:
293 body: {string: '{"id":"1234567890123456","username":"mastodonpy_test","domain":null,"created_at":"2019-06-22T22:24:48.478Z","email":"mastodonpy_test@localhost:3000","ip":"127.0.0.1","role":"user","confirmed":true,"suspended":false,"silenced":false,"disabled":false,"approved":true,"locale":"ja","invite_request":null,"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-06-22T22:24:48.478Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"emojis":[],"fields":[]}}'}
294 headers:
295 Cache-Control: ['no-cache, no-store']
296 Content-Type: [application/json; charset=utf-8]
297 Referrer-Policy: [strict-origin-when-cross-origin]
298 Transfer-Encoding: [chunked]
299 Vary: ['Accept-Encoding, Origin']
300 X-Content-Type-Options: [nosniff]
301 X-Download-Options: [noopen]
302 X-Frame-Options: [SAMEORIGIN]
303 X-Permitted-Cross-Domain-Policies: [none]
304 X-Request-Id: [56c54dd1-089e-4c5c-ab51-93d4c6eb1469]
305 X-Runtime: ['0.086749']
306 X-XSS-Protection: [1; mode=block]
307 content-length: ['879']
308 status: {code: 200, message: OK}
309- request:
310 body: null
311 headers:
312 Accept: ['*/*']
313 Accept-Encoding: ['gzip, deflate']
314 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
315 Connection: [keep-alive]
316 Content-Length: ['0']
317 User-Agent: [python-requests/2.18.4]
318 method: POST
319 uri: http://localhost:3000/api/v1/admin/accounts/1234567890123456/enable
320 response:
321 body: {string: '{"id":"1234567890123456","username":"mastodonpy_test","domain":null,"created_at":"2019-06-22T22:24:48.478Z","email":"mastodonpy_test@localhost:3000","ip":"127.0.0.1","role":"user","confirmed":true,"suspended":true,"silenced":false,"disabled":false,"approved":true,"locale":"ja","invite_request":null,"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T22:24:48.478Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"emojis":[],"fields":[]}}'}
322 headers:
323 Cache-Control: ['no-cache, no-store']
324 Content-Type: [application/json; charset=utf-8]
325 Referrer-Policy: [strict-origin-when-cross-origin]
326 Transfer-Encoding: [chunked]
327 Vary: ['Accept-Encoding, Origin']
328 X-Content-Type-Options: [nosniff]
329 X-Download-Options: [noopen]
330 X-Frame-Options: [SAMEORIGIN]
331 X-Permitted-Cross-Domain-Policies: [none]
332 X-Request-Id: [c9907143-2c1e-4c8f-8d5e-ba064be9d87b]
333 X-Runtime: ['0.164157']
334 X-XSS-Protection: [1; mode=block]
335 content-length: ['879']
336 status: {code: 200, message: OK}
337- request:
338 body: null
339 headers:
340 Accept: ['*/*']
341 Accept-Encoding: ['gzip, deflate']
342 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
343 Connection: [keep-alive]
344 Content-Length: ['0']
345 User-Agent: [python-requests/2.18.4]
346 method: POST
347 uri: http://localhost:3000/api/v1/admin/accounts/1234567890123456/unsilence
348 response:
349 body: {string: '{"id":"1234567890123456","username":"mastodonpy_test","domain":null,"created_at":"2019-06-22T22:24:48.478Z","email":"mastodonpy_test@localhost:3000","ip":"127.0.0.1","role":"user","confirmed":true,"suspended":true,"silenced":false,"disabled":false,"approved":true,"locale":"ja","invite_request":null,"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T22:24:48.478Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"emojis":[],"fields":[]}}'}
350 headers:
351 Cache-Control: ['no-cache, no-store']
352 Content-Type: [application/json; charset=utf-8]
353 Referrer-Policy: [strict-origin-when-cross-origin]
354 Transfer-Encoding: [chunked]
355 Vary: ['Accept-Encoding, Origin']
356 X-Content-Type-Options: [nosniff]
357 X-Download-Options: [noopen]
358 X-Frame-Options: [SAMEORIGIN]
359 X-Permitted-Cross-Domain-Policies: [none]
360 X-Request-Id: [31a3caa7-07d5-48a5-bc5d-138c90ac0413]
361 X-Runtime: ['0.211513']
362 X-XSS-Protection: [1; mode=block]
363 content-length: ['879']
364 status: {code: 200, message: OK}
365version: 1
diff --git a/tests/setup.sql b/tests/setup.sql
index 171f4da..591f4d0 100644
--- a/tests/setup.sql
+++ b/tests/setup.sql
@@ -71,14 +71,14 @@ INSERT INTO oauth_access_tokens (
71) VALUES ( 71) VALUES (
72 1234567890123456, 72 1234567890123456,
73 '__MASTODON_PY_TEST_ACCESS_TOKEN', 73 '__MASTODON_PY_TEST_ACCESS_TOKEN',
74 'read write follow push admin:read admin:write', 74 'read write follow push',
75 1234567890123456, 75 1234567890123456,
76 1234567890123456, 76 1234567890123456,
77 now() 77 now()
78), ( 78), (
79 6543210987654321, 79 6543210987654321,
80 '__MASTODON_PY_TEST_ACCESS_TOKEN_2', 80 '__MASTODON_PY_TEST_ACCESS_TOKEN_2',
81 'read write follow push', 81 'read write follow push admin:read admin:write',
82 1234567890123456, 82 1234567890123456,
83 1, 83 1,
84 now() 84 now()
diff --git a/tests/test_admin.py b/tests/test_admin.py
new file mode 100644
index 0000000..57e9fb2
--- /dev/null
+++ b/tests/test_admin.py
@@ -0,0 +1,46 @@
1import pytest
2
3@pytest.mark.vcr()
4def test_admin_accounts(api2):
5 accounts = api2.admin_accounts()
6
7 assert accounts
8 assert len(accounts) > 0
9
10 account_self = api2.account_verify_credentials()
11 account_admin = api2.admin_account(account_self)
12
13 assert(account_admin)
14 assert(account_admin.id == account_self.id)
15
16@pytest.mark.vcr()
17def test_admin_moderation(api, api2):
18 account_initial = api.account_verify_credentials()
19 account = account_initial
20
21 try:
22 api2.admin_account_moderate(account, "disable")
23 account = api2.admin_account(account_initial)
24 assert(account.disabled)
25
26 account = api2.admin_account_enable(account)
27 assert(not account.disabled)
28
29 api2.admin_account_moderate(account, "silence")
30 account = api2.admin_account(account_initial)
31 assert(account.silenced)
32
33 account = api2.admin_account_unsilence(account)
34 assert(not account.silenced)
35
36 api2.admin_account_moderate(account, "suspend")
37 account = api2.admin_account(account_initial)
38 assert(account.suspended)
39
40 account = api2.admin_account_unsuspend(account)
41 assert(not account.suspended)
42 finally:
43 api2.admin_account_unsuspend(account)
44 api2.admin_account_enable(account)
45 api2.admin_account_unsilence(account)
46
Powered by cgit v1.2.3 (git 2.41.0)