Skip to content

Commit 0da4bc4

Browse files
Harden BannersController authorization test scope
Co-authored-by: frasermolyneux <34033625+frasermolyneux@users.noreply.github.com>
1 parent bc74f74 commit 0da4bc4

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/XtremeIdiots.Portal.Web.Tests/ApiControllers/BannersControllerTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Microsoft.AspNetCore.Authorization;
2+
using System.Reflection;
23
using XtremeIdiots.Portal.Web.ApiControllers;
34

45
namespace XtremeIdiots.Portal.Web.Tests.ApiControllers;
@@ -16,7 +17,7 @@ public void BannersController_HasClassLevelAuthorizeAttribute()
1617
[Fact]
1718
public void GetGameServers_HasAllowAnonymousAttribute_OnlyAnonymousActionInController()
1819
{
19-
var methods = typeof(BannersController).GetMethods();
20+
var methods = typeof(BannersController).GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
2021
var allowAnonymousMethods = methods
2122
.Where(method => method.GetCustomAttributes(typeof(AllowAnonymousAttribute), true).Length > 0)
2223
.ToList();

0 commit comments

Comments
 (0)