Stabilize cargo logout

This commit is contained in:
Eric Huss 2023-04-09 10:19:36 -07:00
parent 96f8d6ced8
commit a70c108961
20 changed files with 493 additions and 58 deletions

View File

@ -10,11 +10,6 @@ pub fn cli() -> Command {
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
if !config.cli_unstable().credential_process {
config
.cli_unstable()
.fail_if_stable_command(config, "logout", 8933)?;
}
let registry = args.registry(config)?;
ops::registry_logout(config, registry.as_deref())?;
Ok(())

View File

@ -48,4 +48,4 @@ Take care to keep the token secret, it should not be shared with anyone else.
cargo login
## SEE ALSO
{{man "cargo" 1}}, {{man "cargo-publish" 1}}
{{man "cargo" 1}}, {{man "cargo-logout" 1}}, {{man "cargo-publish" 1}}

View File

@ -0,0 +1,57 @@
# cargo-logout(1)
## NAME
cargo-logout --- Remove an API token from the registry locally
## SYNOPSIS
`cargo logout` [_options_]
## DESCRIPTION
This command will remove the API token from the local credential storage.
Credentials are stored in `$CARGO_HOME/credentials.toml` where `$CARGO_HOME`
defaults to `.cargo` in your home directory.
If `--registry` is not specified, then the credentials for the default
registry will be removed (configured by
[`registry.default`](../reference/config.html#registrydefault), which defaults
to <https://crates.io/>).
This will not revoke the token on the server. If you need to revoke the token,
visit the registry website and follow its instructions (see
<https://crates.io/me> to revoke the token for <https://crates.io/>).
## OPTIONS
### Logout Options
{{#options}}
{{> options-registry }}
{{/options}}
### Display Options
{{#options}}
{{> options-display }}
{{/options}}
{{> section-options-common }}
{{> section-environment }}
{{> section-exit-status }}
## EXAMPLES
1. Remove the default registry token:
cargo logout
2. Remove the token for a specific registry:
cargo logout --registry my-registry
## SEE ALSO
{{man "cargo" 1}}, {{man "cargo-login" 1}}

View File

@ -102,6 +102,9 @@ available at <https://rust-lang.org>.
{{man "cargo-login" 1}}\
&nbsp;&nbsp;&nbsp;&nbsp;Save an API token from the registry locally.
{{man "cargo-logout" 1}}\
&nbsp;&nbsp;&nbsp;&nbsp;Remove an API token from the registry locally.
{{man "cargo-owner" 1}}\
&nbsp;&nbsp;&nbsp;&nbsp;Manage the owners of a crate on the registry.

View File

@ -107,5 +107,5 @@ EXAMPLES
cargo login
SEE ALSO
cargo(1), cargo-publish(1)
cargo(1), cargo-logout(1), cargo-publish(1)

View File

@ -0,0 +1,115 @@
CARGO-LOGOUT(1)
NAME
cargo-logout — Remove an API token from the registry locally
SYNOPSIS
cargo logout [options]
DESCRIPTION
This command will remove the API token from the local credential
storage. Credentials are stored in $CARGO_HOME/credentials.toml where
$CARGO_HOME defaults to .cargo in your home directory.
If --registry is not specified, then the credentials for the default
registry will be removed (configured by registry.default
<https://doc.rust-lang.org/cargo/reference/config.html#registrydefault>,
which defaults to <https://crates.io/>).
This will not revoke the token on the server. If you need to revoke the
token, visit the registry website and follow its instructions (see
<https://crates.io/me> to revoke the token for <https://crates.io/>).
OPTIONS
Logout Options
--registry registry
Name of the registry to use. Registry names are defined in Cargo
config files
<https://doc.rust-lang.org/cargo/reference/config.html>. If not
specified, the default registry is used, which is defined by the
registry.default config key which defaults to crates-io.
Display Options
-v, --verbose
Use verbose output. May be specified twice for “very verbose”
output which includes extra output such as dependency warnings and
build script output. May also be specified with the term.verbose
config value
<https://doc.rust-lang.org/cargo/reference/config.html>.
-q, --quiet
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.
--color when
Control when colored output is used. Valid values:
o auto (default): Automatically detect if color support is
available on the terminal.
o always: Always display colors.
o never: Never display colors.
May also be specified with the term.color config value
<https://doc.rust-lang.org/cargo/reference/config.html>.
Common Options
+toolchain
If Cargo has been installed with rustup, and the first argument to
cargo begins with +, it will be interpreted as a rustup toolchain
name (such as +stable or +nightly). See the rustup documentation
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.
--config KEY=VALUE or PATH
Overrides a Cargo configuration value. The argument should be in
TOML syntax of KEY=VALUE, or provided as a path to an extra
configuration file. This flag may be specified multiple times. See
the command-line overrides section
<https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides>
for more information.
-C PATH
Changes the current working directory before executing any specified
operations. This affects things like where cargo looks by default
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example. This
option must appear before the command name, for example cargo -C
path/to/my-project build.
This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).
-h, --help
Prints help information.
-Z flag
Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
details.
ENVIRONMENT
See the reference
<https://doc.rust-lang.org/cargo/reference/environment-variables.html>
for details on environment variables that Cargo reads.
EXIT STATUS
o 0: Cargo succeeded.
o 101: Cargo failed to complete.
EXAMPLES
1. Remove the default registry token:
cargo logout
2. Remove the token for a specific registry:
cargo logout --registry my-registry
SEE ALSO
cargo(1), cargo-login(1)

View File

@ -95,6 +95,9 @@ COMMANDS
cargo-login(1)
    Save an API token from the registry locally.
cargo-logout(1)
    Remove an API token from the registry locally.
cargo-owner(1)
    Manage the owners of a crate on the registry.

View File

@ -82,6 +82,7 @@
* [cargo uninstall](commands/cargo-uninstall.md)
* [Publishing Commands](commands/publishing-commands.md)
* [cargo login](commands/cargo-login.md)
* [cargo logout](commands/cargo-logout.md)
* [cargo owner](commands/cargo-owner.md)
* [cargo package](commands/cargo-package.md)
* [cargo publish](commands/cargo-publish.md)

View File

@ -127,4 +127,4 @@ details on environment variables that Cargo reads.
cargo login
## SEE ALSO
[cargo(1)](cargo.html), [cargo-publish(1)](cargo-publish.html)
[cargo(1)](cargo.html), [cargo-logout(1)](cargo-logout.html), [cargo-publish(1)](cargo-publish.html)

View File

@ -0,0 +1,136 @@
# cargo-logout(1)
## NAME
cargo-logout --- Remove an API token from the registry locally
## SYNOPSIS
`cargo logout` [_options_]
## DESCRIPTION
This command will remove the API token from the local credential storage.
Credentials are stored in `$CARGO_HOME/credentials.toml` where `$CARGO_HOME`
defaults to `.cargo` in your home directory.
If `--registry` is not specified, then the credentials for the default
registry will be removed (configured by
[`registry.default`](../reference/config.html#registrydefault), which defaults
to <https://crates.io/>).
This will not revoke the token on the server. If you need to revoke the token,
visit the registry website and follow its instructions (see
<https://crates.io/me> to revoke the token for <https://crates.io/>).
## OPTIONS
### Logout Options
<dl>
<dt class="option-term" id="option-cargo-logout---registry"><a class="option-anchor" href="#option-cargo-logout---registry"></a><code>--registry</code> <em>registry</em></dt>
<dd class="option-desc">Name of the registry to use. Registry names are defined in <a href="../reference/config.html">Cargo config
files</a>. If not specified, the default registry is used,
which is defined by the <code>registry.default</code> config key which defaults to
<code>crates-io</code>.</dd>
</dl>
### Display Options
<dl>
<dt class="option-term" id="option-cargo-logout--v"><a class="option-anchor" href="#option-cargo-logout--v"></a><code>-v</code></dt>
<dt class="option-term" id="option-cargo-logout---verbose"><a class="option-anchor" href="#option-cargo-logout---verbose"></a><code>--verbose</code></dt>
<dd class="option-desc">Use verbose output. May be specified twice for “very verbose” output which
includes extra output such as dependency warnings and build script output.
May also be specified with the <code>term.verbose</code>
<a href="../reference/config.html">config value</a>.</dd>
<dt class="option-term" id="option-cargo-logout--q"><a class="option-anchor" href="#option-cargo-logout--q"></a><code>-q</code></dt>
<dt class="option-term" id="option-cargo-logout---quiet"><a class="option-anchor" href="#option-cargo-logout---quiet"></a><code>--quiet</code></dt>
<dd class="option-desc">Do not print cargo log messages.
May also be specified with the <code>term.quiet</code>
<a href="../reference/config.html">config value</a>.</dd>
<dt class="option-term" id="option-cargo-logout---color"><a class="option-anchor" href="#option-cargo-logout---color"></a><code>--color</code> <em>when</em></dt>
<dd class="option-desc">Control when colored output is used. Valid values:</p>
<ul>
<li><code>auto</code> (default): Automatically detect if color support is available on the
terminal.</li>
<li><code>always</code>: Always display colors.</li>
<li><code>never</code>: Never display colors.</li>
</ul>
<p>May also be specified with the <code>term.color</code>
<a href="../reference/config.html">config value</a>.</dd>
</dl>
### Common Options
<dl>
<dt class="option-term" id="option-cargo-logout-+toolchain"><a class="option-anchor" href="#option-cargo-logout-+toolchain"></a><code>+</code><em>toolchain</em></dt>
<dd class="option-desc">If Cargo has been installed with rustup, and the first argument to <code>cargo</code>
begins with <code>+</code>, it will be interpreted as a rustup toolchain name (such
as <code>+stable</code> or <code>+nightly</code>).
See the <a href="https://rust-lang.github.io/rustup/overrides.html">rustup documentation</a>
for more information about how toolchain overrides work.</dd>
<dt class="option-term" id="option-cargo-logout---config"><a class="option-anchor" href="#option-cargo-logout---config"></a><code>--config</code> <em>KEY=VALUE</em> or <em>PATH</em></dt>
<dd class="option-desc">Overrides a Cargo configuration value. The argument should be in TOML syntax of <code>KEY=VALUE</code>,
or provided as a path to an extra configuration file. This flag may be specified multiple times.
See the <a href="../reference/config.html#command-line-overrides">command-line overrides section</a> for more information.</dd>
<dt class="option-term" id="option-cargo-logout--C"><a class="option-anchor" href="#option-cargo-logout--C"></a><code>-C</code> <em>PATH</em></dt>
<dd class="option-desc">Changes the current working directory before executing any specified operations. This affects
things like where cargo looks by default for the project manifest (<code>Cargo.toml</code>), as well as
the directories searched for discovering <code>.cargo/config.toml</code>, for example. This option must
appear before the command name, for example <code>cargo -C path/to/my-project build</code>.</p>
<p>This option is only available on the <a href="https://doc.rust-lang.org/book/appendix-07-nightly-rust.html">nightly
channel</a> and
requires the <code>-Z unstable-options</code> flag to enable (see
<a href="https://github.com/rust-lang/cargo/issues/10098">#10098</a>).</dd>
<dt class="option-term" id="option-cargo-logout--h"><a class="option-anchor" href="#option-cargo-logout--h"></a><code>-h</code></dt>
<dt class="option-term" id="option-cargo-logout---help"><a class="option-anchor" href="#option-cargo-logout---help"></a><code>--help</code></dt>
<dd class="option-desc">Prints help information.</dd>
<dt class="option-term" id="option-cargo-logout--Z"><a class="option-anchor" href="#option-cargo-logout--Z"></a><code>-Z</code> <em>flag</em></dt>
<dd class="option-desc">Unstable (nightly-only) flags to Cargo. Run <code>cargo -Z help</code> for details.</dd>
</dl>
## ENVIRONMENT
See [the reference](../reference/environment-variables.html) for
details on environment variables that Cargo reads.
## EXIT STATUS
* `0`: Cargo succeeded.
* `101`: Cargo failed to complete.
## EXAMPLES
1. Remove the default registry token:
cargo logout
2. Remove the token for a specific registry:
cargo logout --registry my-registry
## SEE ALSO
[cargo(1)](cargo.html), [cargo-login(1)](cargo-login.html)

View File

@ -102,6 +102,9 @@ available at <https://rust-lang.org>.
[cargo-login(1)](cargo-login.html)\
&nbsp;&nbsp;&nbsp;&nbsp;Save an API token from the registry locally.
[cargo-logout(1)](cargo-logout.html)\
&nbsp;&nbsp;&nbsp;&nbsp;Remove an API token from the registry locally.
[cargo-owner(1)](cargo-owner.html)\
&nbsp;&nbsp;&nbsp;&nbsp;Manage the owners of a crate on the registry.

View File

@ -1,5 +1,6 @@
# Publishing Commands
* [cargo login](cargo-login.md)
* [cargo logout](cargo-logout.md)
* [cargo owner](cargo-owner.md)
* [cargo package](cargo-package.md)
* [cargo publish](cargo-publish.md)

View File

@ -296,7 +296,7 @@ Cargo will search `PATH` for its executable.
Configuration values with sensitive information are stored in the
`$CARGO_HOME/credentials.toml` file. This file is automatically created and updated
by [`cargo login`]. It follows the same format as Cargo config files.
by [`cargo login`] and [`cargo logout`]. It follows the same format as Cargo config files.
```toml
[registry]
@ -1193,6 +1193,7 @@ Sets the width for progress bar.
[`cargo bench`]: ../commands/cargo-bench.md
[`cargo login`]: ../commands/cargo-login.md
[`cargo logout`]: ../commands/cargo-logout.md
[`cargo doc`]: ../commands/cargo-doc.md
[`cargo new`]: ../commands/cargo-new.md
[`cargo publish`]: ../commands/cargo-publish.md

View File

@ -34,6 +34,10 @@ This command will inform Cargo of your API token and store it locally in your
shared with anyone else. If it leaks for any reason, you should revoke it
immediately.
> **Note**: The [`cargo logout`] command can be used to remove the token from
> `credentials.toml`. This can be useful if you no longer need it stored on
> the local machine.
### Before publishing a new crate
Keep in mind that crate names on [crates.io] are allocated on a first-come-first-serve
@ -264,6 +268,7 @@ request the org owner to do so.
[Rust API Guidelines]: https://rust-lang.github.io/api-guidelines/
[`cargo login`]: ../commands/cargo-login.md
[`cargo logout`]: ../commands/cargo-logout.md
[`cargo package`]: ../commands/cargo-package.md
[`cargo publish`]: ../commands/cargo-publish.md
[`categories`]: manifest.md#the-categories-field

View File

@ -101,7 +101,6 @@ Each new feature described below should explain how to use it.
* [`cargo config`](#cargo-config) --- Adds a new subcommand for viewing config files.
* Registries
* [credential-process](#credential-process) --- Adds support for fetching registry tokens from an external authentication program.
* [`cargo logout`](#cargo-logout) --- Adds the `logout` command to remove the currently saved registry token.
* [publish-timeout](#publish-timeout) --- Controls the timeout between uploading the crate and being available in the index
* [registry-auth](#registry-auth) --- Adds support for authenticated registries, and generate registry authentication tokens using asymmetric cryptography.
* Other
@ -905,12 +904,11 @@ The `credential-process` feature adds a config setting to fetch registry
authentication tokens by calling an external process.
Token authentication is used by the [`cargo login`], [`cargo publish`],
[`cargo owner`], and [`cargo yank`] commands. Additionally, this feature adds
a new `cargo logout` command.
[`cargo owner`], [`cargo yank`], and [`cargo logout`] commands.
To use this feature, you must pass the `-Z credential-process` flag on the
command-line. Additionally, you must remove any current tokens currently saved
in the [`credentials.toml` file] (which can be done with the new `logout` command).
in the [`credentials.toml` file] (which can be done with the [`cargo logout`] command).
#### `credential-process` Configuration
@ -999,7 +997,7 @@ A basic authenticator is a process that returns a token on stdout. Newlines
will be trimmed. The process inherits the user's stdin and stderr. It should
exit 0 on success, and nonzero on error.
With this form, [`cargo login`] and `cargo logout` are not supported and
With this form, [`cargo login`] and [`cargo logout`] are not supported and
return an error if used.
##### Cargo authenticator
@ -1044,28 +1042,8 @@ The following environment variables will be provided to the executed command:
* `CARGO_REGISTRY_INDEX_URL` --- The URL of the registry index.
* `CARGO_REGISTRY_NAME_OPT` --- Optional name of the registry. Should not be used as a storage key. Not always available.
#### `cargo logout`
A new `cargo logout` command has been added to make it easier to remove a
token from storage. This supports both [`credentials.toml` file] tokens and
`credential-process` tokens.
When used with `credentials.toml` file tokens, it needs the `-Z unstable-options`
command-line option:
```console
cargo logout -Z unstable-options
```
When used with the `credential-process` config, use the `-Z
credential-process` command-line option:
```console
cargo logout -Z credential-process
```
[`cargo login`]: ../commands/cargo-login.md
[`cargo logout`]: ../commands/cargo-logout.md
[`cargo publish`]: ../commands/cargo-publish.md
[`cargo owner`]: ../commands/cargo-owner.md
[`cargo yank`]: ../commands/cargo-yank.md
@ -1488,4 +1466,8 @@ terminal where Cargo can automatically detect the width.
Sparse registry support has been stabilized in the 1.68 release.
See [Registry Protocols](registries.md#registry-protocols) for more information.
#### `cargo logout`
The [`cargo logout`] command has been stabilized in the 1.70 release.
[target triple]: ../appendix/glossary.md#target '"target" (glossary)'

View File

@ -132,4 +132,4 @@ cargo login
.RE
.RE
.SH "SEE ALSO"
\fBcargo\fR(1), \fBcargo\-publish\fR(1)
\fBcargo\fR(1), \fBcargo\-logout\fR(1), \fBcargo\-publish\fR(1)

147
src/etc/man/cargo-logout.1 Normal file
View File

@ -0,0 +1,147 @@
'\" t
.TH "CARGO\-LOGOUT" "1"
.nh
.ad l
.ss \n[.ss] 0
.SH "NAME"
cargo\-logout \[em] Remove an API token from the registry locally
.SH "SYNOPSIS"
\fBcargo logout\fR [\fIoptions\fR]
.SH "DESCRIPTION"
This command will remove the API token from the local credential storage.
Credentials are stored in \fB$CARGO_HOME/credentials.toml\fR where \fB$CARGO_HOME\fR
defaults to \fB\&.cargo\fR in your home directory.
.sp
If \fB\-\-registry\fR is not specified, then the credentials for the default
registry will be removed (configured by
\fI\f(BIregistry.default\fI\fR <https://doc.rust\-lang.org/cargo/reference/config.html#registrydefault>, which defaults
to <https://crates.io/>).
.sp
This will not revoke the token on the server. If you need to revoke the token,
visit the registry website and follow its instructions (see
<https://crates.io/me> to revoke the token for <https://crates.io/>).
.SH "OPTIONS"
.SS "Logout Options"
.sp
\fB\-\-registry\fR \fIregistry\fR
.RS 4
Name of the registry to use. Registry names are defined in \fICargo config
files\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&. If not specified, the default registry is used,
which is defined by the \fBregistry.default\fR config key which defaults to
\fBcrates\-io\fR\&.
.RE
.SS "Display Options"
.sp
\fB\-v\fR,
\fB\-\-verbose\fR
.RS 4
Use verbose output. May be specified twice for \[lq]very verbose\[rq] output which
includes extra output such as dependency warnings and build script output.
May also be specified with the \fBterm.verbose\fR
\fIconfig value\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&.
.RE
.sp
\fB\-q\fR,
\fB\-\-quiet\fR
.RS 4
Do not print cargo log messages.
May also be specified with the \fBterm.quiet\fR
\fIconfig value\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&.
.RE
.sp
\fB\-\-color\fR \fIwhen\fR
.RS 4
Control when colored output is used. Valid values:
.sp
.RS 4
\h'-04'\(bu\h'+02'\fBauto\fR (default): Automatically detect if color support is available on the
terminal.
.RE
.sp
.RS 4
\h'-04'\(bu\h'+02'\fBalways\fR: Always display colors.
.RE
.sp
.RS 4
\h'-04'\(bu\h'+02'\fBnever\fR: Never display colors.
.RE
.sp
May also be specified with the \fBterm.color\fR
\fIconfig value\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&.
.RE
.SS "Common Options"
.sp
\fB+\fR\fItoolchain\fR
.RS 4
If Cargo has been installed with rustup, and the first argument to \fBcargo\fR
begins with \fB+\fR, it will be interpreted as a rustup toolchain name (such
as \fB+stable\fR or \fB+nightly\fR).
See the \fIrustup documentation\fR <https://rust\-lang.github.io/rustup/overrides.html>
for more information about how toolchain overrides work.
.RE
.sp
\fB\-\-config\fR \fIKEY=VALUE\fR or \fIPATH\fR
.RS 4
Overrides a Cargo configuration value. The argument should be in TOML syntax of \fBKEY=VALUE\fR,
or provided as a path to an extra configuration file. This flag may be specified multiple times.
See the \fIcommand\-line overrides section\fR <https://doc.rust\-lang.org/cargo/reference/config.html#command\-line\-overrides> for more information.
.RE
.sp
\fB\-C\fR \fIPATH\fR
.RS 4
Changes the current working directory before executing any specified operations. This affects
things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as
the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. This option must
appear before the command name, for example \fBcargo \-C path/to/my\-project build\fR\&.
.sp
This option is only available on the \fInightly
channel\fR <https://doc.rust\-lang.org/book/appendix\-07\-nightly\-rust.html> and
requires the \fB\-Z unstable\-options\fR flag to enable (see
\fI#10098\fR <https://github.com/rust\-lang/cargo/issues/10098>).
.RE
.sp
\fB\-h\fR,
\fB\-\-help\fR
.RS 4
Prints help information.
.RE
.sp
\fB\-Z\fR \fIflag\fR
.RS 4
Unstable (nightly\-only) flags to Cargo. Run \fBcargo \-Z help\fR for details.
.RE
.SH "ENVIRONMENT"
See \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/environment\-variables.html> for
details on environment variables that Cargo reads.
.SH "EXIT STATUS"
.sp
.RS 4
\h'-04'\(bu\h'+02'\fB0\fR: Cargo succeeded.
.RE
.sp
.RS 4
\h'-04'\(bu\h'+02'\fB101\fR: Cargo failed to complete.
.RE
.SH "EXAMPLES"
.sp
.RS 4
\h'-04' 1.\h'+01'Remove the default registry token:
.sp
.RS 4
.nf
cargo logout
.fi
.RE
.RE
.sp
.RS 4
\h'-04' 2.\h'+01'Remove the token for a specific registry:
.sp
.RS 4
.nf
cargo logout \-\-registry my\-registry
.fi
.RE
.RE
.SH "SEE ALSO"
\fBcargo\fR(1), \fBcargo\-login\fR(1)

View File

@ -120,6 +120,10 @@ available at <https://rust\-lang.org>\&.
.br
\ \ \ \ Save an API token from the registry locally.
.sp
\fBcargo\-logout\fR(1)
.br
\ \ \ \ Remove an API token from the registry locally.
.sp
\fBcargo\-owner\fR(1)
.br
\ \ \ \ Manage the owners of a crate on the registry.

View File

@ -268,7 +268,7 @@ the credential-process configuration value must pass the \
cargo_process("logout -Z credential-process")
.replace_crates_io(registry.index_url())
.masquerade_as_nightly_cargo(&["credential-process", "cargo-logout"])
.masquerade_as_nightly_cargo(&["credential-process"])
.with_status(101)
.with_stderr(
"\
@ -377,7 +377,7 @@ fn logout() {
.unwrap();
cargo_process("logout -Z credential-process")
.masquerade_as_nightly_cargo(&["credential-process", "cargo-logout"])
.masquerade_as_nightly_cargo(&["credential-process"])
.replace_crates_io(server.index_url())
.with_stderr(
"\

View File

@ -5,31 +5,14 @@ use cargo_test_support::paths::{self, CargoPathExt};
use cargo_test_support::registry::TestRegistry;
use cargo_test_support::{cargo_process, registry};
#[cargo_test]
fn gated() {
registry::init();
cargo_process("logout")
.masquerade_as_nightly_cargo(&["cargo-logout"])
.with_status(101)
.with_stderr(
"\
[ERROR] the `cargo logout` command is unstable, pass `-Z unstable-options` to enable it
See https://github.com/rust-lang/cargo/issues/8933 for more information about \
the `cargo logout` command.
",
)
.run();
}
fn simple_logout_test(registry: &TestRegistry, reg: Option<&str>, flag: &str, note: &str) {
let msg = reg.unwrap_or("crates-io");
check_token(Some(registry.token()), reg);
let mut cargo = cargo_process(&format!("logout -Z unstable-options {}", flag));
let mut cargo = cargo_process(&format!("logout {}", flag));
if reg.is_none() {
cargo.replace_crates_io(registry.index_url());
}
cargo
.masquerade_as_nightly_cargo(&["cargo-logout"])
.with_stderr(&format!(
"\
[LOGOUT] token for `{msg}` has been removed from local storage
@ -40,12 +23,11 @@ If you need to revoke the token, visit {note} and follow the instructions there.
.run();
check_token(None, reg);
let mut cargo = cargo_process(&format!("logout -Z unstable-options {}", flag));
let mut cargo = cargo_process(&format!("logout {}", flag));
if reg.is_none() {
cargo.replace_crates_io(registry.index_url());
}
cargo
.masquerade_as_nightly_cargo(&["cargo-logout"])
.with_stderr(&format!("[LOGOUT] not currently logged in to `{msg}`"))
.run();
check_token(None, reg);