|
| 1 | +//----------------------------------------------------------------------- |
| 2 | +// <copyright file="SigningBindingElementBaseTests.cs" company="Andrew Arnott"> |
| 3 | +// Copyright (c) Andrew Arnott. All rights reserved. |
| 4 | +// </copyright> |
| 5 | +//----------------------------------------------------------------------- |
| 6 | + |
| 7 | +namespace DotNetOAuth.Test.ChannelElements { |
| 8 | + using DotNetOAuth.ChannelElements; |
| 9 | + using DotNetOAuth.Messages; |
| 10 | + using DotNetOAuth.Messaging; |
| 11 | + using DotNetOAuth.Messaging.Reflection; |
| 12 | + using Microsoft.VisualStudio.TestTools.UnitTesting; |
| 13 | + |
| 14 | + [TestClass] |
| 15 | + public class SigningBindingElementBaseTests : MessagingTestBase { |
| 16 | + [TestMethod] |
| 17 | + public void BaseSignatureStringTest() { |
| 18 | + RequestTokenMessage message = CreateTestRequestTokenMessage(); |
| 19 | + |
| 20 | + Assert.AreEqual( |
| 21 | + "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", |
| 22 | + SigningBindingElementBase_Accessor.ConstructSignatureBaseString(message)); |
| 23 | + } |
| 24 | + |
| 25 | + internal static RequestTokenMessage CreateTestRequestTokenMessage() { |
| 26 | + MessageReceivingEndpoint endpoint = new MessageReceivingEndpoint("https://www.google.com/accounts/OAuthGetRequestToken", HttpDeliveryMethod.AuthorizationHeaderRequest); |
| 27 | + RequestTokenMessage message = new RequestTokenMessage(endpoint); |
| 28 | + message.ConsumerKey = "nerdbank.org"; |
| 29 | + message.ConsumerSecret = "nerdbanksecret"; |
| 30 | + var signedMessage = (ITamperResistantOAuthMessage)message; |
| 31 | + signedMessage.HttpMethod = "GET"; |
| 32 | + signedMessage.SignatureMethod = "HMAC-SHA1"; |
| 33 | + MessageDictionary dictionary = new MessageDictionary(message); |
| 34 | + dictionary["oauth_timestamp"] = "1222665749"; |
| 35 | + dictionary["oauth_nonce"] = "fe4045a3f0efdd1e019fa8f8ae3f5c38"; |
| 36 | + dictionary["scope"] = "http://www.google.com/m8/feeds/"; |
| 37 | + return message; |
| 38 | + } |
| 39 | + } |
| 40 | +} |
0 commit comments