summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Test/OAuth/ChannelElements
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.Test/OAuth/ChannelElements')
-rw-r--r--src/DotNetOpenAuth.Test/OAuth/ChannelElements/HmacSha1SigningBindingElementTests.cs2
-rw-r--r--src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs79
-rw-r--r--src/DotNetOpenAuth.Test/OAuth/ChannelElements/PlaintextSigningBindingElementTest.cs10
-rw-r--r--src/DotNetOpenAuth.Test/OAuth/ChannelElements/SigningBindingElementBaseTests.cs4
-rw-r--r--src/DotNetOpenAuth.Test/OAuth/ChannelElements/UriOrOobEncodingTests.cs6
5 files changed, 42 insertions, 59 deletions
diff --git a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/HmacSha1SigningBindingElementTests.cs b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/HmacSha1SigningBindingElementTests.cs
index 6605fad..487ce56 100644
--- a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/HmacSha1SigningBindingElementTests.cs
+++ b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/HmacSha1SigningBindingElementTests.cs
@@ -12,7 +12,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements {
[TestFixture]
public class HmacSha1SigningBindingElementTests : MessagingTestBase {
- [TestCase]
+ [Test]
public void SignatureTest() {
UnauthorizedTokenRequest message = SigningBindingElementBaseTests.CreateTestRequestTokenMessage(this.MessageDescriptions, null);
diff --git a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs
index 1b9d2eb..7999a44 100644
--- a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs
+++ b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs
@@ -56,17 +56,17 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements {
new OAuthConsumerChannel(new RsaSha1ServiceProviderSigningBindingElement(new InMemoryTokenManager()), this.nonceStore, null, this.consumerSecuritySettings, new TestMessageFactory());
}
- [TestCase]
+ [Test]
public void CtorSimpleConsumer() {
new OAuthConsumerChannel(new RsaSha1ServiceProviderSigningBindingElement(new InMemoryTokenManager()), this.nonceStore, (IConsumerTokenManager)new InMemoryTokenManager(), this.consumerSecuritySettings);
}
- [TestCase]
+ [Test]
public void CtorSimpleServiceProvider() {
new OAuthServiceProviderChannel(new RsaSha1ServiceProviderSigningBindingElement(new InMemoryTokenManager()), this.nonceStore, (IServiceProviderTokenManager)new InMemoryTokenManager(), this.serviceProviderSecuritySettings);
}
- [TestCase]
+ [Test]
public void ReadFromRequestAuthorization() {
this.ParameterizedReceiveTest(HttpDeliveryMethods.AuthorizationHeaderRequest);
}
@@ -75,26 +75,27 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements {
/// Verifies that the OAuth ReadFromRequest method gathers parameters
/// from the Authorization header, the query string and the entity form data.
/// </summary>
- [TestCase]
+ [Test]
public void ReadFromRequestAuthorizationScattered() {
// Start by creating a standard POST HTTP request.
- var fields = new Dictionary<string, string> {
+ var postedFields = new Dictionary<string, string> {
{ "age", "15" },
};
- HttpRequestInfo requestInfo = CreateHttpRequestInfo(HttpDeliveryMethods.PostRequest, fields);
// Now add another field to the request URL
- UriBuilder builder = new UriBuilder(requestInfo.UrlBeforeRewriting);
+ var builder = new UriBuilder(MessagingTestBase.DefaultUrlForHttpRequestInfo);
builder.Query = "Name=Andrew";
- requestInfo.UrlBeforeRewriting = builder.Uri;
- requestInfo.RawUrl = builder.Path + builder.Query + builder.Fragment;
// Finally, add an Authorization header
- fields = new Dictionary<string, string> {
+ var authHeaderFields = new Dictionary<string, string> {
{ "Location", "http://hostb/pathB" },
{ "Timestamp", XmlConvert.ToString(DateTime.UtcNow, XmlDateTimeSerializationMode.Utc) },
};
- requestInfo.Headers.Add(HttpRequestHeader.Authorization, CreateAuthorizationHeader(fields));
+ var headers = new NameValueCollection();
+ headers.Add(HttpRequestHeaders.Authorization, CreateAuthorizationHeader(authHeaderFields));
+ headers.Add(HttpRequestHeaders.ContentType, Channel.HttpFormUrlEncoded);
+
+ var requestInfo = new HttpRequestInfo("POST", builder.Uri, form: postedFields.ToNameValueCollection(), headers: headers);
IDirectedProtocolMessage requestMessage = this.channel.ReadFromRequest(requestInfo);
@@ -106,17 +107,17 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements {
Assert.AreEqual("http://hostb/pathB", testMessage.Location.AbsoluteUri);
}
- [TestCase]
+ [Test]
public void ReadFromRequestForm() {
this.ParameterizedReceiveTest(HttpDeliveryMethods.PostRequest);
}
- [TestCase]
+ [Test]
public void ReadFromRequestQueryString() {
this.ParameterizedReceiveTest(HttpDeliveryMethods.GetRequest);
}
- [TestCase]
+ [Test]
public void SendDirectMessageResponse() {
IProtocolMessage message = new TestDirectedMessage {
Age = 15,
@@ -135,7 +136,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements {
Assert.AreEqual("http://hostb/pathB", body["Location"]);
}
- [TestCase]
+ [Test]
public void ReadFromResponse() {
var fields = new Dictionary<string, string> {
{ "age", "15" },
@@ -175,7 +176,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements {
this.channel.Request(message);
}
- [TestCase]
+ [Test]
public void RequestUsingAuthorizationHeader() {
this.ParameterizedRequestTest(HttpDeliveryMethods.AuthorizationHeaderRequest);
}
@@ -183,7 +184,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements {
/// <summary>
/// Verifies that message parts can be distributed to the query, form, and Authorization header.
/// </summary>
- [TestCase]
+ [Test]
public void RequestUsingAuthorizationHeaderScattered() {
TestDirectedMessage request = new TestDirectedMessage(MessageTransport.Direct) {
Age = 15,
@@ -216,17 +217,17 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements {
Assert.AreEqual("appearinform=formish", this.webRequestHandler.RequestEntityAsString);
}
- [TestCase]
+ [Test]
public void RequestUsingGet() {
this.ParameterizedRequestTest(HttpDeliveryMethods.GetRequest);
}
- [TestCase]
+ [Test]
public void RequestUsingPost() {
this.ParameterizedRequestTest(HttpDeliveryMethods.PostRequest);
}
- [TestCase]
+ [Test]
public void RequestUsingHead() {
this.ParameterizedRequestTest(HttpDeliveryMethods.HeadRequest);
}
@@ -234,7 +235,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements {
/// <summary>
/// Verifies that messages asking for special HTTP status codes get them.
/// </summary>
- [TestCase]
+ [Test]
public void SendDirectMessageResponseHonorsHttpStatusCodes() {
IProtocolMessage message = MessagingTestBase.GetStandardTestMessage(MessagingTestBase.FieldFill.AllRequired);
OutgoingWebResponse directResponse = this.channel.PrepareDirectResponseTestHook(message);
@@ -266,51 +267,33 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements {
}
private static HttpRequestInfo CreateHttpRequestInfo(HttpDeliveryMethods scheme, IDictionary<string, string> fields) {
- string query = MessagingUtilities.CreateQueryString(fields);
- UriBuilder requestUri = new UriBuilder("http://localhost/path");
- WebHeaderCollection headers = new WebHeaderCollection();
- MemoryStream ms = new MemoryStream();
+ var requestUri = new UriBuilder(MessagingTestBase.DefaultUrlForHttpRequestInfo);
+ var headers = new NameValueCollection();
+ NameValueCollection form = null;
string method;
switch (scheme) {
case HttpDeliveryMethods.PostRequest:
method = "POST";
- headers.Add(HttpRequestHeader.ContentType, "application/x-www-form-urlencoded");
- StreamWriter sw = new StreamWriter(ms);
- sw.Write(query);
- sw.Flush();
- ms.Position = 0;
+ form = fields.ToNameValueCollection();
+ headers.Add(HttpRequestHeaders.ContentType, Channel.HttpFormUrlEncoded);
break;
case HttpDeliveryMethods.GetRequest:
method = "GET";
- requestUri.Query = query;
+ requestUri.Query = MessagingUtilities.CreateQueryString(fields);
break;
case HttpDeliveryMethods.AuthorizationHeaderRequest:
method = "GET";
- headers.Add(HttpRequestHeader.Authorization, CreateAuthorizationHeader(fields));
+ headers.Add(HttpRequestHeaders.Authorization, CreateAuthorizationHeader(fields));
break;
default:
throw new ArgumentOutOfRangeException("scheme", scheme, "Unexpected value");
}
- HttpRequestInfo request = new HttpRequestInfo {
- HttpMethod = method,
- UrlBeforeRewriting = requestUri.Uri,
- RawUrl = requestUri.Path + requestUri.Query + requestUri.Fragment,
- Headers = headers,
- InputStream = ms,
- };
- return request;
+ return new HttpRequestInfo(method, requestUri.Uri, form: form, headers: headers);
}
private static HttpRequestInfo ConvertToRequestInfo(HttpWebRequest request, Stream postEntity) {
- HttpRequestInfo info = new HttpRequestInfo {
- HttpMethod = request.Method,
- UrlBeforeRewriting = request.RequestUri,
- RawUrl = request.RequestUri.AbsolutePath + request.RequestUri.Query + request.RequestUri.Fragment,
- Headers = request.Headers,
- InputStream = postEntity,
- };
- return info;
+ return new HttpRequestInfo(request.Method, request.RequestUri, request.Headers, postEntity);
}
private void ParameterizedRequestTest(HttpDeliveryMethods scheme) {
diff --git a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/PlaintextSigningBindingElementTest.cs b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/PlaintextSigningBindingElementTest.cs
index 8236c21..b3869e7 100644
--- a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/PlaintextSigningBindingElementTest.cs
+++ b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/PlaintextSigningBindingElementTest.cs
@@ -14,7 +14,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements {
[TestFixture]
public class PlaintextSigningBindingElementTest {
- [TestCase]
+ [Test]
public void HttpsSignatureGeneration() {
SigningBindingElementBase target = new PlaintextSigningBindingElement();
target.Channel = new TestChannel();
@@ -27,7 +27,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements {
Assert.AreEqual("cs&ts", message.Signature);
}
- [TestCase]
+ [Test]
public void HttpsSignatureVerification() {
MessageReceivingEndpoint endpoint = new MessageReceivingEndpoint("https://localtest", HttpDeliveryMethods.GetRequest);
ITamperProtectionChannelBindingElement target = new PlaintextSigningBindingElement();
@@ -40,7 +40,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements {
Assert.IsNotNull(target.ProcessIncomingMessage(message));
}
- [TestCase]
+ [Test]
public void HttpsSignatureVerificationNotApplicable() {
SigningBindingElementBase target = new PlaintextSigningBindingElement();
target.Channel = new TestChannel();
@@ -53,7 +53,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements {
Assert.AreEqual(MessageProtections.None, target.ProcessIncomingMessage(message), "PLAINTEXT binding element should opt-out where it doesn't understand.");
}
- [TestCase]
+ [Test]
public void HttpSignatureGeneration() {
SigningBindingElementBase target = new PlaintextSigningBindingElement();
target.Channel = new TestChannel();
@@ -68,7 +68,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements {
Assert.IsNull(message.Signature);
}
- [TestCase]
+ [Test]
public void HttpSignatureVerification() {
SigningBindingElementBase target = new PlaintextSigningBindingElement();
target.Channel = new TestChannel();
diff --git a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/SigningBindingElementBaseTests.cs b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/SigningBindingElementBaseTests.cs
index 85f7130..dffe6c1 100644
--- a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/SigningBindingElementBaseTests.cs
+++ b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/SigningBindingElementBaseTests.cs
@@ -16,7 +16,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements {
[TestFixture]
public class SigningBindingElementBaseTests : MessagingTestBase {
- [TestCase]
+ [Test]
public void BaseSignatureStringTest() {
// Tests a message sent by HTTP GET, with no query string included in the endpoint.
UnauthorizedTokenRequest message = CreateTestRequestTokenMessage(
@@ -73,7 +73,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements {
SigningBindingElementBase.ConstructSignatureBaseString(message, this.MessageDescriptions.GetAccessor(message)));
}
- [TestCase]
+ [Test]
public void BaseSignatureStringResourceRequests() {
var message = this.CreateResourceRequest(new MessageReceivingEndpoint("http://tom.test.wishpot.com/restapi/List/Search?List.LastName=ciccotosto", HttpDeliveryMethods.GetRequest));
message.ConsumerKey = "public";
diff --git a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/UriOrOobEncodingTests.cs b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/UriOrOobEncodingTests.cs
index 0dc572f..185e75b 100644
--- a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/UriOrOobEncodingTests.cs
+++ b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/UriOrOobEncodingTests.cs
@@ -24,7 +24,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements {
/// <summary>
/// Verifies null value encoding
/// </summary>
- [TestCase]
+ [Test]
public void NullValueEncoding() {
Assert.AreEqual("oob", this.encoding.EncodedNullValue);
}
@@ -32,7 +32,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements {
/// <summary>
/// Verifies decoding "oob" results in a null uri.
/// </summary>
- [TestCase]
+ [Test]
public void DecodeOobToNullUri() {
Assert.IsNull(this.encoding.Decode("oob"));
}
@@ -48,7 +48,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements {
/// <summary>
/// Verifies proper decoding/encoding of a Uri
/// </summary>
- [TestCase]
+ [Test]
public void UriEncodeDecode() {
Uri original = new Uri("http://somehost/p?q=a#frag");
string encodedValue = this.encoding.Encode(original);