summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Test
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2012-03-31 11:45:42 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2012-03-31 11:45:42 -0700
commitaf226f837b7bb5050ab511e66ba75714f79d8865 (patch)
tree3dba68ac08d55fa46e2b5c0b52c96d6612b12a2a /src/DotNetOpenAuth.Test
parentb4aa4d4cf25f358e8ca199fe3fbd446d1bb9bc42 (diff)
parent7265452c16667c6ff499970b0d6778d5184cc8cb (diff)
downloadDotNetOpenAuth-af226f837b7bb5050ab511e66ba75714f79d8865.zip
DotNetOpenAuth-af226f837b7bb5050ab511e66ba75714f79d8865.tar.gz
DotNetOpenAuth-af226f837b7bb5050ab511e66ba75714f79d8865.tar.bz2
Applied some refactoring of OAuth2 classes.
Diffstat (limited to 'src/DotNetOpenAuth.Test')
-rw-r--r--src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj4
-rw-r--r--src/DotNetOpenAuth.Test/OAuth2/AuthorizationServerTests.cs2
-rw-r--r--src/DotNetOpenAuth.Test/OAuth2/MessageFactoryTests.cs32
-rw-r--r--src/DotNetOpenAuth.Test/OAuth2/OAuth2TestBase.cs2
4 files changed, 25 insertions, 15 deletions
diff --git a/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj b/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj
index 00c1bb4..a3edcf6 100644
--- a/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj
+++ b/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj
@@ -437,6 +437,10 @@
<Project>{ADC2CC8C-541E-4F86-ACB1-DD504A36FA4B}</Project>
<Name>DotNetOpenAuth.OAuth2.Client.UI</Name>
</ProjectReference>
+ <ProjectReference Include="..\DotNetOpenAuth.OAuth2.ClientAuthorization\DotNetOpenAuth.OAuth2.ClientAuthorization.csproj">
+ <Project>{CCF3728A-B3D7-404A-9BC6-75197135F2D7}</Project>
+ <Name>DotNetOpenAuth.OAuth2.ClientAuthorization</Name>
+ </ProjectReference>
<ProjectReference Include="..\DotNetOpenAuth.OAuth2.Client\DotNetOpenAuth.OAuth2.Client.csproj">
<Project>{CDEDD439-7F35-4E6E-8605-4E70BDC4CC99}</Project>
<Name>DotNetOpenAuth.OAuth2.Client</Name>
diff --git a/src/DotNetOpenAuth.Test/OAuth2/AuthorizationServerTests.cs b/src/DotNetOpenAuth.Test/OAuth2/AuthorizationServerTests.cs
index f3d8feb..3791e28 100644
--- a/src/DotNetOpenAuth.Test/OAuth2/AuthorizationServerTests.cs
+++ b/src/DotNetOpenAuth.Test/OAuth2/AuthorizationServerTests.cs
@@ -28,7 +28,7 @@ namespace DotNetOpenAuth.Test.OAuth2 {
AuthorizationServerMock,
new UserAgentClient(AuthorizationServerDescription),
client => {
- var request = new AccessTokenAuthorizationCodeRequest(AuthorizationServerDescription)
+ var request = new AccessTokenAuthorizationCodeRequestC(AuthorizationServerDescription)
{ ClientIdentifier = ClientId, ClientSecret = ClientSecret, AuthorizationCode = "foo" };
var response = client.Channel.Request<AccessTokenFailedResponse>(request);
diff --git a/src/DotNetOpenAuth.Test/OAuth2/MessageFactoryTests.cs b/src/DotNetOpenAuth.Test/OAuth2/MessageFactoryTests.cs
index bec85e2..b5ee767 100644
--- a/src/DotNetOpenAuth.Test/OAuth2/MessageFactoryTests.cs
+++ b/src/DotNetOpenAuth.Test/OAuth2/MessageFactoryTests.cs
@@ -17,18 +17,22 @@ namespace DotNetOpenAuth.Test.OAuth2 {
using NUnit.Framework;
/// <summary>
- /// Verifies that the WRAP message types are recognized.
+ /// Verifies that the OAuth 2 message types are recognized.
/// </summary>
public class MessageFactoryTests : OAuth2TestBase {
private readonly MessageReceivingEndpoint recipient = new MessageReceivingEndpoint("http://who", HttpDeliveryMethods.PostRequest);
- private OAuth2AuthorizationServerChannel channel;
- private IMessageFactory messageFactory;
+ private IMessageFactory authServerMessageFactory;
+
+ private IMessageFactory clientMessageFactory;
public override void SetUp() {
base.SetUp();
- this.channel = new OAuth2AuthorizationServerChannel(new Mock<IAuthorizationServer>().Object);
- this.messageFactory = this.channel.MessageFactoryTestHook;
+ var authServerChannel = new OAuth2AuthorizationServerChannel(new Mock<IAuthorizationServer>().Object);
+ this.authServerMessageFactory = authServerChannel.MessageFactoryTestHook;
+
+ var clientChannel = new OAuth2ClientChannel();
+ this.clientMessageFactory = clientChannel.MessageFactoryTestHook;
}
#region End user authorization messages
@@ -40,7 +44,7 @@ namespace DotNetOpenAuth.Test.OAuth2 {
{ Protocol.client_id, "abc" },
{ Protocol.redirect_uri, "abc" },
};
- IDirectedProtocolMessage request = this.messageFactory.GetNewRequestMessage(this.recipient, fields);
+ IDirectedProtocolMessage request = this.authServerMessageFactory.GetNewRequestMessage(this.recipient, fields);
Assert.That(request, Is.InstanceOf(typeof(EndUserAuthorizationRequest)));
}
@@ -51,7 +55,7 @@ namespace DotNetOpenAuth.Test.OAuth2 {
{ Protocol.client_id, "abc" },
{ Protocol.redirect_uri, "abc" },
};
- IDirectedProtocolMessage request = this.messageFactory.GetNewRequestMessage(this.recipient, fields);
+ IDirectedProtocolMessage request = this.authServerMessageFactory.GetNewRequestMessage(this.recipient, fields);
Assert.That(request, Is.InstanceOf(typeof(EndUserAuthorizationImplicitRequest)));
}
@@ -60,7 +64,7 @@ namespace DotNetOpenAuth.Test.OAuth2 {
var fields = new Dictionary<string, string> {
{ Protocol.code, "abc" },
};
- IDirectedProtocolMessage request = this.messageFactory.GetNewRequestMessage(this.recipient, fields);
+ IDirectedProtocolMessage request = this.clientMessageFactory.GetNewRequestMessage(this.recipient, fields);
Assert.That(request, Is.InstanceOf(typeof(EndUserAuthorizationSuccessResponseBase)));
}
@@ -70,7 +74,7 @@ namespace DotNetOpenAuth.Test.OAuth2 {
{ Protocol.access_token, "abc" },
{ Protocol.token_type, "bearer" },
};
- IDirectedProtocolMessage request = this.messageFactory.GetNewRequestMessage(this.recipient, fields);
+ IDirectedProtocolMessage request = this.clientMessageFactory.GetNewRequestMessage(this.recipient, fields);
Assert.That(request, Is.InstanceOf(typeof(EndUserAuthorizationSuccessResponseBase)));
}
@@ -79,7 +83,7 @@ namespace DotNetOpenAuth.Test.OAuth2 {
var fields = new Dictionary<string, string> {
{ Protocol.error, "access-denied" },
};
- IDirectedProtocolMessage request = this.messageFactory.GetNewRequestMessage(this.recipient, fields);
+ IDirectedProtocolMessage request = this.clientMessageFactory.GetNewRequestMessage(this.recipient, fields);
Assert.That(request, Is.InstanceOf(typeof(EndUserAuthorizationFailedResponse)));
}
@@ -94,7 +98,7 @@ namespace DotNetOpenAuth.Test.OAuth2 {
{ Protocol.refresh_token, "abc" },
{ Protocol.grant_type, "refresh-token" },
};
- IDirectedProtocolMessage request = this.messageFactory.GetNewRequestMessage(this.recipient, fields);
+ IDirectedProtocolMessage request = this.authServerMessageFactory.GetNewRequestMessage(this.recipient, fields);
Assert.That(request, Is.InstanceOf(typeof(AccessTokenRefreshRequest)));
}
@@ -106,7 +110,7 @@ namespace DotNetOpenAuth.Test.OAuth2 {
{ Protocol.grant_type, "authorization-code" },
{ Protocol.redirect_uri, "http://someUri" },
};
- IDirectedProtocolMessage request = this.messageFactory.GetNewRequestMessage(this.recipient, fields);
+ IDirectedProtocolMessage request = this.authServerMessageFactory.GetNewRequestMessage(this.recipient, fields);
Assert.That(request, Is.InstanceOf(typeof(AccessTokenAuthorizationCodeRequest)));
}
@@ -119,7 +123,7 @@ namespace DotNetOpenAuth.Test.OAuth2 {
{ Protocol.username, "abc" },
{ Protocol.password, "abc" },
};
- IDirectedProtocolMessage request = this.messageFactory.GetNewRequestMessage(this.recipient, fields);
+ IDirectedProtocolMessage request = this.authServerMessageFactory.GetNewRequestMessage(this.recipient, fields);
Assert.That(request, Is.InstanceOf(typeof(AccessTokenResourceOwnerPasswordCredentialsRequest)));
}
@@ -130,7 +134,7 @@ namespace DotNetOpenAuth.Test.OAuth2 {
{ Protocol.client_secret, "abc" },
{ Protocol.grant_type, "none" },
};
- IDirectedProtocolMessage request = this.messageFactory.GetNewRequestMessage(this.recipient, fields);
+ IDirectedProtocolMessage request = this.authServerMessageFactory.GetNewRequestMessage(this.recipient, fields);
Assert.That(request, Is.InstanceOf(typeof(AccessTokenClientCredentialsRequest)));
}
diff --git a/src/DotNetOpenAuth.Test/OAuth2/OAuth2TestBase.cs b/src/DotNetOpenAuth.Test/OAuth2/OAuth2TestBase.cs
index 87d91f7..ed6ce70 100644
--- a/src/DotNetOpenAuth.Test/OAuth2/OAuth2TestBase.cs
+++ b/src/DotNetOpenAuth.Test/OAuth2/OAuth2TestBase.cs
@@ -13,6 +13,7 @@ namespace DotNetOpenAuth.Test.OAuth2 {
using DotNetOpenAuth.Messaging.Bindings;
using DotNetOpenAuth.OAuth2;
using DotNetOpenAuth.OAuth2.ChannelElements;
+ using DotNetOpenAuth.OAuth2.Messages;
using Moq;
public class OAuth2TestBase : TestBase {
@@ -53,6 +54,7 @@ namespace DotNetOpenAuth.Test.OAuth2 {
d.ClientIdentifier == ClientId && d.User == ResourceOwnerUsername &&
MessagingUtilities.AreEquivalent(d.Scope, TestScopes)))).Returns(true);
authHostMock.Setup(m => m.IsResourceOwnerCredentialValid(ResourceOwnerUsername, ResourceOwnerPassword)).Returns(true);
+ authHostMock.Setup(m => m.GetAccessTokenParameters(It.IsAny<IAccessTokenRequest>())).Returns(new AccessTokenParameters());
return authHostMock;
}
}