blob: 9ba433d05c1c33b4d77ec03b6aaf1569973e6843 (
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
|
//-----------------------------------------------------------------------
// <copyright file="StandardExpirationBindingElementTests.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.Test.Messaging.Bindings {
using System;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.Messaging.Bindings;
using DotNetOpenAuth.Test.Mocks;
using NUnit.Framework;
[TestFixture]
public class StandardExpirationBindingElementTests : MessagingTestBase {
[TestCase]
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(MessageProtections.Expiration);
channel.PrepareResponse(message);
Assert.IsTrue(DateTime.UtcNow - ((IExpiringProtocolMessage)message).UtcCreationDate < TimeSpan.FromSeconds(3), "The timestamp on the message was not set on send.");
}
[TestCase]
public void VerifyGoodTimestampIsAccepted() {
this.Channel = CreateChannel(MessageProtections.Expiration);
this.ParameterizedReceiveProtectedTest(DateTime.UtcNow, false);
}
[TestCase, ExpectedException(typeof(ExpiredMessageException))]
public void VerifyBadTimestampIsRejected() {
this.Channel = CreateChannel(MessageProtections.Expiration);
this.ParameterizedReceiveProtectedTest(DateTime.UtcNow - StandardExpirationBindingElement.MaximumMessageAge - TimeSpan.FromSeconds(1), false);
}
}
}
|