Add authentication back into the operation states
parent: tbd commit: 97a26fd
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 StackOperationState; |
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: &User, |
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 | // Ok(true) |
287 | Ok |
288 | == & from_str |
289 | "test_user:test.giterated.dev/[email protected]", |
290 | |
291 | .unwrap |
292 | |
293 | |
294 | |
295 | |
296 | DatabaseBackend |
297 | our_instance: from_str .unwrap, |
298 | user_backend: new as _, |
299 | repository_backend: new as _, |
300 | |
301 | .into_backend |
302 | |
303 | |
304 | |
305 | todo! |
306 | |
307 | |
308 | |
309 | async |
310 | let backend = test_backend; |
311 | let operation_state = operation_state; |
312 | |
313 | let mut user = backend |
314 | . |
315 | .await |
316 | .expect; |
317 | |
318 | user. |
319 | .await |
320 | .expect; |
321 | |
322 | |
323 | |
324 | async |
325 | let backend = test_backend; |
326 | let operation_state = operation_state; |
327 | |
328 | let mut user = backend |
329 | . |
330 | .await |
331 | .expect; |
332 | |
333 | user. |
334 | .await |
335 | .expect; |
336 | |
337 | |
338 | |
339 | async |
340 | let backend = test_backend; |
341 | let operation_state = operation_state; |
342 | |
343 | let mut user = backend |
344 | . |
345 | .await |
346 | .expect; |
347 | |
348 | user. |
349 | .await |
350 | .expect; |
351 | |
352 | |
353 | |
354 | async |
355 | let backend = test_backend; |
356 | let operation_state = operation_state; |
357 | |
358 | let mut repository = backend |
359 | . |
360 | "test_user:test.giterated.dev/[email protected]", |
361 | &operation_state, |
362 | |
363 | .await |
364 | .expect; |
365 | |
366 | repository |
367 | . |
368 | .await |
369 | .expect; |
370 | |
371 | |
372 | |
373 | async |
374 | let backend = test_backend; |
375 | let operation_state = operation_state; |
376 | |
377 | let mut repository = backend |
378 | . |
379 | "test_user:test.giterated.dev/[email protected]", |
380 | &operation_state, |
381 | |
382 | .await |
383 | .expect; |
384 | |
385 | repository |
386 | . |
387 | .await |
388 | .expect; |
389 | |
390 | |
391 | |
392 | async |
393 | let backend = test_backend; |
394 | let operation_state = operation_state; |
395 | |
396 | let mut repository = backend |
397 | . |
398 | "test_user:test.giterated.dev/[email protected]", |
399 | &operation_state, |
400 | |
401 | .await |
402 | .expect; |
403 | |
404 | repository |
405 | . |
406 | .await |
407 | .expect; |
408 | |
409 | |
410 |