Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a3e4fe5
Add shopify provider (#326)
sbiaudet Jul 21, 2019
6807cf1
Shopify - Fix TokenEndpoint format (#330)
sbiaudet Jul 22, 2019
86f0878
Gitlab (#329)
twsl Jul 23, 2019
81d383e
incorrect LoginPath
mgroves Sep 3, 2019
a652881
Basic Apple provider
martincostello Jun 6, 2019
c78b5e5
Implement Apple provider
martincostello Jun 8, 2019
b4b76d0
Enable Sign In with Apple
martincostello Jun 8, 2019
62d4e79
Update tests
martincostello Jun 8, 2019
06dfc7b
Enable token lifetime validation
martincostello Jun 8, 2019
4a9f230
Add null annotations
martincostello Jun 9, 2019
2c6a89c
Improve exception handling
martincostello Jun 9, 2019
cf3705a
Extend integration tests
martincostello Jun 9, 2019
c65e54f
Move expiry period to options
martincostello Jun 9, 2019
58e642c
Add ClientSecretExpiresAfter validation
martincostello Jun 9, 2019
93965e3
Add tests for options validation
martincostello Jun 9, 2019
fc95923
Add unit tests for client secret
martincostello Jun 9, 2019
38e71ab
Make KeyId required
martincostello Jun 9, 2019
0a55575
Fix test
martincostello Jun 9, 2019
991356d
Fix Linux and macOS secret generation
martincostello Jun 9, 2019
b660372
Add password option for pfx files
martincostello Jun 9, 2019
938e9ad
Fix flaky test
martincostello Jun 9, 2019
56abbbf
Add UsePrivateKey() method
martincostello Jun 9, 2019
d2e2f24
Bump System.IdentityModel.Tokens.Jwt
martincostello Jun 9, 2019
0d2f184
Set response_mode to form_post
martincostello Sep 8, 2019
2dcfb65
Use latest C# version
martincostello Sep 8, 2019
d083871
Retrieve user details after sign-in
martincostello Sep 8, 2019
88c8faa
Update branding
martincostello Sep 15, 2019
221bfeb
Access events via options
martincostello Sep 15, 2019
8ee2f76
Resolve logging TODO
martincostello Sep 15, 2019
15078f4
Comment out Apple option
martincostello Sep 20, 2019
bb83201
Merge branch 'dev' into Sign-In-With-Apple-300
martincostello Sep 20, 2019
99e3185
Update Sign in with Apple provider for ASP.NET Core 3.0
martincostello Sep 20, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add tests for options validation
Add unit tests for options validation.
Improve exception type.
Fix incorrect if condition that meant not all values were validated correctly.
  • Loading branch information
martincostello committed Sep 20, 2019
commit 93965e3137fe9e07c25e5414b58fed35066f18a5
7 changes: 5 additions & 2 deletions src/AspNet.Security.OAuth.Apple/AppleAuthenticationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public override void Validate()
throw new ArgumentException($"The '{nameof(CallbackPath)}' option must be provided.", nameof(CallbackPath));
}

if (GenerateClientSecret && string.IsNullOrEmpty(TeamId))
if (GenerateClientSecret)
{
if (string.IsNullOrEmpty(TeamId))
{
Expand All @@ -136,7 +136,10 @@ public override void Validate()

if (ClientSecretExpiresAfter <= TimeSpan.Zero)
{
throw new ArgumentException($"The '{nameof(ClientSecretExpiresAfter)}' option must be a positive value if the '{nameof(GenerateClientSecret)}' option is set to true.", nameof(ClientSecretExpiresAfter));
throw new ArgumentOutOfRangeException(
nameof(ClientSecretExpiresAfter),
ClientSecretExpiresAfter,
$"The '{nameof(ClientSecretExpiresAfter)}' option must be a positive value if the '{nameof(GenerateClientSecret)}' option is set to true.");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers
* for more information concerning the license and the contributors participating to this project.
*/

using System;
using Xunit;

namespace AspNet.Security.OAuth.Apple
{
public static class AppleAuthenticationOptionsTests
{
[Fact]
public static void Validate_Throws_If_ClientSecret_Is_Null_With_No_Secret_Generation()
{
// Arrange
var options = new AppleAuthenticationOptions()
{
ClientId = "my-client-id",
ClientSecret = null,
};

// Act and Assert
Assert.Throws<ArgumentException>("ClientSecret", () => options.Validate());
}

[Fact]
public static void Validate_Throws_If_AuthorizationEndpoint_Is_Null()
{
// Arrange
var options = new AppleAuthenticationOptions()
{
ClientId = "my-client-id",
GenerateClientSecret = true,
AuthorizationEndpoint = null,
};

// Act and Assert
Assert.Throws<ArgumentException>("AuthorizationEndpoint", () => options.Validate());
}

[Fact]
public static void Validate_Throws_If_TokenEndpoint_Is_Null()
{
// Arrange
var options = new AppleAuthenticationOptions()
{
ClientId = "my-client-id",
GenerateClientSecret = true,
TokenEndpoint = null,
};

// Act and Assert
Assert.Throws<ArgumentException>("TokenEndpoint", () => options.Validate());
}

[Fact]
public static void Validate_Throws_If_CallbackPath_Is_Null()
{
// Arrange
var options = new AppleAuthenticationOptions()
{
ClientId = "my-client-id",
GenerateClientSecret = true,
CallbackPath = null,
};

// Act and Assert
Assert.Throws<ArgumentException>("CallbackPath", () => options.Validate());
}

[Fact]
public static void Validate_Throws_If_TeamId_Is_Null_With_Secret_Generation()
{
// Arrange
var options = new AppleAuthenticationOptions()
{
ClientId = "my-client-id",
GenerateClientSecret = true,
TeamId = null,
};

// Act and Assert
Assert.Throws<ArgumentException>("TeamId", () => options.Validate());
}

[Fact]
public static void Validate_Throws_If_TokenAudience_Is_Null_With_Secret_Generation()
{
// Arrange
var options = new AppleAuthenticationOptions()
{
ClientId = "my-client-id",
GenerateClientSecret = true,
TeamId = "my-team-id",
TokenAudience = null,
};

// Act and Assert
Assert.Throws<ArgumentException>("TokenAudience", () => options.Validate());
}

[Fact]
public static void Validate_Throws_If_ClientSecretExpiresAfter_Is_Zero_With_Secret_Generation()
{
// Arrange
var options = new AppleAuthenticationOptions()
{
ClientId = "my-client-id",
GenerateClientSecret = true,
TeamId = "my-team-id",
ClientSecretExpiresAfter = TimeSpan.Zero,
};

// Act and Assert
Assert.Throws<ArgumentOutOfRangeException>("ClientSecretExpiresAfter", () => options.Validate());
}

[Fact]
public static void Validate_Throws_If_PublicKeyEndpoint_Is_Null_With_Token_Validation()
{
// Arrange
var options = new AppleAuthenticationOptions()
{
ClientId = "my-client-id",
ClientSecret = "my-client-secret",
PublicKeyEndpoint = null,
};

// Act and Assert
Assert.Throws<ArgumentException>("PublicKeyEndpoint", () => options.Validate());
}
}
}