예제 #1
0
            public void AuthSetup(string accessToken, string refreshToken)
            {
                StartServer();
                StaticMethodWrapperMock
                .Setup(t => t.StartProcess(It.IsAny <string>()))
                .Callback((string url) =>
                {
                    //We need to invoke the appropriate method on the signin handler - Easiest way is to just make the call the browser would
                    Task.Run(() =>
                    {
                        using var client = new HttpClient();
                        client.GetAsync(url);
                        Thread.Sleep(TimeSpan.FromSeconds(10));
                    });
                });

                var handler = new UserSigninHandler(RedirectUrl, accessToken, refreshToken, TokenGenerator);

                HttpMock.HttpMock
                .WhenGet(handler.AuthPath)
                .Do(context => { handler.Handle(context); });
                HttpMock.HttpMock
                .WhenPost(handler.AuthPath, context => true)
                .Do(context => { handler.Handle(context); });
            }
예제 #2
0
            public void TokenEndpointSetup(string accessToken, string refreshToken)
            {
                StartServer();
                HttpMock.HttpMock
                .WhenPost(TokenEndpoint, context => true)
                .Do(context =>
                {
                    var handler = new UserSigninHandler(RedirectUrl, accessToken, refreshToken, TokenGenerator);

                    handler.HandleTokenExchange(context);
                });
            }