Skip to content

Commit 6b33ff3

Browse files
committed
Merge branch 'main' into feature/cert-verification-port-handling
2 parents d9cffe4 + b385ab5 commit 6b33ff3

26 files changed

+312
-191
lines changed

Cargo.lock

Lines changed: 18 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ debug = 1
4141
async-trait = "0.1"
4242
base64 = "0.22"
4343
brotli = "8.0"
44+
build-print = "1.0.1"
4445
bytes = "1.11"
4546
chacha20poly1305 = "0.10"
4647
chrono = "0.4.42"

crates/common/src/auction/orchestrator.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,11 @@ mod tests {
724724
"Slot-1 should still be present"
725725
);
726726
assert!(
727-
filtered.get("slot-1").unwrap().price.is_none(),
727+
filtered
728+
.get("slot-1")
729+
.expect("slot-1 should be present")
730+
.price
731+
.is_none(),
728732
"Price should still be None (not decoded yet)"
729733
);
730734
}

crates/common/src/auth.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ mod tests {
8282

8383
let response = enforce_basic_auth(&settings, &req).expect("should challenge");
8484
assert_eq!(response.get_status(), StatusCode::UNAUTHORIZED);
85-
let realm = response.get_header(header::WWW_AUTHENTICATE).unwrap();
85+
let realm = response
86+
.get_header(header::WWW_AUTHENTICATE)
87+
.expect("should have WWW-Authenticate header");
8688
assert_eq!(realm, BASIC_AUTH_REALM);
8789
}
8890

