summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenId.Test/UI/IdentityEndpointTest.cs
blob: 89ec02a915ac5f5e005eb6431a6187a28eda078d (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
40
41
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.IO;
using System.Diagnostics;
using DotNetOpenId.Test.Hosting;
using System.Text.RegularExpressions;
using System.Net;
using System.Globalization;

namespace DotNetOpenId.Test.UI {
	[TestFixture]
	public class IdentityEndpointTest {
		void parameterizedIdentityEndpointPage(ProtocolVersion version) {
			Protocol protocol = Protocol.Lookup(version);
			TestSupport.Scenarios scenario = TestSupport.Scenarios.AutoApproval;
			Identifier identityUrl = TestSupport.GetIdentityUrl(scenario, version);
			string html = UITestSupport.Host.ProcessRequest(identityUrl);
			TestSupport.Logger.InfoFormat("{0} response:{1}{2}", identityUrl, Environment.NewLine, html);
			Assert.IsTrue(Regex.IsMatch(html, string.Format(CultureInfo.InvariantCulture,
				@"\<link rel=""{1}"" href=""http://[^/]+/{0}""\>\</link\>",
				Regex.Escape(TestSupport.ProviderPage),
				Regex.Escape(protocol.HtmlDiscoveryProviderKey))));
			Assert.IsTrue(Regex.IsMatch(html, string.Format(CultureInfo.InvariantCulture,
				@"\<link rel=""{1}"" href=""http://[^/]+{0}""\>\</link\>",
				Regex.Escape(new Uri(TestSupport.GetDelegateUrl(scenario).ToString()).AbsolutePath),
				Regex.Escape(protocol.HtmlDiscoveryLocalIdKey))));
		}

		[Test]
		public void IdentityEndpoint20Page() {
			parameterizedIdentityEndpointPage(ProtocolVersion.V20);
		}

		[Test]
		public void IdentityEndpoint11Page() {
			parameterizedIdentityEndpointPage(ProtocolVersion.V11);
		}
	}
}