@@ -8,7 +8,6 @@ use std::num::NonZeroU32;
88
99use chrono:: { DateTime , Duration , Utc } ;
1010use mas_iana:: oauth:: PkceCodeChallengeMethod ;
11- use mas_matrix:: BoxHomeserverConnection ;
1211use 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) ]
289288mod 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 }
0 commit comments