@@ -8,6 +8,7 @@ use cargo_registry_index::{Credentials, Repository as WorkerRepository, Reposito
8
8
use std:: { rc:: Rc , sync:: Arc , time:: Duration } ;
9
9
10
10
use crate :: util:: github:: { MockGitHubClient , MOCK_GITHUB_DATA } ;
11
+ use cargo_registry:: models:: token:: { CrateScope , EndpointScope } ;
11
12
use diesel:: PgConnection ;
12
13
use reqwest:: { blocking:: Client , Proxy } ;
13
14
use std:: collections:: HashSet ;
@@ -292,6 +293,17 @@ impl TestAppBuilder {
292
293
( app, anon, user, token)
293
294
}
294
295
296
+ pub fn with_scoped_token (
297
+ self ,
298
+ crate_scopes : Option < Vec < CrateScope > > ,
299
+ endpoint_scopes : Option < Vec < EndpointScope > > ,
300
+ ) -> ( TestApp , MockAnonymousUser , MockCookieUser , MockTokenUser ) {
301
+ let ( app, anon) = self . empty ( ) ;
302
+ let user = app. db_new_user ( "foo" ) ;
303
+ let token = user. db_new_scoped_token ( "bar" , crate_scopes, endpoint_scopes) ;
304
+ ( app, anon, user, token)
305
+ }
306
+
295
307
pub fn with_config ( mut self , f : impl FnOnce ( & mut config:: Server ) ) -> Self {
296
308
f ( & mut self . config ) ;
297
309
self
0 commit comments