mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +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 {
|
||||
let registry = args.registry(config)?;
|
||||
ops::registry_login(
|
||||
config,
|
||||
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("secret-key"),
|
||||
args.get_one("key-subject").map(String::as_str),
|
||||
|
@ -15,9 +15,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||
.cli_unstable()
|
||||
.fail_if_stable_command(config, "logout", 8933)?;
|
||||
}
|
||||
ops::registry_logout(
|
||||
config,
|
||||
args.get_one::<String>("registry").map(String::as_str),
|
||||
)?;
|
||||
let registry = args.registry(config)?;
|
||||
ops::registry_logout(config, registry.as_deref())?;
|
||||
Ok(())
|
||||
}
|
||||
|
@ -373,16 +373,13 @@ fn login_with_generate_asymmetric_token() {
|
||||
fn default_registry_configured() {
|
||||
// When registry.default is set, login should use that one when
|
||||
// --registry is not used.
|
||||
let _alternative = RegistryBuilder::new().alternative().build();
|
||||
let cargo_home = paths::home().join(".cargo");
|
||||
cargo_home.mkdir_p();
|
||||
cargo_util::paths::write(
|
||||
&cargo_home.join("config.toml"),
|
||||
r#"
|
||||
cargo_util::paths::append(
|
||||
&cargo_home.join("config"),
|
||||
br#"
|
||||
[registry]
|
||||
default = "dummy-registry"
|
||||
|
||||
[registries.dummy-registry]
|
||||
index = "https://127.0.0.1/index"
|
||||
default = "alternative"
|
||||
"#,
|
||||
)
|
||||
.unwrap();
|
||||
@ -391,12 +388,12 @@ fn default_registry_configured() {
|
||||
.arg("a-new-token")
|
||||
.with_stderr(
|
||||
"\
|
||||
[UPDATING] crates.io index
|
||||
[LOGIN] token for `crates.io` saved
|
||||
[UPDATING] `alternative` index
|
||||
[LOGIN] token for `alternative` saved
|
||||
",
|
||||
)
|
||||
.run();
|
||||
|
||||
check_token(Some("a-new-token"), None);
|
||||
check_token(None, Some("alternative"));
|
||||
check_token(None, None);
|
||||
check_token(Some("a-new-token"), Some("alternative"));
|
||||
}
|
||||
|
@ -105,18 +105,18 @@ fn default_registry_configured() {
|
||||
.masquerade_as_nightly_cargo(&["cargo-logout"])
|
||||
.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.
|
||||
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.
|
||||
",
|
||||
)
|
||||
.run();
|
||||
check_token(Some("dummy-token"), Some("dummy-registry"));
|
||||
check_token(None, None);
|
||||
check_token(None, Some("dummy-registry"));
|
||||
check_token(Some("crates-io-token"), None);
|
||||
|
||||
cargo_process("logout -Zunstable-options")
|
||||
.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();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user