Skip to content

Commit 2696df0

Browse files
committed
Remove mas-matrix dependency on mas-data-model
1 parent e9ae7b4 commit 2696df0

File tree

4 files changed

+8
-16
lines changed

4 files changed

+8
-16
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/data-model/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,4 @@ ruma-common = "0.13.0"
2626

2727
mas-iana.workspace = true
2828
mas-jose.workspace = true
29-
mas-matrix.workspace = true
3029
oauth2-types.workspace = true

crates/data-model/src/oauth2/authorization_grant.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use std::num::NonZeroU32;
88

99
use chrono::{DateTime, Duration, Utc};
1010
use mas_iana::oauth::PkceCodeChallengeMethod;
11-
use mas_matrix::BoxHomeserverConnection;
1211
use oauth2_types::{
1312
pkce::{CodeChallengeError, CodeChallengeMethodExt},
1413
requests::ResponseMode,
@@ -188,7 +187,7 @@ impl AuthorizationGrant {
188187
}
189188

190189
#[must_use]
191-
pub fn parse_login_hint(&self, homeserver: &BoxHomeserverConnection) -> LoginHint {
190+
pub fn parse_login_hint(&self, homeserver: &str) -> LoginHint {
192191
let Some(login_hint) = &self.login_hint else {
193192
return LoginHint::None;
194193
};
@@ -206,7 +205,7 @@ impl AuthorizationGrant {
206205
};
207206

208207
// Only handle MXIDs for current homeserver
209-
if mxid.server_name() != homeserver.homeserver() {
208+
if mxid.server_name() != homeserver {
210209
return LoginHint::None;
211210
}
212211

@@ -287,15 +286,10 @@ impl AuthorizationGrant {
287286

288287
#[cfg(test)]
289288
mod tests {
290-
use mas_matrix::MockHomeserverConnection;
291289
use rand::thread_rng;
292290

293291
use super::*;
294292

295-
fn get_homeserver() -> BoxHomeserverConnection {
296-
Box::new(MockHomeserverConnection::new("example.com"))
297-
}
298-
299293
#[test]
300294
fn no_login_hint() {
301295
#[allow(clippy::disallowed_methods)]
@@ -309,7 +303,7 @@ mod tests {
309303
..AuthorizationGrant::sample(now, &mut rng)
310304
};
311305

312-
let hint = grant.parse_login_hint(&get_homeserver());
306+
let hint = grant.parse_login_hint("example.com");
313307

314308
assert!(matches!(hint, LoginHint::None));
315309
}
@@ -327,7 +321,7 @@ mod tests {
327321
..AuthorizationGrant::sample(now, &mut rng)
328322
};
329323

330-
let hint = grant.parse_login_hint(&get_homeserver());
324+
let hint = grant.parse_login_hint("example.com");
331325

332326
assert!(matches!(hint, LoginHint::MXID(mxid) if mxid.localpart() == "example-user"));
333327
}
@@ -345,7 +339,7 @@ mod tests {
345339
..AuthorizationGrant::sample(now, &mut rng)
346340
};
347341

348-
let hint = grant.parse_login_hint(&get_homeserver());
342+
let hint = grant.parse_login_hint("example.com");
349343

350344
assert!(matches!(hint, LoginHint::None));
351345
}
@@ -363,7 +357,7 @@ mod tests {
363357
..AuthorizationGrant::sample(now, &mut rng)
364358
};
365359

366-
let hint = grant.parse_login_hint(&get_homeserver());
360+
let hint = grant.parse_login_hint("example.com");
367361

368362
assert!(matches!(hint, LoginHint::None));
369363
}
@@ -381,7 +375,7 @@ mod tests {
381375
..AuthorizationGrant::sample(now, &mut rng)
382376
};
383377

384-
let hint = grant.parse_login_hint(&get_homeserver());
378+
let hint = grant.parse_login_hint("example.com");
385379

386380
assert!(matches!(hint, LoginHint::None));
387381
}

crates/handlers/src/views/login.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ fn handle_login_hint(
306306
}
307307

308308
if let PostAuthContextInner::ContinueAuthorizationGrant { ref grant } = next.ctx {
309-
let value = match grant.parse_login_hint(homeserver) {
309+
let value = match grant.parse_login_hint(homeserver.homeserver()) {
310310
LoginHint::MXID(mxid) => Some(mxid.localpart().to_owned()),
311311
LoginHint::None => None,
312312
};

0 commit comments

Comments
 (0)