summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2012-02-20 22:37:31 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2012-02-20 22:37:31 -0800
commit9e448e402eda0b9d372d857d2e17a4b21962afec (patch)
tree285aa4478cfd5307b9ade1d0989a999fe5db28ce
parentcff5a6286292111821fe082755c7b1c1c89d3231 (diff)
downloadDotNetOpenAuth-9e448e402eda0b9d372d857d2e17a4b21962afec.zip
DotNetOpenAuth-9e448e402eda0b9d372d857d2e17a4b21962afec.tar.gz
DotNetOpenAuth-9e448e402eda0b9d372d857d2e17a4b21962afec.tar.bz2
Moved some test code around.
-rw-r--r--src/DotNetOpenAuth.Test/OAuth2/AuthorizeTests.cs12
-rw-r--r--src/DotNetOpenAuth.Test/OAuth2/OAuth2TestBase.cs14
2 files changed, 18 insertions, 8 deletions
diff --git a/src/DotNetOpenAuth.Test/OAuth2/AuthorizeTests.cs b/src/DotNetOpenAuth.Test/OAuth2/AuthorizeTests.cs
index 0f0ad8b..d4e09fa 100644
--- a/src/DotNetOpenAuth.Test/OAuth2/AuthorizeTests.cs
+++ b/src/DotNetOpenAuth.Test/OAuth2/AuthorizeTests.cs
@@ -20,22 +20,18 @@ namespace DotNetOpenAuth.Test.OAuth2 {
[TestFixture]
public class AuthorizeTests : OAuth2TestBase {
[TestCase]
- public void Test1() {
- var authHostMock = new Mock<IAuthorizationServer>();
- var cryptoStore = new MemoryCryptoKeyStore();
- authHostMock.Setup(m => m.GetClient(ClientId)).Returns(ClientDescription);
- authHostMock.SetupGet(m => m.CryptoKeyStore).Returns(cryptoStore);
- authHostMock.Setup(m => m.IsAuthorizationValid(It.Is<IAuthorizationDescription>(d => d.ClientIdentifier == ClientId && d.User == Username))).Returns(true);
+ public void AuthCodeGrantAuthorization() {
var coordinator = new OAuth2Coordinator(
AuthorizationServerDescription,
- authHostMock.Object,
+ AuthorizationServerMock,
client => {
var authState = new AuthorizationState {
Callback = ClientCallback,
};
client.PrepareRequestUserAuthorization(authState).Respond();
var result = client.ProcessUserAuthorization();
- Assert.IsNotNull(result.AccessToken);
+ Assert.IsNotNullOrEmpty(result.AccessToken);
+ Assert.IsNotNullOrEmpty(result.RefreshToken);
},
server => {
var request = server.ReadAuthorizationRequest();
diff --git a/src/DotNetOpenAuth.Test/OAuth2/OAuth2TestBase.cs b/src/DotNetOpenAuth.Test/OAuth2/OAuth2TestBase.cs
index 32de525..cefab0f 100644
--- a/src/DotNetOpenAuth.Test/OAuth2/OAuth2TestBase.cs
+++ b/src/DotNetOpenAuth.Test/OAuth2/OAuth2TestBase.cs
@@ -9,7 +9,10 @@ namespace DotNetOpenAuth.Test.OAuth2 {
using System.Collections.Generic;
using System.Linq;
using System.Text;
+ using DotNetOpenAuth.Messaging.Bindings;
using DotNetOpenAuth.OAuth2;
+ using DotNetOpenAuth.OAuth2.ChannelElements;
+ using Moq;
public class OAuth2TestBase : TestBase {
protected internal const string ClientId = "TestClientId";
@@ -29,5 +32,16 @@ namespace DotNetOpenAuth.Test.OAuth2 {
ClientSecret,
ClientCallback,
ClientType.Confidential);
+
+ protected static readonly IAuthorizationServer AuthorizationServerMock = CreateAuthorizationServerMock().Object;
+
+ protected static Mock<IAuthorizationServer> CreateAuthorizationServerMock() {
+ var authHostMock = new Mock<IAuthorizationServer>();
+ var cryptoStore = new MemoryCryptoKeyStore();
+ authHostMock.Setup(m => m.GetClient(ClientId)).Returns(ClientDescription);
+ authHostMock.SetupGet(m => m.CryptoKeyStore).Returns(cryptoStore);
+ authHostMock.Setup(m => m.IsAuthorizationValid(It.Is<IAuthorizationDescription>(d => d.ClientIdentifier == ClientId && d.User == Username))).Returns(true);
+ return authHostMock;
+ }
}
}