forked from gothinkster/realworld-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#11 moved JWT config values into secrets/env
- Loading branch information
Showing
19 changed files
with
100 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Conduit.Web.Users.Services; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace Conduit.Tests.TestHelpers; | ||
|
||
public static class AuthServiceHelper | ||
{ | ||
public static AuthService Create() | ||
{ | ||
// the issuer, audience, securitykey are hardcoded values | ||
// only meant for testing. Do not use these for your actual secrets! | ||
return new AuthService(new OptionsWrapper<JwtSecrets>( | ||
new JwtSecrets() | ||
{ | ||
Issuer = "ConduitAspNetCouchbase_Issuer", | ||
Audience = "ConduitAspNetCouchbase_Audience", | ||
SecurityKey = "6B{DqP5aT,3b&!YRgk29m@j$L7uvnxE" | ||
})); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
using Conduit.Web.Models; | ||
using Conduit.Tests.TestHelpers; | ||
using Conduit.Web.Models; | ||
using Conduit.Web.Users.Handlers; | ||
using Conduit.Web.Users.Services; | ||
using Moq; | ||
|
@@ -26,7 +27,7 @@ public async Task ValidToken_is_Handled() | |
// arrange request from API | ||
var email = "[email protected]"; | ||
var username = "doesntmatter"; | ||
var fakeToken = new AuthService().GenerateJwtToken(email, username); | ||
var fakeToken = AuthServiceHelper.Create().GenerateJwtToken(email, username); | ||
var request = new GetCurrentUserRequest(fakeToken); | ||
|
||
// arrange user that would be in db | ||
|
@@ -90,7 +91,7 @@ public async Task UserIsMissingFromDatabase_is_Handled() | |
// arrange | ||
// arrange request from API | ||
var email = "[email protected]"; | ||
var fakeToken = new AuthService().GenerateJwtToken(email, "doesntmatter"); | ||
var fakeToken = AuthServiceHelper.Create().GenerateJwtToken(email, "doesntmatter"); | ||
var request = new GetCurrentUserRequest(fakeToken); | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
using Conduit.Tests.TestHelpers.Data; | ||
using Conduit.Tests.TestHelpers; | ||
using Conduit.Tests.TestHelpers.Data; | ||
using Conduit.Web.Follows.Services; | ||
using Conduit.Web.Models; | ||
using Conduit.Web.Users.Handlers; | ||
|
@@ -29,7 +30,7 @@ public void SetUp() | |
public async Task Profile_for_a_user_following_the_user_in_the_profile(bool isUserFollowing) | ||
{ | ||
// arrange | ||
var currentUserToken = new AuthService().GenerateJwtToken("[email protected]", "MattGroves"); | ||
var currentUserToken = AuthServiceHelper.Create().GenerateJwtToken("[email protected]", "MattGroves"); | ||
|
||
// arrange for user to NOT be followed | ||
var user = UserHelper.CreateUser(username: "SurlyDev"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Conduit.Web.Users.Services; | ||
|
||
public class JwtSecrets | ||
{ | ||
public string Issuer { get; set; } | ||
public string Audience { get; set; } | ||
public string SecurityKey { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters