Skip to content

Commit

Permalink
count calls to credential process
Browse files Browse the repository at this point in the history
  • Loading branch information
Eh2406 committed Dec 22, 2022
1 parent d464dbb commit b6adac1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/cargo/util/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ fn auth_token_optional(
}
};

if mutation.is_none() {
if independent_of_endpoint || mutation.is_none() {
cache.insert(
url.clone(),
CredentialCacheValue {
Expand Down Expand Up @@ -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",
Expand Down
22 changes: 20 additions & 2 deletions tests/testsuite/credential_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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('\\', "\\\\")
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit b6adac1

Please sign in to comment.