feat: public invite and check-in endpoints with abuse limits

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-12-01 17:09:55 +08:00
1 parent c700e12865
commit 2f15b117d9
7 files changed
+901 -21

No files matched your search

@@ -0,0 +1,479 @@
package com.solvway.mobile.api.service;
import com.solvway.core.enums.GeneralEnum;
import com.solvway.core.utils.HttpReqRespUtils;
import com.solvway.mobile.api.dto.PublicCheckinLookupRequest;
import com.solvway.mobile.api.dto.PublicRegistrationRequest;
import com.solvway.mobile.api.dto.admin.CompanyEvent;
import com.solvway.mobile.api.errorhandler.CodedResponseStatusException;
import com.solvway.mobile.api.useraccess.AdminCompanyScope;
import com.solvway.mobile.api.util.RestTemplateCustomUtil;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.MockedStatic;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.HttpClientErrorException;
import java.time.Clock;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;
@SuppressWarnings({"unchecked", "rawtypes"})
class PublicInviteServiceTest {
private static final String GUEST = "/counter/eventGuest/findByToken/{token}";
private static final String GUEST_REGISTER = "/counter/eventGuest/register";
private static final String FIND_EVENT = "/counter/checkin/findEvent/{token}";
private static final String LOOKUP = "/counter/checkin/lookup";
private static final String BY_GUEST = "/counter/checkin/byGuest";
private static final String REGISTER = "/counter/registration/register";
private static final String EVENT = "/counter/event/findByUuid/{uuid}";
private static final String COMPANY_URL = "/company/findById/{id}";
private static final String NOTICE = "/company/{id}/privacyNotice";
private static final String INTERESTS = "/counter/interest/findByCompany/{companyId}";
private static final long EV = 3312726793093644288L;
private static final long COMPANY = 5L;
private static final String GT = "abcDEF123_-abcDEF123_-";
private static final String CK = "ZYXwvu987_-ZYXwvu987_-";
private RestTemplateCustomUtil rest;
private RedisTemplate<String, Object> redis;
private ValueOperations<String, Object> ops;
private MockedStatic<HttpReqRespUtils> http;
private PublicInviteService service;
private static Clock at(String utc) { return Clock.fixed(Instant.parse(utc), ZoneOffset.UTC); }
private PublicInviteService svc(String utc) {
AdminEventLeadService leads = new AdminEventLeadService(rest, mock(AdminAuthenticationService.class), new AdminCompanyScope());
return new PublicInviteService(rest, new PublicRegistrationService(rest, leads, redis, at(utc)));
}
@BeforeEach
void setUp() {
rest = mock(RestTemplateCustomUtil.class);
redis = mock(RedisTemplate.class);
ops = mock(ValueOperations.class);
when(redis.opsForValue()).thenReturn(ops);
when(ops.increment(any())).thenReturn(1L);
when(rest.getURLforApiService(any())).thenAnswer(i -> i.getArgument(0));
http = mockStatic(HttpReqRespUtils.class);
http.when(HttpReqRespUtils::getClientIpAddressIfServletRequestExist).thenReturn("1.2.3.4");
service = svc("2027-01-16T04:00:00Z"); // 16 Jan 12:00 Malaysia: an event day
stubGuest(false, false);
stub(FIND_EVENT, CK, Map.of("companyId", COMPANY, "eventUuid", EV));
stubEvent(true, LocalDateTime.of(2027, 1, 17, 23, 59, 59));
stub(COMPANY_URL, COMPANY, new HashMap<>(Map.of("id", COMPANY, "name", "INS", "status", "A")));
stub(NOTICE, COMPANY, Map.of("id", 9L, "textEn", "English notice", "textMs", "Notis"));
stub(INTERESTS, COMPANY, List.of(
Map.of("id", 3L, "companyId", COMPANY, "name", "Cookware", "active", true, "sortOrder", 0),
Map.of("id", 5L, "companyId", COMPANY, "name", "Old", "active", false, "sortOrder", 1)));
post(GUEST_REGISTER, Map.of("outcome", "REGISTERED", "eventLeadUuid", 7L));
post(REGISTER, Map.of());
post(BY_GUEST, Map.of("firstName", "Aisyah"));
post(LOOKUP, Map.of("result", "FORM"));
}
@AfterEach
void close() { http.close(); }
private void stub(String url, Object var, Object body) {
when(rest.getForEntity(eq(url), any(ParameterizedTypeReference.class), eq(var))).thenReturn(ResponseEntity.ok(body));
}
private void post(String url, Object body) {
when(rest.postForEntity(eq(url), any(ParameterizedTypeReference.class), any())).thenReturn(ResponseEntity.ok(body));
}
private void postConflict(String url, String code) {
when(rest.postForEntity(eq(url), any(ParameterizedTypeReference.class), any())).thenThrow(
HttpClientErrorException.create(HttpStatus.CONFLICT, "c", null, ("{\"code\":\"" + code + "\"}").getBytes(), null));
}
private void stubGuest(boolean registered, boolean attended) {
Map<String, Object> g = new HashMap<>();
g.put("companyId", COMPANY);
g.put("eventUuid", EV);
g.put("guestId", 11L);
g.put("name", "Aisyah");
g.put("mobileE164", "+60123456789");
g.put("email", "a@x.com");
g.put("companyName", "Acme");
g.put("salespersonUserId", 21L);
g.put("registered", registered);
g.put("attended", attended);
stub(GUEST, GT, g);
}
private void stubEvent(boolean enabled, LocalDateTime end) {
CompanyEvent e = new CompanyEvent();
e.setCompanyId(COMPANY);
e.setUuid(EV);
e.setName("KL Food Fair 2027");
e.setLocation("MITEC");
e.setDateStart(LocalDateTime.of(2027, 1, 15, 0, 0));
e.setDateEnd(end);
e.setEnabled(enabled ? GeneralEnum.FlagYesNo.Y : GeneralEnum.FlagYesNo.N);
stub(EVENT, EV, e);
}
private static PublicRegistrationRequest req(String website, Boolean consent) {
return new PublicRegistrationRequest("Aisyah", "012-345 6789", "a@x.com", "Acme", "Chef", List.of(3L), consent, website);
}
private static PublicRegistrationRequest ok() { return req(null, true); }
private void assertCoded(Runnable r, HttpStatus status, String code) {
assertThatThrownBy(r::run).isInstanceOfSatisfying(CodedResponseStatusException.class, e -> {
assertThat(e.getStatusCode()).isEqualTo(status);
assertThat(e.getBody().getProperties()).containsEntry("code", code);
});
}
private void assertInvite(Runnable r) {
assertThatThrownBy(r::run).isInstanceOfSatisfying(CodedResponseStatusException.class, e -> {
assertThat(e.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
assertThat(e.getReason()).isEqualTo("This invitation is no longer active.");
assertThat(e.getBody().getProperties()).containsEntry("code", "INVITE_INACTIVE");
});
}
private void assertCode(Runnable r) {
assertThatThrownBy(r::run).isInstanceOfSatisfying(CodedResponseStatusException.class, e -> {
assertThat(e.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
assertThat(e.getReason()).isEqualTo("This code is no longer active.");
assertThat(e.getBody().getProperties()).containsEntry("code", "CODE_INACTIVE");
});
}
private Map<String, Object> sent(String url) {
ArgumentCaptor<Object> c = ArgumentCaptor.forClass(Object.class);
verify(rest).postForEntity(eq(url), any(ParameterizedTypeReference.class), c.capture());
return (Map<String, Object>) c.getValue();
}
private void tooMany(String key, long over, Runnable r) {
when(ops.increment(key)).thenReturn(over);
assertCoded(r, HttpStatus.TOO_MANY_REQUESTS, "TOO_MANY");
}
// --- bad shape ---
@Test
void badTokenShape_404_withoutBackendCall() {
for (String bad : List.of("x", "short-link", GT.substring(1), GT + "A", GT.substring(1) + "!")) {
assertInvite(() -> service.invite(bad));
assertInvite(() -> service.inviteRegister(bad, ok()));
assertInvite(() -> service.inviteCheckin(bad));
assertCode(() -> service.checkin(bad));
assertCode(() -> service.lookup(bad, new PublicCheckinLookupRequest("a@x.com")));
assertCode(() -> service.walkIn(bad, ok()));
}
verifyNoInteractions(rest);
}
// --- inactive ---
@Test
void invite_unknownGuestToken_inactive() {
when(rest.getForEntity(eq(GUEST), any(ParameterizedTypeReference.class), eq(GT)))
.thenThrow(HttpClientErrorException.create(HttpStatus.NOT_FOUND, "nf", null, null, null));
assertInvite(() -> service.invite(GT));
assertInvite(() -> service.inviteRegister(GT, ok()));
assertInvite(() -> service.inviteCheckin(GT));
}
@Test
void invite_eventDisabled_endDatePassed_noNotice_inactive() {
stubEvent(false, LocalDateTime.of(2027, 1, 17, 23, 59, 59));
assertInvite(() -> service.invite(GT));
stubEvent(true, LocalDateTime.of(2027, 1, 17, 23, 59, 59));
assertThat(service.invite(GT)).containsKey("eventName");
assertInvite(() -> svc("2027-01-17T16:00:00Z").invite(GT)); // 18 Jan Malaysia, end passed
when(rest.getForEntity(eq(NOTICE), any(ParameterizedTypeReference.class), eq(COMPANY)))
.thenThrow(HttpClientErrorException.create(HttpStatus.NOT_FOUND, "nf", null, null, null));
assertInvite(() -> service.invite(GT));
}
@Test
void checkin_unknownTokenDisabledEventOrNoNotice_inactive() {
when(rest.getForEntity(eq(FIND_EVENT), any(ParameterizedTypeReference.class), eq("AAAAAAAAAAAAAAAAAAAAAA")))
.thenThrow(HttpClientErrorException.create(HttpStatus.NOT_FOUND, "nf", null, null, null));
assertCode(() -> service.checkin("AAAAAAAAAAAAAAAAAAAAAA"));
stubEvent(false, LocalDateTime.of(2027, 1, 17, 23, 59, 59));
assertCode(() -> service.checkin(CK));
stubEvent(true, LocalDateTime.of(2027, 1, 17, 23, 59, 59));
when(rest.getForEntity(eq(NOTICE), any(ParameterizedTypeReference.class), eq(COMPANY)))
.thenThrow(HttpClientErrorException.create(HttpStatus.NOT_FOUND, "nf", null, null, null));
assertCode(() -> service.checkin(CK));
}
// --- invite GET ---
@Test
void invite_returnsEventNoticeInterestsAndTheGuestsOwnDetails() {
Map<String, Object> out = service.invite(GT);
assertThat(out).containsEntry("eventName", "KL Food Fair 2027").containsEntry("startDate", "2027-01-15")
.containsEntry("endDate", "2027-01-17").containsEntry("location", "MITEC").containsEntry("companyName", "INS")
.containsEntry("state", "OPEN");
assertThat(out.get("interests")).isEqualTo(List.of(Map.of("id", 3L, "name", "Cookware")));
assertThat((Map<String, Object>) out.get("notice")).containsEntry("id", 9L).containsEntry("textEn", "English notice");
assertThat(out.get("guest")).isEqualTo(Map.of("name", "Aisyah", "mobile", "+60123456789", "email", "a@x.com", "companyName", "Acme"));
}
@Test
void invite_states() {
assertThat(service.invite(GT)).containsEntry("state", "OPEN");
stubGuest(true, false);
assertThat(service.invite(GT)).containsEntry("state", "CHECKIN"); // event day
assertThat(svc("2027-01-10T04:00:00Z").invite(GT)).containsEntry("state", "REGISTERED"); // before the event
stubGuest(true, true);
assertThat(service.invite(GT)).containsEntry("state", "CHECKED_IN");
}
// --- invite POST ---
@Test
void inviteRegister_honeypot_looksLikeSuccess_registersNothing() {
assertThat(service.inviteRegister(GT, req("http://spam", true))).containsEntry("eventName", "KL Food Fair 2027");
verify(rest, never()).postForEntity(eq(GUEST_REGISTER), any(ParameterizedTypeReference.class), any());
}
@Test
void inviteRegister_consentMissing_400() {
for (Boolean c : new Boolean[]{null, false}) assertCoded(() -> service.inviteRegister(GT, req(null, c)), HttpStatus.BAD_REQUEST, "CONSENT_REQUIRED");
verify(rest, never()).postForEntity(eq(GUEST_REGISTER), any(ParameterizedTypeReference.class), any());
}
@Test
void inviteRegister_validatesLikeQr() {
PublicRegistrationRequest noContact = new PublicRegistrationRequest("Aisyah", " ", null, null, null, List.of(), true, null);
assertCoded(() -> service.inviteRegister(GT, noContact), HttpStatus.BAD_REQUEST, "REQUIRED_FIELD");
PublicRegistrationRequest inactiveInterest = new PublicRegistrationRequest("Aisyah", "0123456789", null, null, null, List.of(5L), true, null);
assertThatThrownBy(() -> service.inviteRegister(GT, inactiveInterest)).isInstanceOf(CodedResponseStatusException.class);
verify(rest, never()).postForEntity(eq(GUEST_REGISTER), any(ParameterizedTypeReference.class), any());
}
@Test
void inviteRegister_happy_sendsNormalisedBody_neverAttend() {
assertThat(service.inviteRegister(GT, ok())).isEqualTo(Map.of("eventName", "KL Food Fair 2027"));
Map<String, Object> b = sent(GUEST_REGISTER);
assertThat(b).containsEntry("companyId", COMPANY).containsEntry("guestToken", GT).containsEntry("name", "Aisyah")
.containsEntry("email", "a@x.com").containsEntry("companyName", "Acme").containsEntry("jobTitle", "Chef")
.containsEntry("interestIds", List.of(3L)).containsEntry("consentNoticeId", 9L).containsEntry("mobileE164", "+60123456789")
.containsEntry("consentAt", "2027-01-16T12:00").doesNotContainKey("attend");
}
@Test
void inviteRegister_alreadyRegistered_isStill200() {
post(GUEST_REGISTER, Map.of("outcome", "ALREADY_REGISTERED"));
assertThat(service.inviteRegister(GT, ok())).isEqualTo(Map.of("eventName", "KL Food Fair 2027"));
}
@Test
void inviteRegister_eventFull_409() {
postConflict(GUEST_REGISTER, "EVENT_FULL");
assertThatThrownBy(() -> service.inviteRegister(GT, ok())).isInstanceOfSatisfying(CodedResponseStatusException.class, e -> {
assertThat(e.getStatusCode()).isEqualTo(HttpStatus.CONFLICT);
assertThat(e.getReason()).isEqualTo("This event is full");
assertThat(e.getBody().getProperties()).containsEntry("code", "EVENT_FULL");
});
}
// --- invite check-in ---
@Test
void inviteCheckin_callsByGuest_returnsFirstName() {
assertThat(service.inviteCheckin(GT)).isEqualTo(Map.of("firstName", "Aisyah"));
assertThat(sent(BY_GUEST)).isEqualTo(Map.of("companyId", COMPANY, "guestToken", GT));
}
@Test
void inviteCheckin_conflictCodesPassThrough() {
for (String code : List.of("NOT_REGISTERED", "NOT_EVENT_DAY")) {
postConflict(BY_GUEST, code);
assertCoded(() -> service.inviteCheckin(GT), HttpStatus.CONFLICT, code);
}
}
// --- check-in page ---
@Test
void checkin_onEventDay_open_withEventNoticeAndInterests() {
Map<String, Object> out = service.checkin(CK);
assertThat(out).containsEntry("state", "OPEN").containsEntry("eventName", "KL Food Fair 2027").containsEntry("startDate", "2027-01-15")
.containsEntry("endDate", "2027-01-17").containsEntry("location", "MITEC").containsEntry("companyName", "INS");
assertThat(out.get("interests")).isEqualTo(List.of(Map.of("id", 3L, "name", "Cookware")));
assertThat((Map<String, Object>) out.get("notice")).containsEntry("id", 9L);
}
@Test
void checkin_beforeAndAfter_carryOnlyStateAndStartDate() {
assertThat(svc("2027-01-10T04:00:00Z").checkin(CK)).isEqualTo(Map.of("state", "NOT_YET", "startDate", "2027-01-15"));
assertThat(svc("2027-01-17T16:00:00Z").checkin(CK)).isEqualTo(Map.of("state", "ENDED", "startDate", "2027-01-15"));
}
// --- lookup ---
@Test
void lookup_detectsEmailVsMobile() {
service.lookup(CK, new PublicCheckinLookupRequest(" A@X.com "));
assertThat(sent(LOOKUP)).isEqualTo(Map.of("companyId", COMPANY, "eventUuid", EV, "email", "a@x.com"));
}
@Test
void lookup_mobile_normalised() {
service.lookup(CK, new PublicCheckinLookupRequest("012-345 6789"));
assertThat(sent(LOOKUP)).isEqualTo(Map.of("companyId", COMPANY, "eventUuid", EV, "mobileE164", "+60123456789"));
}
@Test
void lookup_firstNameOnlyForCheckedIn() {
post(LOOKUP, Map.of("result", "CHECKED_IN", "firstName", "Aisyah"));
assertThat(service.lookup(CK, new PublicCheckinLookupRequest("a@x.com"))).isEqualTo(Map.of("result", "CHECKED_IN", "firstName", "Aisyah"));
post(LOOKUP, Map.of("result", "FORM", "firstName", "Leak", "name", "Leak"));
assertThat(service.lookup(CK, new PublicCheckinLookupRequest("a@x.com"))).isEqualTo(Map.of("result", "FORM"));
}
@Test
void lookup_invalidValue_400_andNothingSent() {
for (String v : new String[]{"nonsense", "a@", " ", null}) {
assertThatThrownBy(() -> service.lookup(CK, new PublicCheckinLookupRequest(v))).isInstanceOfSatisfying(CodedResponseStatusException.class,
e -> assertThat(e.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST));
}
verify(rest, never()).postForEntity(eq(LOOKUP), any(ParameterizedTypeReference.class), any());
}
@Test
void lookup_andWalkIn_onlyOnEventDays_409() {
PublicInviteService before = svc("2027-01-10T04:00:00Z");
assertCoded(() -> before.lookup(CK, new PublicCheckinLookupRequest("a@x.com")), HttpStatus.CONFLICT, "NOT_EVENT_DAY");
assertCoded(() -> before.walkIn(CK, ok()), HttpStatus.CONFLICT, "NOT_EVENT_DAY");
verify(rest, never()).postForEntity(eq(LOOKUP), any(ParameterizedTypeReference.class), any());
verify(rest, never()).postForEntity(eq(REGISTER), any(ParameterizedTypeReference.class), any());
}
// --- walk-in ---
@Test
void walkIn_callsRegisterWithAttendTrue_noSalesperson() {
assertThat(service.walkIn(CK, ok())).isEqualTo(Map.of("eventName", "KL Food Fair 2027"));
Map<String, Object> b = sent(REGISTER);
assertThat(b).containsEntry("attend", true).containsEntry("companyId", COMPANY).containsEntry("eventUuid", EV)
.containsEntry("name", "Aisyah").containsEntry("mobileE164", "+60123456789").containsEntry("consentNoticeId", 9L)
.containsEntry("interestIds", List.of(3L)).doesNotContainKey("guestToken");
assertThat(b.get("salespersonUserId")).isNull();
}
@Test
void walkIn_honeypotAndConsent() {
assertThat(service.walkIn(CK, req("spam", true))).containsEntry("eventName", "KL Food Fair 2027");
verify(rest, never()).postForEntity(eq(REGISTER), any(ParameterizedTypeReference.class), any());
assertCoded(() -> service.walkIn(CK, req(null, false)), HttpStatus.BAD_REQUEST, "CONSENT_REQUIRED");
verify(rest, never()).postForEntity(eq(REGISTER), any(ParameterizedTypeReference.class), any());
}
// --- QR guard ---
@Test
void qrRegistration_neverPassesAttend() {
stub("/counter/registrationLink/findByToken/{token}", GT, Map.of("enabled", true, "eventUuid", EV, "companyId", COMPANY));
stub("/counter/eventSalesperson/findByEventUuid/{eventUuid}", EV, List.of());
new PublicRegistrationService(rest, new AdminEventLeadService(rest, mock(AdminAuthenticationService.class), new AdminCompanyScope()),
redis, at("2027-01-16T04:00:00Z")).register(GT, ok());
assertThat(sent(REGISTER)).doesNotContainKey("attend");
}
// --- limits ---
@Test
void inviteLoadLimit_120_countsGetsAndPosts() {
tooMany("inv:load:1.2.3.4", 121L, () -> service.invite(GT));
tooMany("inv:load:1.2.3.4", 121L, () -> service.inviteRegister(GT, ok()));
tooMany("inv:load:1.2.3.4", 121L, () -> service.inviteCheckin(GT));
when(ops.increment("inv:load:1.2.3.4")).thenReturn(120L);
assertThat(service.invite(GT)).containsKey("eventName");
}
@Test
void inviteSubmitLimit_60_perEventAndIp_forRegisterAndCheckin() {
tooMany("inv:submit:" + EV + ":1.2.3.4", 61L, () -> service.inviteRegister(GT, ok()));
tooMany("inv:submit:" + EV + ":1.2.3.4", 61L, () -> service.inviteCheckin(GT));
verify(rest, never()).postForEntity(eq(GUEST_REGISTER), any(ParameterizedTypeReference.class), any());
verify(rest, never()).postForEntity(eq(BY_GUEST), any(ParameterizedTypeReference.class), any());
}
@Test
void checkinLimit_300_everyCall_andNeverCountsRegLoad() {
String key = "chk:" + EV + ":1.2.3.4";
tooMany(key, 301L, () -> service.checkin(CK));
tooMany(key, 301L, () -> service.lookup(CK, new PublicCheckinLookupRequest("a@x.com")));
tooMany(key, 301L, () -> service.walkIn(CK, ok()));
when(ops.increment(key)).thenReturn(300L);
service.checkin(CK);
service.lookup(CK, new PublicCheckinLookupRequest("a@x.com"));
service.walkIn(CK, ok());
verify(ops, never()).increment("reg:load:1.2.3.4");
}
// --- review minors ---
@Test
void walkIn_honeypot_onNotYetOrEndedCode_409_neverEchoesTheEventName() {
for (String now : List.of("2027-01-10T04:00:00Z", "2027-01-20T04:00:00Z")) {
PublicInviteService off = svc(now);
assertCoded(() -> off.walkIn(CK, req("spam", true)), HttpStatus.CONFLICT, "NOT_EVENT_DAY");
}
}
@Test
void missingFirstName_isEmptyNotTheStringNull() {
post(BY_GUEST, Map.of());
assertThat(service.inviteCheckin(GT)).isEqualTo(Map.of("firstName", ""));
post(LOOKUP, Map.of("result", "CHECKED_IN"));
assertThat(service.lookup(CK, new PublicCheckinLookupRequest("a@x.com"))).isEqualTo(Map.of("result", "CHECKED_IN", "firstName", ""));
}
@Test
void checkinLoadLimit_300_perIp_countsUnknownTokens_beforeTheLookup() {
String unknown = "AAAAAAAAAAAAAAAAAAAAAA";
when(rest.getForEntity(eq(FIND_EVENT), any(ParameterizedTypeReference.class), eq(unknown)))
.thenThrow(HttpClientErrorException.create(HttpStatus.NOT_FOUND, "nf", null, null, null));
assertCode(() -> service.checkin(unknown));
when(ops.increment("chk:load:1.2.3.4")).thenReturn(301L);
assertCoded(() -> service.checkin(unknown), HttpStatus.TOO_MANY_REQUESTS, "TOO_MANY");
verify(rest, never()).getForEntity(eq(FIND_EVENT), any(ParameterizedTypeReference.class), eq("BBBBBBBBBBBBBBBBBBBBBB"));
verify(ops, never()).increment("reg:load:1.2.3.4");
}
@Test
void endedQrCode_fetchesNeitherCompanyNorNotice() {
stub("/counter/registrationLink/findByToken/{token}", GT, Map.of("enabled", true, "eventUuid", EV, "companyId", COMPANY));
PublicRegistrationService qr = new PublicRegistrationService(rest, new AdminEventLeadService(rest, mock(AdminAuthenticationService.class), new AdminCompanyScope()),
redis, at("2027-01-20T04:00:00Z"));
assertThatThrownBy(() -> qr.page(GT)).isInstanceOf(CodedResponseStatusException.class);
verify(rest, never()).getForEntity(eq(COMPANY_URL), any(ParameterizedTypeReference.class), any());
verify(rest, never()).getForEntity(eq(NOTICE), any(ParameterizedTypeReference.class), any());
}
}