1
//-----------------------------------------------------------------------
2 // <copyright file="OpenIdTestBase.cs" company="Andrew Arnott">
3 // Copyright (c) Andrew Arnott. All rights reserved.
5 //-----------------------------------------------------------------------
7 namespace DotNetOpenAuth
.Test
.OpenId
{
9 using DotNetOpenAuth
.Configuration
;
10 using DotNetOpenAuth
.Messaging
;
11 using DotNetOpenAuth
.Messaging
.Bindings
;
12 using DotNetOpenAuth
.OpenId
;
13 using DotNetOpenAuth
.OpenId
.Provider
;
14 using DotNetOpenAuth
.OpenId
.RelyingParty
;
15 using DotNetOpenAuth
.Test
.Mocks
;
16 using Microsoft
.VisualStudio
.TestTools
.UnitTesting
;
18 public class OpenIdTestBase
: TestBase
{
19 internal IDirectSslWebRequestHandler RequestHandler
;
21 internal MockHttpRequest MockResponder
;
23 protected internal static readonly Uri ProviderUri
= new Uri("http://provider");
24 protected internal static readonly Uri RPUri
= new Uri("http://rp");
25 protected const string IdentifierSelect
= "http://specs.openid.net/auth/2.0/identifier_select";
27 protected RelyingPartySecuritySettings RelyingPartySecuritySettings { get; private set; }
29 protected ProviderSecuritySettings ProviderSecuritySettings { get; private set; }
32 public override void SetUp() {
35 this.RelyingPartySecuritySettings
= DotNetOpenAuthSection
.Configuration
.OpenId
.RelyingParty
.SecuritySettings
.CreateSecuritySettings();
36 this.ProviderSecuritySettings
= DotNetOpenAuthSection
.Configuration
.OpenId
.Provider
.SecuritySettings
.CreateSecuritySettings();
38 this.MockResponder
= MockHttpRequest
.CreateUntrustedMockHttpHandler();
39 this.RequestHandler
= this.MockResponder
.MockWebRequestHandler
;
42 protected Identifier
GetMockIdentifier(TestSupport
.Scenarios scenario
, ProtocolVersion providerVersion
) {
43 return this.GetMockIdentifier(scenario
, providerVersion
, false);
46 protected Identifier
GetMockIdentifier(TestSupport
.Scenarios scenario
, ProtocolVersion providerVersion
, bool useSsl
) {
47 return TestSupport
.GetMockIdentifier(scenario
, this.MockResponder
, providerVersion
, useSsl
);
51 /// Creates a standard <see cref="OpenIdRelyingParty"/> instance for general testing.
53 /// <returns>The new instance.</returns>
54 protected OpenIdRelyingParty
CreateRelyingParty() {
55 var rp
= new OpenIdRelyingParty(new StandardRelyingPartyApplicationStore());
56 rp
.Channel
.WebRequestHandler
= this.MockResponder
.MockWebRequestHandler
;
61 /// Creates a standard <see cref="OpenIdProvider"/> instance for general testing.
63 /// <returns>The new instance.</returns>
64 protected OpenIdProvider
CreateProvider() {
65 var op
= new OpenIdProvider(new StandardProviderApplicationStore());
66 op
.Channel
.WebRequestHandler
= this.MockResponder
.MockWebRequestHandler
;