create relation with holder- and contact-data, and search for contact emailAddress + relation mark #136

Merged
hsh-michaelhoennig merged 12 commits from feature/create-relation-with-holder-and-contact-data into master 2024-12-13 14:09:03 +01:00
3 changed files with 6 additions and 5 deletions
Showing only changes of commit 025ebac846 - Show all commits

View File

@ -4,6 +4,7 @@ import io.micrometer.core.annotation.Timed;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
import jakarta.validation.constraints.NotNull;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
@ -28,8 +29,8 @@ public interface HsOfficeContactRbacRepository extends Repository<HsOfficeContac
@Timed("app.office.contacts.repo.findContactByEmailAddressImpl.rbac")
List<HsOfficeContactRbacEntity> findContactByEmailAddressImpl(final String emailAddressExpression);
default List<HsOfficeContactRbacEntity> findContactByEmailAddress(final String emailAddress) {
return findContactByEmailAddressImpl("$.** ? (@ == \"" + emailAddress + "\")");
default List<HsOfficeContactRbacEntity> findContactByEmailAddress(@NotNull final String emailAddress) {
return findContactByEmailAddressImpl("$.** ? (@ like_regex \"" + emailAddress.replace("%", ".*") + "\")");
}
@Timed("app.office.contacts.repo.save.rbac")

View File

@ -18,7 +18,7 @@ get:
required: false
schema:
type: string
description: Beginning of email-address to filter the results.
description: Beginning of email-address to filter the results, use '%' as wildcard.
responses:
"200":
description: OK

View File

@ -188,12 +188,12 @@ class HsOfficeContactRbacRepositoryIntegrationTest extends ContextBasedTestWithC
class FindByEmailAddress {
@Test
public void globalAdmin_withoutAssumedRole_canViewAllContacts() {
public void globalAdmin_withoutAssumedRole_canFindContactsByEmailAddress() {
// given
context("superuser-alex@hostsharing.net", null);
// when
final var result = contactRepo.findContactByEmailAddress("contact-admin@secondcontact.example.com");
final var result = contactRepo.findContactByEmailAddress("%@secondcontact.example.com");
hsh-michaelhoennig marked this conversation as resolved Outdated

regexp?

regexp?
// then
exactlyTheseContactsAreReturned(result, "second contact");