mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Use registry.default for login/logout
This commit is contained in:
parent
0e13f667c8
commit
117eb4b33f
@ -34,10 +34,11 @@ pub fn cli() -> Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
|
let registry = args.registry(config)?;
|
||||||
ops::registry_login(
|
ops::registry_login(
|
||||||
config,
|
config,
|
||||||
args.get_one::<String>("token").map(|s| s.as_str().into()),
|
args.get_one::<String>("token").map(|s| s.as_str().into()),
|
||||||
args.get_one("registry").map(String::as_str),
|
registry.as_deref(),
|
||||||
args.flag("generate-keypair"),
|
args.flag("generate-keypair"),
|
||||||
args.flag("secret-key"),
|
args.flag("secret-key"),
|
||||||
args.get_one("key-subject").map(String::as_str),
|
args.get_one("key-subject").map(String::as_str),
|
||||||
|
@ -15,9 +15,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
|||||||
.cli_unstable()
|
.cli_unstable()
|
||||||
.fail_if_stable_command(config, "logout", 8933)?;
|
.fail_if_stable_command(config, "logout", 8933)?;
|
||||||
}
|
}
|
||||||
ops::registry_logout(
|
let registry = args.registry(config)?;
|
||||||
config,
|
ops::registry_logout(config, registry.as_deref())?;
|
||||||
args.get_one::<String>("registry").map(String::as_str),
|
|
||||||
)?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -373,16 +373,13 @@ fn login_with_generate_asymmetric_token() {
|
|||||||
fn default_registry_configured() {
|
fn default_registry_configured() {
|
||||||
// When registry.default is set, login should use that one when
|
// When registry.default is set, login should use that one when
|
||||||
// --registry is not used.
|
// --registry is not used.
|
||||||
|
let _alternative = RegistryBuilder::new().alternative().build();
|
||||||
let cargo_home = paths::home().join(".cargo");
|
let cargo_home = paths::home().join(".cargo");
|
||||||
cargo_home.mkdir_p();
|
cargo_util::paths::append(
|
||||||
cargo_util::paths::write(
|
&cargo_home.join("config"),
|
||||||
&cargo_home.join("config.toml"),
|
br#"
|
||||||
r#"
|
|
||||||
[registry]
|
[registry]
|
||||||
default = "dummy-registry"
|
default = "alternative"
|
||||||
|
|
||||||
[registries.dummy-registry]
|
|
||||||
index = "https://127.0.0.1/index"
|
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -391,12 +388,12 @@ fn default_registry_configured() {
|
|||||||
.arg("a-new-token")
|
.arg("a-new-token")
|
||||||
.with_stderr(
|
.with_stderr(
|
||||||
"\
|
"\
|
||||||
[UPDATING] crates.io index
|
[UPDATING] `alternative` index
|
||||||
[LOGIN] token for `crates.io` saved
|
[LOGIN] token for `alternative` saved
|
||||||
",
|
",
|
||||||
)
|
)
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
check_token(Some("a-new-token"), None);
|
check_token(None, None);
|
||||||
check_token(None, Some("alternative"));
|
check_token(Some("a-new-token"), Some("alternative"));
|
||||||
}
|
}
|
||||||
|
@ -105,18 +105,18 @@ fn default_registry_configured() {
|
|||||||
.masquerade_as_nightly_cargo(&["cargo-logout"])
|
.masquerade_as_nightly_cargo(&["cargo-logout"])
|
||||||
.with_stderr(
|
.with_stderr(
|
||||||
"\
|
"\
|
||||||
[LOGOUT] token for `crates-io` has been removed from local storage
|
[LOGOUT] token for `dummy-registry` has been removed from local storage
|
||||||
[NOTE] This does not revoke the token on the registry server.
|
[NOTE] This does not revoke the token on the registry server.
|
||||||
If you need to revoke the token, visit <https://crates.io/me> \
|
If you need to revoke the token, visit the `dummy-registry` website \
|
||||||
and follow the instructions there.
|
and follow the instructions there.
|
||||||
",
|
",
|
||||||
)
|
)
|
||||||
.run();
|
.run();
|
||||||
check_token(Some("dummy-token"), Some("dummy-registry"));
|
check_token(None, Some("dummy-registry"));
|
||||||
check_token(None, None);
|
check_token(Some("crates-io-token"), None);
|
||||||
|
|
||||||
cargo_process("logout -Zunstable-options")
|
cargo_process("logout -Zunstable-options")
|
||||||
.masquerade_as_nightly_cargo(&["cargo-logout"])
|
.masquerade_as_nightly_cargo(&["cargo-logout"])
|
||||||
.with_stderr("[LOGOUT] not currently logged in to `crates-io`")
|
.with_stderr("[LOGOUT] not currently logged in to `dummy-registry`")
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user