22// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33
44using System ;
5+ using System . Linq ;
56using System . Threading ;
67using System . Threading . Tasks ;
78using Azure . Identity ;
9+ using Microsoft . Azure . SignalR ;
810using Microsoft . Azure . SignalR . Tests . Common ;
911using Microsoft . Extensions . Logging . Abstractions ;
1012using Xunit ;
1113
12- namespace Microsoft . Azure . SignalR . Common ;
14+ namespace Microsoft . Azure . SignalR . Common . Tests . Auth ;
1315
1416public class AccessKeySynchronizerFacts
1517{
@@ -26,6 +28,7 @@ public void AddAndRemoveServiceEndpointsTest()
2628 synchronizer . UpdateServiceEndpoints ( [ endpoint1 ] ) ;
2729 Assert . Equal ( 1 , synchronizer . Count ( ) ) ;
2830 synchronizer . UpdateServiceEndpoints ( [ endpoint1 , endpoint2 ] ) ;
31+ Assert . Empty ( synchronizer . AvailableKeyList ) ;
2932
3033 Assert . Equal ( 2 , synchronizer . Count ( ) ) ;
3134 Assert . True ( synchronizer . ContainsKey ( endpoint1 ) ) ;
@@ -35,6 +38,7 @@ public void AddAndRemoveServiceEndpointsTest()
3538 Assert . Equal ( 1 , synchronizer . Count ( ) ) ;
3639 synchronizer . UpdateServiceEndpoints ( [ ] ) ;
3740 Assert . Equal ( 0 , synchronizer . Count ( ) ) ;
41+ Assert . Empty ( synchronizer . AvailableKeyList ) ;
3842 }
3943
4044 [ Fact ]
@@ -51,6 +55,7 @@ public async Task GenerateAccessTokenTriggerLoadedTaskTest()
5155
5256 var key = Assert . IsType < MicrosoftEntraAccessKey > ( endpoint . AccessKey ) ;
5357 Assert . False ( key . LoadedTask . IsCompleted ) ;
58+ Assert . Empty ( synchronizer . AvailableKeyList ) ;
5459
5560 await Assert . ThrowsAsync < TaskCanceledException > (
5661 async ( ) => await key . GenerateAccessTokenAsync ( "https://localhost" , [ ] , TimeSpan . FromSeconds ( 1 ) , AccessTokenAlgorithm . HS256 , source . Token )
@@ -59,6 +64,7 @@ await Assert.ThrowsAsync<TaskCanceledException>(
5964
6065 await initializeTask ;
6166 Assert . False ( key . Available ) ;
67+ Assert . Single ( synchronizer . AvailableKeyList ) ;
6268
6369 await Assert . ThrowsAsync < AzureSignalRAccessTokenNotAuthorizedException > (
6470 async ( ) => await key . GenerateAccessTokenAsync ( "https://localhost" , [ ] , TimeSpan . FromSeconds ( 1 ) , AccessTokenAlgorithm . HS256 )
0 commit comments