Skip to content

Commit b6adac1

Browse files
committed
count calls to credential process
1 parent d464dbb commit b6adac1

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

src/cargo/util/auth.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ fn auth_token_optional(
429429
}
430430
};
431431

432-
if mutation.is_none() {
432+
if independent_of_endpoint || mutation.is_none() {
433433
cache.insert(
434434
url.clone(),
435435
CredentialCacheValue {
@@ -582,7 +582,7 @@ fn run_command(
582582
}
583583
}
584584
// todo: PASETO with process
585-
let independent_of_endpoint = false;
585+
let independent_of_endpoint = true;
586586
let action_str = match action {
587587
Action::Get => "get",
588588
Action::Store(_) => "store",

tests/testsuite/credential_process.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use cargo_test_support::registry::{Package, TestRegistry};
44
use cargo_test_support::{basic_manifest, cargo_process, paths, project, registry, Project};
5-
use std::fs;
5+
use std::fs::{self, read_to_string};
66

77
fn toml_bin(proj: &Project, name: &str) -> String {
88
proj.bin(name).display().to_string().replace('\\', "\\\\")
@@ -168,7 +168,22 @@ fn get_token_test() -> (Project, TestRegistry) {
168168
let cred_proj = project()
169169
.at("cred_proj")
170170
.file("Cargo.toml", &basic_manifest("test-cred", "1.0.0"))
171-
.file("src/main.rs", r#"fn main() { println!("sekrit"); } "#)
171+
.file(
172+
"src/main.rs",
173+
r#"
174+
use std::fs::File;
175+
use std::io::Write;
176+
fn main() {
177+
let mut f = File::options()
178+
.write(true)
179+
.create(true)
180+
.append(true)
181+
.open("runs.log")
182+
.unwrap();
183+
write!(f, "+");
184+
println!("sekrit");
185+
} "#,
186+
)
172187
.build();
173188
cred_proj.cargo("build").run();
174189

@@ -219,6 +234,9 @@ fn publish() {
219234
",
220235
)
221236
.run();
237+
238+
let calls = read_to_string(p.root().join("runs.log")).unwrap().len();
239+
assert_eq!(calls, 1);
222240
}
223241

224242
#[cargo_test]

0 commit comments

Comments
 (0)