diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRbacRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRbacRepositoryIntegrationTest.java index 6263d425..481847c2 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRbacRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRbacRepositoryIntegrationTest.java @@ -143,7 +143,38 @@ class HsOfficePersonRbacRepositoryIntegrationTest extends ContextBasedTestWithCl allThesePersonsAreReturned( result, "NP Smith, Peter", - "LP Peter Smith - The Second Hand and Thrift Stores-n-Shipping e.K."); + "LP Peter Smith - The Second Hand and Thrift Stores-n-Shipping e.K.", + "IF Third OHG", + "UF Erben Bessler"); + } + + @Test + public void arbitraryUser_canViewOnlyItsOwnPerson() { + // given: + final var givenPerson = givenSomeTemporaryPerson("pac-admin-zzz00@zzz.example.com"); + + // when: + context("pac-admin-zzz00@zzz.example.com"); + final var result = personRbacRepo.findPersonByOptionalNameLike(null); + + // then: + exactlyThesePersonsAreReturned(result, givenPerson.getTradeName()); + } + } + + @Nested + class FindByCaptionLike { + + @Test + public void globalAdmin_withoutAssumedRole_canViewAllPersons() { + // given + context("superuser-alex@hostsharing.net", null); + + // when + final var result = personRbacRepo.findPersonByOptionalNameLike("Peter Smith - The Second Hand%"); + + // then + exactlyThesePersonsAreReturned(result, "Peter Smith - The Second Hand and Thrift Stores-n-Shipping e.K."); } @Test diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealRepositoryIntegrationTest.java index e7f50fed..2fc268a6 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealRepositoryIntegrationTest.java @@ -126,7 +126,25 @@ class HsOfficePersonRealRepositoryIntegrationTest extends ContextBasedTestWithCl allThesePersonsAreReturned( result, "NP Smith, Peter", - "LP Peter Smith - The Second Hand and Thrift Stores-n-Shipping e.K."); + "LP Peter Smith - The Second Hand and Thrift Stores-n-Shipping e.K.", + "IF Third OHG", + "UF Erben Bessler"); + } + } + + @Nested + class FindByCaptionLike { + + @Test + public void arbitraryUser_canViewAllPersons() { + // given + context("selfregistered-user-drew@hostsharing.org"); + + // when + final var result = personRealRepo.findPersonByOptionalNameLike("Peter Smith - The Second Hand%"); + + // then + exactlyThesePersonsAreReturned(result, "Peter Smith - The Second Hand and Thrift Stores-n-Shipping e.K."); } }