public void CheckCallProgressHttpTriggerConcurrentRuns() { FunctionSettings functionSettings = FunctionSettings.Load(@".\functionSettings.json"); using (HttpClient httpClient = new HttpClient()) { string accessToken = AzureADHelper.GetAccessTokenAsync(functionSettings.Authority, functionSettings.ApplicationId, functionSettings.ClientSecret, functionSettings.ResourceId).Result; if (accessToken == null) { throw new Exception("Could not obtain access token!"); } httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); Task[] threads = new Task[_concurrentConfig.NumberOfThreads]; for (int i = 0; i < _concurrentConfig.NumberOfThreads; i++) { threads[i] = Task.Run( new Action( () => CheckCallProgressRunnerAsync(httpClient, functionSettings, _concurrentConfig.TestConfigurationQueue).Wait())); } _log.LogInformation("Waiting on threads..."); Task.WaitAll(threads); _log.LogInformation("All threads completed..."); } _concurrentConfig.Save(GlobalTestConstants.ConcurrentTestConfigurationFilePath); }
public void TranscribeCallHttpTriggerOpenSpeechRepositoryConcurrentRuns() { ConcurrentTestConfiguration testConfiguration = ConcurrentTestConfiguration.Load(@".\TestConfigurations\TranscribeCall\multiThreaded\testconfig_test1.json"); FunctionSettings functionSettings = FunctionSettings.Load(@".\functionSettings.json"); using (HttpClient httpClient = new HttpClient()) { string accessToken = AzureADHelper.GetAccessTokenAsync(functionSettings.Authority, functionSettings.ApplicationId, functionSettings.ClientSecret, functionSettings.ResourceId).Result; if (accessToken == null) { throw new Exception("Could not obtain access token!"); } httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); Task[] threads = new Task[testConfiguration.NumberOfThreads]; for (int i = 0; i < testConfiguration.NumberOfThreads; i++) { threads[i] = Task.Run( new Action( () => TranscribeCallRunnerAsync(httpClient, functionSettings, testConfiguration.TestConfigurationQueue).Wait())); } _log.LogInformation("Waiting on threads..."); Task.WaitAll(threads); _log.LogInformation("All threads completed..."); } }
public async Task GetAuthUrlAync_Azure_Success() { ResumptionCookie cookie = new ResumptionCookie(new Address("botId", "channelId", "userId", "conversationId", "serviceUrl"), "userName", false, "en"); var authUrl = await AzureADHelper.GetAuthUrlAsync(cookie, "https://test"); string expected = "https://login.microsoftonline.com/49445e6c-4079-4692-8349-8bb3853f22fc/oauth2/authorize?resource=https:%2F%2Ftest&client_id=4db3e943-ac1d-46cc-bbc1-b1a47a091492&response_type=code&haschrome=1&redirect_uri=http:%2F%2Flocalhost:3978%2Fapi%2Foauth&x-client-SKU=PCL.Desktop&x-client-Ver=3.13.8.999&x-client-CPU=x64&x-client-OS=Microsoft+Windows+NT+6.3.9600.0&state=H4sIAAAAAAAEAFWMSw7CMAxELVfiu-BM0AWqhNhADxASS1QKMbKTrjkkB8JtEZ-V5z1r5gkA1TYEIVV4GOCOcxNgZvEyJqyvLiWKFlcm_YewVRK7c7Nlilhz6knU5Y6T8WYo_Cs8kfSdp1YirO2tX5wWj-5GsHxvjrBo9CxFM4Wf7mD3wuVutQN7FwkqK1ECeAE2vIiE1AAAAA2&response_mode=form_post"; Assert.AreEqual(expected, authUrl); }
public async Task GetAuthToken_Azure_Success() { using (var autoMock = AutoMock.GetLoose()) { AuthenticationSettings authenticationSettings = AuthenticationSettings.GetFromAppSettings(); string resource = "https://test"; Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult result = autoMock.Mock <Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult>().Object; autoMock.Mock <AuthenticationContext>() .Setup(t => t.AcquireTokenSilentAsync(resource, authenticationSettings.ClientId)) .Returns(() => Task.FromResult(result)); await AzureADHelper.GetToken("userUniqueId", authenticationSettings, resource); } }
public void DeleteAccountRecordingsHttpTriggerRun() { FunctionSettings functionSettings = FunctionSettings.Load(@".\functionSettings.json"); using (HttpClient httpClient = new HttpClient()) { string accessToken = AzureADHelper.GetAccessTokenAsync(functionSettings.Authority, functionSettings.ApplicationId, functionSettings.ClientSecret, functionSettings.ResourceId).Result; if (accessToken == null) { throw new Exception("Could not obtain access token!"); } httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); DeleteRecordingsRunner(httpClient, functionSettings); } }