blob: 13079a710fa9a34384d25a5479c3819ea6e129ef (
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
//-----------------------------------------------------------------------
// <copyright file="OpenIdTestBase.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.Test.OpenId {
using System;
using DotNetOpenAuth.Configuration;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.Messaging.Bindings;
using DotNetOpenAuth.OpenId;
using DotNetOpenAuth.OpenId.Provider;
using DotNetOpenAuth.OpenId.RelyingParty;
using DotNetOpenAuth.Test.Mocks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
public class OpenIdTestBase : TestBase {
internal IDirectSslWebRequestHandler RequestHandler;
internal MockHttpRequest MockResponder;
protected internal static readonly Uri ProviderUri = new Uri("http://provider");
protected internal static readonly Uri RPUri = new Uri("http://rp");
protected const string IdentifierSelect = "http://specs.openid.net/auth/2.0/identifier_select";
protected RelyingPartySecuritySettings RelyingPartySecuritySettings { get; private set; }
protected ProviderSecuritySettings ProviderSecuritySettings { get; private set; }
[TestInitialize]
public override void SetUp() {
base.SetUp();
this.RelyingPartySecuritySettings = RelyingPartySection.Configuration.SecuritySettings.CreateSecuritySettings();
this.ProviderSecuritySettings = ProviderSection.Configuration.SecuritySettings.CreateSecuritySettings();
this.MockResponder = MockHttpRequest.CreateUntrustedMockHttpHandler();
this.RequestHandler = this.MockResponder.MockWebRequestHandler;
}
protected Identifier GetMockIdentifier(TestSupport.Scenarios scenario, ProtocolVersion providerVersion) {
return this.GetMockIdentifier(scenario, providerVersion, false);
}
protected Identifier GetMockIdentifier(TestSupport.Scenarios scenario, ProtocolVersion providerVersion, bool useSsl) {
return TestSupport.GetMockIdentifier(scenario, this.MockResponder, providerVersion, useSsl);
}
/// <summary>
/// Creates a standard <see cref="OpenIdRelyingParty"/> instance for general testing.
/// </summary>
/// <returns>The new instance.</returns>
protected OpenIdRelyingParty CreateRelyingParty() {
var rp = new OpenIdRelyingParty(new StandardRelyingPartyApplicationStore(TimeSpan.FromMinutes(5)));
rp.Channel.WebRequestHandler = this.MockResponder.MockWebRequestHandler;
return rp;
}
/// <summary>
/// Creates a standard <see cref="OpenIdProvider"/> instance for general testing.
/// </summary>
/// <returns>The new instance.</returns>
protected OpenIdProvider CreateProvider() {
var op = new OpenIdProvider(new StandardProviderApplicationStore(TimeSpan.FromMinutes(5)));
op.Channel.WebRequestHandler = this.MockResponder.MockWebRequestHandler;
return op;
}
}
}
|