crates/common/src/backend.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ pub fn ensure_origin_backend(
8787
if scheme.eq_ignore_ascii_case("https") {
8888
builder = builder.enable_ssl().sni_hostname(host);
8989
if certificate_check {
90-
builder = builder.check_certificate(host);
90+
builder = builder
91+
.enable_ssl()
92+
.sni_hostname(host)
93+
.check_certificate(host);
9194
} else {
9295
log::warn!(
9396
"INSECURE: certificate check disabled for backend: {}",

crates/common/src/cookies.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ mod tests {
8383
let jar = parse_cookies_to_jar(header_value);
8484

8585
assert!(jar.iter().count() == 2);
86-
assert_eq!(jar.get("c1").unwrap().value(), "v1");
87-
assert_eq!(jar.get("c2").unwrap().value(), "v2");
86+
assert_eq!(jar.get("c1").expect("should have cookie c1").value(), "v1");
87+
assert_eq!(jar.get("c2").expect("should have cookie c2").value(), "v2");
8888
}
8989

9090
#[test]
@@ -93,7 +93,7 @@ mod tests {
9393
let jar = parse_cookies_to_jar(cookie_str);
9494

9595
assert!(jar.iter().count() == 1);
96-
assert_eq!(jar.get("c1").unwrap().value(), "v2");
96+
assert_eq!(jar.get("c1").expect("should have cookie c1").value(), "v2");
9797
}
9898

9999
#[test]
@@ -120,8 +120,8 @@ mod tests {
120120
.expect("should have cookie jar");
121121

122122
assert!(jar.iter().count() == 2);
123-
assert_eq!(jar.get("c1").unwrap().value(), "v1");
124-
assert_eq!(jar.get("c2").unwrap().value(), "v2");
123+
assert_eq!(jar.get("c1").expect("should have cookie c1").value(), "v1");
124+
assert_eq!(jar.get("c2").expect("should have cookie c2").value(), "v2");
125125
}
126126

127127
#[test]

crates/common/src/html_processor.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,8 @@ mod tests {
521521
let mut output = Vec::new();
522522
pipeline
523523
.process(Cursor::new(html.as_bytes()), &mut output)
524-
.unwrap();
525-
let processed = String::from_utf8(output).unwrap();
524+
.expect("pipeline should process HTML");
525+
let processed = String::from_utf8(output).expect("output should be valid UTF-8");
526526

527527
assert!(processed.contains("keep-me"));
528528
assert!(!processed.contains("remove-me"));
@@ -554,9 +554,9 @@ mod tests {
554554
let mut output = Vec::new();
555555
pipeline
556556
.process(Cursor::new(html.as_bytes()), &mut output)
557-
.unwrap();
557+
.expect("pipeline should process HTML");
558558

559-
let result = String::from_utf8(output).unwrap();
559+
let result = String::from_utf8(output).expect("output should be valid UTF-8");
560560
assert!(result.contains(r#"href="https://test.example.com/page""#));
561561
assert!(result.contains(r#"href="//test.example.com/proto""#));
562562
assert!(result.contains(r#"href="test.example.com/bare""#));
@@ -615,8 +615,8 @@ mod tests {
615615
let mut output = Vec::new();
616616
pipeline
617617
.process(Cursor::new(html.as_bytes()), &mut output)
618-
.unwrap();
619-
let result = String::from_utf8(output).unwrap();
618+
.expect("pipeline should process HTML");
619+
let result = String::from_utf8(output).expect("output should be valid UTF-8");
620620

621621
// Assertions - only URL attribute replacements are expected
622622
// Check URL replacements (not all occurrences will be replaced since
@@ -717,8 +717,10 @@ mod tests {
717717

718718
// Compress
719719
let mut encoder = GzEncoder::new(Vec::new(), GzCompression::default());
720-
encoder.write_all(html.as_bytes()).unwrap();
721-
let compressed_input = encoder.finish().unwrap();
720+
encoder
721+
.write_all(html.as_bytes())
722+
.expect("should write to gzip encoder");
723+
let compressed_input = encoder.finish().expect("should finish gzip encoding");
722724

723725
println!("Compressed input size: {} bytes", compressed_input.len());
724726

@@ -738,7 +740,7 @@ mod tests {
738740
let mut compressed_output = Vec::new();
739741
pipeline
740742
.process(Cursor::new(&compressed_input), &mut compressed_output)
741-
.unwrap();
743+
.expect("pipeline should process gzipped HTML");
742744

743745
// Ensure we produced output
744746
assert!(
@@ -749,7 +751,9 @@ mod tests {
749751
// Decompress and verify
750752
let mut decoder = GzDecoder::new(&compressed_output[..]);
751753
let mut decompressed = String::new();
752-
decoder.read_to_string(&mut decompressed).unwrap();
754+
decoder
755+
.read_to_string(&mut decompressed)
756+
.expect("should decompress gzip output");
753757

754758
let remaining_urls = decompressed.matches("www.test-publisher.com").count();
755759
let replaced_urls = decompressed

crates/common/src/http_util.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,19 @@ pub fn verify_clear_url_signature(settings: &Settings, clear_url: &str, token: &
277277
/// 2) Base64-decode the `x1||nonce||ciphertext+tag` bytes
278278
/// 3) Compute SHA-256 over those bytes
279279
/// 4) Return Base64 URL-safe (no padding) digest as `tstoken`
280+
///
281+
/// # Panics
282+
///
283+
/// This function will not panic under normal circumstances. The internal base64 decode
284+
/// cannot fail because it operates on data that was just encoded by `encode_url`.
280285
#[must_use]
281286
pub fn compute_encrypted_sha256_token(settings: &Settings, full_url: &str) -> String {
282287
// Encrypt deterministically using existing helper
283288
let enc = encode_url(settings, full_url);
284289
// Decode to raw bytes (x1 + nonce + ciphertext+tag)
285-
let raw = URL_SAFE_NO_PAD.decode(enc.as_bytes()).unwrap_or_default();
290+
let raw = URL_SAFE_NO_PAD
291+
.decode(enc.as_bytes())
292+
.expect("decode must succeed for just-encoded data");
286293
let digest = Sha256::digest(&raw);
287294
URL_SAFE_NO_PAD.encode(digest)
288295
}

crates/common/src/integrations/adserver_mock.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -470,20 +470,26 @@ mod tests {
470470

471471
auction_request.context.insert(
472472
"provider_responses".to_string(),
473-
serde_json::to_value(&bidder_responses).unwrap(),
473+
serde_json::to_value(&bidder_responses).expect("should serialize bidder responses"),
474474
);
475475

476476
let mediation_req = provider
477477
.build_mediation_request(&auction_request, &bidder_responses)
478-
.unwrap();
478+
.expect("should build mediation request");
479479

480480
// Verify structure
481481
assert_eq!(mediation_req["id"], "test-auction-123");
482-
assert_eq!(mediation_req["imp"].as_array().unwrap().len(), 1);
482+
assert_eq!(
483+
mediation_req["imp"]
484+
.as_array()
485+
.expect("imp should be array")
486+
.len(),
487+
1
488+
);
483489
assert_eq!(
484490
mediation_req["ext"]["bidder_responses"]
485491
.as_array()
486-
.unwrap()
492+
.expect("bidder_responses should be array")
487493
.len(),
488494
2
489495
);

crates/common/src/integrations/didomi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ mod tests {
261261
let integration = DidomiIntegration::new(Arc::new(config(true)));
262262
let url = integration
263263
.build_target_url("https://sdk.privacy-center.org", "/loader.js", Some("v=1"))
264-
.unwrap();
264+
.expect("should build target URL");
265265
assert_eq!(url, "https://sdk.privacy-center.org/loader.js?v=1");
266266
}
267267

0 commit comments

Comments
 (0)