public void GetAuthorizationCodeViaUserAgentAndRequestProtectedResource()
        {
            //TODO: webrequest mocken
            // diesen dann mit "Pseudo"-Auth-Code ausstatten, die SetToken(server, incommingRequest) => resoruceOwner
            // und die WebRequest.Authorize(server, resourceOwner) anschubsen
            // dabei müssen die UserCredentials richtig gesetzt sein

            var resourceOwnertmp = ResourceOwners.GetResourceOwner(_resourceOwnerName);
            var servertmp = ServersWithAuthorizationCode.GetServerWithAuthorizationCode(_clientId, _authorizationRequestUri,_accessTokenRequestUri, _redirectionUri);

            var mockContext = new Mock<IWebOperationContext> { DefaultValue = DefaultValue.Mock };
            mockContext.SetupAllProperties();
            var context = mockContext.Object;

            context.IncomingRequest.UriTemplateMatch.RequestUri = _redirectionUri;
            context.IncomingRequest.UriTemplateMatch.QueryParameters.Add("code", "Splx10BeZQQYbYS6WxSbIA");
            context.IncomingRequest.UriTemplateMatch.QueryParameters.Add("state", servertmp.Guid.ToString() + "_" + resourceOwnertmp.Guid.ToString());
            var tuple = context.GetCredentialsFromAuthorizationRedirect();

            var server = tuple.Item1;
            var resourceOwner = tuple.Item2;

            server.Should().Be(servertmp);
            resourceOwner.Should().Be(resourceOwner);

            
            var webRequest = resourceOwner.GetSignedRequestFor(server,"http://example.com/ProtectedResource");;

            //Test ob WebRequest richtig unterschrieben wurde

            Assert.Fail("Test is not completed yet");
        }
        public void CreateServerAndUsersAndGetCorrectRedirectToAuthorizationRequest()
        {
            // Spec v2-22 4.1.1

            var resourceOwner = ResourceOwners.GetResourceOwner(_resourceOwnerName);
            var server = ServersWithAuthorizationCode.GetServerWithAuthorizationCode(_clientId, _authorizationRequestUri,
                                                                                     _accessTokenRequestUri,
                                                                                     _redirectionUri);

            var mockContext = new Mock<IWebOperationContext> {DefaultValue = DefaultValue.Mock};
            mockContext.SetupAllProperties();
            resourceOwner.AuthorizesMeToAccessTo(server).Should().BeFalse();
            var context = mockContext.Object;

            context.RedirectToAuthorization(server, resourceOwner);

            context.OutgoingResponse.StatusCode.Should().Be(HttpStatusCode.Redirect);
            context.OutgoingResponse.Location.Should().NotBeNullOrEmpty();

        }
Пример #3
0
        public void PushesStimulusConfigurationSpansToEpoch()
        {
            const string UNUSED_NAME = "UNUSED";

            var c = new SingleEpochController();
            var dev = new UnitConvertingExternalDevice(UNUSED_NAME, UNUSED_DEVICE_MANUFACTURER, UNUSED_BACKGROUND);

            var outputTime = DateTimeOffset.Now;
            var configuration = new List<IPipelineNodeConfiguration>();
            var config = new Dictionary<string, object>();
            config["key"] = "value";

            configuration.Add(new PipelineNodeConfiguration(UNUSED_NAME, config));

            var epochMock = new Mock<Epoch>("test-epoch");
            epochMock.Setup(epoch => epoch.DidOutputData(dev, outputTime, TimeSpan.FromSeconds(0.1), configuration)).AtMostOnce();
            epochMock.Setup(epoch => epoch.IsComplete).Returns(false);

            c.SetCurrentEpoch(epochMock.Object);

            c.DidOutputData(dev, outputTime, TimeSpan.FromSeconds(0.1), configuration);

            epochMock.Verify(epoch => epoch.DidOutputData(dev, outputTime, TimeSpan.FromSeconds(0.1), configuration));
        }