diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2008-09-13 13:42:46 -0700 |
---|---|---|
committer | Andrew <andrewarnott@gmail.com> | 2008-09-13 13:42:46 -0700 |
commit | f665e1e639319918385fcc8397f8c0d5009e3bdd (patch) | |
tree | 6219f476ab24bc187eac79b501d7de73c9acd234 /src/DotNetOAuth.Test/Messaging/StandardMessageExpirationBindingElementTests.cs | |
parent | 61650a6ec207c94cb92e27227dac75606c3e7e00 (diff) | |
download | DotNetOpenAuth-f665e1e639319918385fcc8397f8c0d5009e3bdd.zip DotNetOpenAuth-f665e1e639319918385fcc8397f8c0d5009e3bdd.tar.gz DotNetOpenAuth-f665e1e639319918385fcc8397f8c0d5009e3bdd.tar.bz2 |
Totally refactored signing, expiration and replay detection into extensible channel binding elements.
Diffstat (limited to 'src/DotNetOAuth.Test/Messaging/StandardMessageExpirationBindingElementTests.cs')
-rw-r--r-- | src/DotNetOAuth.Test/Messaging/StandardMessageExpirationBindingElementTests.cs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/DotNetOAuth.Test/Messaging/StandardMessageExpirationBindingElementTests.cs b/src/DotNetOAuth.Test/Messaging/StandardMessageExpirationBindingElementTests.cs new file mode 100644 index 0000000..5a664a4 --- /dev/null +++ b/src/DotNetOAuth.Test/Messaging/StandardMessageExpirationBindingElementTests.cs @@ -0,0 +1,38 @@ +//-----------------------------------------------------------------------
+// <copyright file="StandardMessageExpirationBindingElementTests.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOAuth.Test.Messaging {
+ using System;
+ using DotNetOAuth.Messaging;
+ using DotNetOAuth.Test.Mocks;
+ using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+ [TestClass]
+ public class StandardMessageExpirationBindingElementTests : MessagingTestBase {
+ [TestMethod]
+ public void SendSetsTimestamp() {
+ TestExpiringMessage message = new TestExpiringMessage(MessageTransport.Indirect);
+ message.Recipient = new Uri("http://localtest");
+ ((IExpiringProtocolMessage)message).UtcCreationDate = DateTime.Parse("1/1/1990");
+
+ Channel channel = CreateChannel(ChannelProtection.Expiration, ChannelProtection.Expiration);
+ channel.Send(message);
+ Assert.IsTrue(DateTime.UtcNow - ((IExpiringProtocolMessage)message).UtcCreationDate < TimeSpan.FromSeconds(3), "The timestamp on the message was not set on send.");
+ }
+
+ [TestMethod]
+ public void VerifyGoodTimestampIsAccepted() {
+ this.Channel = CreateChannel(ChannelProtection.Expiration, ChannelProtection.Expiration);
+ this.ParameterizedReceiveProtectedTest(DateTime.UtcNow, false);
+ }
+
+ [TestMethod, ExpectedException(typeof(ExpiredMessageException))]
+ public void VerifyBadTimestampIsRejected() {
+ this.Channel = CreateChannel(ChannelProtection.Expiration, ChannelProtection.Expiration);
+ this.ParameterizedReceiveProtectedTest(DateTime.UtcNow - StandardMessageExpirationBindingElement.DefaultMaximumMessageAge - TimeSpan.FromSeconds(1), false);
+ }
+ }
+}
|