diff options
author | 杨宇千 <crupest@outlook.com> | 2019-11-07 22:57:04 +0800 |
---|---|---|
committer | 杨宇千 <crupest@outlook.com> | 2019-11-07 22:57:04 +0800 |
commit | 976d6158e67e79e9d6d7e140f5749aa6630d0fb6 (patch) | |
tree | ef1873d7e6b86d9cbeded9a5c84e63e3cd6b3baa /Timeline.Tests/Helpers/Authentication/PrincipalHelper.cs | |
parent | 5f9f9a9e40306f83bf360c3d27e4e33e78565fce (diff) | |
download | timeline-976d6158e67e79e9d6d7e140f5749aa6630d0fb6.tar.gz timeline-976d6158e67e79e9d6d7e140f5749aa6630d0fb6.tar.bz2 timeline-976d6158e67e79e9d6d7e140f5749aa6630d0fb6.zip |
Add Get method tests for PersonalTimelineController.
Diffstat (limited to 'Timeline.Tests/Helpers/Authentication/PrincipalHelper.cs')
-rw-r--r-- | Timeline.Tests/Helpers/Authentication/PrincipalHelper.cs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Timeline.Tests/Helpers/Authentication/PrincipalHelper.cs b/Timeline.Tests/Helpers/Authentication/PrincipalHelper.cs new file mode 100644 index 00000000..214472a2 --- /dev/null +++ b/Timeline.Tests/Helpers/Authentication/PrincipalHelper.cs @@ -0,0 +1,23 @@ +using System.Linq;
+using System.Security.Claims;
+using Timeline.Models;
+
+namespace Timeline.Tests.Helpers.Authentication
+{
+ public static class PrincipalHelper
+ {
+ internal const string AuthScheme = "TESTAUTH";
+
+ internal static ClaimsPrincipal Create(string username, bool administrator)
+ {
+ var identity = new ClaimsIdentity(AuthScheme);
+ identity.AddClaim(new Claim(identity.NameClaimType, username, ClaimValueTypes.String));
+ identity.AddClaims(UserRoleConvert.ToArray(administrator).Select(role => new Claim(identity.RoleClaimType, role, ClaimValueTypes.String)));
+
+ var principal = new ClaimsPrincipal();
+ principal.AddIdentity(identity);
+
+ return principal;
+ }
+ }
+}
|