Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
38 changes: 38 additions & 0 deletions crates/trusted-server-adapter-fastly/src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,44 @@ mod tests {
);
}

#[test]
fn edge_request_to_fastly_preserves_query_encoding_order_and_duplicates() {
let expected_query = "space=a+b&plus=%2B&quote=%27&empty=&x=1&x=2&country=US&region=CA";
let request = request_builder()
.method("GET")
.uri(format!(
"https://sdk.example.com/key/loader.js?{expected_query}"
))
.body(Body::empty())
.expect("should build request with encoded query");

let fastly_req = edge_request_to_fastly(request).expect("should convert request");

assert_eq!(
fastly_req.get_url().query(),
Some(expected_query),
"should preserve query encoding and order across Fastly conversion"
);
assert_eq!(
fastly_req
.get_url()
.query_pairs()
.filter(|(name, _)| name.eq_ignore_ascii_case("country"))
.count(),
1,
"should retain exactly one country pair"
);
assert_eq!(
fastly_req
.get_url()
.query_pairs()
.filter(|(name, _)| name.eq_ignore_ascii_case("region"))
.count(),
1,
"should retain exactly one region pair"
);
}

// --- FastlyPlatformBackend::predict_name --------------------------------

#[test]
Expand Down
31 changes: 31 additions & 0 deletions crates/trusted-server-core/src/config_payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub fn settings_from_config_blob(
#[cfg(test)]
mod tests {
use super::*;
use crate::integrations::didomi::DidomiIntegrationConfig;
use crate::redacted::Redacted;
use crate::test_support::tests::crate_test_settings_str;
use serde::Deserialize;
Expand Down Expand Up @@ -99,6 +100,36 @@ mod tests {
);
}

#[test]
fn didomi_geo_query_parameters_survive_blob_round_trip() {
let mut original = test_settings();
original
.integrations
.insert_config(
"didomi",
&DidomiIntegrationConfig {
enabled: true,
geo_query_parameters: true,
proxy_path: None,
sdk_origin: "https://sdk.example.com".to_string(),
api_origin: "https://api.example.com".to_string(),
},
)
.expect("should insert Didomi configuration");

let reconstructed = settings_from_config_blob(&envelope_json(&original))
.expect("should reconstruct settings");
let config = reconstructed
.integration_config::<DidomiIntegrationConfig>("didomi")
.expect("should read Didomi configuration")
.expect("should enable Didomi");

assert!(
config.geo_query_parameters,
"should preserve Didomi geo opt-in"
);
}

#[test]
fn legacy_blob_without_rewrite_creatives_preserves_rewriting() {
let data =
Expand Down
Loading
Loading