Skip to content

Commit 41ef219

Browse files
test(webauthn): use reserved example.* domains in related_origins integration test
Swap brand.com/app.brand.org for example.org/app.example.com. RFC 2606 reserves example.* for documentation, so it cannot accidentally collide with a real party. The two-eTLD shape that exercises the related-origins fetch path is preserved.
1 parent 12f716a commit 41ef219

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

libwebauthn/tests/related_origins.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl RelatedOriginsHttpClient for StaticHttp {
4949

5050
const MAKE_CREDENTIAL_JSON: &str = r#"
5151
{
52-
"rp": {"id": "brand.com", "name": "brand.com"},
52+
"rp": {"id": "example.org", "name": "example.org"},
5353
"user": {
5454
"id": "dXNlcmlk",
5555
"name": "mario.rossi",
@@ -71,21 +71,22 @@ const GET_ASSERTION_JSON: &str = r#"
7171
{
7272
"challenge": "Y3JlZGVudGlhbHMtZm9yLWxpbnV4L2xpYndlYmF1dGhu",
7373
"timeout": 30000,
74-
"rpId": "brand.com",
74+
"rpId": "example.org",
7575
"allowCredentials": [
7676
{"type": "public-key", "id": "bXktY3JlZGVudGlhbC1pZA"}
7777
],
7878
"userVerification": "preferred"
7979
}
8080
"#;
8181

82-
// `.de` in design §8.3 substituted with `.org` (test PSL knows `.com` and
83-
// `.org`); pattern (different eTLD between caller and rp.id) is identical.
84-
const WELL_KNOWN_BODY: &str = r#"{"origins":["https://app.brand.org","https://brand.com"]}"#;
82+
// Caller and rp.id sit on different eTLDs (`example.com` vs `example.org`),
83+
// matching the §8.3 design example so the related-origins fetch path is
84+
// actually exercised.
85+
const WELL_KNOWN_BODY: &str = r#"{"origins":["https://app.example.com","https://example.org"]}"#;
8586

8687
#[tokio::test]
8788
async fn end_to_end_mock_match_via_make_credential() {
88-
let request_origin: RequestOrigin = "https://app.brand.org".parse().unwrap();
89+
let request_origin: RequestOrigin = "https://app.example.com".parse().unwrap();
8990
let http = StaticHttp {
9091
body: WELL_KNOWN_BODY,
9192
};
@@ -95,15 +96,15 @@ async fn end_to_end_mock_match_via_make_credential() {
9596
.await
9697
.unwrap();
9798

98-
assert_eq!(req.relying_party.id, "brand.com");
99+
assert_eq!(req.relying_party.id, "example.org");
99100
assert!(req
100101
.client_data_json()
101-
.contains(r#""origin":"https://app.brand.org""#));
102+
.contains(r#""origin":"https://app.example.com""#));
102103
}
103104

104105
#[tokio::test]
105106
async fn end_to_end_mock_match_via_get_assertion() {
106-
let request_origin: RequestOrigin = "https://app.brand.org".parse().unwrap();
107+
let request_origin: RequestOrigin = "https://app.example.com".parse().unwrap();
107108
let http = StaticHttp {
108109
body: WELL_KNOWN_BODY,
109110
};
@@ -112,8 +113,8 @@ async fn end_to_end_mock_match_via_get_assertion() {
112113
.await
113114
.unwrap();
114115

115-
assert_eq!(req.relying_party_id, "brand.com");
116+
assert_eq!(req.relying_party_id, "example.org");
116117
assert!(req
117118
.client_data_json()
118-
.contains(r#""origin":"https://app.brand.org""#));
119+
.contains(r#""origin":"https://app.example.com""#));
119120
}

0 commit comments

Comments
 (0)