summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Test/Mocks/MockRealm.cs
blob: ae39ebb7ee72d0636eeef1e275da08614728b4b9 (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
42
//-----------------------------------------------------------------------
// <copyright file="MockRealm.cs" company="Andrew Arnott">
//     Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace DotNetOpenAuth.Test.Mocks {
	using System.Collections.Generic;
	using DotNetOpenAuth.Messaging;
	using DotNetOpenAuth.OpenId;

	internal class MockRealm : Realm {
		private RelyingPartyEndpointDescription[] relyingPartyDescriptions;

		/// <summary>
		/// Initializes a new instance of the <see cref="MockRealm"/> class.
		/// </summary>
		/// <param name="wrappedRealm">The wrapped realm.</param>
		/// <param name="relyingPartyDescriptions">The relying party descriptions.</param>
		internal MockRealm(Realm wrappedRealm, params RelyingPartyEndpointDescription[] relyingPartyDescriptions)
			: base(wrappedRealm) {
			ErrorUtilities.VerifyArgumentNotNull(relyingPartyDescriptions, "relyingPartyDescriptions");

			this.relyingPartyDescriptions = relyingPartyDescriptions;
		}

		/// <summary>
		/// Searches for an XRDS document at the realm URL, and if found, searches
		/// for a description of a relying party endpoints (OpenId login pages).
		/// </summary>
		/// <param name="requestHandler">The mechanism to use for sending HTTP requests.</param>
		/// <param name="allowRedirects">Whether redirects may be followed when discovering the Realm.
		/// This may be true when creating an unsolicited assertion, but must be
		/// false when performing return URL verification per 2.0 spec section 9.2.1.</param>
		/// <returns>
		/// The details of the endpoints if found, otherwise null.
		/// </returns>
		internal override IEnumerable<RelyingPartyEndpointDescription> DiscoverReturnToEndpoints(IDirectWebRequestHandler requestHandler, bool allowRedirects) {
			return this.relyingPartyDescriptions;
		}
	}
}