create relation with holder- and contact-data, and search for contact emailAddress + relation mark #136
@ -4,6 +4,7 @@ import io.micrometer.core.annotation.Timed;
|
|||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.Repository;
|
import org.springframework.data.repository.Repository;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -28,8 +29,8 @@ public interface HsOfficeContactRbacRepository extends Repository<HsOfficeContac
|
|||||||
@Timed("app.office.contacts.repo.findContactByEmailAddressImpl.rbac")
|
@Timed("app.office.contacts.repo.findContactByEmailAddressImpl.rbac")
|
||||||
List<HsOfficeContactRbacEntity> findContactByEmailAddressImpl(final String emailAddressExpression);
|
List<HsOfficeContactRbacEntity> findContactByEmailAddressImpl(final String emailAddressExpression);
|
||||||
|
|
||||||
default List<HsOfficeContactRbacEntity> findContactByEmailAddress(final String emailAddress) {
|
default List<HsOfficeContactRbacEntity> findContactByEmailAddress(@NotNull final String emailAddress) {
|
||||||
return findContactByEmailAddressImpl("$.** ? (@ == \"" + emailAddress + "\")");
|
return findContactByEmailAddressImpl("$.** ? (@ like_regex \"" + emailAddress.replace("%", ".*") + "\")");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Timed("app.office.contacts.repo.save.rbac")
|
@Timed("app.office.contacts.repo.save.rbac")
|
||||||
|
@ -18,7 +18,7 @@ get:
|
|||||||
required: false
|
required: false
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: Beginning of email-address to filter the results.
|
description: Beginning of email-address to filter the results, use '%' as wildcard.
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
|
@ -188,12 +188,12 @@ class HsOfficeContactRbacRepositoryIntegrationTest extends ContextBasedTestWithC
|
|||||||
class FindByEmailAddress {
|
class FindByEmailAddress {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void globalAdmin_withoutAssumedRole_canViewAllContacts() {
|
public void globalAdmin_withoutAssumedRole_canFindContactsByEmailAddress() {
|
||||||
// given
|
// given
|
||||||
context("superuser-alex@hostsharing.net", null);
|
context("superuser-alex@hostsharing.net", null);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = contactRepo.findContactByEmailAddress("contact-admin@secondcontact.example.com");
|
final var result = contactRepo.findContactByEmailAddress("%@secondcontact.example.com");
|
||||||
|
|
||||||
// then
|
// then
|
||||||
exactlyTheseContactsAreReturned(result, "second contact");
|
exactlyTheseContactsAreReturned(result, "second contact");
|
||||||
|
Loading…
Reference in New Issue
Block a user