diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2008-12-15 14:40:15 -0800 |
---|---|---|
committer | Andrew <andrewarnott@gmail.com> | 2008-12-15 14:40:15 -0800 |
commit | e6ba4ad0adde9a1bda4b9227014360fdf34d164a (patch) | |
tree | 113ea04e13e3c47fa68aabe29df2d19b95ed4739 /src/DotNetOpenAuth.Test/OpenId/ChannelElements | |
parent | 424f328b527caad0be9099cc7be10053e8d3382f (diff) | |
download | DotNetOpenAuth-e6ba4ad0adde9a1bda4b9227014360fdf34d164a.zip DotNetOpenAuth-e6ba4ad0adde9a1bda4b9227014360fdf34d164a.tar.gz DotNetOpenAuth-e6ba4ad0adde9a1bda4b9227014360fdf34d164a.tar.bz2 |
Added nonce and expiration checking to the openid channel stack.
Diffstat (limited to 'src/DotNetOpenAuth.Test/OpenId/ChannelElements')
-rw-r--r-- | src/DotNetOpenAuth.Test/OpenId/ChannelElements/OpenIdChannelTests.cs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/DotNetOpenAuth.Test/OpenId/ChannelElements/OpenIdChannelTests.cs b/src/DotNetOpenAuth.Test/OpenId/ChannelElements/OpenIdChannelTests.cs index 7b92ba8..f47dfdf 100644 --- a/src/DotNetOpenAuth.Test/OpenId/ChannelElements/OpenIdChannelTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/ChannelElements/OpenIdChannelTests.cs @@ -12,6 +12,7 @@ namespace DotNetOpenAuth.Test.OpenId.ChannelElements { using System.Net; using System.Text; using DotNetOpenAuth.Messaging; + using DotNetOpenAuth.Messaging.Bindings; using DotNetOpenAuth.Messaging.Reflection; using DotNetOpenAuth.OpenId; using DotNetOpenAuth.OpenId.ChannelElements; @@ -19,6 +20,7 @@ namespace DotNetOpenAuth.Test.OpenId.ChannelElements { [TestClass] public class OpenIdChannelTests : TestBase { + private static readonly TimeSpan maximumMessageAge = TimeSpan.FromHours(3); // good for tests, too long for production private OpenIdChannel channel; private OpenIdChannel_Accessor accessor; private Mocks.TestWebRequestHandler webHandler; @@ -26,13 +28,24 @@ namespace DotNetOpenAuth.Test.OpenId.ChannelElements { [TestInitialize] public void Setup() { this.webHandler = new Mocks.TestWebRequestHandler(); - this.channel = new OpenIdChannel(new AssociationMemoryStore<Uri>()); + this.channel = new OpenIdChannel(new AssociationMemoryStore<Uri>(), new NonceMemoryStore(maximumMessageAge)); this.accessor = OpenIdChannel_Accessor.AttachShadow(this.channel); this.channel.WebRequestHandler = this.webHandler; } [TestMethod] public void Ctor() { + // Verify that the channel stack includes the expected types. + // While other binding elements may be substituted for these, we'd then have + // to test them. Since we're not testing them in the OpenID battery of tests, + // we make sure they are the standard ones so that we trust they are tested + // elsewhere by the testing library. + var replayElement = (StandardReplayProtectionBindingElement)this.channel.BindingElements.SingleOrDefault(el => el is StandardReplayProtectionBindingElement); + Assert.IsTrue(this.channel.BindingElements.Any(el => el is StandardExpirationBindingElement)); + Assert.IsNotNull(replayElement); + + // Verify that empty nonces are allowed, since OpenID 2.0 allows this. + Assert.IsTrue(replayElement.AllowZeroLengthNonce); } /// <summary> |