@@ -134,40 +134,45 @@ fn invalid_login_token() {
134
134
. build ( ) ;
135
135
setup_new_credentials ( ) ;
136
136
137
- let check = |stdin : & str , stderr : & str | {
137
+ let check = |stdin : & str , stderr : & str , status : i32 | {
138
138
cargo_process ( "login" )
139
139
. replace_crates_io ( registry. index_url ( ) )
140
140
. with_stdout ( "please paste the token found on [..]/me below" )
141
141
. with_stdin ( stdin)
142
142
. with_stderr ( stderr)
143
- . with_status ( 101 )
143
+ . with_status ( status )
144
144
. run ( ) ;
145
145
} ;
146
146
147
- check (
148
- "😄" ,
149
- "\
150
- [UPDATING] crates.io index
151
- [ERROR] token contains invalid characters.
147
+ let invalid = |stdin : & str | {
148
+ check (
149
+ stdin,
150
+ "[ERROR] token contains invalid characters.
152
151
Only printable ISO-8859-1 characters are allowed as it is sent in a HTTPS header." ,
153
- ) ;
154
- check (
155
- " \u{0016} " ,
156
- " \
157
- [ERROR] token contains invalid characters.
158
- Only printable ISO-8859-1 characters are allowed as it is sent in a HTTPS header." ,
159
- ) ;
152
+ 101 ,
153
+ )
154
+ } ;
155
+ let valid = | stdin : & str | check ( stdin , "[LOGIN] token for `crates.io` saved" , 0 ) ;
156
+
157
+ // Update config.json so that the rest of the tests don't need to care
158
+ // whether or not `Updating` is printed.
160
159
check (
161
- "\u{0000} " ,
160
+ "test " ,
162
161
"\
163
- [ERROR] token contains invalid characters.
164
- Only printable ISO-8859-1 characters are allowed as it is sent in a HTTPS header." ,
162
+ [UPDATING] crates.io index
163
+ [LOGIN] token for `crates.io` saved
164
+ " ,
165
+ 0 ,
165
166
) ;
166
- check (
167
- "你好" ,
168
- "\
169
- [ERROR] token contains invalid characters.
170
- Only printable ISO-8859-1 characters are allowed as it is sent in a HTTPS header." ,
167
+
168
+ invalid ( "😄" ) ;
169
+ invalid ( "\u{0016} " ) ;
170
+ invalid ( "\u{0000} " ) ;
171
+ invalid ( "你好" ) ;
172
+ valid ( "foo\t bar" ) ;
173
+ valid ( "foo bar" ) ;
174
+ valid (
175
+ r##"!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"## ,
171
176
) ;
172
177
}
173
178
0 commit comments