diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/auth/AuthorizationFilter.java b/notification-core/src/main/java/org/opengroup/osdu/notification/auth/AuthorizationFilter.java index 6ed600bebec9d500e3403b6c5ebba0ba0f799a6c..4281902e62ed4d1444937dd4e98031d0dcb4de4c 100644 --- a/notification-core/src/main/java/org/opengroup/osdu/notification/auth/AuthorizationFilter.java +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/auth/AuthorizationFilter.java @@ -94,8 +94,9 @@ public class AuthorizationFilter { } private boolean authorizeWithCache(String[] requiredRoles, Groups groups) { - if(groups.any(requiredRoles)) + if(groups.any(requiredRoles)) { return true; + } return false; } diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/di/GroupVmCache.java b/notification-core/src/main/java/org/opengroup/osdu/notification/di/GroupVmCache.java index ffb7b049cf1e495f55f4f1d05fd9802e3f23d54d..451dc4732034cdb8121920db91c55065c193787d 100644 --- a/notification-core/src/main/java/org/opengroup/osdu/notification/di/GroupVmCache.java +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/di/GroupVmCache.java @@ -1,4 +1,4 @@ -// Copyright 2017-2024, SLB +// Copyright 2017-2025, SLB // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/utils/MathUtils.java b/notification-core/src/main/java/org/opengroup/osdu/notification/utils/MathUtils.java index 52b8a7048c78340b6a577ef4fff844f54c71deeb..40ac37b02fe14333ccb825359f8512cab342ef99 100644 --- a/notification-core/src/main/java/org/opengroup/osdu/notification/utils/MathUtils.java +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/utils/MathUtils.java @@ -1,4 +1,4 @@ -// Copyright 2017-2024, SLB +// Copyright 2017-2025, SLB // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -22,6 +22,10 @@ public class MathUtils { */ public static int generateRandomNumberBetweenBounds(int lower, int upper) { Random random = new Random(); - return random.nextInt(upper - lower) + lower; + if (upper > lower) { + return random.nextInt(upper - lower) + lower; + } else { + return random.nextInt(lower - upper) + upper; + } } } diff --git a/notification-core/src/test/java/org/opengroup/osdu/notification/auth/AuthorizationFilterTest.java b/notification-core/src/test/java/org/opengroup/osdu/notification/auth/AuthorizationFilterTest.java index c042f4f3677de064357bfa29d00082e243e0927f..a84b0d5ec5adfc962c4d89e34d051544add91bf7 100644 --- a/notification-core/src/test/java/org/opengroup/osdu/notification/auth/AuthorizationFilterTest.java +++ b/notification-core/src/test/java/org/opengroup/osdu/notification/auth/AuthorizationFilterTest.java @@ -94,7 +94,6 @@ public class AuthorizationFilterTest { final String USER_EMAIL = "test@test.com"; AuthorizationResponse authorizationResponse = AuthorizationResponse.builder().user(USER_EMAIL).build(); when(this.authorizationService.authorizeAny(any(), eq(ROLE1), eq(ROLE2))).thenReturn(authorizationResponse); - //when(this.groupVmCache.get("8Z2MjQ==")).thenReturn(null); assertTrue(this.sut.hasAnyPermission(ROLE1, ROLE2)); verify(headers).put(DpsHeaders.USER_EMAIL, "test@test.com");