diff options
Diffstat (limited to 'src')
3 files changed, 17 insertions, 7 deletions
diff --git a/src/DotNetOpenAuth.Test/OAuth2/OAuth2TestBase.cs b/src/DotNetOpenAuth.Test/OAuth2/OAuth2TestBase.cs index 1b5c329..87d91f7 100644 --- a/src/DotNetOpenAuth.Test/OAuth2/OAuth2TestBase.cs +++ b/src/DotNetOpenAuth.Test/OAuth2/OAuth2TestBase.cs @@ -9,6 +9,7 @@ namespace DotNetOpenAuth.Test.OAuth2 { using System.Collections.Generic; using System.Linq; using System.Text; + using DotNetOpenAuth.Messaging; using DotNetOpenAuth.Messaging.Bindings; using DotNetOpenAuth.OAuth2; using DotNetOpenAuth.OAuth2.ChannelElements; @@ -23,6 +24,8 @@ namespace DotNetOpenAuth.Test.OAuth2 { protected const string ResourceOwnerPassword = "TestUserPassword"; + protected static readonly string[] TestScopes = new[] { "Scope1", "Scope2" }; + protected static readonly Uri ClientCallback = new Uri("http://client/callback"); protected static readonly AuthorizationServerDescription AuthorizationServerDescription = new AuthorizationServerDescription { @@ -42,7 +45,13 @@ namespace DotNetOpenAuth.Test.OAuth2 { 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 == ResourceOwnerUsername))).Returns(true); + authHostMock.Setup( + m => + m.IsAuthorizationValid( + It.Is<IAuthorizationDescription>( + d => + d.ClientIdentifier == ClientId && d.User == ResourceOwnerUsername && + MessagingUtilities.AreEquivalent(d.Scope, TestScopes)))).Returns(true); authHostMock.Setup(m => m.IsResourceOwnerCredentialValid(ResourceOwnerUsername, ResourceOwnerPassword)).Returns(true); return authHostMock; } diff --git a/src/DotNetOpenAuth.Test/OAuth2/UserAgentClientAuthorizeTests.cs b/src/DotNetOpenAuth.Test/OAuth2/UserAgentClientAuthorizeTests.cs index 3a8944f..4e9e984 100644 --- a/src/DotNetOpenAuth.Test/OAuth2/UserAgentClientAuthorizeTests.cs +++ b/src/DotNetOpenAuth.Test/OAuth2/UserAgentClientAuthorizeTests.cs @@ -26,7 +26,7 @@ namespace DotNetOpenAuth.Test.OAuth2 { AuthorizationServerMock, new UserAgentClient(AuthorizationServerDescription), client => { - var authState = new AuthorizationState { + var authState = new AuthorizationState(TestScopes) { Callback = ClientCallback, }; var request = client.PrepareRequestUserAuthorization(authState); @@ -57,7 +57,7 @@ namespace DotNetOpenAuth.Test.OAuth2 { AuthorizationServerMock, coordinatorClient, client => { - var authState = new AuthorizationState { + var authState = new AuthorizationState(TestScopes) { Callback = ClientCallback, }; var request = client.PrepareRequestUserAuthorization(authState, implicitResponseType: true); diff --git a/src/DotNetOpenAuth.Test/OAuth2/WebServerClientAuthorizeTests.cs b/src/DotNetOpenAuth.Test/OAuth2/WebServerClientAuthorizeTests.cs index 91b5a10..df89beb 100644 --- a/src/DotNetOpenAuth.Test/OAuth2/WebServerClientAuthorizeTests.cs +++ b/src/DotNetOpenAuth.Test/OAuth2/WebServerClientAuthorizeTests.cs @@ -9,6 +9,7 @@ namespace DotNetOpenAuth.Test.OAuth2 { using System.Collections.Generic; using System.Linq; using System.Text; + using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OAuth2; using DotNetOpenAuth.OAuth2.ChannelElements; using DotNetOpenAuth.OAuth2.Messages; @@ -24,7 +25,7 @@ namespace DotNetOpenAuth.Test.OAuth2 { AuthorizationServerMock, new WebServerClient(AuthorizationServerDescription), client => { - var authState = new AuthorizationState { + var authState = new AuthorizationState(TestScopes) { Callback = ClientCallback, }; client.PrepareRequestUserAuthorization(authState).Respond(); @@ -51,7 +52,7 @@ namespace DotNetOpenAuth.Test.OAuth2 { AuthorizationServerMock, new WebServerClient(AuthorizationServerDescription), client => { - var authState = client.ExchangeUserCredentialForToken(ResourceOwnerUsername, ResourceOwnerPassword); + var authState = client.ExchangeUserCredentialForToken(ResourceOwnerUsername, ResourceOwnerPassword, TestScopes); Assert.IsNotNullOrEmpty(authState.AccessToken); Assert.IsNotNullOrEmpty(authState.RefreshToken); }, @@ -67,14 +68,14 @@ namespace DotNetOpenAuth.Test.OAuth2 { public void ClientCredentialGrant() { var authServer = CreateAuthorizationServerMock(); authServer.Setup( - a => a.IsAuthorizationValid(It.Is<IAuthorizationDescription>(d => d.User == null && d.ClientIdentifier == ClientId))) + a => a.IsAuthorizationValid(It.Is<IAuthorizationDescription>(d => d.User == null && d.ClientIdentifier == ClientId && MessagingUtilities.AreEquivalent(d.Scope, TestScopes)))) .Returns(true); var coordinator = new OAuth2Coordinator<WebServerClient>( AuthorizationServerDescription, authServer.Object, new WebServerClient(AuthorizationServerDescription), client => { - var authState = client.GetClientAccessToken(); + var authState = client.GetClientAccessToken(TestScopes); Assert.IsNotNullOrEmpty(authState.AccessToken); Assert.IsNull(authState.RefreshToken); }, |