summaryrefslogtreecommitdiffstats
path: root/src/DotNetOAuth.Test
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOAuth.Test')
-rw-r--r--src/DotNetOAuth.Test/ChannelElements/HmacSha1SigningBindingElementTests.cs22
-rw-r--r--src/DotNetOAuth.Test/ChannelElements/SigningBindingElementBaseTests.cs40
-rw-r--r--src/DotNetOAuth.Test/DotNetOAuth.Test.csproj2
3 files changed, 64 insertions, 0 deletions
diff --git a/src/DotNetOAuth.Test/ChannelElements/HmacSha1SigningBindingElementTests.cs b/src/DotNetOAuth.Test/ChannelElements/HmacSha1SigningBindingElementTests.cs
new file mode 100644
index 0000000..b35855e
--- /dev/null
+++ b/src/DotNetOAuth.Test/ChannelElements/HmacSha1SigningBindingElementTests.cs
@@ -0,0 +1,22 @@
+//-----------------------------------------------------------------------
+// <copyright file="HmacSha1SigningBindingElementTests.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOAuth.Test.ChannelElements {
+ using DotNetOAuth.ChannelElements;
+ using DotNetOAuth.Messages;
+ using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+ [TestClass]
+ public class HmacSha1SigningBindingElementTests : MessagingTestBase {
+ [TestMethod]
+ public void SignatureTest() {
+ RequestTokenMessage message = SigningBindingElementBaseTests.CreateTestRequestTokenMessage();
+
+ HmacSha1SigningBindingElement_Accessor hmac = new HmacSha1SigningBindingElement_Accessor();
+ Assert.AreEqual("kR0LhH8UqylaLfR%2FesXVVlP4sQI%3D", hmac.GetSignature(message));
+ }
+ }
+}
diff --git a/src/DotNetOAuth.Test/ChannelElements/SigningBindingElementBaseTests.cs b/src/DotNetOAuth.Test/ChannelElements/SigningBindingElementBaseTests.cs
new file mode 100644
index 0000000..832f50c
--- /dev/null
+++ b/src/DotNetOAuth.Test/ChannelElements/SigningBindingElementBaseTests.cs
@@ -0,0 +1,40 @@
+//-----------------------------------------------------------------------
+// <copyright file="SigningBindingElementBaseTests.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOAuth.Test.ChannelElements {
+ using DotNetOAuth.ChannelElements;
+ using DotNetOAuth.Messages;
+ using DotNetOAuth.Messaging;
+ using DotNetOAuth.Messaging.Reflection;
+ using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+ [TestClass]
+ public class SigningBindingElementBaseTests : MessagingTestBase {
+ [TestMethod]
+ public void BaseSignatureStringTest() {
+ RequestTokenMessage message = CreateTestRequestTokenMessage();
+
+ Assert.AreEqual(
+ "GET&https%3A%2F%2Fwww.google.com%2Faccounts%2FOAuthGetRequestToken&oauth_consumer_key%3Dnerdbank.org%26oauth_nonce%3Dfe4045a3f0efdd1e019fa8f8ae3f5c38%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1222665749%26oauth_version%3D1.0%26scope%3Dhttp%253A%252F%252Fwww.google.com%252Fm8%252Ffeeds%252F",
+ SigningBindingElementBase_Accessor.ConstructSignatureBaseString(message));
+ }
+
+ internal static RequestTokenMessage CreateTestRequestTokenMessage() {
+ MessageReceivingEndpoint endpoint = new MessageReceivingEndpoint("https://www.google.com/accounts/OAuthGetRequestToken", HttpDeliveryMethod.AuthorizationHeaderRequest);
+ RequestTokenMessage message = new RequestTokenMessage(endpoint);
+ message.ConsumerKey = "nerdbank.org";
+ message.ConsumerSecret = "nerdbanksecret";
+ var signedMessage = (ITamperResistantOAuthMessage)message;
+ signedMessage.HttpMethod = "GET";
+ signedMessage.SignatureMethod = "HMAC-SHA1";
+ MessageDictionary dictionary = new MessageDictionary(message);
+ dictionary["oauth_timestamp"] = "1222665749";
+ dictionary["oauth_nonce"] = "fe4045a3f0efdd1e019fa8f8ae3f5c38";
+ dictionary["scope"] = "http://www.google.com/m8/feeds/";
+ return message;
+ }
+ }
+}
diff --git a/src/DotNetOAuth.Test/DotNetOAuth.Test.csproj b/src/DotNetOAuth.Test/DotNetOAuth.Test.csproj
index 6afe84c..19917ea 100644
--- a/src/DotNetOAuth.Test/DotNetOAuth.Test.csproj
+++ b/src/DotNetOAuth.Test/DotNetOAuth.Test.csproj
@@ -58,6 +58,8 @@
</Reference>
</ItemGroup>
<ItemGroup>
+ <Compile Include="ChannelElements\SigningBindingElementBaseTests.cs" />
+ <Compile Include="ChannelElements\HmacSha1SigningBindingElementTests.cs" />
<Compile Include="Messaging\CollectionAssert.cs" />
<Compile Include="Messaging\MessageSerializerTests.cs" />
<Compile Include="Messaging\Reflection\MessageDescriptionTests.cs" />