@@ -134,6 +134,85 @@ fn environment_token_with_asymmetric() {
134
134
. run ( ) ;
135
135
}
136
136
137
+ #[ cargo_test]
138
+ fn bad_environment_token_with_asymmetric_subject ( ) {
139
+ let registry = RegistryBuilder :: new ( )
140
+ . alternative ( )
141
+ . auth_required ( )
142
+ . no_configure_token ( )
143
+ . http_index ( )
144
+ . token ( cargo_test_support:: registry:: Token :: Keys (
145
+ "k3.secret.fNYVuMvBgOlljt9TDohnaYLblghqaHoQquVZwgR6X12cBFHZLFsaU3q7X3k1Zn36"
146
+ . to_string ( ) ,
147
+ None ,
148
+ ) )
149
+ . build ( ) ;
150
+
151
+ let p = make_project ( ) ;
152
+ cargo ( & p, "build" )
153
+ . env ( "CARGO_REGISTRIES_ALTERNATIVE_SECRET_KEY" , registry. key ( ) )
154
+ . env (
155
+ "CARGO_REGISTRIES_ALTERNATIVE_SECRET_KEY_SUBJECT" ,
156
+ "incorrect" ,
157
+ )
158
+ . with_stderr_contains (
159
+ " token rejected for `alternative`, please run `cargo login --registry alternative`" ,
160
+ )
161
+ . with_status ( 101 )
162
+ . run ( ) ;
163
+ }
164
+
165
+ #[ cargo_test]
166
+ fn bad_environment_token_with_asymmetric_incorrect_subject ( ) {
167
+ let registry = RegistryBuilder :: new ( )
168
+ . alternative ( )
169
+ . auth_required ( )
170
+ . no_configure_token ( )
171
+ . http_index ( )
172
+ . token ( cargo_test_support:: registry:: Token :: rfc_key ( ) )
173
+ . build ( ) ;
174
+
175
+ let p = make_project ( ) ;
176
+ cargo ( & p, "build" )
177
+ . env ( "CARGO_REGISTRIES_ALTERNATIVE_SECRET_KEY" , registry. key ( ) )
178
+ . env (
179
+ "CARGO_REGISTRIES_ALTERNATIVE_SECRET_KEY_SUBJECT" ,
180
+ "incorrect" ,
181
+ )
182
+ . with_stderr_contains (
183
+ " token rejected for `alternative`, please run `cargo login --registry alternative`" ,
184
+ )
185
+ . with_status ( 101 )
186
+ . run ( ) ;
187
+ }
188
+
189
+ #[ cargo_test]
190
+ fn bad_environment_token_with_incorrect_asymmetric ( ) {
191
+ let _registry = RegistryBuilder :: new ( )
192
+ . alternative ( )
193
+ . auth_required ( )
194
+ . no_configure_token ( )
195
+ . http_index ( )
196
+ . token ( cargo_test_support:: registry:: Token :: Keys (
197
+ "k3.secret.fNYVuMvBgOlljt9TDohnaYLblghqaHoQquVZwgR6X12cBFHZLFsaU3q7X3k1Zn36"
198
+ . to_string ( ) ,
199
+ None ,
200
+ ) )
201
+ . build ( ) ;
202
+
203
+ let p = make_project ( ) ;
204
+ cargo ( & p, "build" )
205
+ . env (
206
+ "CARGO_REGISTRIES_ALTERNATIVE_SECRET_KEY" ,
207
+ "k3.secret.9Vxr5hVlI_g_orBZN54vPz20bmB4O76wB_MVqUSuJJJqHFLwP8kdn_RY5g6J6pQG" ,
208
+ )
209
+ . with_stderr_contains (
210
+ " token rejected for `alternative`, please run `cargo login --registry alternative`" ,
211
+ )
212
+ . with_status ( 101 )
213
+ . run ( ) ;
214
+ }
215
+
137
216
#[ cargo_test]
138
217
fn missing_token ( ) {
139
218
let _registry = RegistryBuilder :: new ( )
0 commit comments