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