summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenId.Test/Provider/IAuthenticationRequestTest.cs
blob: 87521e1c61a4284638c1049fea1c25ef12fddd65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using DotNetOpenId.RelyingParty;
using System.Net;

namespace DotNetOpenId.Test.Provider {
	[TestFixture]
	public class IAuthenticationRequestTest {
		[SetUp]
		public void Setup() {
			if (!UntrustedWebRequest.WhitelistHosts.Contains("localhost"))
				UntrustedWebRequest.WhitelistHosts.Add("localhost");
		}

		[TearDown]
		public void TearDown() {
			Mocks.MockHttpRequest.Reset();
		}

		[Test]
		public void UnverifiableReturnUrl() {
			var request = TestSupport.CreateRelyingPartyRequest(true, TestSupport.Scenarios.AutoApproval, ProtocolVersion.V20, false);

			// Clear out the RP discovery information registered by TestSupport
			Mocks.MockHttpRequest.DeleteResponse(TestSupport.Realm.UriWithWildcardChangedToWww);

			bool reachedOP = false;
			var response = TestSupport.CreateRelyingPartyResponseThroughProvider(request, req => {
				Assert.IsFalse(req.IsReturnUrlDiscoverable);
				reachedOP = true;
				req.IsAuthenticated = false;
			});
			Assert.IsTrue(reachedOP);
		}
	}
}