server-util: make destination parameter of XMatrix::new mandatory

This commit is contained in:
Matthias Ahouansou 2024-05-29 15:38:52 +01:00
parent d91e6d7e63
commit a8025de761
2 changed files with 9 additions and 4 deletions

View File

@ -1,5 +1,10 @@
# [unreleased]
Breaking changes:
- The `XMatrix::new` method now takes `OwnedServerName` instead of `Option<OwnedServerName>`
for the destination, since servers must always set the destination.
# 0.3.0
Breaking changes:

View File

@ -31,11 +31,11 @@ impl XMatrix {
/// Construct a new X-Matrix Authorization header.
pub fn new(
origin: OwnedServerName,
destination: Option<OwnedServerName>,
destination: OwnedServerName,
key: OwnedServerSigningKeyId,
sig: String,
) -> Self {
Self { origin, destination, key, sig }
Self { origin, destination: Some(destination), key, sig }
}
}
@ -259,7 +259,7 @@ mod tests {
assert_eq!(credentials.key, key);
assert_eq!(credentials.sig, sig);
let credentials = XMatrix::new(origin, None, key, sig);
let credentials = XMatrix { origin, destination: None, key, sig };
assert_eq!(credentials.encode(), header);
}
@ -277,7 +277,7 @@ mod tests {
assert_eq!(credentials.key, key);
assert_eq!(credentials.sig, sig);
let credentials = XMatrix::new(origin, Some(destination), key, sig);
let credentials = XMatrix::new(origin, destination, key, sig);
assert_eq!(credentials.encode(), header);
}