@@ -216,102 +216,70 @@ mod tests {
216216 use super :: * ;
217217
218218 #[ test]
219- fn test_entra_defaults ( ) {
219+ fn test_entra_defaults_id ( ) {
220+ let tenant_id = "1234-5678-1234-5678" ;
221+ let user = "1234-5678-1234-5678" ;
222+
220223 let entra = EntraBackend :: try_new (
221224 & HostName :: from_str ( "login.microsoft.com" ) . unwrap ( ) ,
222225 & HostName :: from_str ( "graph.microsoft.com" ) . unwrap ( ) ,
223226 443 ,
224- "1234-5678" ,
227+ tenant_id ,
225228 true ,
226229 )
227230 . unwrap ( ) ;
228231
229232 assert_eq ! (
230233 entra. oauth2_token( ) ,
231- Url :: parse( "https://login.microsoft.com/1234-5678/oauth2/v2.0/token" ) . unwrap( )
234+ Url :: parse( & format!(
235+ "https://login.microsoft.com/{tenant_id}/oauth2/v2.0/token"
236+ ) )
237+ . unwrap( )
232238 ) ;
233239 assert_eq ! (
234- entra. user_info( "0000-0000" ) ,
235- Url :: parse( "https://graph.microsoft.com/v1.0/users/0000-0000" ) . unwrap( )
240+ entra. user_info( user ) ,
241+ Url :: parse( & format! ( "https://graph.microsoft.com/v1.0/users/{user}" ) ) . unwrap( )
236242 ) ;
237243 assert_eq ! (
238- entra. group_info( "0000-0000" ) ,
239- Url :: parse( "https://graph.microsoft.com/v1.0/users/0000-0000/memberOf" ) . unwrap( )
244+ entra. group_info( user) ,
245+ Url :: parse( & format!(
246+ "https://graph.microsoft.com/v1.0/users/{user}/memberOf"
247+ ) )
248+ . unwrap( )
240249 ) ;
241250 }
242251
243252 #[ test]
244- fn test_entra_non_default_host_non_default_port_tls ( ) {
245- let entra = EntraBackend :: try_new (
246- & HostName :: from_str ( "login.myentra.com" ) . unwrap ( ) ,
247- & HostName :: from_str ( "graph.myentra.com" ) . unwrap ( ) ,
248- 8443 ,
249- "1234-5678" ,
250- true ,
251- )
252- . unwrap ( ) ;
253+ fn test_entra_defaults_email ( ) {
254+ let tenant_id = "1234-5678-1234-5678" ;
255+ let user = "test@stackable.tech" ;
253256
254- assert_eq ! (
255- entra. oauth2_token( ) ,
256- Url :: parse( "https://login.myentra.com:8443/1234-5678/oauth2/v2.0/token" ) . unwrap( )
257- ) ;
258- assert_eq ! (
259- entra. user_info( "0000-0000" ) ,
260- Url :: parse( "https://graph.myentra.com:8443/v1.0/users/0000-0000" ) . unwrap( )
261- ) ;
262- assert_eq ! (
263- entra. group_info( "0000-0000" ) ,
264- Url :: parse( "https://graph.myentra.com:8443/v1.0/users/0000-0000/memberOf" ) . unwrap( )
265- ) ;
266- }
267-
268- #[ test]
269- fn test_entra_non_default_host_default_port_non_tls ( ) {
270257 let entra = EntraBackend :: try_new (
271- & HostName :: from_str ( "login.myentra.com" ) . unwrap ( ) ,
272- & HostName :: from_str ( "graph.myentra.com" ) . unwrap ( ) ,
273- 80 ,
274- "1234-5678" ,
275- false ,
276- )
277- . unwrap ( ) ;
278-
279- assert_eq ! (
280- entra. oauth2_token( ) ,
281- Url :: parse( "http://login.myentra.com/1234-5678/oauth2/v2.0/token" ) . unwrap( )
282- ) ;
283- assert_eq ! (
284- entra. user_info( "0000-0000" ) ,
285- Url :: parse( "http://graph.myentra.com/v1.0/users/0000-0000" ) . unwrap( )
286- ) ;
287- assert_eq ! (
288- entra. group_info( "0000-0000" ) ,
289- Url :: parse( "http://graph.myentra.com/v1.0/users/0000-0000/memberOf" ) . unwrap( )
290- ) ;
291- }
292-
293- #[ test]
294- fn test_entra_non_default_host_non_default_port_non_tls ( ) {
295- let entra = EntraBackend :: try_new (
296- & HostName :: from_str ( "login.myentra.com" ) . unwrap ( ) ,
297- & HostName :: from_str ( "graph.myentra.com" ) . unwrap ( ) ,
298- 8080 ,
299- "1234-5678" ,
300- false ,
258+ & HostName :: from_str ( "login.microsoft.com" ) . unwrap ( ) ,
259+ & HostName :: from_str ( "graph.microsoft.com" ) . unwrap ( ) ,
260+ 443 ,
261+ tenant_id,
262+ true ,
301263 )
302264 . unwrap ( ) ;
303265
304266 assert_eq ! (
305267 entra. oauth2_token( ) ,
306- Url :: parse( "http://login.myentra.com:8080/1234-5678/oauth2/v2.0/token" ) . unwrap( )
268+ Url :: parse( & format!(
269+ "https://login.microsoft.com/{tenant_id}/oauth2/v2.0/token"
270+ ) )
271+ . unwrap( )
307272 ) ;
308273 assert_eq ! (
309- entra. user_info( "0000-0000" ) ,
310- Url :: parse( "http ://graph.myentra .com:8080 /v1.0/users/0000-0000" ) . unwrap( )
274+ entra. user_info( user ) ,
275+ Url :: parse( & format! ( "https ://graph.microsoft .com/v1.0/users/{user}" ) ) . unwrap( )
311276 ) ;
312277 assert_eq ! (
313- entra. group_info( "0000-0000" ) ,
314- Url :: parse( "http://graph.myentra.com:8080/v1.0/users/0000-0000/memberOf" ) . unwrap( )
278+ entra. group_info( user) ,
279+ Url :: parse( & format!(
280+ "https://graph.microsoft.com/v1.0/users/{user}/memberOf"
281+ ) )
282+ . unwrap( )
315283 ) ;
316284 }
317285}
0 commit comments