@@ -8,6 +8,7 @@ use cargo_registry_index::{Credentials, Repository as WorkerRepository, Reposito
88use std:: { rc:: Rc , sync:: Arc , time:: Duration } ;
99
1010use crate :: util:: github:: { MockGitHubClient , MOCK_GITHUB_DATA } ;
11+ use cargo_registry:: models:: token:: { CrateScope , EndpointScope } ;
1112use diesel:: PgConnection ;
1213use reqwest:: { blocking:: Client , Proxy } ;
1314use std:: collections:: HashSet ;
@@ -292,6 +293,17 @@ impl TestAppBuilder {
292293 ( app, anon, user, token)
293294 }
294295
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+
295307 pub fn with_config ( mut self , f : impl FnOnce ( & mut config:: Server ) ) -> Self {
296308 f ( & mut self . config ) ;
297309 self
0 commit comments