コード例 #1
0
		public override void SetUp() {
			base.SetUp();

			this.webRequestHandler = new TestWebRequestHandler();
			this.signingElement = new RsaSha1ServiceProviderSigningBindingElement(new InMemoryTokenManager());
			this.nonceStore = new NonceMemoryStore(StandardExpirationBindingElement.MaximumMessageAge);
			this.channel = new OAuthServiceProviderChannel(this.signingElement, this.nonceStore, new InMemoryTokenManager(), this.serviceProviderSecuritySettings, new TestMessageFactory());
			this.channel.WebRequestHandler = this.webRequestHandler;
		}
コード例 #2
0
		public override void SetUp() {
			base.SetUp();

			this.webRequestHandler = new TestWebRequestHandler();
			this.signingElement = new RsaSha1SigningBindingElement(new InMemoryTokenManager());
			this.nonceStore = new NonceMemoryStore(StandardExpirationBindingElement.MaximumMessageAge);
			this.channel = new OAuthChannel(this.signingElement, this.nonceStore, new InMemoryTokenManager(), new TestMessageFactory());
			this.accessor = OAuthChannel_Accessor.AttachShadow(this.channel);
			this.channel.WebRequestHandler = this.webRequestHandler;
		}
コード例 #3
0
		internal static MockHttpRequest CreateUntrustedMockHttpHandler() {
			TestWebRequestHandler testHandler = new TestWebRequestHandler();
			UntrustedWebRequestHandler untrustedHandler = new UntrustedWebRequestHandler(testHandler);
			if (!untrustedHandler.WhitelistHosts.Contains("localhost")) {
				untrustedHandler.WhitelistHosts.Add("localhost");
			}
			untrustedHandler.WhitelistHosts.Add(OpenIdTestBase.OPUri.Host);
			MockHttpRequest mock = new MockHttpRequest(untrustedHandler);
			testHandler.Callback = mock.GetMockResponse;
			return mock;
		}
コード例 #4
0
        internal static MockHttpRequest CreateUntrustedMockHttpHandler()
        {
            TestWebRequestHandler      testHandler      = new TestWebRequestHandler();
            UntrustedWebRequestHandler untrustedHandler = new UntrustedWebRequestHandler(testHandler);

            if (!untrustedHandler.WhitelistHosts.Contains("localhost"))
            {
                untrustedHandler.WhitelistHosts.Add("localhost");
            }
            untrustedHandler.WhitelistHosts.Add(OpenIdTestBase.OPUri.Host);
            MockHttpRequest mock = new MockHttpRequest(untrustedHandler);

            testHandler.Callback = mock.GetMockResponse;
            return(mock);
        }
コード例 #5
0
		public void PostMultipart() {
			var httpHandler = new TestWebRequestHandler();
			bool callbackTriggered = false;
			httpHandler.Callback = req => {
				var m = Regex.Match(req.ContentType, "multipart/form-data; boundary=(.+)");
				Assert.IsTrue(m.Success, "Content-Type HTTP header not set correctly.");
				string boundary = m.Groups[1].Value;
				boundary = boundary.Substring(0, boundary.IndexOf(';')); // trim off charset
				string expectedEntity = "--{0}\r\nContent-Disposition: form-data; name=\"a\"\r\n\r\nb\r\n--{0}--\r\n";
				expectedEntity = string.Format(expectedEntity, boundary);
				string actualEntity = httpHandler.RequestEntityAsString;
				Assert.AreEqual(expectedEntity, actualEntity);
				callbackTriggered = true;
				Assert.AreEqual(req.ContentLength, actualEntity.Length);
				IncomingWebResponse resp = new CachedDirectWebResponse();
				return resp;
			};
			var request = (HttpWebRequest)WebRequest.Create("http://someserver");
			var parts = new[] {
				MultipartPostPart.CreateFormPart("a", "b"),
			};
			request.PostMultipart(httpHandler, parts);
			Assert.IsTrue(callbackTriggered);
		}