Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Commit

Permalink
Add synchronous test for SAuthc1 escaping fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nbarbettini committed Mar 9, 2016
1 parent 86ba3d2 commit 21fc5b9
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions test/Stormpath.SDK.Tests.Integration/Sync/Oauth_tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using Stormpath.SDK.Sync;
using Stormpath.SDK.Tests.Common;
using Stormpath.SDK.Tests.Common.Integration;
using Stormpath.SDK.Tests.Common.RandomData;
using Xunit;

namespace Stormpath.SDK.Tests.Integration.Sync
Expand Down Expand Up @@ -83,6 +84,48 @@ public void Creating_token_with_password_grant(TestClientProvider clientBuilder)
this.fixture.CreatedApplicationHrefs.Remove(createdApplication.Href);
}

/// <summary>
/// Regression test for stormpath/stormpath-sdk-dotnet#161
/// </summary>
/// <remarks>The ! character was causing the SAuthc1 signer to break.</remarks>
/// <param name="clientBuilder">The client builder.</param>
[Theory]
[MemberData(nameof(TestClients.GetClients), MemberType = typeof(TestClients))]
public void Password_grant_with_special_characters(TestClientProvider clientBuilder)
{
var client = clientBuilder.GetClient();
var tenant = client.GetCurrentTenant();

// Create a dummy application
var createdApplication = tenant.CreateApplication(
$".NET IT {this.fixture.TestRunIdentifier}-{clientBuilder.Name} Password Grant Flow With Special Characters",
createDirectory: true);
createdApplication.Href.ShouldNotBeNullOrEmpty();
this.fixture.CreatedApplicationHrefs.Add(createdApplication.Href);

var createdDirectory = createdApplication.GetDefaultAccountStore();
this.fixture.CreatedDirectoryHrefs.Add(createdDirectory.Href);

// Add the test accounts
var randomEmail = new RandomEmail("foo.bar");
var password = "P@sword#123$!";
createdApplication.CreateAccount("Test", "testerman", randomEmail, password);

var passwordGrantRequest = OauthRequests.NewPasswordGrantRequest()
.SetLogin(randomEmail)
.SetPassword(password)
.Build();
var authenticateResult = createdApplication.NewPasswordGrantAuthenticator()
.Authenticate(passwordGrantRequest);

// Verify authentication response
authenticateResult.AccessTokenString.ShouldNotBeNullOrEmpty();

// Clean up
(createdApplication.Delete()).ShouldBeTrue();
this.fixture.CreatedApplicationHrefs.Remove(createdApplication.Href);
}

[Theory]
[MemberData(nameof(TestClients.GetClients), MemberType = typeof(TestClients))]
public void Failed_password_grant_throws_ResourceException(TestClientProvider clientBuilder)
Expand Down

0 comments on commit 21fc5b9

Please sign in to comment.