From ece8145d7b3f25f468a913c7960828c15256178c Mon Sep 17 00:00:00 2001
From: Lars Johansson <lars.johansson@ess.eu>
Date: Mon, 27 May 2024 09:17:09 +0200
Subject: [PATCH] Get username from @AuthenticationPrincipal

Use username from @AuthenticationPrincipal to create, update, delete entries
for names and structures.
Update integration tests.

Note that commit is third step in introducing authentication and authorization.
---
 .../openepics/names/rest/api/v1/INames.java   |  5 +++++
 .../names/rest/api/v1/IStructures.java        |  5 +++++
 .../rest/controller/NamesController.java      | 17 +++++++++++------
 .../rest/controller/StructuresController.java | 17 +++++++++++------
 .../names/service/security/UserService.java   |  4 ++--
 ...{ConversionUtil.java => SecurityUtil.java} | 19 +++++++++++++++++--
 .../org/openepics/names/util/TextUtil.java    |  3 ---
 .../org/openepics/names/docker/NamesIT.java   | 10 +---------
 .../names/docker/StructuresDeviceGroupIT.java | 10 +---------
 .../names/docker/StructuresDeviceTypeIT.java  | 10 +---------
 .../names/docker/StructuresDisciplineIT.java  | 10 +---------
 .../names/docker/StructuresSubsystemIT.java   | 10 +---------
 .../names/docker/StructuresSystemGroupIT.java | 10 +---------
 .../names/docker/StructuresSystemIT.java      | 10 +---------
 14 files changed, 58 insertions(+), 82 deletions(-)
 rename src/main/java/org/openepics/names/service/security/util/{ConversionUtil.java => SecurityUtil.java} (65%)

diff --git a/src/main/java/org/openepics/names/rest/api/v1/INames.java b/src/main/java/org/openepics/names/rest/api/v1/INames.java
index e9370c46..7626cb87 100644
--- a/src/main/java/org/openepics/names/rest/api/v1/INames.java
+++ b/src/main/java/org/openepics/names/rest/api/v1/INames.java
@@ -30,8 +30,10 @@ import org.openepics.names.rest.beans.response.Response;
 import org.openepics.names.rest.beans.response.ResponseBoolean;
 import org.openepics.names.rest.beans.response.ResponseBooleanList;
 import org.openepics.names.rest.beans.response.ResponsePageNameElements;
+import org.openepics.names.service.security.dto.UserDetails;
 import org.springframework.http.ResponseEntity;
 import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.security.core.annotation.AuthenticationPrincipal;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
