count calls to credential process

This commit is contained in:
Jacob Finkelman 2022-12-21 21:46:18 +00:00
parent d464dbbb5e
commit b6adac1a6b
2 changed files with 22 additions and 4 deletions

View file

@ -429,7 +429,7 @@ fn auth_token_optional(
}
};
if mutation.is_none() {
if independent_of_endpoint || mutation.is_none() {
cache.insert(
url.clone(),
CredentialCacheValue {
@ -582,7 +582,7 @@ fn run_command(
}
}
// todo: PASETO with process
let independent_of_endpoint = false;
let independent_of_endpoint = true;
let action_str = match action {
Action::Get => "get",
Action::Store(_) => "store",

View file

@ -2,7 +2,7 @@
use cargo_test_support::registry::{Package, TestRegistry};
use cargo_test_support::{basic_manifest, cargo_process, paths, project, registry, Project};
use std::fs;
use std::fs::{self, read_to_string};
fn toml_bin(proj: &Project, name: &str) -> String {
proj.bin(name).display().to_string().replace('\\', "\\\\")
@ -168,7 +168,22 @@ fn get_token_test() -> (Project, TestRegistry) {
let cred_proj = project()
.at("cred_proj")
.file("Cargo.toml", &basic_manifest("test-cred", "1.0.0"))
.file("src/main.rs", r#"fn main() { println!("sekrit"); } "#)
.file(
"src/main.rs",
r#"
use std::fs::File;
use std::io::Write;
fn main() {
let mut f = File::options()
.write(true)
.create(true)
.append(true)
.open("runs.log")
.unwrap();
write!(f, "+");
println!("sekrit");
} "#,
)
.build();
cred_proj.cargo("build").run();
@ -219,6 +234,9 @@ fn publish() {
",
)
.run();
let calls = read_to_string(p.root().join("runs.log")).unwrap().len();
assert_eq!(calls, 1);
}
#[cargo_test]