public void GivenMissingAudParamToV1AAd_WhenAuthorizeRequestAction_ThenRedirectResultReturned() { _securityConfiguration.Authentication = new AuthenticationConfiguration { Audience = "testaudience", Authority = "http://testauthority.com/", }; var v1Controller = new AadSmartOnFhirProxyController( Options.Create(_securityConfiguration), _httpClientFactory, _urlResolver, _logger); var redirect = new Uri("http://test.uri"); _urlResolver.ResolveRouteNameUrl(Arg.Any <string>(), Arg.Any <IDictionary <string, object> >()).Returns(redirect); var result = _controller.Authorize("code", "clientId", redirect, "launch", null, "state", null); var redirectResult = result as RedirectResult; Assert.NotNull(redirectResult); var uri = new Uri(redirectResult.Url); var queryParams = HttpUtility.ParseQueryString(uri.Query); Assert.Null(queryParams["resource"]); }
public AadSmartOnFhirProxyControllerTests() { _securityConfiguration.EnableAadSmartOnFhirProxy = true; _securityConfiguration.Enabled = true; _securityConfiguration.Authorization = new AuthorizationConfiguration { Enabled = true, }; _securityConfiguration.Authentication = new AuthenticationConfiguration { Audience = "testaudience", Authority = "http://testauthority.com/v2.0", }; string openIdConfiguration; using (StreamReader r = new StreamReader(Assembly.GetExecutingAssembly(). GetManifestResourceStream("Microsoft.Health.Fhir.Api.UnitTests.Controllers.openid-configuration.json"))) { openIdConfiguration = r.ReadToEnd(); } _httpMessageHandler = new TestHttpMessageHandler(new HttpResponseMessage() { StatusCode = System.Net.HttpStatusCode.OK, Content = new StringContent(openIdConfiguration), }); var httpClient = new HttpClient(_httpMessageHandler); _httpClientFactory.CreateClient().Returns(httpClient); _controller = new AadSmartOnFhirProxyController( Options.Create(_securityConfiguration), _httpClientFactory, _urlResolver, _logger); }