Files
lincodex/backend/integration_test/notification_inbox_test.go
T

432 lines
23 KiB
Go

//go:build integration
package integration_test
import (
"context"
"encoding/json"
"errors"
"log/slog"
"net/http"
"net/http/httptest"
"net/url"
"strings"
"testing"
"time"
"github.com/google/uuid"
"github.com/jackc/pgx/v5"
httpadapter "lincodex/backend/internal/adapter/primary/http"
"lincodex/backend/internal/adapter/primary/http/problem"
v1 "lincodex/backend/internal/adapter/primary/http/v1"
"lincodex/backend/internal/adapter/secondary/argon2id"
postgresadapter "lincodex/backend/internal/adapter/secondary/postgres"
"lincodex/backend/internal/adapter/secondary/prometheus"
"lincodex/backend/internal/domain"
"lincodex/backend/internal/port/outbound"
"lincodex/backend/internal/usecase/health"
"lincodex/backend/internal/usecase/identity"
"lincodex/backend/internal/usecase/notification"
"lincodex/backend/internal/usecase/organization"
)
const (
notificationHTTPTimeout = 5 * time.Minute
notificationConsumerTTL = 10 * time.Second
// inboxRenamedConsumer stands for a consumer renamed after a deployment:
// its markers are empty, so only the inbox key can absorb the replay.
inboxRenamedConsumer = "notification_inbox_renamed"
)
type notificationBody struct {
ID uuid.UUID `json:"id"`
Kind string `json:"kind"`
OrganizationID uuid.UUID `json:"organization_id"`
DeliveredAt time.Time `json:"delivered_at"`
ReadAt *time.Time `json:"read_at"`
Content *struct {
Title string `json:"title"`
Summary string `json:"summary"`
LinkPath *string `json:"link_path"`
} `json:"content"`
}
type notificationPageBody struct {
Items []notificationBody `json:"items"`
Page struct {
HasMore bool `json:"has_more"`
NextCursor *string `json:"next_cursor"`
} `json:"page"`
}
func newNotificationHTTPHarness(ctx context.Context, t *testing.T, env *testEnvironment) *sessionHTTPHarness {
t.Helper()
pool := env.newPool(ctx, t)
store := postgresadapter.NewIdentityStore(pool)
hasher, err := argon2id.NewHasher(1)
if err != nil {
t.Fatalf("NewHasher() error = %v", err)
}
credentials := identity.NewCredentials(hasher)
keyring, err := identity.NewKeyring([]byte(env.Config.IdentityKeySecret))
if err != nil {
t.Fatalf("NewKeyring() error = %v", err)
}
clock := &testClock{now: time.Now().UTC().Truncate(time.Microsecond)}
transactor := postgresadapter.NewTransactor(pool)
sessionService, err := identity.NewSessionService(identity.SessionDependencies{
Transactor: transactor, Users: store.Users(), Sessions: store.Sessions(), Credentials: credentials,
Limiter: env.Redis, Keyring: keyring, Clock: clock.Now,
}, identity.SessionSettings{
ClientHourlyLimit: int64(env.Config.IdentityClientHourlyLimit),
EmailHourlyLimit: int64(env.Config.IdentityLoginEmailHourlyLimit),
IdleTimeout: env.Config.IdentitySessionIdleTimeout,
AbsoluteLifetime: env.Config.IdentitySessionAbsoluteLifetime,
})
if err != nil {
t.Fatalf("NewSessionService() error = %v", err)
}
organizationService, err := organization.NewService(organization.Dependencies{
Transactor: transactor, Keyring: keyring, Clock: clock.Now,
})
if err != nil {
t.Fatalf("organization.NewService() error = %v", err)
}
inbox, err := notification.NewInboxService(transactor,
notification.NewInboxContentResolver(notification.DefaultInboxSourceResolvers(true)), clock.Now)
if err != nil {
t.Fatalf("notification.NewInboxService() error = %v", err)
}
logs := &strings.Builder{}
logger := slog.New(slog.DiscardHandler)
responder := problem.NewResponder(logger)
healthHandler := v1.NewHealthHandler(health.NewReadiness(env.Postgres), time.Second)
identityHandler := v1.NewIdentityHandler(nil,
v1.WithSessionService(sessionService),
v1.WithPublicOrigin(env.Config.AppPublicURL),
)
organizationHandler := v1.NewOrganizationHandler(organizationService, env.Config.AppPublicURL)
handler := v1.NewHandler(healthHandler, responder,
v1.WithIdentity(identityHandler), v1.WithOrganization(organizationHandler),
v1.WithNotifications(v1.NewNotificationHandler(inbox)),
)
router, err := httpadapter.NewRouter(healthHandler, handler, identityHandler.SessionSecurity(), responder,
prometheus.New(), logger, nil, httpadapter.NewCompanyContextMiddleware(organizationHandler))
if err != nil {
t.Fatalf("NewRouter() error = %v", err)
}
return &sessionHTTPHarness{pool: pool, store: store, router: router, credentials: credentials, clock: clock, logs: logs}
}
// appendSyntheticNotice records a synthetic inbox event through the real
// outbox writer, as a producer does in its own transaction, and returns the
// envelope a consumer would receive for it.
func appendSyntheticNotice(
ctx context.Context,
t *testing.T,
transactor outbound.Transactor,
recipientID, organizationID uuid.UUID,
occurredAt time.Time,
) outbound.ConsumedEvent {
t.Helper()
payload, err := notification.SyntheticNoticeEventPayload(recipientID, organizationID)
if err != nil {
t.Fatalf("SyntheticNoticeEventPayload() error = %v", err)
}
event, err := domain.NewDomainEvent(domain.DomainEventInput{
EventType: string(domain.NotificationInboxSyntheticDelivered), SchemaVersion: 1,
AggregateType: notification.SyntheticNoticeAggregateType, AggregateID: uuid.New(),
AggregateVersion: notification.SyntheticNoticeAggregateVersion, Payload: payload,
})
if err != nil {
t.Fatalf("NewDomainEvent() error = %v", err)
}
err = transactor.WithinTransaction(ctx, func(ctx context.Context, unit outbound.UnitOfWork) error {
return unit.Outbox().Append(ctx, event)
})
if err != nil {
t.Fatalf("Append(synthetic notice) error = %v", err)
}
return outbound.ConsumedEvent{
EventID: event.EventID(), EventType: event.EventType(), SchemaVersion: event.SchemaVersion(),
AggregateType: event.AggregateType(), AggregateID: event.AggregateID(), AggregateVersion: event.AggregateVersion(),
OccurredAt: occurredAt, Payload: event.Payload(),
}
}
func deliverToInbox(
ctx context.Context,
t *testing.T,
store *postgresadapter.EventConsumerStore,
consumer string,
event outbound.ConsumedEvent,
) bool {
t.Helper()
handler := notification.NewInboxHandler(slog.New(slog.DiscardHandler), true)
applied, err := store.ApplyOnce(ctx, consumer, event.EventID, func(ctx context.Context, unit outbound.UnitOfWork) error {
return handler.Handle(ctx, unit, event)
})
if err != nil {
t.Fatalf("ApplyOnce(%s, %s) error = %v", consumer, event.EventID, err)
}
return applied
}
func notificationRequest(
t *testing.T,
harness *sessionHTTPHarness,
method, path, origin string,
session organizationHTTPSession,
) *httptest.ResponseRecorder {
t.Helper()
return organizationHTTPRequest(t, harness, method, path, "", origin, session, "")
}
func decodeNotificationPage(t *testing.T, response *httptest.ResponseRecorder) notificationPageBody {
t.Helper()
if response.Code != http.StatusOK || response.Header().Get("Cache-Control") != "no-store" {
t.Fatalf("notification list = %d %q %s, want a no-store 200", response.Code, response.Header().Get("Cache-Control"), response.Body.String())
}
var page notificationPageBody
if err := json.Unmarshal(response.Body.Bytes(), &page); err != nil {
t.Fatalf("decode notification page: %v", err)
}
return page
}
func requireNotificationProblem(t *testing.T, response *httptest.ResponseRecorder, status int, code string) {
t.Helper()
requireSessionProblem(t, response, status, code)
}
func TestNotificationInboxOverHTTP(t *testing.T) {
env := bootstrap(t, postgresService, redisService)
ctx, cancel := context.WithTimeout(t.Context(), notificationHTTPTimeout)
defer cancel()
harness := newNotificationHTTPHarness(ctx, t, env)
resetTables := append(append([]pgx.Identifier{}, usersDependentTables...), pgx.Identifier{"idempotency_records"})
truncateTables(ctx, t, harness.pool, resetTables...)
transactor := postgresadapter.NewTransactor(harness.pool)
consumerStore := postgresadapter.NewEventConsumerStore(harness.pool, notificationConsumerTTL)
passwordHash, err := harness.credentials.HashNewPassword(ctx, sessionHTTPTestPass)
if err != nil {
t.Fatalf("HashNewPassword() error = %v", err)
}
now := harness.clock.Now()
candidate := createOrganizationHTTPUser(ctx, t, harness, "inbox-candidate@example.test", passwordHash, domain.ScenarioCandidate, true, now)
otherCandidate := createOrganizationHTTPUser(ctx, t, harness, "inbox-other-candidate@example.test", passwordHash, domain.ScenarioCandidate, true, now)
owner := createOrganizationHTTPUser(ctx, t, harness, "inbox-owner@example.test", passwordHash, domain.ScenarioEmployer, true, now)
foreign := createOrganizationHTTPUser(ctx, t, harness, "inbox-foreign@example.test", passwordHash, domain.ScenarioEmployer, true, now)
recruiter := createOrganizationHTTPUser(ctx, t, harness, "inbox-recruiter@example.test", passwordHash, domain.ScenarioEmployer, true, now)
candidateSession := loginOrganizationHTTP(t, harness, candidate.Email.Address())
otherCandidateSession := loginOrganizationHTTP(t, harness, otherCandidate.Email.Address())
ownerSession := loginOrganizationHTTP(t, harness, owner.Email.Address())
foreignSession := loginOrganizationHTTP(t, harness, foreign.Email.Address())
recruiterSession := loginOrganizationHTTP(t, harness, recruiter.Email.Address())
origin := env.Config.AppPublicURL
organizationID := createCompanyForContextTest(t, harness, origin, ownerSession, "inbox-company")
foreignOrganizationID := createCompanyForContextTest(t, harness, origin, foreignSession, "inbox-foreign-company")
var organizationName string
if err := harness.pool.QueryRow(ctx, `SELECT name FROM organizations WHERE id = $1`, organizationID).Scan(&organizationName); err != nil {
t.Fatalf("read organization name: %v", err)
}
// One synthetic event delivered twice, and once more by a renamed
// consumer, stores exactly one row.
deliveredAt := now.Add(-time.Hour)
event := appendSyntheticNotice(ctx, t, transactor, candidate.ID, organizationID, deliveredAt)
if !deliverToInbox(ctx, t, consumerStore, notification.InboxConsumerName, event) {
t.Fatal("the first delivery was reported as a duplicate")
}
if deliverToInbox(ctx, t, consumerStore, notification.InboxConsumerName, event) {
t.Fatal("the second delivery of the same event ID was applied again")
}
deliverToInbox(ctx, t, consumerStore, inboxRenamedConsumer, event)
var rows int
if err := harness.pool.QueryRow(ctx, `SELECT count(*) FROM notification_inbox_events WHERE event_id = $1`, event.EventID).Scan(&rows); err != nil || rows != 1 {
t.Fatalf("inbox rows for the repeated event = %d, %v, want 1", rows, err)
}
list := func(session organizationHTTPSession) notificationPageBody {
t.Helper()
return decodeNotificationPage(t, notificationRequest(t, harness, http.MethodGet, "/api/v1/me/notifications", "", session))
}
page := list(candidateSession)
if len(page.Items) != 1 || page.Page.HasMore || page.Page.NextCursor != nil {
t.Fatalf("candidate inbox = %+v, want one item on the last page", page)
}
item := page.Items[0]
if item.ID != event.EventID || item.Kind != "synthetic" || item.OrganizationID != organizationID ||
item.ReadAt != nil || !item.DeliveredAt.Equal(deliveredAt.Truncate(time.Second)) {
t.Fatalf("candidate item = %+v, want the unread synthetic event", item)
}
if item.Content == nil || item.Content.Title != "Тестовое уведомление" || !strings.Contains(item.Content.Summary, organizationName) ||
item.Content.LinkPath != nil {
t.Fatalf("candidate item content = %+v, want the current organization name", item.Content)
}
if got := list(otherCandidateSession); len(got.Items) != 0 {
t.Fatalf("another candidate's inbox = %+v, want empty", got)
}
// Account and cabinet boundaries.
markPath := "/api/v1/me/notifications/" + event.EventID.String() + "/read"
requireNotificationProblem(t, notificationRequest(t, harness, http.MethodGet, "/api/v1/me/notifications", "", organizationHTTPSession{}), http.StatusUnauthorized, "unauthenticated")
requireNotificationProblem(t, notificationRequest(t, harness, http.MethodGet, "/api/v1/me/notifications", "", ownerSession), http.StatusForbidden, "forbidden")
requireNotificationProblem(t, notificationRequest(t, harness, http.MethodPost, markPath, origin, ownerSession), http.StatusForbidden, "forbidden")
requireNotificationProblem(t, notificationRequest(t, harness, http.MethodPost, markPath, origin, otherCandidateSession), http.StatusNotFound, "not_found")
requireNotificationProblem(t, notificationRequest(t, harness, http.MethodPost, "/api/v1/me/notifications/"+uuid.NewString()+"/read", origin, candidateSession), http.StatusNotFound, "not_found")
requireNotificationProblem(t, notificationRequest(t, harness, http.MethodPost, "/api/v1/me/notifications/not-a-uuid/read", origin, candidateSession), http.StatusBadRequest, "validation_failed")
requireNotificationProblem(t, notificationRequest(t, harness, http.MethodPost, markPath, "https://evil.example", candidateSession), http.StatusForbidden, "csrf_check_failed")
noCSRFSession := candidateSession
noCSRFSession.csrf = ""
requireNotificationProblem(t, notificationRequest(t, harness, http.MethodPost, markPath, origin, noCSRFSession), http.StatusForbidden, "csrf_check_failed")
if got := list(candidateSession); got.Items[0].ReadAt != nil {
t.Fatal("a refused request marked the item read")
}
requireNotificationProblem(t, notificationRequest(t, harness, http.MethodGet,
"/api/v1/organizations/"+organizationID.String()+"/notifications", "", candidateSession), http.StatusForbidden, "forbidden")
// Mark read twice: the first time stays, and the list persists it.
first := notificationRequest(t, harness, http.MethodPost, markPath, origin, candidateSession)
var receipt struct {
ID uuid.UUID `json:"id"`
ReadAt time.Time `json:"read_at"`
}
if first.Code != http.StatusOK || first.Header().Get("Cache-Control") != "no-store" {
t.Fatalf("mark read = %d %s, want a no-store 200", first.Code, first.Body.String())
}
if err := json.Unmarshal(first.Body.Bytes(), &receipt); err != nil || receipt.ID != event.EventID || receipt.ReadAt.IsZero() {
t.Fatalf("mark read receipt = %s, %v", first.Body.String(), err)
}
harness.clock.Advance(time.Hour)
again := notificationRequest(t, harness, http.MethodPost, markPath, origin, candidateSession)
var repeated struct {
ReadAt time.Time `json:"read_at"`
}
if err := json.Unmarshal(again.Body.Bytes(), &repeated); err != nil || !repeated.ReadAt.Equal(receipt.ReadAt) {
t.Fatalf("repeated mark = %s, %v, want the first read time %s", again.Body.String(), err, receipt.ReadAt)
}
if got := list(candidateSession); got.Items[0].ReadAt == nil || !got.Items[0].ReadAt.Equal(receipt.ReadAt) {
t.Fatalf("list after mark = %+v, want the persisted read time", got.Items)
}
// Hiding the organization removes the content from the next read; the
// item and its read state stay.
if _, err := harness.pool.Exec(ctx, `INSERT INTO candidate_hidden_organizations (user_id, organization_id, hidden_at) VALUES ($1, $2, $3)`,
candidate.ID, organizationID, now); err != nil {
t.Fatalf("hide organization: %v", err)
}
hidden := list(candidateSession)
if len(hidden.Items) != 1 || hidden.Items[0].Content != nil || hidden.Items[0].ReadAt == nil {
t.Fatalf("list after hiding = %+v, want the item without content and still read", hidden.Items)
}
if strings.Contains(notificationRequest(t, harness, http.MethodGet, "/api/v1/me/notifications", "", candidateSession).Body.String(), organizationName) {
t.Fatal("the organization name still reaches a candidate who hid the organization")
}
// Pagination: newest first, a cursor bound to the account.
for offset := 1; offset <= 3; offset++ {
extra := appendSyntheticNotice(ctx, t, transactor, candidate.ID, organizationID, now.Add(-time.Duration(offset)*time.Minute))
deliverToInbox(ctx, t, consumerStore, notification.InboxConsumerName, extra)
}
firstPage := decodeNotificationPage(t, notificationRequest(t, harness, http.MethodGet, "/api/v1/me/notifications?limit=2", "", candidateSession))
if len(firstPage.Items) != 2 || !firstPage.Page.HasMore || firstPage.Page.NextCursor == nil ||
!firstPage.Items[0].DeliveredAt.After(firstPage.Items[1].DeliveredAt) {
t.Fatalf("first page = %+v, want two newest-first items and a cursor", firstPage)
}
cursor := url.QueryEscape(*firstPage.Page.NextCursor)
secondPage := decodeNotificationPage(t, notificationRequest(t, harness, http.MethodGet, "/api/v1/me/notifications?limit=2&cursor="+cursor, "", candidateSession))
if len(secondPage.Items) != 2 || secondPage.Page.HasMore || secondPage.Items[0].ID == firstPage.Items[1].ID ||
!secondPage.Items[0].DeliveredAt.Before(firstPage.Items[1].DeliveredAt) {
t.Fatalf("second page = %+v, want the remaining two items after the first page", secondPage)
}
requireNotificationProblem(t, notificationRequest(t, harness, http.MethodGet, "/api/v1/me/notifications?cursor="+cursor, "", otherCandidateSession), http.StatusBadRequest, "validation_failed")
requireNotificationProblem(t, notificationRequest(t, harness, http.MethodGet, "/api/v1/me/notifications?limit=101", "", candidateSession), http.StatusBadRequest, "validation_failed")
// The employer cabinet: only the caller's items of this organization, and
// no access after the membership ends.
employerEvent := appendSyntheticNotice(ctx, t, transactor, owner.ID, organizationID, now.Add(-time.Minute))
deliverToInbox(ctx, t, consumerStore, notification.InboxConsumerName, employerEvent)
foreignOrganizationEvent := appendSyntheticNotice(ctx, t, transactor, owner.ID, foreignOrganizationID, now.Add(-time.Minute))
// An owner of another organization is not a member of it: the row exists
// but stays out of the cabinet of the first organization.
deliverToInbox(ctx, t, consumerStore, notification.InboxConsumerName, foreignOrganizationEvent)
organizationPath := "/api/v1/organizations/" + organizationID.String() + "/notifications"
organizationPage := decodeNotificationPage(t, notificationRequest(t, harness, http.MethodGet, organizationPath, "", ownerSession))
if len(organizationPage.Items) != 1 || organizationPage.Items[0].ID != employerEvent.EventID || organizationPage.Items[0].Content == nil {
t.Fatalf("employer inbox = %+v, want only the item of this organization with content", organizationPage.Items)
}
requireNotificationProblem(t, notificationRequest(t, harness, http.MethodGet, organizationPath, "", foreignSession), http.StatusNotFound, "not_found")
requireNotificationProblem(t, notificationRequest(t, harness, http.MethodGet, "/api/v1/organizations/"+uuid.NewString()+"/notifications", "", ownerSession), http.StatusNotFound, "not_found")
employerMark := organizationPath + "/" + employerEvent.EventID.String() + "/read"
requireNotificationProblem(t, notificationRequest(t, harness, http.MethodPost, employerMark, origin, foreignSession), http.StatusNotFound, "not_found")
requireNotificationProblem(t, notificationRequest(t, harness, http.MethodPost,
organizationPath+"/"+foreignOrganizationEvent.EventID.String()+"/read", origin, ownerSession), http.StatusNotFound, "not_found")
requireNotificationProblem(t, notificationRequest(t, harness, http.MethodPost,
organizationPath+"/"+event.EventID.String()+"/read", origin, ownerSession), http.StatusNotFound, "not_found")
if marked := notificationRequest(t, harness, http.MethodPost, employerMark, origin, ownerSession); marked.Code != http.StatusOK {
t.Fatalf("employer mark read = %d %s, want 200", marked.Code, marked.Body.String())
}
// A member of another role reads and marks its own items only, although the
// owner-only operations refuse it.
insertOrganizationHTTPMembership(ctx, t, harness, organizationID, recruiter.ID, "recruiter", "active", now)
recruiterEvent := appendSyntheticNotice(ctx, t, transactor, recruiter.ID, organizationID, now.Add(-time.Minute))
deliverToInbox(ctx, t, consumerStore, notification.InboxConsumerName, recruiterEvent)
recruiterPage := decodeNotificationPage(t, notificationRequest(t, harness, http.MethodGet, organizationPath, "", recruiterSession))
if len(recruiterPage.Items) != 1 || recruiterPage.Items[0].ID != recruiterEvent.EventID || recruiterPage.Items[0].Content == nil {
t.Fatalf("recruiter inbox = %+v, want only its own item with content", recruiterPage.Items)
}
if marked := notificationRequest(t, harness, http.MethodPost, organizationPath+"/"+recruiterEvent.EventID.String()+"/read", origin, recruiterSession); marked.Code != http.StatusOK {
t.Fatalf("recruiter mark read = %d %s, want 200", marked.Code, marked.Body.String())
}
requireNotificationProblem(t, notificationRequest(t, harness, http.MethodPost, employerMark, origin, recruiterSession), http.StatusNotFound, "not_found")
if _, err := harness.pool.Exec(ctx, `UPDATE memberships SET state = 'removed' WHERE organization_id = $1 AND user_id = $2`, organizationID, owner.ID); err != nil {
t.Fatalf("revoke membership: %v", err)
}
requireNotificationProblem(t, notificationRequest(t, harness, http.MethodGet, organizationPath, "", ownerSession), http.StatusNotFound, "not_found")
requireNotificationProblem(t, notificationRequest(t, harness, http.MethodPost, employerMark, origin, ownerSession), http.StatusNotFound, "not_found")
}
// A recipient or an organization that does not exist is told apart, so a
// handler can retry and skip a deleted account but reject a broken reference.
func TestNotificationInboxStoreNamesTheMissingReference(t *testing.T) {
env := bootstrap(t, postgresService, redisService)
ctx, cancel := context.WithTimeout(t.Context(), notificationHTTPTimeout)
defer cancel()
harness := newNotificationHTTPHarness(ctx, t, env)
truncateTables(ctx, t, harness.pool, append([]pgx.Identifier{}, usersDependentTables...)...)
passwordHash, err := harness.credentials.HashNewPassword(ctx, sessionHTTPTestPass)
if err != nil {
t.Fatalf("HashNewPassword() error = %v", err)
}
now := harness.clock.Now()
candidate := createOrganizationHTTPUser(ctx, t, harness, "inbox-ref-candidate@example.test", passwordHash, domain.ScenarioCandidate, true, now)
owner := createOrganizationHTTPUser(ctx, t, harness, "inbox-ref-owner@example.test", passwordHash, domain.ScenarioEmployer, true, now)
ownerSession := loginOrganizationHTTP(t, harness, owner.Email.Address())
organizationID := createCompanyForContextTest(t, harness, env.Config.AppPublicURL, ownerSession, "inbox-ref-company")
repository := postgresadapter.NewNotificationInboxRepository(harness.pool)
entry := func(recipientID, orgID uuid.UUID) domain.NotificationInboxEntry {
built, err := domain.NewNotificationInboxEntry(domain.NotificationInboxEntryInput{
EventID: uuid.New(), RecipientUserID: recipientID, OrganizationID: orgID,
EventType: domain.NotificationInboxSyntheticDelivered, SchemaVersion: 1,
SourceType: domain.NotificationInboxSourceOrganization, SourceID: orgID, OccurredAt: now,
})
if err != nil {
t.Fatalf("NewNotificationInboxEntry() error = %v", err)
}
return built
}
if _, err := repository.Store(ctx, entry(uuid.New(), organizationID)); !errors.Is(err, outbound.ErrNotificationInboxRecipientMissing) {
t.Fatalf("Store(unknown recipient) error = %v, want ErrNotificationInboxRecipientMissing", err)
}
if _, err := repository.Store(ctx, entry(candidate.ID, uuid.New())); !errors.Is(err, outbound.ErrNotificationInboxReferenceMissing) {
t.Fatalf("Store(unknown organization) error = %v, want ErrNotificationInboxReferenceMissing", err)
}
if created, err := repository.Store(ctx, entry(candidate.ID, organizationID)); err != nil || !created {
t.Fatalf("Store(valid) = %t, %v, want true, nil", created, err)
}
}