File tree 2 files changed +19
-1
lines changed 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -764,7 +764,7 @@ pub fn registry_login(
764
764
. with_context ( || "failed to read stdin" ) ?;
765
765
// Automatically remove `cargo login` from an inputted token to
766
766
// allow direct pastes from `registry.host()`/me.
767
- line. replace ( "cargo login" , "" ) . trim ( ) . to_string ( ) ;
767
+ line = line . replace ( "cargo login" , "" ) . trim ( ) . to_string ( ) ;
768
768
if line. is_empty ( ) {
769
769
bail ! ( "please provide a non-empty token" ) ;
770
770
}
Original file line number Diff line number Diff line change @@ -90,3 +90,21 @@ fn registry_credentials() {
90
90
assert ! ( check_token( TOKEN , Some ( reg) ) ) ;
91
91
assert ! ( check_token( TOKEN2 , Some ( reg2) ) ) ;
92
92
}
93
+
94
+ #[ cargo_test]
95
+ fn empty_login_token ( ) {
96
+ let _registry = RegistryBuilder :: new ( ) . build ( ) ;
97
+ setup_new_credentials ( ) ;
98
+
99
+ cargo_process ( "login" )
100
+ . with_stdout ( "please paste the API Token found on [..]/me below" )
101
+ . with_stdin ( "\t \n " )
102
+ . with_stderr (
103
+ "\
104
+ [UPDATING] `dummy-registry` index
105
+ [ERROR] please provide a non-empty token
106
+ " ,
107
+ )
108
+ . with_status ( 101 )
109
+ . run ( )
110
+ }
You can’t perform that action at this time.
0 commit comments