diff options
Diffstat (limited to 'src/DotNetOpenAuth.Test/OpenId')
8 files changed, 44 insertions, 9 deletions
diff --git a/src/DotNetOpenAuth.Test/OpenId/ChannelElements/ExtensionsBindingElementTests.cs b/src/DotNetOpenAuth.Test/OpenId/ChannelElements/ExtensionsBindingElementTests.cs index 0ef4bca..a4291d6 100644 --- a/src/DotNetOpenAuth.Test/OpenId/ChannelElements/ExtensionsBindingElementTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/ChannelElements/ExtensionsBindingElementTests.cs @@ -52,9 +52,9 @@ namespace DotNetOpenAuth.Test.OpenId.ChannelElements { Assert.AreSame(this.factory, this.rpElement.ExtensionFactory); } - [TestCase, ExpectedException(typeof(ArgumentNullException))] + [TestCase] public void PrepareMessageForSendingNull() { - this.rpElement.ProcessOutgoingMessage(null); + Assert.IsNull(this.rpElement.ProcessOutgoingMessage(null)); } /// <summary> diff --git a/src/DotNetOpenAuth.Test/OpenId/ChannelElements/SigningBindingElementTests.cs b/src/DotNetOpenAuth.Test/OpenId/ChannelElements/SigningBindingElementTests.cs index 955ea2d..22714a9 100644 --- a/src/DotNetOpenAuth.Test/OpenId/ChannelElements/SigningBindingElementTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/ChannelElements/SigningBindingElementTests.cs @@ -6,13 +6,16 @@ namespace DotNetOpenAuth.Test.OpenId.ChannelElements { using System; + using System.Collections.Generic; using System.Linq; + using DotNetOpenAuth.Messaging; using DotNetOpenAuth.Messaging.Bindings; using DotNetOpenAuth.OpenId; using DotNetOpenAuth.OpenId.ChannelElements; using DotNetOpenAuth.OpenId.Messages; using DotNetOpenAuth.OpenId.Provider; using DotNetOpenAuth.Test.Mocks; + using Moq; using NUnit.Framework; [TestFixture] @@ -68,5 +71,37 @@ namespace DotNetOpenAuth.Test.OpenId.ChannelElements { Assert.IsTrue(signedParameters.Contains("somesigned")); Assert.IsFalse(signedParameters.Contains("someunsigned")); } + + /// <summary> + /// Regression test for bug #45 (https://github.com/AArnott/dotnetopenid/issues/45) + /// </summary> + [TestCase, ExpectedException(typeof(ProtocolException))] + public void MissingSignedParameter() { + var cryptoStore = new MemoryCryptoKeyStore(); + byte[] associationSecret = Convert.FromBase64String("rsSwv1zPWfjPRQU80hciu8FPDC+GONAMJQ/AvSo1a2M="); + string handle = "{634477555066085461}{TTYcIg==}{32}"; + cryptoStore.StoreKey(ProviderAssociationKeyStorage.PrivateAssociationBucket, handle, new CryptoKey(associationSecret, DateTime.UtcNow.AddDays(1))); + + var signer = new ProviderSigningBindingElement(new ProviderAssociationKeyStorage(cryptoStore), new ProviderSecuritySettings()); + var testChannel = new TestChannel(new OpenIdProviderMessageFactory()); + signer.Channel = testChannel; + + var buggyRPMessage = new Dictionary<string, string>() { + { "openid.assoc_handle", "{634477555066085461}{TTYcIg==}{32}" }, + { "openid.claimed_id", "https://openid.stackexchange.com/user/f5e91123-e5b4-43c5-871f-5f276c75d31a" }, + { "openid.identity", "https://openid.stackexchange.com/user/f5e91123-e5b4-43c5-871f-5f276c75d31a" }, + { "openid.mode", "check_authentication" }, + { "openid.op_endpoint", "https://openid.stackexchange.com/openid/provider" }, + { "openid.response_nonce", "2011-08-01T00:32:10Zvdyt3efw" }, + { "openid.return_to", "http://openid-consumer.appspot.com/finish?session_id=1543025&janrain_nonce=2011-08-01T00%3A32%3A09ZIPGz7D" }, + { "openid.sig", "b0Rll6Kt1KKBWWBEg/qBvW3sQYtmhOUmpI0/UREBVZ0=" }, + { "openid.signed", "claimed_id,identity,assoc_handle,op_endpoint,return_to,response_nonce,ns.sreg,sreg.email,sreg.fullname" }, + { "openid.sreg.email", "kevin.montrose@stackoverflow.com" }, + { "openid.sreg.fullname", "Kevin K Montrose" }, + }; + var message = (CheckAuthenticationRequest)testChannel.Receive(buggyRPMessage, new MessageReceivingEndpoint(OPUri, HttpDeliveryMethods.PostRequest)); + var originalResponse = new IndirectSignedResponse(message, signer.Channel); + signer.ProcessIncomingMessage(originalResponse); + } } } diff --git a/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/AttributeRequestTests.cs b/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/AttributeRequestTests.cs index 5cc8ec1..3a7ecd7 100644 --- a/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/AttributeRequestTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/AttributeRequestTests.cs @@ -25,7 +25,7 @@ namespace DotNetOpenAuth.Test.OpenId.Extensions { new AttributeRequest(string.Empty); } - [TestCase, ExpectedException(typeof(ArgumentException))] + [TestCase, ExpectedException(typeof(ArgumentNullException))] public void CtorNullTypeUri() { new AttributeRequest(null); } diff --git a/src/DotNetOpenAuth.Test/OpenId/IdentifierTests.cs b/src/DotNetOpenAuth.Test/OpenId/IdentifierTests.cs index 01e2fdc..5d3a15e 100644 --- a/src/DotNetOpenAuth.Test/OpenId/IdentifierTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/IdentifierTests.cs @@ -75,7 +75,7 @@ namespace DotNetOpenAuth.Test.OpenId { Assert.AreEqual(this.uri, ((UriIdentifier)id).Uri.AbsoluteUri); } - [TestCase, ExpectedException(typeof(ArgumentException))] + [TestCase, ExpectedException(typeof(ArgumentNullException))] public void ParseNull() { Identifier.Parse(null); } diff --git a/src/DotNetOpenAuth.Test/OpenId/Messages/IndirectSignedResponseTests.cs b/src/DotNetOpenAuth.Test/OpenId/Messages/IndirectSignedResponseTests.cs index 406a48b..848c849 100644 --- a/src/DotNetOpenAuth.Test/OpenId/Messages/IndirectSignedResponseTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/Messages/IndirectSignedResponseTests.cs @@ -125,7 +125,7 @@ namespace DotNetOpenAuth.Test.OpenId.Messages { } } - [TestCase, ExpectedException(typeof(ArgumentException))] + [TestCase, ExpectedException(typeof(ArgumentNullException))] public void GetReturnToArgumentNullKey() { this.response.GetReturnToArgument(null); } diff --git a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/IdentifierDiscoveryResultTests.cs b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/IdentifierDiscoveryResultTests.cs index 896cf57..6d2de71 100644 --- a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/IdentifierDiscoveryResultTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/IdentifierDiscoveryResultTests.cs @@ -143,7 +143,7 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty { Assert.IsFalse(se.IsTypeUriPresent("http://someother")); } - [TestCase, ExpectedException(typeof(ArgumentException))] + [TestCase, ExpectedException(typeof(ArgumentNullException))] public void IsTypeUriPresentNull() { IdentifierDiscoveryResult se = IdentifierDiscoveryResult.CreateForClaimedIdentifier(this.claimedXri, this.userSuppliedXri, this.localId, new ProviderEndpointDescription(this.providerEndpoint, this.v20TypeUris), this.servicePriority, this.uriPriority); se.IsTypeUriPresent(null); @@ -161,7 +161,7 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty { se.IsExtensionSupported((Type)null); } - [TestCase, ExpectedException(typeof(ArgumentException))] + [TestCase, ExpectedException(typeof(ArgumentNullException))] public void IsTypeUriPresentNullString() { var se = IdentifierDiscoveryResult.CreateForProviderIdentifier(OPUri, new ProviderEndpointDescription(OPUri, this.v20TypeUris), null, null); se.IsTypeUriPresent((string)null); diff --git a/src/DotNetOpenAuth.Test/OpenId/UriIdentifierTests.cs b/src/DotNetOpenAuth.Test/OpenId/UriIdentifierTests.cs index e6bed2f..427f890 100644 --- a/src/DotNetOpenAuth.Test/OpenId/UriIdentifierTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/UriIdentifierTests.cs @@ -31,7 +31,7 @@ namespace DotNetOpenAuth.Test.OpenId { new UriIdentifier((Uri)null); } - [TestCase, ExpectedException(typeof(ArgumentException))] + [TestCase, ExpectedException(typeof(ArgumentNullException))] public void CtorNullString() { new UriIdentifier((string)null); } diff --git a/src/DotNetOpenAuth.Test/OpenId/XriIdentifierTests.cs b/src/DotNetOpenAuth.Test/OpenId/XriIdentifierTests.cs index 0c80821..e2acf34 100644 --- a/src/DotNetOpenAuth.Test/OpenId/XriIdentifierTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/XriIdentifierTests.cs @@ -22,7 +22,7 @@ namespace DotNetOpenAuth.Test.OpenId { base.SetUp(); } - [TestCase, ExpectedException(typeof(ArgumentException))] + [TestCase, ExpectedException(typeof(ArgumentNullException))] public void CtorNull() { new XriIdentifier(null); } |