Beispiel #1
0
        public async Task WhenCallingAuthorizeAdditionalRecordsAsync_ThenBrowserUrlIsConstructedCorrectly()
        {
            Uri successUri = new Uri("https://contoso.com/success?instanceid=3");

            _subBrowserAuthBroker
            .AuthenticateAsync(Arg.Is <Uri>(url => CheckStartUrlAdditionalRecords(url)), Arg.Any <Uri>())
            .Returns(successUri);

            ShellAuthService service = CreateService();
            await service.AuthorizeAdditionalRecordsAsync(s_shellUrl, s_appInstanceId);

            await _subBrowserAuthBroker
            .Received()
            .AuthenticateAsync(Arg.Any <Uri>(), Arg.Any <Uri>());
        }
Beispiel #2
0
        private async Task <Uri> AuthenticateInBrowserAsync(Uri shellUrl, string query, string target)
        {
            UriBuilder provisionBuilder = GetShellUriBuilder(shellUrl);
            string     fullQuery        = $"target={target}&targetqs=" + Uri.EscapeDataString(query);

            provisionBuilder.Query = fullQuery;
            Uri provisionUIUrl = provisionBuilder.Uri;

            UriBuilder endUriBuilder = new UriBuilder(shellUrl);

            endUriBuilder.Path = "application/complete";
            Uri stopUrl = endUriBuilder.Uri;

            return(await _browserAuthBroker.AuthenticateAsync(provisionUIUrl, stopUrl).ConfigureAwait(false));
        }