summaryrefslogtreecommitdiffstats
path: root/src/DotNetOAuth.Test/Messaging
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOAuth.Test/Messaging')
-rw-r--r--src/DotNetOAuth.Test/Messaging/ChannelTests.cs13
-rw-r--r--src/DotNetOAuth.Test/Messaging/MessagingTestBase.cs13
-rw-r--r--src/DotNetOAuth.Test/Messaging/ProtocolExceptionTests.cs8
-rw-r--r--src/DotNetOAuth.Test/Messaging/StandardExpirationBindingElementTests.cs (renamed from src/DotNetOAuth.Test/Messaging/StandardMessageExpirationBindingElementTests.cs)13
4 files changed, 25 insertions, 22 deletions
diff --git a/src/DotNetOAuth.Test/Messaging/ChannelTests.cs b/src/DotNetOAuth.Test/Messaging/ChannelTests.cs
index 6f58133..e4381a6 100644
--- a/src/DotNetOAuth.Test/Messaging/ChannelTests.cs
+++ b/src/DotNetOAuth.Test/Messaging/ChannelTests.cs
@@ -11,6 +11,7 @@ namespace DotNetOAuth.Test.Messaging {
using System.Net;
using System.Web;
using DotNetOAuth.Messaging;
+ using DotNetOAuth.Messaging.Bindings;
using DotNetOAuth.Test.Mocks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -222,26 +223,26 @@ namespace DotNetOAuth.Test.Messaging {
TestReplayProtectedMessage message = new TestReplayProtectedMessage(MessageTransport.Indirect);
message.Recipient = new Uri("http://localtest");
- this.Channel = CreateChannel(ChannelProtection.ReplayProtection, ChannelProtection.ReplayProtection);
+ this.Channel = CreateChannel(MessageProtection.ReplayProtection, MessageProtection.ReplayProtection);
this.Channel.Send(message);
Assert.IsNotNull(((IReplayProtectedProtocolMessage)message).Nonce);
}
[TestMethod, ExpectedException(typeof(InvalidSignatureException))]
public void ReceivedInvalidSignature() {
- this.Channel = CreateChannel(ChannelProtection.TamperProtection, ChannelProtection.TamperProtection);
+ this.Channel = CreateChannel(MessageProtection.TamperProtection, MessageProtection.TamperProtection);
this.ParameterizedReceiveProtectedTest(DateTime.UtcNow, true);
}
[TestMethod]
public void ReceivedReplayProtectedMessageJustOnce() {
- this.Channel = CreateChannel(ChannelProtection.ReplayProtection, ChannelProtection.ReplayProtection);
+ this.Channel = CreateChannel(MessageProtection.ReplayProtection, MessageProtection.ReplayProtection);
this.ParameterizedReceiveProtectedTest(DateTime.UtcNow, false);
}
[TestMethod, ExpectedException(typeof(ReplayedMessageException))]
public void ReceivedReplayProtectedMessageTwice() {
- this.Channel = CreateChannel(ChannelProtection.ReplayProtection, ChannelProtection.ReplayProtection);
+ this.Channel = CreateChannel(MessageProtection.ReplayProtection, MessageProtection.ReplayProtection);
this.ParameterizedReceiveProtectedTest(DateTime.UtcNow, false);
this.ParameterizedReceiveProtectedTest(DateTime.UtcNow, false);
}
@@ -250,7 +251,7 @@ namespace DotNetOAuth.Test.Messaging {
public void MessageExpirationWithoutTamperResistance() {
new TestChannel(
new TestMessageTypeProvider(),
- new StandardMessageExpirationBindingElement());
+ new StandardExpirationBindingElement());
}
[TestMethod, ExpectedException(typeof(ProtocolException))]
@@ -267,7 +268,7 @@ namespace DotNetOAuth.Test.Messaging {
IChannelBindingElement transformB = new MockTransformationBindingElement("b");
IChannelBindingElement sign = new MockSigningBindingElement();
IChannelBindingElement replay = new MockReplayProtectionBindingElement();
- IChannelBindingElement expire = new StandardMessageExpirationBindingElement();
+ IChannelBindingElement expire = new StandardExpirationBindingElement();
Channel channel = new TestChannel(
new TestMessageTypeProvider(),
diff --git a/src/DotNetOAuth.Test/Messaging/MessagingTestBase.cs b/src/DotNetOAuth.Test/Messaging/MessagingTestBase.cs
index 61be6a7..b0b4eba 100644
--- a/src/DotNetOAuth.Test/Messaging/MessagingTestBase.cs
+++ b/src/DotNetOAuth.Test/Messaging/MessagingTestBase.cs
@@ -11,6 +11,7 @@ namespace DotNetOAuth.Test {
using System.Net;
using System.Xml;
using DotNetOAuth.Messaging;
+ using DotNetOAuth.Messaging.Bindings;
using DotNetOAuth.Test.Mocks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -53,22 +54,22 @@ namespace DotNetOAuth.Test {
return request;
}
- internal static Channel CreateChannel(ChannelProtection capabilityAndRecognition) {
+ internal static Channel CreateChannel(MessageProtection capabilityAndRecognition) {
return CreateChannel(capabilityAndRecognition, capabilityAndRecognition);
}
- internal static Channel CreateChannel(ChannelProtection capability, ChannelProtection recognition) {
+ internal static Channel CreateChannel(MessageProtection capability, MessageProtection recognition) {
bool signing = false, expiration = false, replay = false;
var bindingElements = new List<IChannelBindingElement>();
- if (capability >= ChannelProtection.TamperProtection) {
+ if (capability >= MessageProtection.TamperProtection) {
bindingElements.Add(new MockSigningBindingElement());
signing = true;
}
- if (capability >= ChannelProtection.Expiration) {
- bindingElements.Add(new StandardMessageExpirationBindingElement());
+ if (capability >= MessageProtection.Expiration) {
+ bindingElements.Add(new StandardExpirationBindingElement());
expiration = true;
}
- if (capability >= ChannelProtection.ReplayProtection) {
+ if (capability >= MessageProtection.ReplayProtection) {
bindingElements.Add(new MockReplayProtectionBindingElement());
replay = true;
}
diff --git a/src/DotNetOAuth.Test/Messaging/ProtocolExceptionTests.cs b/src/DotNetOAuth.Test/Messaging/ProtocolExceptionTests.cs
index 072b57c..0e01e33 100644
--- a/src/DotNetOAuth.Test/Messaging/ProtocolExceptionTests.cs
+++ b/src/DotNetOAuth.Test/Messaging/ProtocolExceptionTests.cs
@@ -38,7 +38,7 @@ namespace DotNetOAuth.Test.Messaging {
IDirectedProtocolMessage msg = (IDirectedProtocolMessage)ex;
Assert.AreEqual("some error occurred", ex.Message);
Assert.AreSame(receiver, msg.Recipient);
- Assert.AreEqual(request.Protocol, msg.Protocol);
+ Assert.AreEqual(request.ProtocolVersion, msg.ProtocolVersion);
Assert.AreEqual(request.Transport, msg.Transport);
msg.EnsureValidMessage();
}
@@ -62,15 +62,15 @@ namespace DotNetOAuth.Test.Messaging {
ProtocolException ex = new ProtocolException("message", request, null);
IDirectedProtocolMessage msg = (IDirectedProtocolMessage)ex;
Assert.IsNull(msg.Recipient);
- Assert.AreEqual(request.Protocol, msg.Protocol);
+ Assert.AreEqual(request.ProtocolVersion, msg.ProtocolVersion);
Assert.AreEqual(request.Transport, msg.Transport);
}
[TestMethod, ExpectedException(typeof(InvalidOperationException))]
- public void ProtocolWithoutMessage() {
+ public void ProtocolVersionWithoutMessage() {
ProtocolException ex = new ProtocolException();
IDirectedProtocolMessage msg = (IDirectedProtocolMessage)ex;
- var temp = msg.Protocol;
+ var temp = msg.ProtocolVersion;
}
[TestMethod, ExpectedException(typeof(InvalidOperationException))]
diff --git a/src/DotNetOAuth.Test/Messaging/StandardMessageExpirationBindingElementTests.cs b/src/DotNetOAuth.Test/Messaging/StandardExpirationBindingElementTests.cs
index 5a664a4..84b12c6 100644
--- a/src/DotNetOAuth.Test/Messaging/StandardMessageExpirationBindingElementTests.cs
+++ b/src/DotNetOAuth.Test/Messaging/StandardExpirationBindingElementTests.cs
@@ -1,5 +1,5 @@
//-----------------------------------------------------------------------
-// <copyright file="StandardMessageExpirationBindingElementTests.cs" company="Andrew Arnott">
+// <copyright file="StandardExpirationBindingElementTests.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
@@ -7,32 +7,33 @@
namespace DotNetOAuth.Test.Messaging {
using System;
using DotNetOAuth.Messaging;
+ using DotNetOAuth.Messaging.Bindings;
using DotNetOAuth.Test.Mocks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
- public class StandardMessageExpirationBindingElementTests : MessagingTestBase {
+ public class StandardExpirationBindingElementTests : 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 channel = CreateChannel(MessageProtection.Expiration, MessageProtection.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.Channel = CreateChannel(MessageProtection.Expiration, MessageProtection.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);
+ this.Channel = CreateChannel(MessageProtection.Expiration, MessageProtection.Expiration);
+ this.ParameterizedReceiveProtectedTest(DateTime.UtcNow - StandardExpirationBindingElement.DefaultMaximumMessageAge - TimeSpan.FromSeconds(1), false);
}
}
}