summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2009-01-10 10:13:55 -0800
committerAndrew <andrewarnott@gmail.com>2009-01-10 10:13:55 -0800
commit048be0346b64d4fed9960ebc4d71376c074b1e8b (patch)
treef6bd89f3f1cec1c139c9ca67cc6bdddcd666fa76
parentde87f812ff52c78e0738a56db1a8b1879ab63b44 (diff)
downloadDotNetOpenAuth-048be0346b64d4fed9960ebc4d71376c074b1e8b.zip
DotNetOpenAuth-048be0346b64d4fed9960ebc4d71376c074b1e8b.tar.gz
DotNetOpenAuth-048be0346b64d4fed9960ebc4d71376c074b1e8b.tar.bz2
Added several tests for RP.AuthenticationRequest.
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs1
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs54
2 files changed, 51 insertions, 4 deletions
diff --git a/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs b/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs
index d9701b1..181fd4e 100644
--- a/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs
@@ -22,6 +22,7 @@ namespace DotNetOpenAuth.Test.OpenId {
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; }
diff --git a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs
index 50e5f37..d6a0600 100644
--- a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs
@@ -18,6 +18,9 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty {
public class AuthenticationRequestTests : OpenIdTestBase {
private readonly Realm realm = new Realm(TestSupport.GetFullUrl(TestSupport.ConsumerPage).AbsoluteUri);
private readonly Uri returnTo = TestSupport.GetFullUrl(TestSupport.ConsumerPage);
+ private readonly Identifier claimedId = "http://claimedId";
+ private readonly Identifier delegatedLocalId = "http://localId";
+ private readonly Protocol protocol = Protocol.Default;
[TestInitialize]
public override void SetUp() {
@@ -25,18 +28,61 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty {
}
/// <summary>
- /// Verifies the Provider property returns non-null.
+ /// Verifies IsDirectedIdentity returns true when appropriate.
/// </summary>
[TestMethod]
- public void Provider() {
+ public void IsDirectedIdentity() {
+ var iauthRequest = this.CreateAuthenticationRequest(this.claimedId, this.claimedId);
+ Assert.IsFalse(iauthRequest.IsDirectedIdentity);
+
+ iauthRequest = this.CreateAuthenticationRequest(IdentifierSelect, IdentifierSelect);
+ Assert.IsTrue(iauthRequest.IsDirectedIdentity);
+ }
+
+ /// <summary>
+ /// Verifies ProviderVersion behavior.
+ /// </summary>
+ [TestMethod]
+ public void ProviderVersion() {
+ var authRequest = this.CreateAuthenticationRequest(this.claimedId, this.claimedId);
+ Assert.AreEqual(this.protocol.Version, authRequest.ProviderVersion);
+ }
+
+ /// <summary>
+ /// Verifies RedirectingResponse.
+ /// </summary>
+ [TestMethod]
+ public void RedirectingResponse() {
OpenIdCoordinator coordinator = new OpenIdCoordinator(
rp => {
Identifier id = this.GetMockIdentifier(TestSupport.Scenarios.AutoApproval, ProtocolVersion.V20);
- IAuthenticationRequest request = rp.CreateRequest(id, this.realm, this.returnTo);
- Assert.IsNotNull(request.Provider);
+ IAuthenticationRequest authRequest = rp.CreateRequest(id, this.realm, this.returnTo);
+ var response = authRequest.RedirectingResponse;
+ Assert.IsNotNull(response);
+ Assert.IsInstanceOfType(response.OriginalMessage, typeof(CheckIdRequest));
},
TestSupport.AutoProvider);
coordinator.Run();
}
+
+ /// <summary>
+ /// Verifies the Provider property returns non-null.
+ /// </summary>
+ [TestMethod]
+ public void Provider() {
+ IAuthenticationRequest_Accessor authRequest = this.CreateAuthenticationRequest(this.claimedId, this.claimedId);
+ Assert.IsNotNull(authRequest.Provider);
+ Assert.AreEqual(ProviderUri, authRequest.Provider.Uri);
+ Assert.AreEqual(this.protocol.Version, authRequest.Provider.Version);
+ }
+
+ private AuthenticationRequest_Accessor CreateAuthenticationRequest(Identifier claimedIdentifier, Identifier providerLocalIdentifier) {
+ ProviderEndpointDescription providerEndpoint = new ProviderEndpointDescription(ProviderUri, this.protocol.Version);
+ ServiceEndpoint endpoint = ServiceEndpoint.CreateForClaimedIdentifier(claimedIdentifier, providerLocalIdentifier, providerEndpoint, 10, 5);
+ ServiceEndpoint_Accessor endpointAccessor = ServiceEndpoint_Accessor.AttachShadow(endpoint);
+ OpenIdRelyingParty rp = this.CreateRelyingParty();
+ AuthenticationRequest_Accessor authRequest = new AuthenticationRequest_Accessor(endpointAccessor, this.realm, this.returnTo, rp);
+ return authRequest;
+ }
}
}