@@ -189,6 +189,24 @@ Caused by:
189189 ) ;
190190}
191191
192+ #[ cargo_test]
193+ fn bad_asymmetric_token_args ( ) {
194+ let registry = RegistryBuilder :: new ( )
195+ . credential_provider ( & [ "cargo:paseto" ] )
196+ . no_configure_token ( )
197+ . build ( ) ;
198+
199+ // These cases are kept brief as the implementation is covered by clap, so this is only smoke testing that we have clap configured correctly.
200+ cargo_process ( "login -Zcredential-process -- --key-subject" )
201+ . masquerade_as_nightly_cargo ( & [ "credential-process" ] )
202+ . replace_crates_io ( registry. index_url ( ) )
203+ . with_stderr_contains (
204+ " error: a value is required for '--key-subject <SUBJECT>' but none was supplied" ,
205+ )
206+ . with_status ( 101 )
207+ . run ( ) ;
208+ }
209+
192210#[ cargo_test]
193211fn login_with_no_cargo_dir ( ) {
194212 // Create a config in the root directory because `login` requires the
@@ -203,6 +221,28 @@ fn login_with_no_cargo_dir() {
203221 assert_eq ! ( credentials, "[registry]\n token = \" foo\" \n " ) ;
204222}
205223
224+ #[ cargo_test]
225+ fn login_with_asymmetric_token_and_subject_on_stdin ( ) {
226+ let registry = RegistryBuilder :: new ( )
227+ . credential_provider ( & [ "cargo:paseto" ] )
228+ . no_configure_token ( )
229+ . build ( ) ;
230+ let credentials = credentials_toml ( ) ;
231+ cargo_process ( "login -v -Z credential-process -- --key-subject=foo" )
232+ . masquerade_as_nightly_cargo ( & [ "credential-process" ] )
233+ . replace_crates_io ( registry. index_url ( ) )
234+ . with_stdout (
235+ "\
236+ k3.public.AmDwjlyf8jAV3gm5Z7Kz9xAOcsKslt_Vwp5v-emjFzBHLCtcANzTaVEghTNEMj9PkQ",
237+ )
238+ . with_stdin ( "k3.secret.fNYVuMvBgOlljt9TDohnaYLblghqaHoQquVZwgR6X12cBFHZLFsaU3q7X3k1Zn36" )
239+ . run ( ) ;
240+ let credentials = fs:: read_to_string ( & credentials) . unwrap ( ) ;
241+ assert ! ( credentials. starts_with( "[registry]\n " ) ) ;
242+ assert ! ( credentials. contains( "secret-key-subject = \" foo\" \n " ) ) ;
243+ assert ! ( credentials. contains( "secret-key = \" k3.secret.fNYVuMvBgOlljt9TDohnaYLblghqaHoQquVZwgR6X12cBFHZLFsaU3q7X3k1Zn36\" \n " ) ) ;
244+ }
245+
206246#[ cargo_test]
207247fn login_with_differently_sized_token ( ) {
208248 // Verify that the configuration file gets properly truncated.
@@ -248,12 +288,7 @@ fn login_with_asymmetric_token_on_stdin() {
248288 let credentials = credentials_toml ( ) ;
249289 cargo_process ( "login -vZ credential-process --registry alternative" )
250290 . masquerade_as_nightly_cargo ( & [ "credential-process" ] )
251- . with_stderr (
252- "\
253- [UPDATING] [..]
254- [CREDENTIAL] cargo:paseto login alternative
255- k3.public.AmDwjlyf8jAV3gm5Z7Kz9xAOcsKslt_Vwp5v-emjFzBHLCtcANzTaVEghTNEMj9PkQ" ,
256- )
291+ . with_stdout ( "k3.public.AmDwjlyf8jAV3gm5Z7Kz9xAOcsKslt_Vwp5v-emjFzBHLCtcANzTaVEghTNEMj9PkQ" )
257292 . with_stdin ( "k3.secret.fNYVuMvBgOlljt9TDohnaYLblghqaHoQquVZwgR6X12cBFHZLFsaU3q7X3k1Zn36" )
258293 . run ( ) ;
259294 let credentials = fs:: read_to_string ( & credentials) . unwrap ( ) ;
@@ -270,7 +305,8 @@ fn login_with_generate_asymmetric_token() {
270305 let credentials = credentials_toml ( ) ;
271306 cargo_process ( "login -Z credential-process --registry alternative" )
272307 . masquerade_as_nightly_cargo ( & [ "credential-process" ] )
273- . with_stderr ( "[UPDATING] `alternative` index\n k3.public.[..]" )
308+ . with_stderr ( "[UPDATING] `alternative` index" )
309+ . with_stdout ( "k3.public.[..]" )
274310 . run ( ) ;
275311 let credentials = fs:: read_to_string ( & credentials) . unwrap ( ) ;
276312 assert ! ( credentials. contains( "secret-key = \" k3.secret." ) ) ;
0 commit comments