Debian Codegraph @

ansible_collections/community/general/tests/unit/plugins/modules/gitlab.py

raw
1 # Copyright (c) 2019, Guillaume Martinez ([email protected])
2 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
3 # SPDX-License-Identifier: GPL-3.0-or-later
4
5 from __future__ import annotations
6
7 import json
8 import unittest
9 from typing import Any
10 from unittest.mock import Mock
11
12 import gitlab
13 from httmock import (
14 response, # noqa
15 urlmatch, # noqa
16 )
17
18
19 class FakeAnsibleModule:
20 def __init__(self, module_params=None):
21 self.check_mode = False
22 self.params = module_params if module_params else {}
23 self.warn = Mock()
24
25 def fail_json(self, **args):
26 pass
27
28 def exit_json(self, **args):
29 pass
30
31
32 class GitlabModuleTestCase(unittest.TestCase):
33 def setUp(self):
34 self.mock_module = FakeAnsibleModule()
35
36 self.gitlab_instance = gitlab.Gitlab("http://localhost", private_token="private_token", api_version=4)
37
38
39 def python_gitlab_module_version():
40 return gitlab.__version__
41
42
43 def python_gitlab_version_match_requirement():
44 return "2.3.0"
45
46
47 deleted_user_key_ids: list[str] = []
48 created_user_keys: list[dict[str, Any]] = []
49
50
51 """
52 USER API
53 """
54
55
56 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/users", method="get")
57 def resp_find_user(url, request):
58 headers = {"content-type": "application/json"}
59 content = (
60 '[{"id": 1, "username": "john_smith", "name": "John Smith", "state": "active",'
61 '"avatar_url": "http://localhost:3000/uploads/user/avatar/1/cd8.jpeg",'
62 '"web_url": "http://localhost:3000/john_smith"}, {"id": 2,'
63 '"username": "jack_smith", "name": "Jack Smith", "state": "blocked",'
64 '"avatar_url": "http://gravatar.com/../e32131cd8.jpeg",'
65 '"web_url": "http://localhost:3000/jack_smith"}]'
66 )
67 content = content.encode("utf-8")
68 return response(200, content, headers, None, 5, request)
69
70
71 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/users", method="post")
72 def resp_create_user(url, request):
73 headers = {"content-type": "application/json"}
74 content = (
75 '{"id": 1, "username": "john_smith", "name": "John Smith", "state": "active",'
76 '"avatar_url": "http://localhost:3000/uploads/user/avatar/1/cd8.jpeg",'
77 '"web_url": "http://localhost:3000/john_smith","created_at": "2012-05-23T08:00:58Z",'
78 '"bio": null, "location": null, "public_email": "[email protected]", "skype": "",'
79 '"linkedin": "", "twitter": "", "website_url": "", "organization": ""}'
80 )
81 content = content.encode("utf-8")
82 return response(201, content, headers, None, 5, request)
83
84
85 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/users/1", method="get")
86 def resp_get_user(url, request):
87 headers = {"content-type": "application/json"}
88 content = (
89 '{"id": 1, "username": "john_smith", "name": "John Smith",'
90 '"state": "active",'
91 '"avatar_url": "http://localhost:3000/uploads/user/avatar/1/cd8.jpeg",'
92 '"web_url": "http://localhost:3000/john_smith",'
93 '"created_at": "2012-05-23T08:00:58Z", "bio": null, "location": null,'
94 '"public_email": "[email protected]", "skype": "", "linkedin": "",'
95 '"twitter": "", "website_url": "", "organization": "", "is_admin": false}'
96 )
97 content = content.encode("utf-8")
98 return response(200, content, headers, None, 5, request)
99
100
101 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/users/1", method="get")
102 def resp_get_missing_user(url, request):
103 headers = {"content-type": "application/json"}
104 content = "{}"
105 content = content.encode("utf-8")
106 return response(404, content, headers, None, 5, request)
107
108
109 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/users/1", method="delete")
110 def resp_delete_user(url, request):
111 headers = {"content-type": "application/json"}
112 content = "{}"
113 content = content.encode("utf-8")
114 return response(204, content, headers, None, 5, request)
115
116
117 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/users/1", method="delete")
118 def resp_delete_missing_user(url, request):
119 headers = {"content-type": "application/json"}
120 content = "{}"
121 content = content.encode("utf-8")
122 return response(404, content, headers, None, 5, request)
123
124
125 """
126 USER SSHKEY API
127 """
128
129
130 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/users/1/keys", method="get")
131 def resp_get_user_keys(url, request):
132 headers = {"content-type": "application/json"}
133 content = (
134 '[{"id": 1, "title": "Public key",'
135 '"key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596'
136 "k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQa"
137 'SeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=",'
138 '"created_at": "2014-08-01T14:47:39.080Z"},{"id": 3,'
139 '"title": "Another Public key",'
140 '"key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596'
141 "k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaS"
142 'eP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=",'
143 '"created_at": "2014-08-01T14:47:39.080Z"}]'
144 )
145 content = content.encode("utf-8")
146 return response(200, content, headers, None, 5, request)
147
148
149 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/users/1/keys", method="post")
150 def resp_create_user_keys(url, request):
151 if request.body:
152 created_user_keys.append(json.loads(request.body))
153 headers = {"content-type": "application/json"}
154 content = (
155 '{"id": 1, "title": "Private key",'
156 '"key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDA1YotVDm2mAyk2tPt4E7AHm01sS6JZmcUdRuSuA5z'
157 "szUJzYPPUSRAX3BCgTqLqYx//UuVncK7YqLVSbbwjKR2Ez5lISgCnVfLVEXzwhv+xawxKWmI7hJ5S0tOv6MJ+Ixy"
158 "Ta4xcKwJTwB86z22n9fVOQeJTR2dSOH1WJrf0PvRk+KVNY2jTiGHTi9AIjLnyD/jWRpOgtdfkLRc8EzAWrWlgNmH"
159 "2WOKBw6za0az6XoG75obUdFVdW3qcD0xc809OHLi7FDf+E7U4wiZJCFuUizMeXyuK/SkaE1aee4Qp5R4dxTR4TP9"
160 'M1XAYkf+kF0W9srZ+mhF069XD/zhUPJsvwEF",'
161 '"created_at": "2014-08-01T14:47:39.080Z"}'
162 )
163 content = content.encode("utf-8")
164 return response(201, content, headers, None, 5, request)
165
166
167 @urlmatch(scheme="http", netloc="localhost", path=r"/api/v4/users/1/keys/[0-9]+", method="delete")
168 def resp_delete_user_key(url, request):
169 deleted_user_key_ids.append(url.path.rsplit("/", 1)[1])
170 headers = {"content-type": "application/json"}
171 content = "{}"
172 content = content.encode("utf-8")
173 return response(204, content, headers, None, 5, request)
174
175
176 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/users/1/keys", method="get")
177 def resp_get_user_duplicate_keys(url, request):
178 headers = {"content-type": "application/json"}
179 content = (
180 '[{"id": 1, "title": "Public key",'
181 '"key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDA1YotVDm2mAyk2tPt4E7AHm01sS6JZmcU'
182 "dRuSuA5zszUJzYPPUSRAX3BCgTqLqYx//UuVncK7YqLVSbbwjKR2Ez5lISgCnVfLVEXzwhv+"
183 "xawxKWmI7hJ5S0tOv6MJ+IxyTa4xcKwJTwB86z22n9fVOQeJTR2dSOH1WJrf0PvRk+KVNY2j"
184 "TiGHTi9AIjLnyD/jWRpOgtdfkLRc8EzAWrWlgNmH2WOKBw6za0az6XoG75obUdFVdW3qcD0x"
185 'c809OHLi7FDf+E7U4wiZJCFuUizMeXyuK/SkaE1aee4Qp5R4dxTR4TP9M1XAYkf+kF0W9srZ+mhF069XD/zhUPJsvwEF",'
186 '"created_at": "2014-08-01T14:47:39.080Z"},'
187 '{"id": 3, "title": "Public key",'
188 '"key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596'
189 "k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQa"
190 'SeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=",'
191 '"created_at": "2014-08-01T14:47:39.080Z"}]'
192 )
193 content = content.encode("utf-8")
194 return response(200, content, headers, None, 5, request)
195
196
197 """
198 GROUP API
199 """
200
201
202 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/groups", method="get")
203 def resp_find_group(url, request):
204 headers = {"content-type": "application/json"}
205 content = (
206 '[{"id": 1, "name": "Foobar Group", "path": "foo-bar",'
207 '"description": "An interesting group", "visibility": "public",'
208 '"lfs_enabled": true, "avatar_url": "http://localhost:3000/uploads/group/avatar/1/foo.jpg",'
209 '"web_url": "http://localhost:3000/groups/foo-bar", "request_access_enabled": false,'
210 '"full_name": "Foobar Group", "full_path": "foo-bar",'
211 '"file_template_project_id": 1, "parent_id": null, "projects": []}, {"id": 2, "name": "BarFoo Group", "path": "bar-foor",'
212 '"description": "An interesting group", "visibility": "public",'
213 '"lfs_enabled": true, "avatar_url": "http://localhost:3000/uploads/group/avatar/2/bar.jpg",'
214 '"web_url": "http://localhost:3000/groups/bar-foo", "request_access_enabled": false,'
215 '"full_name": "BarFoo Group", "full_path": "bar-foo",'
216 '"file_template_project_id": 1, "parent_id": null, "projects": []}]'
217 )
218 content = content.encode("utf-8")
219 return response(200, content, headers, None, 5, request)
220
221
222 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/groups/1", method="get")
223 def resp_get_group(url, request):
224 headers = {"content-type": "application/json"}
225 content = (
226 '{"id": 1, "name": "Foobar Group", "path": "foo-bar",'
227 '"description": "An interesting group", "visibility": "public",'
228 '"lfs_enabled": true, "avatar_url": "http://localhost:3000/uploads/group/avatar/1/foo.jpg",'
229 '"web_url": "http://localhost:3000/groups/foo-bar", "request_access_enabled": false,'
230 '"full_name": "Foobar Group", "full_path": "foo-bar",'
231 '"project_creation_level": "maintainer", "subgroup_creation_level": "maintainer",'
232 '"require_two_factor_authentication": true,'
233 '"file_template_project_id": 1, "parent_id": null, "projects": [{"id": 1,"description": null, "default_branch": "master",'
234 '"ssh_url_to_repo": "[email protected]:diaspora/diaspora-client.git",'
235 '"http_url_to_repo": "http://example.com/diaspora/diaspora-client.git",'
236 '"web_url": "http://example.com/diaspora/diaspora-client",'
237 '"readme_url": "http://example.com/diaspora/diaspora-client/blob/master/README.md",'
238 '"tag_list": ["example","disapora client"],"name": "Diaspora Client",'
239 '"name_with_namespace": "Diaspora / Diaspora Client","path": "diaspora-client",'
240 '"path_with_namespace": "diaspora/diaspora-client","created_at": "2013-09-30T13:46:02Z",'
241 '"last_activity_at": "2013-09-30T13:46:02Z","forks_count": 0,'
242 '"avatar_url": "http://example.com/uploads/project/avatar/4/uploads/avatar.png",'
243 '"star_count": 0}]}'
244 )
245 content = content.encode("utf-8")
246 return response(200, content, headers, None, 5, request)
247
248
249 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/groups/foo-bar", method="get")
250 def resp_get_group_by_name(url, request):
251 headers = {"content-type": "application/json"}
252 content = (
253 '{"id": 1, "name": "Foobar Group", "path": "foo-bar",'
254 '"description": "An interesting group", "visibility": "public",'
255 '"lfs_enabled": true, "avatar_url": "http://localhost:3000/uploads/group/avatar/1/foo.jpg",'
256 '"web_url": "http://localhost:3000/groups/foo-bar", "request_access_enabled": false,'
257 '"full_name": "Foobar Group", "full_path": "foo-bar",'
258 '"project_creation_level": "maintainer", "subgroup_creation_level": "maintainer",'
259 '"require_two_factor_authentication": true,'
260 '"file_template_project_id": 1, "parent_id": null, "projects": [{"id": 1,"description": null, "default_branch": "master",'
261 '"ssh_url_to_repo": "[email protected]:diaspora/diaspora-client.git",'
262 '"http_url_to_repo": "http://example.com/diaspora/diaspora-client.git",'
263 '"web_url": "http://example.com/diaspora/diaspora-client",'
264 '"readme_url": "http://example.com/diaspora/diaspora-client/blob/master/README.md",'
265 '"tag_list": ["example","disapora client"],"name": "Diaspora Client",'
266 '"name_with_namespace": "Diaspora / Diaspora Client","path": "diaspora-client",'
267 '"path_with_namespace": "diaspora/diaspora-client","created_at": "2013-09-30T13:46:02Z",'
268 '"last_activity_at": "2013-09-30T13:46:02Z","forks_count": 0,'
269 '"avatar_url": "http://example.com/uploads/project/avatar/4/uploads/avatar.png",'
270 '"star_count": 0}]}'
271 )
272 content = content.encode("utf-8")
273 return response(200, content, headers, None, 5, request)
274
275
276 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/groups/1", method="get")
277 def resp_get_missing_group(url, request):
278 headers = {"content-type": "application/json"}
279 content = "{}"
280 content = content.encode("utf-8")
281 return response(404, content, headers, None, 5, request)
282
283
284 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/groups", method="post")
285 def resp_create_group(url, request):
286 headers = {"content-type": "application/json"}
287 content = (
288 '{"id": 1, "name": "Foobar Group", "path": "foo-bar",'
289 '"description": "An interesting group", "visibility": "public",'
290 '"lfs_enabled": true, "avatar_url": "http://localhost:3000/uploads/group/avatar/1/foo.jpg",'
291 '"web_url": "http://localhost:3000/groups/foo-bar", "request_access_enabled": false,'
292 '"full_name": "Foobar Group", "full_path": "foo-bar",'
293 '"file_template_project_id": 1, "parent_id": null,'
294 '"project_creation_level": "developer", "subgroup_creation_level": "maintainer",'
295 '"require_two_factor_authentication": true}'
296 )
297 content = content.encode("utf-8")
298 return response(200, content, headers, None, 5, request)
299
300
301 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/groups", method="post")
302 def resp_create_subgroup(url, request):
303 headers = {"content-type": "application/json"}
304 content = (
305 '{"id": 2, "name": "BarFoo Group", "path": "bar-foor",'
306 '"description": "An interesting group", "visibility": "public",'
307 '"lfs_enabled": true, "avatar_url": "http://localhost:3000/uploads/group/avatar/2/bar.jpg",'
308 '"web_url": "http://localhost:3000/groups/foo-bar/bar-foo", "request_access_enabled": false,'
309 '"full_name": "BarFoo Group", "full_path": "foo-bar/bar-foo",'
310 '"file_template_project_id": 1, "parent_id": 1,'
311 '"project_creation_level": "noone",'
312 '"require_two_factor_authentication": true}'
313 )
314 content = content.encode("utf-8")
315 return response(200, content, headers, None, 5, request)
316
317
318 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/users/1", method="delete")
319 def resp_delete_group(url, request):
320 headers = {"content-type": "application/json"}
321 content = "{}"
322 content = content.encode("utf-8")
323 return response(204, content, headers, None, 5, request)
324
325
326 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/groups/1/access_tokens", method="get")
327 def resp_list_group_access_tokens(url, request):
328 headers = {"content-type": "application/json"}
329 content = (
330 '[{"id":689,"name":"test-token","revoked":true,"created_at":"2025-06-02T09:18:01.484Z",'
331 '"description":null,"scopes":["read_repository","write_repository"],"user_id":1779,'
332 '"last_used_at":null,"active":false,"expires_at":"2025-07-02","access_level":40,'
333 '"resource_type":"group","resource_id":1730},'
334 '{"id":690,"name":"test-token","revoked":true,"created_at":"2025-06-02T09:36:30.650Z",'
335 '"description":null,"scopes":["read_repository","write_repository"],"user_id":1780,'
336 '"last_used_at":null,"active":false,"expires_at":"2025-07-02","access_level":40,'
337 '"resource_type":"group","resource_id":1730},'
338 '{"id":691,"name":"test-token","revoked":false,"created_at":"2025-06-02T09:39:18.252Z",'
339 '"description":null,"scopes":["read_repository","write_repository"],"user_id":1781,'
340 '"last_used_at":null,"active":false,"expires_at":"2025-07-02","access_level":40,'
341 '"resource_type":"group","resource_id":1730},'
342 '{"id":695,"name":"test-token-no-revoked","created_at":"2025-06-02T09:39:18.252Z",'
343 '"description":null,"scopes":["read_repository","write_repository"],"user_id":1781,'
344 '"last_used_at":null,"active":false,"expires_at":"2025-07-02","access_level":40,'
345 '"resource_type":"group","resource_id":1730},'
346 '{"id":692,"name":"test-token-two","revoked":true,"created_at":"2025-06-02T09:41:18.442Z",'
347 '"description":null,"scopes":["read_repository","write_repository"],"user_id":1782,'
348 '"last_used_at":null,"active":false,"expires_at":"2025-07-02","access_level":40,'
349 '"resource_type":"group","resource_id":1730},'
350 '{"id":693,"name":"test-token-three","revoked":true,"created_at":"2025-06-02T09:50:00.976Z"'
351 ',"description":null,"scopes":["read_repository","write_repository"],"user_id":1783,'
352 '"last_used_at":null,"active":false,"expires_at":"2025-06-04","access_level":40,'
353 '"resource_type":"group","resource_id":1730},'
354 '{"id":694,"name":"test-token-three","revoked":true,"created_at":"2025-06-02T09:56:45.779Z"'
355 ',"description":null,"scopes":["read_repository","write_repository"],"user_id":1784,'
356 '"last_used_at":null,"active":false,"expires_at":"2025-06-04","access_level":40,'
357 '"resource_type":"group","resource_id":1730}]'
358 )
359 content = content.encode("utf-8")
360 return response(200, content, headers, None, 5, request)
361
362
363 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/groups/1/access_tokens", method="post")
364 def resp_create_group_access_tokens(url, request):
365 headers = {"content-type": "application/json"}
366 content = (
367 '{"user_id" : 1, "scopes" : ["api"], "name" : "token1", "expires_at" : "2021-01-31",'
368 '"id" : 1, "active" : false, "created_at" : "2021-01-20T22:11:48.151Z", "revoked" : true,'
369 '"access_level": 40, "token": "Der423FErcdv35qEEWc"}'
370 )
371 content = content.encode("utf-8")
372 return response(201, content, headers, None, 5, request)
373
374
375 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/groups/1/access_tokens/[0-9]+", method="delete")
376 def resp_revoke_group_access_tokens(url, request):
377 headers = {"content-type": "application/json"}
378 content = ""
379 content = content.encode("utf-8")
380 return response(204, content, headers, None, 5, request)
381
382
383 """
384 GROUP MEMBER API
385 """
386
387
388 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/groups/1/members/1", method="get")
389 def resp_get_member(url, request):
390 headers = {"content-type": "application/json"}
391 content = (
392 '{"id": 1, "username": "raymond_smith", "name": "Raymond Smith", "state": "active",'
393 '"avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80&d=identicon",'
394 '"web_url": "http://192.168.1.8:3000/root", "expires_at": "2012-10-22T14:13:35Z", "access_level": 30}'
395 )
396 content = content.encode("utf-8")
397 return response(200, content, headers, None, 5, request)
398
399
400 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/groups/1/members", method="get")
401 def resp_find_member(url, request):
402 headers = {"content-type": "application/json"}
403 content = (
404 '[{"id": 1, "username": "raymond_smith", "name": "Raymond Smith", "state": "active",'
405 '"avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80&d=identicon",'
406 '"web_url": "http://192.168.1.8:3000/root", "expires_at": "2012-10-22T14:13:35Z", "access_level": 30},{'
407 '"id": 2, "username": "john_doe", "name": "John Doe","state": "active",'
408 '"avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80&d=identicon",'
409 '"web_url": "http://192.168.1.8:3000/root","expires_at": "2012-10-22T14:13:35Z",'
410 '"access_level": 30}]'
411 )
412 content = content.encode("utf-8")
413 return response(200, content, headers, None, 5, request)
414
415
416 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/groups/1/members", method="post")
417 def resp_add_member(url, request):
418 headers = {"content-type": "application/json"}
419 content = (
420 '{"id": 1, "username": "raymond_smith", "name": "Raymond Smith",'
421 '"state": "active",'
422 '"avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80&d=identicon",'
423 '"web_url": "http://192.168.1.8:3000/root", "expires_at": "2012-10-22T14:13:35Z",'
424 '"access_level": 30}'
425 )
426 content = content.encode("utf-8")
427 return response(200, content, headers, None, 5, request)
428
429
430 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/groups/1/members/1", method="put")
431 def resp_update_member(url, request):
432 headers = {"content-type": "application/json"}
433 content = (
434 '{"id": 1, "username": "raymond_smith", "name": "Raymond Smith",'
435 '"state": "active",'
436 '"avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80&d=identicon",'
437 '"web_url": "http://192.168.1.8:3000/root", "expires_at": "2012-10-22T14:13:35Z",'
438 '"access_level": 10}'
439 )
440 content = content.encode("utf-8")
441 return response(200, content, headers, None, 5, request)
442
443
444 """
445 DEPLOY KEY API
446 """
447
448
449 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects/1/deploy_keys", method="get")
450 def resp_find_project_deploy_key(url, request):
451 headers = {"content-type": "application/json"}
452 content = (
453 '[{"id": 1,"title": "Public key",'
454 '"key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxc'
455 'KDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=",'
456 '"created_at": "2013-10-02T10:12:29Z"},{"id": 3,"title": "Another Public key",'
457 '"key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxc'
458 'KDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=",'
459 '"created_at": "2013-10-02T11:12:29Z"}]'
460 )
461 content = content.encode("utf-8")
462 return response(200, content, headers, None, 5, request)
463
464
465 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects/1/deploy_keys/1", method="get")
466 def resp_get_project_deploy_key(url, request):
467 headers = {"content-type": "application/json"}
468 content = (
469 '{"id": 1,"title": "Public key",'
470 '"key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxc'
471 'KDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=",'
472 '"created_at": "2013-10-02T10:12:29Z"}'
473 )
474 content = content.encode("utf-8")
475 return response(200, content, headers, None, 5, request)
476
477
478 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects/1/deploy_keys", method="post")
479 def resp_create_project_deploy_key(url, request):
480 headers = {"content-type": "application/json"}
481 content = (
482 '{"id": 1,"title": "Public key",'
483 '"key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxc'
484 'KDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=",'
485 '"created_at": "2013-10-02T10:12:29Z"}'
486 )
487 content = content.encode("utf-8")
488 return response(201, content, headers, None, 5, request)
489
490
491 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects/1/deploy_keys/1", method="delete")
492 def resp_delete_project_deploy_key(url, request):
493 headers = {"content-type": "application/json"}
494 content = "{}"
495 content = content.encode("utf-8")
496 return response(204, content, headers, None, 5, request)
497
498
499 """
500 PROJECT API
501 """
502
503
504 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects", method="get")
505 def resp_find_project(url, request):
506 headers = {"content-type": "application/json"}
507 content = (
508 '[{"id": 1,"description": null, "default_branch": "master", "merge_method": "merge",'
509 '"ssh_url_to_repo": "[email protected]:diaspora/diaspora-client.git",'
510 '"http_url_to_repo": "http://example.com/diaspora/diaspora-client.git",'
511 '"web_url": "http://example.com/diaspora/diaspora-client",'
512 '"readme_url": "http://example.com/diaspora/diaspora-client/blob/master/README.md",'
513 '"tag_list": ["example","disapora client"],"name": "Diaspora Client",'
514 '"name_with_namespace": "Diaspora / Diaspora Client","path": "diaspora-client",'
515 '"path_with_namespace": "diaspora/diaspora-client","created_at": "2013-09-30T13:46:02Z",'
516 '"last_activity_at": "2013-09-30T13:46:02Z","forks_count": 0,'
517 '"avatar_url": "http://example.com/uploads/project/avatar/4/uploads/avatar.png",'
518 '"star_count": 0}]'
519 )
520 content = content.encode("utf-8")
521 return response(200, content, headers, None, 5, request)
522
523
524 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects/1", method="get")
525 def resp_get_project(url, request):
526 headers = {"content-type": "application/json"}
527 content = (
528 '{"id": 1,"description": null, "default_branch": "master", "merge_method": "merge",'
529 '"ssh_url_to_repo": "[email protected]:diaspora/diaspora-client.git",'
530 '"http_url_to_repo": "http://example.com/diaspora/diaspora-client.git",'
531 '"web_url": "http://example.com/diaspora/diaspora-client",'
532 '"readme_url": "http://example.com/diaspora/diaspora-client/blob/master/README.md",'
533 '"tag_list": ["example","disapora client"],"name": "Diaspora Client",'
534 '"name_with_namespace": "Diaspora / Diaspora Client","path": "diaspora-client",'
535 '"path_with_namespace": "diaspora/diaspora-client","created_at": "2013-09-30T13:46:02Z",'
536 '"last_activity_at": "2013-09-30T13:46:02Z","forks_count": 0,'
537 '"avatar_url": "http://example.com/uploads/project/avatar/4/uploads/avatar.png",'
538 '"star_count": 0}'
539 )
540 content = content.encode("utf-8")
541 return response(200, content, headers, None, 5, request)
542
543
544 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects/foo-bar%2Fdiaspora-client", method="get")
545 def resp_get_project_by_name(url, request):
546 headers = {"content-type": "application/json"}
547 content = (
548 '{"id": 1,"description": null, "default_branch": "master", "merge_method": "merge",'
549 '"ssh_url_to_repo": "[email protected]:diaspora/diaspora-client.git",'
550 '"http_url_to_repo": "http://example.com/diaspora/diaspora-client.git",'
551 '"web_url": "http://example.com/diaspora/diaspora-client",'
552 '"readme_url": "http://example.com/diaspora/diaspora-client/blob/master/README.md",'
553 '"tag_list": ["example","disapora client"],"name": "Diaspora Client",'
554 '"name_with_namespace": "Diaspora / Diaspora Client","path": "diaspora-client",'
555 '"path_with_namespace": "diaspora/diaspora-client","created_at": "2013-09-30T13:46:02Z",'
556 '"last_activity_at": "2013-09-30T13:46:02Z","forks_count": 0,'
557 '"avatar_url": "http://example.com/uploads/project/avatar/4/uploads/avatar.png",'
558 '"star_count": 0}'
559 )
560 content = content.encode("utf-8")
561 return response(200, content, headers, None, 5, request)
562
563
564 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/groups/1/projects", method="get")
565 def resp_find_group_project(url, request):
566 headers = {"content-type": "application/json"}
567 content = (
568 '[{"id": 1,"description": null, "default_branch": "master", "merge_method": "merge",'
569 '"ssh_url_to_repo": "[email protected]:diaspora/diaspora-client.git",'
570 '"http_url_to_repo": "http://example.com/diaspora/diaspora-client.git",'
571 '"web_url": "http://example.com/diaspora/diaspora-client",'
572 '"readme_url": "http://example.com/diaspora/diaspora-client/blob/master/README.md",'
573 '"tag_list": ["example","disapora client"],"name": "Diaspora Client",'
574 '"name_with_namespace": "Diaspora / Diaspora Client","path": "diaspora-client",'
575 '"path_with_namespace": "diaspora/diaspora-client","created_at": "2013-09-30T13:46:02Z",'
576 '"last_activity_at": "2013-09-30T13:46:02Z","forks_count": 0,'
577 '"avatar_url": "http://example.com/uploads/project/avatar/4/uploads/avatar.png",'
578 '"star_count": 0}]'
579 )
580 content = content.encode("utf-8")
581 return response(200, content, headers, None, 5, request)
582
583
584 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/groups/1/projects/1", method="get")
585 def resp_get_group_project(url, request):
586 headers = {"content-type": "application/json"}
587 content = (
588 '{"id": 1,"description": null, "default_branch": "master", "merge_method": "merge",'
589 '"ssh_url_to_repo": "[email protected]:diaspora/diaspora-client.git",'
590 '"http_url_to_repo": "http://example.com/diaspora/diaspora-client.git",'
591 '"web_url": "http://example.com/diaspora/diaspora-client",'
592 '"readme_url": "http://example.com/diaspora/diaspora-client/blob/master/README.md",'
593 '"tag_list": ["example","disapora client"],"name": "Diaspora Client",'
594 '"name_with_namespace": "Diaspora / Diaspora Client","path": "diaspora-client",'
595 '"path_with_namespace": "diaspora/diaspora-client","created_at": "2013-09-30T13:46:02Z",'
596 '"last_activity_at": "2013-09-30T13:46:02Z","forks_count": 0,'
597 '"avatar_url": "http://example.com/uploads/project/avatar/4/uploads/avatar.png",'
598 '"star_count": 0}'
599 )
600 content = content.encode("utf-8")
601 return response(200, content, headers, None, 5, request)
602
603
604 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects", method="post")
605 def resp_create_project(url, request):
606 headers = {"content-type": "application/json"}
607 content = (
608 '{"id": 1,"description": null, "default_branch": "master", "merge_method": "merge",'
609 '"ssh_url_to_repo": "[email protected]:diaspora/diaspora-client.git",'
610 '"http_url_to_repo": "http://example.com/diaspora/diaspora-client.git",'
611 '"web_url": "http://example.com/diaspora/diaspora-client",'
612 '"readme_url": "http://example.com/diaspora/diaspora-client/blob/master/README.md",'
613 '"tag_list": ["example","disapora client"],"name": "Diaspora Client",'
614 '"name_with_namespace": "Diaspora / Diaspora Client","path": "diaspora-client",'
615 '"path_with_namespace": "diaspora/diaspora-client","created_at": "2013-09-30T13:46:02Z",'
616 '"last_activity_at": "2013-09-30T13:46:02Z","forks_count": 0,'
617 '"avatar_url": "http://example.com/uploads/project/avatar/4/uploads/avatar.png",'
618 '"star_count": 0}'
619 )
620 content = content.encode("utf-8")
621 return response(201, content, headers, None, 5, request)
622
623
624 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects/1", method="delete")
625 def resp_delete_project(url, request):
626 headers = {"content-type": "application/json"}
627 content = "{}"
628 content = content.encode("utf-8")
629
630 return response(204, content, headers, None, 5, request)
631
632
633 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects/1/protected_branches/master", method="get")
634 def resp_get_protected_branch(url, request):
635 headers = {"content-type": "application/json"}
636 content = (
637 '{"id": 1, "name": "master", "push_access_levels": [{"access_level": 40, "access_level_description": "Maintainers"}],'
638 '"merge_access_levels": [{"access_level": 40, "access_level_description": "Maintainers"}],'
639 '"allow_force_push":false, "code_owner_approval_required": false}'
640 )
641 content = content.encode("utf-8")
642 return response(200, content, headers, None, 5, request)
643
644
645 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects/1/protected_branches/master", method="get")
646 def resp_get_protected_branch_not_exist(url, request):
647 headers = {"content-type": "application/json"}
648 content = ""
649 content = content.encode("utf-8")
650 return response(404, content, headers, None, 5, request)
651
652
653 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects/1/protected_branches/master", method="delete")
654 def resp_delete_protected_branch(url, request):
655 headers = {"content-type": "application/json"}
656 content = ""
657 content = content.encode("utf-8")
658 return response(204, content, headers, None, 5, request)
659
660
661 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects/1/access_tokens", method="get")
662 def resp_list_project_access_tokens(url, request):
663 headers = {"content-type": "application/json"}
664 content = (
665 '[{"id":689,"name":"test-token","revoked":true,"created_at":"2025-06-02T09:18:01.484Z",'
666 '"description":null,"scopes":["read_repository","write_repository"],"user_id":1779,'
667 '"last_used_at":null,"active":false,"expires_at":"2025-07-02","access_level":40,'
668 '"resource_type":"project","resource_id":1730},'
669 '{"id":690,"name":"test-token","revoked":true,"created_at":"2025-06-02T09:36:30.650Z",'
670 '"description":null,"scopes":["read_repository","write_repository"],"user_id":1780,'
671 '"last_used_at":null,"active":false,"expires_at":"2025-07-02","access_level":40,'
672 '"resource_type":"project","resource_id":1730},'
673 '{"id":691,"name":"test-token","revoked":false,"created_at":"2025-06-02T09:39:18.252Z",'
674 '"description":null,"scopes":["read_repository","write_repository"],"user_id":1781,'
675 '"last_used_at":null,"active":false,"expires_at":"2025-07-02","access_level":40,'
676 '"resource_type":"project","resource_id":1730},'
677 '{"id":695,"name":"test-token-no-revoked","created_at":"2025-06-02T09:39:18.252Z",'
678 '"description":null,"scopes":["read_repository","write_repository"],"user_id":1781,'
679 '"last_used_at":null,"active":false,"expires_at":"2025-07-02","access_level":40,'
680 '"resource_type":"group","resource_id":1730},'
681 '{"id":692,"name":"test-token-two","revoked":true,"created_at":"2025-06-02T09:41:18.442Z",'
682 '"description":null,"scopes":["read_repository","write_repository"],"user_id":1782,'
683 '"last_used_at":null,"active":false,"expires_at":"2025-07-02","access_level":40,'
684 '"resource_type":"project","resource_id":1730},'
685 '{"id":693,"name":"test-token-three","revoked":true,"created_at":"2025-06-02T09:50:00.976Z"'
686 ',"description":null,"scopes":["read_repository","write_repository"],"user_id":1783,'
687 '"last_used_at":null,"active":false,"expires_at":"2025-06-04","access_level":40,'
688 '"resource_type":"project","resource_id":1730},'
689 '{"id":694,"name":"test-token-three","revoked":true,"created_at":"2025-06-02T09:56:45.779Z"'
690 ',"description":null,"scopes":["read_repository","write_repository"],"user_id":1784,'
691 '"last_used_at":null,"active":false,"expires_at":"2025-06-04","access_level":40,'
692 '"resource_type":"project","resource_id":1730}]'
693 )
694 content = content.encode("utf-8")
695 return response(200, content, headers, None, 5, request)
696
697
698 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects/1/access_tokens", method="post")
699 def resp_create_project_access_tokens(url, request):
700 headers = {"content-type": "application/json"}
701 content = (
702 '{"user_id" : 1, "scopes" : ["api"], "name" : "token1", "expires_at" : "2021-01-31",'
703 '"id" : 1, "active" : false, "created_at" : "2021-01-20T22:11:48.151Z", "revoked" : true,'
704 '"access_level": 40, "token": "Der423FErcdv35qEEWc"}'
705 )
706 content = content.encode("utf-8")
707 return response(201, content, headers, None, 5, request)
708
709
710 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects/1/access_tokens/[0-9]+", method="delete")
711 def resp_revoke_project_access_tokens(url, request):
712 headers = {"content-type": "application/json"}
713 content = ""
714 content = content.encode("utf-8")
715 return response(204, content, headers, None, 5, request)
716
717
718 """
719 HOOK API
720 """
721
722
723 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects/1/hooks", method="get")
724 def resp_find_project_hook(url, request):
725 headers = {"content-type": "application/json"}
726 content = (
727 '[{"id": 1,"url": "http://example.com/hook","project_id": 3,'
728 '"push_events": true,"push_events_branch_filter": "","issues_events": true,'
729 '"confidential_issues_events": true,"merge_requests_events": true,'
730 '"tag_push_events": true,"note_events": true,"job_events": true,'
731 '"pipeline_events": true,"wiki_page_events": true,"enable_ssl_verification": true,'
732 '"created_at": "2012-10-12T17:04:47Z"}]'
733 )
734 content = content.encode("utf-8")
735 return response(200, content, headers, None, 5, request)
736
737
738 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects/1/hooks/1", method="get")
739 def resp_get_project_hook(url, request):
740 headers = {"content-type": "application/json"}
741 content = (
742 '{"id": 1,"url": "http://example.com/hook","project_id": 3,'
743 '"push_events": true,"push_events_branch_filter": "","issues_events": true,'
744 '"confidential_issues_events": true,"merge_requests_events": true,'
745 '"tag_push_events": true,"note_events": true,"job_events": true,'
746 '"pipeline_events": true,"wiki_page_events": true,"enable_ssl_verification": true,'
747 '"created_at": "2012-10-12T17:04:47Z"}'
748 )
749 content = content.encode("utf-8")
750 return response(200, content, headers, None, 5, request)
751
752
753 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects/1/hooks", method="post")
754 def resp_create_project_hook(url, request):
755 headers = {"content-type": "application/json"}
756 content = (
757 '{"id": 1,"url": "http://example.com/hook","project_id": 3,'
758 '"push_events": true,"push_events_branch_filter": "","issues_events": true,'
759 '"confidential_issues_events": true,"merge_requests_events": true,'
760 '"tag_push_events": true,"note_events": true,"job_events": true,'
761 '"pipeline_events": true,"wiki_page_events": true,"enable_ssl_verification": true,'
762 '"created_at": "2012-10-12T17:04:47Z"}'
763 )
764 content = content.encode("utf-8")
765 return response(201, content, headers, None, 5, request)
766
767
768 @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects/1/hooks/1", method="delete")
769 def resp_delete_project_hook(url, request):
770 headers = {"content-type": "application/json"}
771 content = "{}"
772 content = content.encode("utf-8")
773 return response(204, content, headers, None, 5, request)
774
775
776 """
777 RUNNER API
778 """
779
780
781 @urlmatch(scheme="http", netloc="localhost", path=r"/api/v4/runners/all$", method="get")
782 def resp_find_runners_all(url, request):
783 headers = {
784 "content-type": "application/json",
785 "X-Page": 1,
786 "X-Next-Page": 2,
787 "X-Per-Page": 1,
788 "X-Total-Pages": 1,
789 "X-Total": 2,
790 }
791 content = (
792 '[{"active": true,"description": "test-1-20150125","id": 1,'
793 '"is_shared": false,"ip_address": "127.0.0.1","name": null,'
794 '"online": true,"status": "online"},{"active": true,'
795 '"description": "test-2-20150125","id": 2,"ip_address": "127.0.0.1",'
796 '"is_shared": false,"name": null,"online": false,"status": "offline"}]'
797 )
798 content = content.encode("utf-8")
799 return response(200, content, headers, None, 5, request)
800
801
802 @urlmatch(scheme="http", netloc="localhost", path=r"/api/v4/runners$", method="get")
803 def resp_find_runners_list(url, request):
804 headers = {
805 "content-type": "application/json",
806 "X-Page": 1,
807 "X-Next-Page": 2,
808 "X-Per-Page": 1,
809 "X-Total-Pages": 1,
810 "X-Total": 2,
811 }
812 content = (
813 '[{"active": true,"description": "test-1-20201214","id": 1,'
814 '"is_shared": false,"ip_address": "127.0.0.1","name": null,'
815 '"online": true,"status": "online"},{"active": true,'
816 '"description": "test-2-20201214","id": 2,"ip_address": "127.0.0.1",'
817 '"is_shared": false,"name": null,"online": false,"status": "offline"}]'
818 )
819 content = content.encode("utf-8")
820 return response(200, content, headers, None, 5, request)
821
822
823 @urlmatch(scheme="http", netloc="localhost", path=r"/api/v4/projects/1/runners$", method="get")
824 def resp_find_project_runners(url, request):
825 headers = {
826 "content-type": "application/json",
827 "X-Page": 1,
828 "X-Next-Page": 2,
829 "X-Per-Page": 1,
830 "X-Total-Pages": 1,
831 "X-Total": 2,
832 }
833 content = (
834 '[{"active": true,"description": "test-1-20220210","id": 1,'
835 '"is_shared": false,"ip_address": "127.0.0.1","name": null,'
836 '"online": true,"status": "online"},{"active": true,'
837 '"description": "test-2-20220210","id": 2,"ip_address": "127.0.0.1",'
838 '"is_shared": false,"name": null,"online": false,"status": "offline"}]'
839 )
840 content = content.encode("utf-8")
841 return response(200, content, headers, None, 5, request)
842
843
844 @urlmatch(scheme="http", netloc="localhost", path=r"/api/v4/groups/1/runners$", method="get")
845 def resp_find_group_runners(url, request):
846 headers = {
847 "content-type": "application/json",
848 "X-Page": 1,
849 "X-Next-Page": 2,
850 "X-Per-Page": 1,
851 "X-Total-Pages": 1,
852 "X-Total": 2,
853 }
854 content = (
855 '[{"active": true,"description": "test-3-20220210","id": 1,'
856 '"is_shared": false,"ip_address": "127.0.0.1","name": null,'
857 '"online": true,"status": "online"},{"active": true,'
858 '"description": "test-4-20220210","id": 2,"ip_address": "127.0.0.1",'
859 '"is_shared": false,"name": null,"online": false,"status": "offline"}]'
860 )
861 content = content.encode("utf-8")
862 return response(200, content, headers, None, 5, request)
863
864
865 @urlmatch(scheme="http", netloc="localhost", path=r"/api/v4/runners/1$", method="put")
866 def resp_update_runner(url, request):
867 headers = {
868 "content-type": "application/json",
869 "X-Page": 1,
870 "X-Next-Page": 2,
871 "X-Per-Page": 1,
872 "X-Total-Pages": 1,
873 "X-Total": 2,
874 }
875 content = (
876 '[{"active": true,"description": "test-1-20201214","id": 1,'
877 '"is_shared": false,"ip_address": "127.0.0.1","name": null,'
878 '"online": true,"status": "online"},{"active": true,'
879 '"description": "test-2-20201214","id": 2,"ip_address": "127.0.0.1",'
880 '"is_shared": false,"name": null,"online": false,"status": "offline"}]'
881 )
882 content = content.encode("utf-8")
883 return response(200, content, headers, None, 5, request)
884
885
886 @urlmatch(scheme="http", netloc="localhost", path=r"/api/v4/runners/1$", method="get")
887 def resp_get_runner(url, request):
888 headers = {"content-type": "application/json"}
889 content = (
890 '{"active": true,"description": "test-1-20150125","id": 1,'
891 '"is_shared": false,"ip_address": "127.0.0.1","name": null,'
892 '"online": true,"status": "online"}'
893 )
894 content = content.encode("utf-8")
895 return response(200, content, headers, None, 5, request)
896
897
898 @urlmatch(scheme="http", netloc="localhost", path=r"/api/v4/runners$", method="post")
899 def resp_create_runner(url, request):
900 headers = {"content-type": "application/json"}
901 content = (
902 '{"active": true,"description": "test-1-20150125","id": 1,'
903 '"is_shared": false,"ip_address": "127.0.0.1","name": null,'
904 '"online": true,"status": "online"}'
905 )
906 content = content.encode("utf-8")
907 return response(201, content, headers, None, 5, request)
908
909
910 @urlmatch(scheme="http", netloc="localhost", path=r"/api/v4/runners/1$", method="delete")
911 def resp_delete_runner(url, request):
912 headers = {"content-type": "application/json"}
913 content = "{}"
914 content = content.encode("utf-8")
915 return response(204, content, headers, None, 5, request)