From fc9a34e36e79effd2e1d77fa9e045834b44ea31d Mon Sep 17 00:00:00 2001 From: Okke Harsta Date: Fri, 13 Dec 2024 16:15:01 +0100 Subject: [PATCH] Strip space test --- server/src/main/java/access/security/UserPermissions.java | 8 ++++++-- .../test/java/access/api/FullSearchQueryParserTest.java | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/access/security/UserPermissions.java b/server/src/main/java/access/security/UserPermissions.java index b045a3f..e8d492a 100644 --- a/server/src/main/java/access/security/UserPermissions.java +++ b/server/src/main/java/access/security/UserPermissions.java @@ -41,11 +41,15 @@ public static void assertAuthority(User user, Authority authority) { throw new UserRestrictionException(); } + if (user.isSuperUser()) { + return; + } + if (user.isInstitutionAdmin() && Authority.INSTITUTION_ADMIN.hasEqualOrHigherRights(authority)) { return; } - if (!user.isSuperUser() && user.getUserRoles().stream() - .noneMatch(userRole -> userRole.getAuthority().hasEqualOrHigherRights(authority))) + if (user.getUserRoles().stream() + .noneMatch(userRole -> userRole.getAuthority().hasEqualOrHigherRights(authority))) throw new UserRestrictionException(); } diff --git a/server/src/test/java/access/api/FullSearchQueryParserTest.java b/server/src/test/java/access/api/FullSearchQueryParserTest.java index 0409f55..3bf08be 100644 --- a/server/src/test/java/access/api/FullSearchQueryParserTest.java +++ b/server/src/test/java/access/api/FullSearchQueryParserTest.java @@ -15,6 +15,9 @@ void parse() { String emailParsed = FullSearchQueryParser.parse("brand+ms@play.com"); assertEquals("+brand +ms +play*", emailParsed); + + String strippedWhiteSpace = FullSearchQueryParser.parse(" Leitndhireedisvea@example.com "); + assertEquals("+Leitndhireedisvea +example*", strippedWhiteSpace); } @Test