diff --git a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/configuration/auto/MigrationTasksContextLoadedListener.java b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/configuration/auto/MigrationTasksContextLoadedListener.java index 9fc942dc8..4dbe3656d 100644 --- a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/configuration/auto/MigrationTasksContextLoadedListener.java +++ b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/configuration/auto/MigrationTasksContextLoadedListener.java @@ -66,17 +66,5 @@ void doshibui_1740_migration() { userService.save(user); // this will ensure group is set as the default user group } }); - - // SHIBUI-1743: Adding regex expression to groups - groupService.findAll().forEach(g -> { - g.setValidationRegex(Group.DEFAULT_REGEX); - try { - groupService.updateGroup(g); - } - catch (Exception e) { - // Shouldn't happen - e.printStackTrace(); - } - }); } } \ No newline at end of file diff --git a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/security/model/Group.java b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/security/model/Group.java index f90423b66..c0d579c30 100644 --- a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/security/model/Group.java +++ b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/security/model/Group.java @@ -49,7 +49,7 @@ public class Group implements Owner { private String resourceId = UUID.randomUUID().toString(); @Column(name = "validation_regex") - private String validationRegex = DEFAULT_REGEX; + private String validationRegex; /** * Define a Group object based on the user @@ -58,7 +58,6 @@ public Group(User user) { resourceId = user.getUsername(); name = user.getUsername(); description = "default user-group"; - validationRegex = DEFAULT_REGEX; } @Override diff --git a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/security/service/GroupServiceImpl.java b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/security/service/GroupServiceImpl.java index 8eed21f7f..cb36b21f3 100644 --- a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/security/service/GroupServiceImpl.java +++ b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/security/service/GroupServiceImpl.java @@ -74,6 +74,10 @@ public boolean doesStringMatchGroupPattern(String groupId, String uri) { Group group = find(groupId); String regExp = group.getValidationRegex(); + if (StringUtils.isEmpty(regExp)) { + return true; + } + engine.put("str", uri); try { engine.eval("var rgx=" + regExp); @@ -123,11 +127,10 @@ public Group updateGroup(Group group) throws EntityNotFoundException, InvalidGro } /** - * If the regex is missing, go with the default "anything goes" regex, otherwise validate that the pattern is valid to use. + * If the regex is blank simply return */ private void validateGroupRegex(Group group) throws InvalidGroupRegexException { if (StringUtils.isEmpty(group.getValidationRegex())) { - group.setValidationRegex(Group.DEFAULT_REGEX); return; } try { diff --git a/backend/src/test/groovy/edu/internet2/tier/shibboleth/admin/ui/security/controller/UsersControllerIntegrationTests.groovy b/backend/src/test/groovy/edu/internet2/tier/shibboleth/admin/ui/security/controller/UsersControllerIntegrationTests.groovy index fbd232620..0965b0891 100644 --- a/backend/src/test/groovy/edu/internet2/tier/shibboleth/admin/ui/security/controller/UsersControllerIntegrationTests.groovy +++ b/backend/src/test/groovy/edu/internet2/tier/shibboleth/admin/ui/security/controller/UsersControllerIntegrationTests.groovy @@ -141,12 +141,12 @@ class UsersControllerIntegrationTests extends AbstractBaseDataJpaTest { .andExpect(jsonPath("\$.[1].emailAddress").value("peter@institution.edu")) .andExpect(jsonPath("\$.[1].role").value("ROLE_USER")) .andExpect(jsonPath("\$.[1].groupId").value("nonadmin")) - .andExpect(jsonPath("\$.[1].userGroups.[0].validationRegex").value(Group.DEFAULT_REGEX)) + .andExpect(jsonPath("\$.[1].userGroups.[0].validationRegex").value(null)) .andExpect(jsonPath("\$.[2].username").value("none")) .andExpect(jsonPath("\$.[2].emailAddress").value("badboy@institution.edu")) .andExpect(jsonPath("\$.[2].role").value("ROLE_NONE")) .andExpect(jsonPath("\$.[2].groupId").value("none")) - .andExpect(jsonPath("\$.[2].userGroups.[0].validationRegex").value(Group.DEFAULT_REGEX)) + .andExpect(jsonPath("\$.[2].userGroups.[0].validationRegex").value(null)) .andExpect(jsonPath("\$.[3].username").value("anonymousUser")) .andExpect(jsonPath("\$.[3].emailAddress").value("anon@institution.edu")) .andExpect(jsonPath("\$.[3].role").value("ROLE_ADMIN")) diff --git a/backend/src/test/groovy/edu/internet2/tier/shibboleth/admin/ui/security/service/GroupServiceTests.groovy b/backend/src/test/groovy/edu/internet2/tier/shibboleth/admin/ui/security/service/GroupServiceTests.groovy index e71fdeb17..619a4e567 100644 --- a/backend/src/test/groovy/edu/internet2/tier/shibboleth/admin/ui/security/service/GroupServiceTests.groovy +++ b/backend/src/test/groovy/edu/internet2/tier/shibboleth/admin/ui/security/service/GroupServiceTests.groovy @@ -22,7 +22,7 @@ class GroupServiceTests extends AbstractBaseDataJpaTest { } then: - g.getValidationRegex() == Group.DEFAULT_REGEX + g.getValidationRegex() == null when: g.setValidationRegex("/\\w\\b\\w/")