Implement `FromOperationState` for `AuthenticatedUser` and `AuthenticatedInstance`
Use `AuthenticatedUser` on repository requests so we can filter by privacy. Woohoo! Attempt to filter `UserRepositoriesRequest` responses by visibility to the requester.
parent: tbd commit: 75dcac3
1 | |
2 | |
3 | use Arc; |
4 | |
5 | use OperationError; |
6 | use Instance; |
7 | use ; |
8 | use ObjectBackend; |
9 | use GiteratedOperation; |
10 | use Repository; |
11 | use User; |
12 | use GiteratedBackend; |
13 | use ; |
14 | use Debug; |
15 | use Mutex; |
16 | |
17 | use crate; |
18 | |
19 | use |
20 | instance_authentication_request, instance_create_repository_request, |
21 | instance_registration_request, repository_commit_before, repository_diff, |
22 | repository_diff_patch, repository_file_from_id, repository_file_from_path, |
23 | repository_get_setting, repository_get_value, repository_info, repository_set_setting, |
24 | user_get_repositories, user_get_setting, user_get_value, user_set_setting, |
25 | ; |
26 | |
27 | |
28 | |
29 | |
30 | |
31 | |
32 | async |
33 | &self, |
34 | _object: O, |
35 | _operation: &str, |
36 | _payload: D, |
37 | _operation_state: &StackOperationState, |
38 | |
39 | // We don't handle operations with this backend |
40 | Err |
41 | |
42 | |
43 | async |
44 | &self, |
45 | _object_str: &str, |
46 | _operation_state: &StackOperationState, |
47 | |
48 | Err |
49 | |
50 | |
51 | |
52 | /// A backend implementation which attempts to resolve data from the instance's database. |
53 | |
54 | |
55 | pub(self) our_instance: Instance, |
56 | pub(self) user_backend: , |
57 | pub(self) repository_backend: , |
58 | |
59 | |
60 | |
61 | |
62 | instance: Instance, |
63 | user_backend: , |
64 | repository_backend: , |
65 | |
66 | Self |
67 | our_instance: instance, |
68 | user_backend, |
69 | repository_backend, |
70 | |
71 | |
72 | |
73 | |
74 | let mut handlers = default; |
75 | |
76 | handlers |
77 | .insert |
78 | .insert |
79 | .insert |
80 | .insert |
81 | .insert |
82 | .insert |
83 | .insert |
84 | .insert |
85 | .insert |
86 | .insert |
87 | .insert |
88 | .insert |
89 | .insert |
90 | .insert |
91 | .insert |
92 | .insert |
93 | . |
94 | . |
95 | .; |
96 | |
97 | new |
98 | |
99 | |
100 | |
101 | |
102 | |
103 | f.debug_struct .finish |
104 | |
105 | |
106 | |
107 | // TODO: These should be on the stack |
108 | // These tests verify that the essential handling of the database backend is |
109 | // functional and correct. |
110 | |
111 | |
112 | use ; |
113 | |
114 | use Error; |
115 | |
116 | use UserAuthenticationToken; |
117 | |
118 | use |
119 | AuthenticationTokenRequest, Instance, RegisterAccountRequest, RepositoryCreateRequest, |
120 | ; |
121 | |
122 | use ObjectBackend; |
123 | |
124 | use |
125 | Commit, Description, Repository, RepositoryCommitBeforeRequest, RepositoryDiff, |
126 | RepositoryDiffPatchRequest, RepositoryDiffRequest, RepositoryFile, |
127 | RepositoryFileFromIdRequest, RepositoryFileFromPathRequest, RepositoryFileInspectRequest, |
128 | RepositorySummary, RepositoryTreeEntry, |
129 | ; |
130 | use AnySetting; |
131 | use ; |
132 | use ; |
133 | use GiteratedBackend; |
134 | use ; |
135 | use Value; |
136 | use Mutex; |
137 | |
138 | use crate; |
139 | |
140 | use DatabaseBackend; |
141 | ; |
142 | |
143 | |
144 | |
145 | async |
146 | assert_eq!; |
147 | |
148 | Ok |
149 | & to_vec .unwrap, |
150 | |
151 | .unwrap |
152 | |
153 | async |
154 | Ok |
155 | & to_vec .unwrap, |
156 | |
157 | .unwrap |
158 | |
159 | async |
160 | &mut self, |
161 | _user: &User, |
162 | _name: &str, |
163 | _setting: &Value, |
164 | |
165 | Ok |
166 | |
167 | async |
168 | Ok |
169 | |
170 | async |
171 | &mut self, |
172 | _requester: & , |
173 | _user: &User, |
174 | |
175 | todo! |
176 | |
177 | |
178 | |
179 | |
180 | |
181 | async |
182 | &mut self, |
183 | _request: RegisterAccountRequest, |
184 | |
185 | todo! |
186 | |
187 | |
188 | async |
189 | &mut self, |
190 | _source: &Instance, |
191 | _request: AuthenticationTokenRequest, |
192 | |
193 | todo! |
194 | |
195 | |
196 | |
197 | ; |
198 | |
199 | |
200 | |
201 | async |
202 | &mut self, |
203 | _user: &AuthenticatedUser, |
204 | _request: &RepositoryCreateRequest, |
205 | |
206 | todo! |
207 | |
208 | async |
209 | &mut self, |
210 | _requester: & , |
211 | _repository: &Repository, |
212 | _request: &RepositoryFileInspectRequest, |
213 | |
214 | todo! |
215 | |
216 | async |
217 | &mut self, |
218 | _requester: & , |
219 | _repository: &Repository, |
220 | _request: &RepositoryFileFromIdRequest, |
221 | |
222 | todo! |
223 | |
224 | async |
225 | &mut self, |
226 | _requester: & , |
227 | _repository: &Repository, |
228 | _request: &RepositoryFileFromPathRequest, |
229 | |
230 | todo! |
231 | |
232 | async |
233 | &mut self, |
234 | _requester: & , |
235 | _repository: &Repository, |
236 | _request: &RepositoryDiffRequest, |
237 | |
238 | todo! |
239 | |
240 | async |
241 | &mut self, |
242 | _requester: & , |
243 | _repository: &Repository, |
244 | _request: &RepositoryDiffPatchRequest, |
245 | |
246 | todo! |
247 | |
248 | async |
249 | &mut self, |
250 | _requester: & , |
251 | _repository: &Repository, |
252 | _request: &RepositoryCommitBeforeRequest, |
253 | |
254 | todo! |
255 | |
256 | async |
257 | &mut self, |
258 | _repository: &Repository, |
259 | _name: &str, |
260 | |
261 | Ok |
262 | & to_vec .unwrap, |
263 | |
264 | .unwrap |
265 | |
266 | async |
267 | &mut self, |
268 | _repository: &Repository, |
269 | _name: &str, |
270 | |
271 | Ok |
272 | & to_vec .unwrap, |
273 | |
274 | .unwrap |
275 | |
276 | async |
277 | &mut self, |
278 | _repository: &Repository, |
279 | _name: &str, |
280 | _setting: &Value, |
281 | |
282 | Ok |
283 | |
284 | |
285 | async |
286 | &mut self, |
287 | _requester: & , |
288 | repository: &Repository, |
289 | |
290 | // Ok(true) |
291 | Ok |
292 | == & from_str |
293 | "test_user:test.giterated.dev/[email protected]", |
294 | |
295 | .unwrap |
296 | |
297 | |
298 | |
299 | |
300 | DatabaseBackend |
301 | our_instance: from_str .unwrap, |
302 | user_backend: new as _, |
303 | repository_backend: new as _, |
304 | |
305 | .into_backend |
306 | |
307 | |
308 | |
309 | todo! |
310 | |
311 | |
312 | |
313 | async |
314 | let backend = test_backend; |
315 | let operation_state = operation_state; |
316 | |
317 | let mut user = backend |
318 | . |
319 | .await |
320 | .expect; |
321 | |
322 | user. |
323 | .await |
324 | .expect; |
325 | |
326 | |
327 | |
328 | async |
329 | let backend = test_backend; |
330 | let operation_state = operation_state; |
331 | |
332 | let mut user = backend |
333 | . |
334 | .await |
335 | .expect; |
336 | |
337 | user. |
338 | .await |
339 | .expect; |
340 | |
341 | |
342 | |
343 | async |
344 | let backend = test_backend; |
345 | let operation_state = operation_state; |
346 | |
347 | let mut user = backend |
348 | . |
349 | .await |
350 | .expect; |
351 | |
352 | user. |
353 | .await |
354 | .expect; |
355 | |
356 | |
357 | |
358 | async |
359 | let backend = test_backend; |
360 | let operation_state = operation_state; |
361 | |
362 | let mut repository = backend |
363 | . |
364 | "test_user:test.giterated.dev/[email protected]", |
365 | &operation_state, |
366 | |
367 | .await |
368 | .expect; |
369 | |
370 | repository |
371 | . |
372 | .await |
373 | .expect; |
374 | |
375 | |
376 | |
377 | async |
378 | let backend = test_backend; |
379 | let operation_state = operation_state; |
380 | |
381 | let mut repository = backend |
382 | . |
383 | "test_user:test.giterated.dev/[email protected]", |
384 | &operation_state, |
385 | |
386 | .await |
387 | .expect; |
388 | |
389 | repository |
390 | . |
391 | .await |
392 | .expect; |
393 | |
394 | |
395 | |
396 | async |
397 | let backend = test_backend; |
398 | let operation_state = operation_state; |
399 | |
400 | let mut repository = backend |
401 | . |
402 | "test_user:test.giterated.dev/[email protected]", |
403 | &operation_state, |
404 | |
405 | .await |
406 | .expect; |
407 | |
408 | repository |
409 | . |
410 | .await |
411 | .expect; |
412 | |
413 | |
414 |