Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4506480
fix(node): gate GET /ipfs/{cid} on reachable allowed-set, not deny-se…
Gravirei Jun 30, 2026
3aa7bf0
perf(ipfs): check object existence before allowed-blob walk
Gravirei Jun 30, 2026
63580c7
refactor(ipfs): improve formatting and readability in get_by_cid func…
Gravirei Jun 30, 2026
002f354
refactor(ipfs): streamline object retrieval by separating type and co…
Gravirei Jun 30, 2026
f2c91a8
docs(ipfs): update get_by_cid comment to reflect split object retrieval
Gravirei Jul 1, 2026
0b7c494
Merge remote-tracking branch 'upstream/main'
Gravirei Jul 1, 2026
03ba714
Run cargo fmt on store.rs
Gravirei Jul 1, 2026
03c90f8
Merge remote-tracking branch 'upstream/main'
Gravirei Jul 2, 2026
94bb216
Merge remote-tracking branch 'upstream/main'
Gravirei Jul 3, 2026
79650df
Merge remote-tracking branch 'upstream/main'
Gravirei Jul 5, 2026
26d8d48
Merge remote-tracking branch 'upstream/main'
Gravirei Jul 6, 2026
8c51c63
Merge remote-tracking branch 'upstream/main'
Gravirei Jul 7, 2026
69d64c5
Merge remote-tracking branch 'upstream/main'
Gravirei Jul 9, 2026
8d0f41c
test(gl): add tests for iCaptcha transparent retry flow (#167)
Gravirei Jul 9, 2026
cb8761d
fix(clippy): remove redundant borrow in format! arg
Gravirei Jul 9, 2026
d98e202
fix(review): use runtime GITLAWB_ICAPTCHA_INSECURE flag instead of cf…
Gravirei Jul 9, 2026
41d277e
fix(review): set mock expectations at creation time, tighten insecure…
Gravirei Jul 9, 2026
5698c2e
fix(test): serialize icaptcha integration tests with global Mutex to …
Gravirei Jul 9, 2026
edaf238
fix(icaptcha): compare origins (scheme+host+port) in resolve_solver_u…
Gravirei Jul 10, 2026
2f25fb3
fix(test): save/restore inherited iCaptcha env vars instead of uncond…
Gravirei Jul 10, 2026
58769e7
fix(test): constrain negative send_once mocks with Matcher::Missing s…
Gravirei Jul 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(test): save/restore inherited iCaptcha env vars instead of uncond…
…itional remove; share lock in icaptcha-client tests
  • Loading branch information
Gravirei committed Jul 10, 2026
commit 2f25fb3ae69ac562f1892530ee1562b04411d35f
24 changes: 20 additions & 4 deletions crates/gl/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ mod tests {
use super::*;
use gitlawb_core::identity::Keypair;
use mockito::Server;
use std::ffi::OsString;
use std::sync::{Mutex, MutexGuard};

/// Serializes the two integration tests that touch the process-global
Expand Down Expand Up @@ -418,26 +419,41 @@ mod tests {
// ── send_signed iCaptcha retry (full integration) ────────────────────

/// Set GITLAWB_ICAPTCHA_URL and GITLAWB_ICAPTCHA_INSECURE so the iCaptcha
/// client trusts a local mockito HTTP server, cleaning them up on drop.
/// client trusts a local mockito HTTP server, restoring any prior values on
/// drop so a test run launched with those variables keeps working.
/// Holds [`ICAPTCHA_ENV_LOCK`] for its lifetime so concurrent tests don't
/// race on the process-global env vars.
struct IcaptchaEnv {
_lock: MutexGuard<'static, ()>,
prev_url: Option<OsString>,
prev_insecure: Option<OsString>,
}

impl IcaptchaEnv {
fn new(url: &str) -> Self {
let lock = ICAPTCHA_ENV_LOCK.lock().unwrap();
let prev_url = std::env::var_os("GITLAWB_ICAPTCHA_URL");
let prev_insecure = std::env::var_os("GITLAWB_ICAPTCHA_INSECURE");
std::env::set_var("GITLAWB_ICAPTCHA_URL", url);
std::env::set_var("GITLAWB_ICAPTCHA_INSECURE", "1");
IcaptchaEnv { _lock: lock }
IcaptchaEnv {
_lock: lock,
prev_url,
prev_insecure,
}
}
}

impl Drop for IcaptchaEnv {
fn drop(&mut self) {
std::env::remove_var("GITLAWB_ICAPTCHA_URL");
std::env::remove_var("GITLAWB_ICAPTCHA_INSECURE");
match self.prev_url.take() {
Some(v) => std::env::set_var("GITLAWB_ICAPTCHA_URL", v),
None => std::env::remove_var("GITLAWB_ICAPTCHA_URL"),
}
match self.prev_insecure.take() {
Some(v) => std::env::set_var("GITLAWB_ICAPTCHA_INSECURE", v),
None => std::env::remove_var("GITLAWB_ICAPTCHA_INSECURE"),
}
}
}

Expand Down
40 changes: 32 additions & 8 deletions crates/icaptcha-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,37 @@ fn interactive_prompt(challenge: &Challenge) -> Option<String> {
#[cfg(test)]
mod tests {
use super::*;
use std::ffi::OsString;
use std::sync::{Mutex, MutexGuard};

/// Serializes tests that touch the process-global
/// `GITLAWB_ICAPTCHA_INSECURE` env var so they never race.
static ICAPTCHA_ENV_LOCK: Mutex<()> = Mutex::new(());

/// Set `GITLAWB_ICAPTCHA_INSECURE` for the test lifetime, restoring any
/// prior value on drop.
struct InsecureEnv {
_lock: MutexGuard<'static, ()>,
prev: Option<OsString>,
}

impl InsecureEnv {
fn new() -> Self {
let lock = ICAPTCHA_ENV_LOCK.lock().unwrap();
let prev = std::env::var_os("GITLAWB_ICAPTCHA_INSECURE");
std::env::set_var("GITLAWB_ICAPTCHA_INSECURE", "1");
InsecureEnv { _lock: lock, prev }
}
}

impl Drop for InsecureEnv {
fn drop(&mut self) {
match self.prev.take() {
Some(v) => std::env::set_var("GITLAWB_ICAPTCHA_INSECURE", v),
None => std::env::remove_var("GITLAWB_ICAPTCHA_INSECURE"),
}
}
}

// ── P1: hostile error bodies must not reach the terminal raw ──────────

Expand Down Expand Up @@ -434,14 +465,7 @@ mod tests {
// With GITLAWB_ICAPTCHA_INSECURE=1, two loopback URLs on different
// ports must be treated as distinct origins so a hostile node cannot
// redirect the bearer key to a different listener on localhost.
struct _EnvGuard;
impl Drop for _EnvGuard {
fn drop(&mut self) {
std::env::remove_var("GITLAWB_ICAPTCHA_INSECURE");
}
}
std::env::set_var("GITLAWB_ICAPTCHA_INSECURE", "1");
let _guard = _EnvGuard;
let _env = InsecureEnv::new();

let op = "http://localhost:3000";
let (url, key_trusted) = resolve_solver_url(Some("http://localhost:9000"), Some(op));
Expand Down
Loading