Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Eh2406 committed Dec 19, 2022
1 parent a3857f7 commit d464dbb
Showing 1 changed file with 91 additions and 0 deletions.
91 changes: 91 additions & 0 deletions tests/testsuite/registry_auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,97 @@ fn environment_token_with_asymmetric() {
.run();
}

#[cargo_test]
fn warn_both_asymmetric_and_token() {
let _server = RegistryBuilder::new()
.alternative()
.no_configure_token()
.build();
let p = project()
.file(
".cargo/config",
r#"
[registries.alternative]
token = "sekrit"
secret-key = "k3.secret.fNYVuMvBgOlljt9TDohnaYLblghqaHoQquVZwgR6X12cBFHZLFsaU3q7X3k1Zn36"
"#,
)
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
description = "foo"
authors = []
license = "MIT"
homepage = "https://example.com/"
"#,
)
.file("src/lib.rs", "")
.build();

p.cargo("publish --no-verify --registry alternative")
.masquerade_as_nightly_cargo(&["credential-process", "sparse-registry", "registry-auth"])
.arg("-Zsparse-registry")
.arg("-Zregistry-auth")
.with_status(101)
.with_stderr(
"\
[UPDATING] [..]
[ERROR] both `token` and `secret-key` were specified in the config for registry `alternative`.
Only one of these values may be set, remove one or the other to proceed.
",
)
.run();
}

#[cargo_test]
fn warn_both_asymmetric_and_credential_process() {
let _server = RegistryBuilder::new()
.alternative()
.no_configure_token()
.build();
let p = project()
.file(
".cargo/config",
r#"
[registries.alternative]
credential-process = "false"
secret-key = "k3.secret.fNYVuMvBgOlljt9TDohnaYLblghqaHoQquVZwgR6X12cBFHZLFsaU3q7X3k1Zn36"
"#,
)
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
description = "foo"
authors = []
license = "MIT"
homepage = "https://example.com/"
"#,
)
.file("src/lib.rs", "")
.build();

p.cargo("publish --no-verify --registry alternative")
.masquerade_as_nightly_cargo(&["credential-process", "sparse-registry", "registry-auth"])
.arg("-Zcredential-process")
.arg("-Zsparse-registry")
.arg("-Zregistry-auth")
.with_status(101)
.with_stderr(
"\
[UPDATING] [..]
[ERROR] both `credential-process` and `secret-key` were specified in the config for registry `alternative`.
Only one of these values may be set, remove one or the other to proceed.
",
)
.run();
}

#[cargo_test]
fn bad_environment_token_with_asymmetric_subject() {
let registry = RegistryBuilder::new()
Expand Down

0 comments on commit d464dbb

Please sign in to comment.