@@ -188,6 +190,7 @@ public interface INames {
             consumes = {"application/json"})
     @PreAuthorize(SecurityConfiguration.IS_ADMINISTRATOR_OR_USER)
     public ResponseEntity<List<NameElement>> createNames(
+            @AuthenticationPrincipal UserDetails user,
             @Parameter(
                     in = ParameterIn.DEFAULT,
                     description = "array of name elements",
@@ -720,6 +723,7 @@ public interface INames {
             consumes = {"application/json"})
     @PreAuthorize(SecurityConfiguration.IS_ADMINISTRATOR_OR_USER)
     public List<NameElement> updateNames(
+            @AuthenticationPrincipal UserDetails user,
             @Parameter(
                     in = ParameterIn.DEFAULT,
                     description = "array of name elements",
@@ -784,6 +788,7 @@ public interface INames {
             consumes = {"application/json"})
     @PreAuthorize(SecurityConfiguration.IS_ADMINISTRATOR_OR_USER)
     public ResponseEntity<Response> deleteNames(
+            @AuthenticationPrincipal UserDetails user,
             @Parameter(
                     in = ParameterIn.DEFAULT,
                     description = "array of name elements",
diff --git a/src/main/java/org/openepics/names/rest/api/v1/IStructures.java b/src/main/java/org/openepics/names/rest/api/v1/IStructures.java
index 1f78f4dc..fa9b542e 100644
--- a/src/main/java/org/openepics/names/rest/api/v1/IStructures.java
+++ b/src/main/java/org/openepics/names/rest/api/v1/IStructures.java
@@ -31,8 +31,10 @@ import org.openepics.names.rest.beans.response.Response;
 import org.openepics.names.rest.beans.response.ResponseBoolean;
 import org.openepics.names.rest.beans.response.ResponseBooleanList;
 import org.openepics.names.rest.beans.response.ResponsePageStructureElements;
+import org.openepics.names.service.security.dto.UserDetails;
 import org.springframework.http.ResponseEntity;
 import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.security.core.annotation.AuthenticationPrincipal;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
@@ -192,6 +194,7 @@ public interface IStructures {
             consumes = {"application/json"})
     @PreAuthorize(SecurityConfiguration.IS_ADMINISTRATOR)
     public ResponseEntity<List<StructureElement>> createStructures(
+            @AuthenticationPrincipal UserDetails user,
             @Parameter(
                     in = ParameterIn.DEFAULT,
                     description = "array of structure elements",
@@ -782,6 +785,7 @@ public interface IStructures {
             consumes = {"application/json"})
     @PreAuthorize(SecurityConfiguration.IS_ADMINISTRATOR)
     public List<StructureElement> updateStructures(
+            @AuthenticationPrincipal UserDetails user,
             @Parameter(
                     in = ParameterIn.DEFAULT,
                     description = "array of structure elements",
@@ -847,6 +851,7 @@ public interface IStructures {
             consumes = {"application/json"})
     @PreAuthorize(SecurityConfiguration.IS_ADMINISTRATOR)
     public ResponseEntity<Response> deleteStructures(
+            @AuthenticationPrincipal UserDetails user,
             @Parameter(
                     in = ParameterIn.DEFAULT,
                     description = "array of structure elements",
diff --git a/src/main/java/org/openepics/names/rest/controller/NamesController.java b/src/main/java/org/openepics/names/rest/controller/NamesController.java
index 33569e4a..2e0eb347 100644
--- a/src/main/java/org/openepics/names/rest/controller/NamesController.java
+++ b/src/main/java/org/openepics/names/rest/controller/NamesController.java
@@ -36,6 +36,8 @@ import org.openepics.names.rest.beans.response.ResponseBooleanList;
 import org.openepics.names.rest.beans.response.ResponsePageNameElements;
 import org.openepics.names.service.LogService;
 import org.openepics.names.service.NamesService;
+import org.openepics.names.service.security.dto.UserDetails;
+import org.openepics.names.service.security.util.SecurityUtil;
 import org.openepics.names.util.NameElementUtil;
 import org.openepics.names.util.TextUtil;
 import org.openepics.names.util.ValidateNameElementUtil;
@@ -76,7 +78,8 @@ public class NamesController implements INames {
     }
 
     @Override
-    public ResponseEntity<List<NameElement>> createNames(List<NameElementCommandCreate> nameElementCommands) {
+    public ResponseEntity<List<NameElement>> createNames(UserDetails user,
+            List<NameElementCommandCreate> nameElementCommands) {
         // validate authority - user & admin
         // convert
         // validate
@@ -85,7 +88,7 @@ public class NamesController implements INames {
         try {
             List<NameElementCommand> commands = NameElementUtil.convertCommandCreate2Command(nameElementCommands);
             namesService.validateNamesCreate(commands);
-            return new ResponseEntity<>(namesService.createNames(commands, TextUtil.TEST_WHO), Response.getHeaderJson(), HttpStatus.CREATED);
+            return new ResponseEntity<>(namesService.createNames(commands, SecurityUtil.getUsername(user)), Response.getHeaderJson(), HttpStatus.CREATED);
         } catch (ServiceException e) {
             logService.logServiceException(LOGGER, Level.WARNING, e);
             throw e;
@@ -346,7 +349,8 @@ public class NamesController implements INames {
     // ----------------------------------------------------------------------------------------------------
 
     @Override
-    public List<NameElement> updateNames(List<NameElementCommandUpdate> nameElementCommands) {
+    public List<NameElement> updateNames(UserDetails user,
+            List<NameElementCommandUpdate> nameElementCommands) {
         // validate authority - user & admin
         // convert
         // validate
@@ -355,7 +359,7 @@ public class NamesController implements INames {
         try {
             List<NameElementCommand> commands = NameElementUtil.convertCommandUpdate2Command(nameElementCommands);
             namesService.validateNamesUpdate(commands);
-            return namesService.updateNames(commands, TextUtil.TEST_WHO);
+            return namesService.updateNames(commands, SecurityUtil.getUsername(user));
         } catch (ServiceException e) {
             logService.logServiceException(LOGGER, Level.WARNING, e);
             throw e;
@@ -368,7 +372,8 @@ public class NamesController implements INames {
     // ----------------------------------------------------------------------------------------------------
 
     @Override
-    public ResponseEntity<Response> deleteNames(List<NameElementCommandConfirm> nameElementCommands) {
+    public ResponseEntity<Response> deleteNames(UserDetails user,
+            List<NameElementCommandConfirm> nameElementCommands) {
         // validate authority - user & admin
         // convert
         // validate
@@ -377,7 +382,7 @@ public class NamesController implements INames {
         try {
             List<NameElementCommand> commands = NameElementUtil.convertCommandConfirm2Command(nameElementCommands);
             namesService.validateNamesDelete(commands);
-            namesService.deleteNames(commands, TextUtil.TEST_WHO);
+            namesService.deleteNames(commands, SecurityUtil.getUsername(user));
             return new ResponseEntity<>(HttpStatus.NO_CONTENT);
         } catch (ServiceException e) {
             logService.logServiceException(LOGGER, Level.WARNING, e);
diff --git a/src/main/java/org/openepics/names/rest/controller/StructuresController.java b/src/main/java/org/openepics/names/rest/controller/StructuresController.java
index 5b7fe169..32c51cfc 100644
--- a/src/main/java/org/openepics/names/rest/controller/StructuresController.java
+++ b/src/main/java/org/openepics/names/rest/controller/StructuresController.java
@@ -37,6 +37,8 @@ import org.openepics.names.rest.beans.response.ResponseBooleanList;
 import org.openepics.names.rest.beans.response.ResponsePageStructureElements;
 import org.openepics.names.service.LogService;
 import org.openepics.names.service.StructuresService;
+import org.openepics.names.service.security.dto.UserDetails;
+import org.openepics.names.service.security.util.SecurityUtil;
 import org.openepics.names.util.StructureElementUtil;
 import org.openepics.names.util.TextUtil;
 import org.openepics.names.util.ValidateStructureElementUtil;
@@ -77,7 +79,8 @@ public class StructuresController implements IStructures {
     }
 
     @Override
-    public ResponseEntity<List<StructureElement>> createStructures(List<StructureElementCommandCreate> structureElementCommands) {
+    public ResponseEntity<List<StructureElement>> createStructures(UserDetails user,
+            List<StructureElementCommandCreate> structureElementCommands) {
         // validate authority - user & admin
         // convert
         // validate
@@ -86,7 +89,7 @@ public class StructuresController implements IStructures {
         try {
             List<StructureElementCommand> commands = StructureElementUtil.convertCommandCreate2Command(structureElementCommands);
             structuresService.validateStructuresCreate(commands);
-            return new ResponseEntity<>(structuresService.createStructures(commands, TextUtil.TEST_WHO), Response.getHeaderJson(), HttpStatus.CREATED);
+            return new ResponseEntity<>(structuresService.createStructures(commands, SecurityUtil.getUsername(user)), Response.getHeaderJson(), HttpStatus.CREATED);
         } catch (ServiceException e) {
             logService.logServiceException(LOGGER, Level.WARNING, e);
             throw e;
@@ -347,7 +350,8 @@ public class StructuresController implements IStructures {
     // ----------------------------------------------------------------------------------------------------
 
     @Override
-    public List<StructureElement> updateStructures(List<StructureElementCommandUpdate> structureElementCommands) {
+    public List<StructureElement> updateStructures(UserDetails user,
+            List<StructureElementCommandUpdate> structureElementCommands) {
         // validate authority - user & admin
         // convert
         // validate
@@ -356,7 +360,7 @@ public class StructuresController implements IStructures {
         try {
             List<StructureElementCommand> commands = StructureElementUtil.convertCommandUpdate2Command(structureElementCommands);
             structuresService.validateStructuresUpdate(commands);
-            return structuresService.updateStructures(commands, TextUtil.TEST_WHO);
+            return structuresService.updateStructures(commands, SecurityUtil.getUsername(user));
         } catch (ServiceException e) {
             logService.logServiceException(LOGGER, Level.WARNING, e);
             throw e;
@@ -369,7 +373,8 @@ public class StructuresController implements IStructures {
     // ----------------------------------------------------------------------------------------------------
 
     @Override
-    public ResponseEntity<Response> deleteStructures(List<StructureElementCommandConfirm> structureElementCommands) {
+    public ResponseEntity<Response> deleteStructures(UserDetails user,
+            List<StructureElementCommandConfirm> structureElementCommands) {
         // validate authority - user & admin
         // convert
         // validate
@@ -378,7 +383,7 @@ public class StructuresController implements IStructures {
         try {
             List<StructureElementCommand> commands = StructureElementUtil.convertCommandConfirm2Command(structureElementCommands);
             structuresService.validateStructuresDelete(commands);
-            structuresService.deleteStructures(commands, TextUtil.TEST_WHO);
+            structuresService.deleteStructures(commands, SecurityUtil.getUsername(user));
             return new ResponseEntity<>(HttpStatus.NO_CONTENT);
         } catch (ServiceException e) {
             logService.logServiceException(LOGGER, Level.WARNING, e);
diff --git a/src/main/java/org/openepics/names/service/security/UserService.java b/src/main/java/org/openepics/names/service/security/UserService.java
index 4a679f98..140f2f11 100644
--- a/src/main/java/org/openepics/names/service/security/UserService.java
+++ b/src/main/java/org/openepics/names/service/security/UserService.java
@@ -31,7 +31,7 @@ import org.openepics.names.service.LogService;
 import org.openepics.names.service.security.dto.LoginTokenDto;
 import org.openepics.names.service.security.dto.UserDetails;
 import org.openepics.names.service.security.rbac.RBACToken;
-import org.openepics.names.service.security.util.ConversionUtil;
+import org.openepics.names.service.security.util.SecurityUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -90,7 +90,7 @@ public class UserService {
      * @return The user-information stored in RBAC
      */
     public UserDetails getUserInfoFromToken(String token) {
-        return ConversionUtil.convertToUserDetails(rbacService.userInfoFromToken(token));
+        return SecurityUtil.convertToUserDetails(rbacService.userInfoFromToken(token));
     }
 
     /**
diff --git a/src/main/java/org/openepics/names/service/security/util/ConversionUtil.java b/src/main/java/org/openepics/names/service/security/util/SecurityUtil.java
similarity index 65%
rename from src/main/java/org/openepics/names/service/security/util/ConversionUtil.java
rename to src/main/java/org/openepics/names/service/security/util/SecurityUtil.java
index 6a6a5328..cfca9311 100644
--- a/src/main/java/org/openepics/names/service/security/util/ConversionUtil.java
+++ b/src/main/java/org/openepics/names/service/security/util/SecurityUtil.java
@@ -5,10 +5,15 @@ import org.openepics.names.service.security.rbac.RBACToken;
 
 /**
  * @author <a href="mailto:zoltan.runyo@ess.eu">Zoltan Runyo</a>
+ * @author Lars Johansson
  */
-public class ConversionUtil {
+public class SecurityUtil {
 
-    private ConversionUtil() {
+    /**
+     * This class is not to be instantiated.
+     */
+    private SecurityUtil() {
+        throw new IllegalStateException("Utility class");
     }
 
     /**
@@ -32,4 +37,14 @@ public class ConversionUtil {
         return result;
     }
 
+    /**
+     * Return username for a user.
+     *
+     * @param userDetails user details
+     * @return username
+     */
+    public static String getUsername(UserDetails userDetails) {
+        return userDetails != null ? userDetails.getUserName() : null;
+    }
+
 }
diff --git a/src/main/java/org/openepics/names/util/TextUtil.java b/src/main/java/org/openepics/names/util/TextUtil.java
index b47222d1..b5a972c7 100644
--- a/src/main/java/org/openepics/names/util/TextUtil.java
+++ b/src/main/java/org/openepics/names/util/TextUtil.java
@@ -132,9 +132,6 @@ public class TextUtil {
     public static final String ATTACHMENT_FILENAME_NAME_ELEMENT_XLSX      = "attachment; filename=NameElement.xlsx";
     public static final String ATTACHMENT_FILENAME_STRUCTURE_ELEMENT_XLSX = "attachment; filename=StructureElement.xlsx";
 
-    // test
-    public static final String TEST_WHO                                = "test who";
-
     // log
     public static final String DESCRIPTION_NUMBER_ELEMENTS        = "{0}, # elements: {1}";
     public static final String DESCRIPTION_NUMBER_ELEMENTS_IN_OUT = "{0}, # elements (in): {1}, # elements (out): {2}";
diff --git a/src/test/java/org/openepics/names/docker/NamesIT.java b/src/test/java/org/openepics/names/docker/NamesIT.java
index 049ad1f2..b2b142d1 100644
--- a/src/test/java/org/openepics/names/docker/NamesIT.java
+++ b/src/test/java/org/openepics/names/docker/NamesIT.java
@@ -678,16 +678,8 @@ class NamesIT {
         ITUtilNames.assertRead("?description=updated description%",                 1, -1);
         ITUtilNames.assertRead("?description=updated description again",            1);
 
-        ITUtilNames.assertRead("?who=test who",                                    13, -1);
+        ITUtilNames.assertRead("?who=",                                            13, -1);
         ITUtilNames.assertRead("?who=test",                                         0);
-        ITUtilNames.assertRead("?who=who",                                          0);
-        ITUtilNames.assertRead("?who=test%",                                       13, -1);
-        ITUtilNames.assertRead("?who=%who",                                        13, -1);
-        ITUtilNames.assertRead("?who=%est%",                                       13, -1);
-        ITUtilNames.assertRead("?who=%wh%",                                        13, -1);
-        ITUtilNames.assertRead("?who=wh%",                                          0);
-        ITUtilNames.assertRead("?who=asdf",                                         0);
-        ITUtilNames.assertRead("?who=%asdf%",                                       0);
 
         ITUtilNames.assertRead("?deviceStructure=EMR-FS&index=003",                 1);
 
diff --git a/src/test/java/org/openepics/names/docker/StructuresDeviceGroupIT.java b/src/test/java/org/openepics/names/docker/StructuresDeviceGroupIT.java
index 6286303a..64f88b73 100644
--- a/src/test/java/org/openepics/names/docker/StructuresDeviceGroupIT.java
+++ b/src/test/java/org/openepics/names/docker/StructuresDeviceGroupIT.java
@@ -864,16 +864,8 @@ class StructuresDeviceGroupIT {
         ITUtilStructures.assertRead("?type=DEVICEGROUP&description=%sc%",                                                         30, -1);
         ITUtilStructures.assertRead("?type=DEVICEGROUP&description=description",                                                  10, -1);
 
-        ITUtilStructures.assertRead("?type=DEVICEGROUP&who=test who",                                                             30, -1);
+        ITUtilStructures.assertRead("?type=DEVICEGROUP&who=",                                                                     30, -1);
         ITUtilStructures.assertRead("?type=DEVICEGROUP&who=test",                                                                  0);
-        ITUtilStructures.assertRead("?type=DEVICEGROUP&who=who",                                                                   0);
-        ITUtilStructures.assertRead("?type=DEVICEGROUP&who=test%",                                                                30, -1);
-        ITUtilStructures.assertRead("?type=DEVICEGROUP&who=%who",                                                                 30, -1);
-        ITUtilStructures.assertRead("?type=DEVICEGROUP&who=%est%",                                                                30, -1);
-        ITUtilStructures.assertRead("?type=DEVICEGROUP&who=%wh%",                                                                 30, -1);
-        ITUtilStructures.assertRead("?type=DEVICEGROUP&who=wh%",                                                                   0);
-        ITUtilStructures.assertRead("?type=DEVICEGROUP&who=asdf",                                                                  0);
-        ITUtilStructures.assertRead("?type=DEVICEGROUP&who=%asdf%",                                                                0);
 
         // order by
         //     avoid
diff --git a/src/test/java/org/openepics/names/docker/StructuresDeviceTypeIT.java b/src/test/java/org/openepics/names/docker/StructuresDeviceTypeIT.java
index a512138d..27946088 100644
--- a/src/test/java/org/openepics/names/docker/StructuresDeviceTypeIT.java
+++ b/src/test/java/org/openepics/names/docker/StructuresDeviceTypeIT.java
@@ -872,16 +872,8 @@ class StructuresDeviceTypeIT {
         ITUtilStructures.assertRead("?type=DEVICETYPE&description=%sc%",                                                     30, -1);
         ITUtilStructures.assertRead("?type=DEVICETYPE&description=description",                                              10, -1);
 
-        ITUtilStructures.assertRead("?type=DEVICETYPE&who=test who",                                                         30, -1);
+        ITUtilStructures.assertRead("?type=DEVICETYPE&who=",                                                                 30, -1);
         ITUtilStructures.assertRead("?type=DEVICETYPE&who=test",                                                              0);
-        ITUtilStructures.assertRead("?type=DEVICETYPE&who=who",                                                               0);
-        ITUtilStructures.assertRead("?type=DEVICETYPE&who=test%",                                                            30, -1);
-        ITUtilStructures.assertRead("?type=DEVICETYPE&who=%who",                                                             30, -1);
-        ITUtilStructures.assertRead("?type=DEVICETYPE&who=%est%",                                                            30, -1);
-        ITUtilStructures.assertRead("?type=DEVICETYPE&who=%wh%",                                                             30, -1);
-        ITUtilStructures.assertRead("?type=DEVICETYPE&who=wh%",                                                               0);
-        ITUtilStructures.assertRead("?type=DEVICETYPE&who=asdf",                                                              0);
-        ITUtilStructures.assertRead("?type=DEVICETYPE&who=%asdf%",                                                            0);
 
         // order by
         //     avoid
diff --git a/src/test/java/org/openepics/names/docker/StructuresDisciplineIT.java b/src/test/java/org/openepics/names/docker/StructuresDisciplineIT.java
index 510df00a..1d36c322 100644
--- a/src/test/java/org/openepics/names/docker/StructuresDisciplineIT.java
+++ b/src/test/java/org/openepics/names/docker/StructuresDisciplineIT.java
@@ -766,16 +766,8 @@ class StructuresDisciplineIT {
         ITUtilStructures.assertRead("?type=DISCIPLINE&description=%sc%",                                                     30, -1);
         ITUtilStructures.assertRead("?type=DISCIPLINE&description=description",                                              10, -1);
 
-        ITUtilStructures.assertRead("?type=DISCIPLINE&who=test who",                                                         30, -1);
+        ITUtilStructures.assertRead("?type=DISCIPLINE&who=",                                                                 30, -1);
         ITUtilStructures.assertRead("?type=DISCIPLINE&who=test",                                                              0);
-        ITUtilStructures.assertRead("?type=DISCIPLINE&who=who",                                                               0);
-        ITUtilStructures.assertRead("?type=DISCIPLINE&who=test%",                                                            30, -1);
-        ITUtilStructures.assertRead("?type=DISCIPLINE&who=%who",                                                             30, -1);
-        ITUtilStructures.assertRead("?type=DISCIPLINE&who=%est%",                                                            30, -1);
-        ITUtilStructures.assertRead("?type=DISCIPLINE&who=%wh%",                                                             30, -1);
-        ITUtilStructures.assertRead("?type=DISCIPLINE&who=wh%",                                                               0);
-        ITUtilStructures.assertRead("?type=DISCIPLINE&who=asdf",                                                              0);
-        ITUtilStructures.assertRead("?type=DISCIPLINE&who=%asdf%",                                                            0);
 
         // order by
         //     avoid
diff --git a/src/test/java/org/openepics/names/docker/StructuresSubsystemIT.java b/src/test/java/org/openepics/names/docker/StructuresSubsystemIT.java
index eb3c04b4..cef336b7 100644
--- a/src/test/java/org/openepics/names/docker/StructuresSubsystemIT.java
+++ b/src/test/java/org/openepics/names/docker/StructuresSubsystemIT.java
@@ -908,16 +908,8 @@ class StructuresSubsystemIT {
         ITUtilStructures.assertRead("?type=SUBSYSTEM&description=%sc%",                                                     30, -1);
         ITUtilStructures.assertRead("?type=SUBSYSTEM&description=description",                                              10, -1);
 
-        ITUtilStructures.assertRead("?type=SUBSYSTEM&who=test who",                                                         30, -1);
+        ITUtilStructures.assertRead("?type=SUBSYSTEM&who=",                                                                 30, -1);
         ITUtilStructures.assertRead("?type=SUBSYSTEM&who=test",                                                              0);
-        ITUtilStructures.assertRead("?type=SUBSYSTEM&who=who",                                                               0);
-        ITUtilStructures.assertRead("?type=SUBSYSTEM&who=test%",                                                            30, -1);
-        ITUtilStructures.assertRead("?type=SUBSYSTEM&who=%who",                                                             30, -1);
-        ITUtilStructures.assertRead("?type=SUBSYSTEM&who=%est%",                                                            30, -1);
-        ITUtilStructures.assertRead("?type=SUBSYSTEM&who=%wh%",                                                             30, -1);
-        ITUtilStructures.assertRead("?type=SUBSYSTEM&who=wh%",                                                               0);
-        ITUtilStructures.assertRead("?type=SUBSYSTEM&who=asdf",                                                              0);
-        ITUtilStructures.assertRead("?type=SUBSYSTEM&who=%asdf%",                                                            0);
 
         // order by
         //     avoid
diff --git a/src/test/java/org/openepics/names/docker/StructuresSystemGroupIT.java b/src/test/java/org/openepics/names/docker/StructuresSystemGroupIT.java
index e284a557..b4b05e97 100644
--- a/src/test/java/org/openepics/names/docker/StructuresSystemGroupIT.java
+++ b/src/test/java/org/openepics/names/docker/StructuresSystemGroupIT.java
@@ -813,16 +813,8 @@ class StructuresSystemGroupIT {
         ITUtilStructures.assertRead("?type=SYSTEMGROUP&description=%sc%",                                                     30, -1);
         ITUtilStructures.assertRead("?type=SYSTEMGROUP&description=description",                                              10, -1);
 
-        ITUtilStructures.assertRead("?type=SYSTEMGROUP&who=test who",                                                         30, -1);
+        ITUtilStructures.assertRead("?type=SYSTEMGROUP&who=",                                                                 30, -1);
         ITUtilStructures.assertRead("?type=SYSTEMGROUP&who=test",                                                              0);
-        ITUtilStructures.assertRead("?type=SYSTEMGROUP&who=who",                                                               0);
-        ITUtilStructures.assertRead("?type=SYSTEMGROUP&who=test%",                                                            30, -1);
-        ITUtilStructures.assertRead("?type=SYSTEMGROUP&who=%who",                                                             30, -1);
-        ITUtilStructures.assertRead("?type=SYSTEMGROUP&who=%est%",                                                            30, -1);
-        ITUtilStructures.assertRead("?type=SYSTEMGROUP&who=%wh%",                                                             30, -1);
-        ITUtilStructures.assertRead("?type=SYSTEMGROUP&who=wh%",                                                               0);
-        ITUtilStructures.assertRead("?type=SYSTEMGROUP&who=asdf",                                                              0);
-        ITUtilStructures.assertRead("?type=SYSTEMGROUP&who=%asdf%",                                                            0);
 
         // order by
         //     avoid
diff --git a/src/test/java/org/openepics/names/docker/StructuresSystemIT.java b/src/test/java/org/openepics/names/docker/StructuresSystemIT.java
index e307784a..9afadef2 100644
--- a/src/test/java/org/openepics/names/docker/StructuresSystemIT.java
+++ b/src/test/java/org/openepics/names/docker/StructuresSystemIT.java
@@ -852,16 +852,8 @@ class StructuresSystemIT {
         ITUtilStructures.assertRead("?type=SYSTEM&description=%sc%",                                                     30, -1);
         ITUtilStructures.assertRead("?type=SYSTEM&description=description",                                              10, -1);
 
-        ITUtilStructures.assertRead("?type=SYSTEM&who=test who",                                                         30, -1);
+        ITUtilStructures.assertRead("?type=SYSTEM&who=",                                                                 30, -1);
         ITUtilStructures.assertRead("?type=SYSTEM&who=test",                                                              0);
-        ITUtilStructures.assertRead("?type=SYSTEM&who=who",                                                               0);
-        ITUtilStructures.assertRead("?type=SYSTEM&who=test%",                                                            30, -1);
-        ITUtilStructures.assertRead("?type=SYSTEM&who=%who",                                                             30, -1);
-        ITUtilStructures.assertRead("?type=SYSTEM&who=%est%",                                                            30, -1);
-        ITUtilStructures.assertRead("?type=SYSTEM&who=%wh%",                                                             30, -1);
-        ITUtilStructures.assertRead("?type=SYSTEM&who=wh%",                                                               0);
-        ITUtilStructures.assertRead("?type=SYSTEM&who=asdf",                                                              0);
-        ITUtilStructures.assertRead("?type=SYSTEM&who=%asdf%",                                                            0);
 
         // order by
         //     avoid
-- 
GitLab