Skip to content

Commit 63cf032

Browse files
committed
Add test Auth Services to check for Roles/Permission
1 parent a29f31d commit 63cf032

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

tests/ServiceStack.AuthWeb.Tests/AppHost.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,16 @@ public class CustomUserSession : AuthUserSession
373373
{
374374
public string ProfileUrl64 { get; set; }
375375

376+
public override bool HasPermission(string permission, IAuthRepository authRepo)
377+
{
378+
return base.HasPermission(permission, authRepo);
379+
}
380+
381+
public override bool HasRole(string role, IAuthRepository authRepo)
382+
{
383+
return base.HasRole(role, authRepo);
384+
}
385+
376386
public override void OnAuthenticated(IServiceBase authService, IAuthSession session, IAuthTokens tokens, Dictionary<string, string> authInfo)
377387
{
378388
base.OnAuthenticated(authService, session, tokens, authInfo);

tests/ServiceStack.AuthWeb.Tests/Services.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,4 +200,28 @@ public object Any(ViewThatUsesLayoutAndModel request)
200200
};
201201
}
202202
}
203+
204+
[Route("/has-permission")]
205+
public class HasPermission : IReturn<CustomUserSession> { }
206+
207+
[RequiredPermission("ThePermission")]
208+
public class RequiresPermissionService : Service
209+
{
210+
public object Any(HasPermission request)
211+
{
212+
return SessionAs<CustomUserSession>();
213+
}
214+
}
215+
216+
[Route("/has-role")]
217+
public class HasRole : IReturn<CustomUserSession> { }
218+
219+
[RequiredRole("TheRole")]
220+
public class RequiresRoleService : Service
221+
{
222+
public object Any(HasRole request)
223+
{
224+
return SessionAs<CustomUserSession>();
225+
}
226+
}
203227
}

0 commit comments

Comments
 (0)