Skip to content

Commit 36e1e4d

Browse files
test(auth): add tests showing token rejected behavior for alt registries
1 parent adf9cde commit 36e1e4d

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

tests/testsuite/registry_auth.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,36 @@ Caused by:
418418
.run();
419419
}
420420

421+
#[cargo_test]
422+
fn incorrect_token_bearer_scheme() {
423+
let _registry = RegistryBuilder::new()
424+
.alternative()
425+
.auth_required()
426+
.no_configure_token()
427+
.http_index()
428+
.build();
429+
430+
let p = make_project();
431+
cargo(&p, "build")
432+
.env("CARGO_REGISTRIES_ALTERNATIVE_TOKEN", "Bearer incorrect")
433+
.with_status(101)
434+
.with_stderr_data(str![[r#"
435+
[UPDATING] `alternative` index
436+
[ERROR] failed to get `bar` as a dependency of package `foo v0.0.1 ([ROOT]/foo)`
437+
438+
Caused by:
439+
token rejected for `alternative`, please run `cargo login --registry alternative`
440+
or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN
441+
442+
Caused by:
443+
failed to get successful HTTP response from `http://127.0.0.1:[..]/index/config.json`, got 401
444+
body:
445+
Unauthorized message from server.
446+
447+
"#]])
448+
.run();
449+
}
450+
421451
#[cargo_test]
422452
fn anonymous_alt_registry() {
423453
// An alternative registry that requires auth, but is not in the config.

0 commit comments

Comments
 (0)