mirror of
https://github.com/rust-lang/cargo
synced 2024-09-13 21:11:44 +00:00
Add test for wrighting keys
This commit is contained in:
parent
a917fa0d4e
commit
b907a7f7ea
|
@ -1127,6 +1127,51 @@ fn login_with_token_on_stdin() {
|
||||||
assert_eq!(credentials, "[registry]\ntoken = \"some token\"\n");
|
assert_eq!(credentials, "[registry]\ntoken = \"some token\"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cargo_test]
|
||||||
|
fn login_with_asymmetric_token_and_subject_on_stdin() {
|
||||||
|
let registry = registry::init();
|
||||||
|
let credentials = paths::home().join(".cargo/credentials");
|
||||||
|
fs::remove_file(&credentials).unwrap();
|
||||||
|
cargo_process("login --key-subject=foo --secret-key -v -Z registry-auth")
|
||||||
|
.masquerade_as_nightly_cargo(&["registry-auth"])
|
||||||
|
.replace_crates_io(registry.index_url())
|
||||||
|
.with_stdout("please paste the API secret key below")
|
||||||
|
.with_stdin("some token")
|
||||||
|
.run();
|
||||||
|
let credentials = fs::read_to_string(&credentials).unwrap();
|
||||||
|
assert!(credentials.starts_with("[registry]\n"));
|
||||||
|
assert!(credentials.contains("secret-key-subject = \"foo\"\n"));
|
||||||
|
assert!(credentials.contains("secret-key = \"some token\"\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cargo_test]
|
||||||
|
fn login_with_asymmetric_token_on_stdin() {
|
||||||
|
let registry = registry::init();
|
||||||
|
let credentials = paths::home().join(".cargo/credentials");
|
||||||
|
fs::remove_file(&credentials).unwrap();
|
||||||
|
cargo_process("login --secret-key -v -Z registry-auth")
|
||||||
|
.masquerade_as_nightly_cargo(&["registry-auth"])
|
||||||
|
.replace_crates_io(registry.index_url())
|
||||||
|
.with_stdout("please paste the API secret key below")
|
||||||
|
.with_stdin("some token")
|
||||||
|
.run();
|
||||||
|
let credentials = fs::read_to_string(&credentials).unwrap();
|
||||||
|
assert_eq!(credentials, "[registry]\nsecret-key = \"some token\"\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cargo_test]
|
||||||
|
fn login_with_asymmetric_key_subject_without_key() {
|
||||||
|
let registry = registry::init();
|
||||||
|
let credentials = paths::home().join(".cargo/credentials");
|
||||||
|
fs::remove_file(&credentials).unwrap();
|
||||||
|
cargo_process("login --key-subject=foo -Z registry-auth")
|
||||||
|
.masquerade_as_nightly_cargo(&["registry-auth"])
|
||||||
|
.replace_crates_io(registry.index_url())
|
||||||
|
.with_stderr_contains("error: need a secret_key to set a key_subject")
|
||||||
|
.with_status(101)
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
|
||||||
#[cargo_test]
|
#[cargo_test]
|
||||||
fn bad_license_file_http() {
|
fn bad_license_file_http() {
|
||||||
let registry = setup_http();
|
let registry = setup_http();
|
||||||
|
|
Loading…
Reference in a new issue