diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2013-03-26 11:19:06 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2013-03-26 11:19:06 -0700 |
commit | 3d37ff45cab6838d80b22e6b782a0b9b4c2f4aeb (patch) | |
tree | c15816c3d7f6e74334553f2ff98605ce1c22c538 /src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseTests.cs | |
parent | 5e9014f36b2d53b8e419918675df636540ea24e2 (diff) | |
parent | e6f7409f4caceb7bc2a5b4ddbcb1a4097af340f2 (diff) | |
download | DotNetOpenAuth-3d37ff45cab6838d80b22e6b782a0b9b4c2f4aeb.zip DotNetOpenAuth-3d37ff45cab6838d80b22e6b782a0b9b4c2f4aeb.tar.gz DotNetOpenAuth-3d37ff45cab6838d80b22e6b782a0b9b4c2f4aeb.tar.bz2 |
Move to HttpClient throughout library.
Diffstat (limited to 'src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseTests.cs')
-rw-r--r-- | src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseTests.cs | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseTests.cs b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseTests.cs index 91318f5..6ce74fd 100644 --- a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseTests.cs @@ -7,6 +7,9 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty { using System; using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OpenId; using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration; @@ -29,12 +32,12 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty { /// Verifies good, positive assertions are accepted. /// </summary> [Test] - public void Valid() { + public async Task Valid() { PositiveAssertionResponse assertion = this.GetPositiveAssertion(); ClaimsResponse extension = new ClaimsResponse(); assertion.Extensions.Add(extension); var rp = CreateRelyingParty(); - var authResponse = new PositiveAuthenticationResponse(assertion, rp); + var authResponse = await PositiveAuthenticationResponse.CreateAsync(assertion, rp, CancellationToken.None); Assert.AreEqual(AuthenticationStatus.Authenticated, authResponse.Status); Assert.IsNull(authResponse.Exception); Assert.AreEqual((string)assertion.ClaimedIdentifier, (string)authResponse.ClaimedIdentifier); @@ -49,13 +52,13 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty { /// Verifies that discovery verification of a positive assertion can match a dual identifier. /// </summary> [Test] - public void DualIdentifierMatchesInAssertionVerification() { + public async Task DualIdentifierMatchesInAssertionVerification() { PositiveAssertionResponse assertion = this.GetPositiveAssertion(true); ClaimsResponse extension = new ClaimsResponse(); assertion.Extensions.Add(extension); var rp = CreateRelyingParty(); rp.SecuritySettings.AllowDualPurposeIdentifiers = true; - new PositiveAuthenticationResponse(assertion, rp); // this will throw if it fails to find a match + await PositiveAuthenticationResponse.CreateAsync(assertion, rp, CancellationToken.None); // this will throw if it fails to find a match } /// <summary> @@ -63,12 +66,12 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty { /// if the default settings are in place. /// </summary> [Test, ExpectedException(typeof(ProtocolException))] - public void DualIdentifierNoMatchInAssertionVerificationByDefault() { + public async Task DualIdentifierNoMatchInAssertionVerificationByDefault() { PositiveAssertionResponse assertion = this.GetPositiveAssertion(true); ClaimsResponse extension = new ClaimsResponse(); assertion.Extensions.Add(extension); var rp = CreateRelyingParty(); - new PositiveAuthenticationResponse(assertion, rp); // this will throw if it fails to find a match + await PositiveAuthenticationResponse.CreateAsync(assertion, rp, CancellationToken.None); // this will throw if it fails to find a match } /// <summary> @@ -77,11 +80,11 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty { /// that the OP has no authority to assert positively regarding. /// </summary> [Test, ExpectedException(typeof(ProtocolException))] - public void SpoofedClaimedIdDetectionSolicited() { + public async Task SpoofedClaimedIdDetectionSolicited() { PositiveAssertionResponse assertion = this.GetPositiveAssertion(); assertion.ProviderEndpoint = new Uri("http://rogueOP"); var rp = CreateRelyingParty(); - var authResponse = new PositiveAuthenticationResponse(assertion, rp); + var authResponse = await PositiveAuthenticationResponse.CreateAsync(assertion, rp, CancellationToken.None); Assert.AreEqual(AuthenticationStatus.Failed, authResponse.Status); } @@ -90,22 +93,22 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty { /// Cdentifiers when RequireSsl is set to true. /// </summary> [Test, ExpectedException(typeof(ProtocolException))] - public void InsecureIdentifiersRejectedWithRequireSsl() { + public async Task InsecureIdentifiersRejectedWithRequireSsl() { PositiveAssertionResponse assertion = this.GetPositiveAssertion(); var rp = CreateRelyingParty(); rp.SecuritySettings.RequireSsl = true; - var authResponse = new PositiveAuthenticationResponse(assertion, rp); + var authResponse = await PositiveAuthenticationResponse.CreateAsync(assertion, rp, CancellationToken.None); } [Test] - public void GetCallbackArguments() { + public async Task GetCallbackArguments() { PositiveAssertionResponse assertion = this.GetPositiveAssertion(); var rp = CreateRelyingParty(); UriBuilder returnToBuilder = new UriBuilder(assertion.ReturnTo); returnToBuilder.AppendQueryArgs(new Dictionary<string, string> { { "a", "b" } }); assertion.ReturnTo = returnToBuilder.Uri; - var authResponse = new PositiveAuthenticationResponse(assertion, rp); + var authResponse = await PositiveAuthenticationResponse.CreateAsync(assertion, rp, CancellationToken.None); // First pretend that the return_to args were signed. assertion.ReturnToParametersSignatureValidated = true; @@ -124,18 +127,18 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty { /// Verifies that certain problematic claimed identifiers pass through to the RP response correctly. /// </summary> [Test] - public void ProblematicClaimedId() { + public async Task ProblematicClaimedId() { var providerEndpoint = new ProviderEndpointDescription(OpenIdTestBase.OPUri, Protocol.Default.Version); string claimed_id = BaseMockUri + "a./b."; var se = IdentifierDiscoveryResult.CreateForClaimedIdentifier(claimed_id, claimed_id, providerEndpoint, null, null); - UriIdentifier identityUri = (UriIdentifier)se.ClaimedIdentifier; - var mockId = new MockIdentifier(identityUri, this.MockResponder, new IdentifierDiscoveryResult[] { se }); + var identityUri = (UriIdentifier)se.ClaimedIdentifier; + this.RegisterMockXrdsResponse(se); + var rp = this.CreateRelyingParty(); var positiveAssertion = this.GetPositiveAssertion(); - positiveAssertion.ClaimedIdentifier = mockId; - positiveAssertion.LocalIdentifier = mockId; - var rp = CreateRelyingParty(); - var authResponse = new PositiveAuthenticationResponse(positiveAssertion, rp); + positiveAssertion.ClaimedIdentifier = claimed_id; + positiveAssertion.LocalIdentifier = claimed_id; + var authResponse = await PositiveAuthenticationResponse.CreateAsync(positiveAssertion, rp, CancellationToken.None); Assert.AreEqual(AuthenticationStatus.Authenticated, authResponse.Status); Assert.AreEqual(claimed_id, authResponse.ClaimedIdentifier.ToString()); } |