public static void ConfigureMockWebUI(IPlatformProxy platformProxy, IWebUI webUi = null)
        {
            IWebUIFactory mockFactory = Substitute.For <IWebUIFactory>();

            mockFactory.CreateAuthenticationDialog(Arg.Any <CoreUIParent>(), Arg.Any <RequestContext>()).Returns(webUi);
            platformProxy.SetWebUiFactory(mockFactory);
        }
Beispiel #2
0
        public static void ConfigureMockWebUI(MockWebUI webUi)
        {
            IWebUIFactory mockFactory = Substitute.For <IWebUIFactory>();

            mockFactory.CreateAuthenticationDialog(Arg.Any <UIParent>(), Arg.Any <RequestContext>()).Returns(webUi);
            PlatformPlugin.WebUIFactory = mockFactory;
        }
 public static void InjectDependecies(IWebUIFactory webUIFactory, LoggerBase logger, PlatformInformationBase platformInformation, ICryptographyHelper cryptographyHelper)
 {
     WebUIFactory        = webUIFactory;
     Logger              = logger;
     PlatformInformation = platformInformation;
     CryptographyHelper  = cryptographyHelper;
 }
 public static void InjectDependecies(IWebUIFactory webUIFactory, ITokenCachePlugin tokenCachePlugin, LoggerBase logger, PlatformInformationBase platformInformation, ICryptographyHelper cryptographyHelper)
 {
     WebUIFactory = webUIFactory;
     TokenCachePlugin = tokenCachePlugin;
     Logger = logger;
     PlatformInformation = platformInformation;
     CryptographyHelper = cryptographyHelper;            
 }
Beispiel #5
0
 public static void InjectDependecies(IWebUIFactory webUIFactory,
                                      ILogger platformlogger,
                                      PlatformInformationBase platformInformation)
 {
     WebUIFactory        = webUIFactory;
     PlatformLogger      = platformlogger;
     PlatformInformation = platformInformation;
 }
        public void AcquireTokenIdTokenOnlyResponseTest()
        {
            MockWebUI webUi = new MockWebUI();

            webUi.HeadersToValidate = new Dictionary <string, string>();
            webUi.MockResult        = new AuthorizationResult(AuthorizationStatus.Success,
                                                              TestConstants.DefaultAuthorityHomeTenant + "?code=some-code");

            IWebUIFactory mockFactory = Substitute.For <IWebUIFactory>();

            mockFactory.CreateAuthenticationDialog(Arg.Any <IPlatformParameters>()).Returns(webUi);
            PlatformPlugin.WebUIFactory = mockFactory;

            HttpMessageHandlerFactory.MockHandler = new MockHttpMessageHandler()
            {
                Method          = HttpMethod.Post,
                ResponseMessage = MockHelpers.CreateSuccessIdTokenResponseMessage()
            };

            // this is a flow where we pass client id as a scope
            PublicClientApplication     app    = new PublicClientApplication(TestConstants.DefaultClientId);
            Task <AuthenticationResult> task   = app.AcquireTokenAsync(new string[] { TestConstants.DefaultClientId });
            AuthenticationResult        result = task.Result;

            Assert.IsNotNull(result);
            Assert.AreEqual(result.Token, result.IdToken);
            Assert.AreEqual(1, app.UserTokenCache.Count);
            foreach (var item in app.UserTokenCache.ReadItems(TestConstants.DefaultClientId))
            {
                Assert.AreEqual(1, item.Scope.Count);
                Assert.AreEqual(TestConstants.DefaultClientId, item.Scope.AsSingleString());
            }

            //call AcquireTokenSilent to make sure we get same token back and no call goes over network
            HttpMessageHandlerFactory.MockHandler = new MockHttpMessageHandler()
            {
                Method          = HttpMethod.Post,
                ResponseMessage = new HttpResponseMessage(HttpStatusCode.BadRequest)
            };

            task = app.AcquireTokenSilentAsync(new string[] { TestConstants.DefaultClientId });

            AuthenticationResult result1 = task.Result;

            Assert.IsNotNull(result1);
            Assert.AreEqual(result1.Token, result1.IdToken);
            Assert.AreEqual(result.Token, result1.Token);
            Assert.AreEqual(result.IdToken, result1.IdToken);
            Assert.AreEqual(1, app.UserTokenCache.Count);
            foreach (var item in app.UserTokenCache.ReadItems(TestConstants.DefaultClientId))
            {
                Assert.AreEqual(1, item.Scope.Count);
                Assert.AreEqual(TestConstants.DefaultClientId, item.Scope.AsSingleString());
            }
        }
        private static void ConfigureWebUiFactory(IServiceBundle serviceBundle, IWebUI webUi)
        {
            IWebUIFactory mockFactory = Substitute.For <IWebUIFactory>();

            mockFactory.CreateAuthenticationDialog(
                Arg.Any <CoreUIParent>(),
                Arg.Any <WebViewPreference>(),
                Arg.Any <RequestContext>()).Returns(webUi);

            serviceBundle.Config.WebUiFactoryCreator = () => mockFactory;
        }
 internal static void InjectDependecies(IWebUIFactory webUIFactory, ITokenCachePlugin tokenCachePlugin, LoggerBase logger,
                                        PlatformInformationBase platformInformation, ICryptographyHelper cryptographyHelper,
                                        IDeviceAuthHelper deviceAuthHelper, IBrokerHelper brokerHelper)
 {
     WebUIFactory        = webUIFactory;
     TokenCachePlugin    = tokenCachePlugin;
     Logger              = logger;
     PlatformInformation = platformInformation;
     CryptographyHelper  = cryptographyHelper;
     DeviceAuthHelper    = deviceAuthHelper;
     BrokerHelper        = brokerHelper;
 }
Beispiel #9
0
        public static void ConfigureMockWebUI(AuthorizationResult authorizationResult, Dictionary <string, string> headersToValidate)
        {
            MockWebUI webUi = new MockWebUI();

            webUi.HeadersToValidate = headersToValidate;
            webUi.MockResult        = authorizationResult;

            IWebUIFactory mockFactory = Substitute.For <IWebUIFactory>();

            mockFactory.CreateAuthenticationDialog(Arg.Any <IPlatformParameters>()).Returns(webUi);
            PlatformPlugin.WebUIFactory = mockFactory;
        }
 public static void InjectDependecies(IWebUIFactory webUIFactory, ITokenCachePlugin tokenCachePlugin, LoggerBase logger, 
     PlatformInformationBase platformInformation, ICryptographyHelper cryptographyHelper,
     IDeviceAuthHelper deviceAuthHelper, IBrokerHelper brokerHelper, IPlatformParameters platformParameters)
 {
     WebUIFactory = webUIFactory;
     TokenCachePlugin = tokenCachePlugin;
     Logger = logger;
     PlatformInformation = platformInformation;
     CryptographyHelper = cryptographyHelper;
     DeviceAuthHelper = deviceAuthHelper;
     BrokerHelper = brokerHelper;
     DefaultPlatformParameters = platformParameters;
 }
Beispiel #11
0
 /// <inheritdoc />
 public void SetWebUiFactory(IWebUIFactory webUiFactory)
 {
     OverloadWebUiFactory = webUiFactory;
 }