test(backend): check company isolation and revocation over every org read
This commit is contained in:
1 parent
e367553d7c
commit
84454116f2
5 files changed
+837
-2
No files matched your search
@@ -1101,7 +1101,7 @@ Implemented: `GetOrganizationInvitationContacts` ([contract](../../api/README.en
|
||||
- Quota and audit. A successful read writes one `contact_read` row to `candidate_card_access_events` in the same transaction, with the granted kinds and never a value. It does not consume the card-view quota, because the contract does not count contact reads against it. The candidate's own history read stays a contract-only operation.
|
||||
- Not implemented: the candidate's cancellation, and the organization's withdrawal. `CurrentContactFields` in `usecase/candidateview` stays closed, because the card-handle read has no contract operation.
|
||||
|
||||
Tests: `domain/contact_disclosure_test.go` (confirmed values only, refused revoked grants, redacted formatting), `usecase/invitation/contacts_test.go` (owner and role checks, visibility, revoked grant and C4 record, unknown invitations), `usecase/invitation/contact_access_test.go` (the organization's states, their agreement with the read in each closing state, a blocked grant that opens once it is visible, and a revoked grant that never reopens), and the integration test `TestOrganizationContactReadsAndRevocationOverHTTP` over the real router and PostgreSQL. It covers the email-only read, the repeated read, the refusals of another organization, a recruiter, and a candidate, C4 revocation with an independent organization, hiding and unhiding without reopening, C2 revocation with republication, closing the publication, and the index. It also checks `contact_access` of the single read and of the list after each change, a declined invitation, and an expired one, which runs last because it moves the clock.
|
||||
Tests: `domain/contact_disclosure_test.go` (confirmed values only, refused revoked grants, redacted formatting), `usecase/invitation/contacts_test.go` (owner and role checks, visibility, revoked grant and C4 record, unknown invitations), `usecase/invitation/contact_access_test.go` (the organization's states, their agreement with the read in each closing state, a blocked grant that opens once it is visible, and a revoked grant that never reopens), and the integration test `TestOrganizationContactReadsAndRevocationOverHTTP` over the real router and PostgreSQL. It covers the email-only read, the repeated read, the refusals of another organization, a recruiter, and a candidate, C4 revocation with an independent organization, hiding and unhiding without reopening, C2 revocation with republication, closing the publication, and the index. It also checks `contact_access` of the single read and of the list after each change, a declined invitation, and an expired one, which runs last because it moves the clock. `TestCompanyIsolationAndRevocationOverHTTP` walks every organization-scoped operation of the minimal path with the valid session of another company, on the path of the owning company and on its own path with the identifiers from the owner's responses, and checks that each one answers the documented refusal, the same as for an identifier that does not exist, and changes nothing. It does the same for a candidate with the invitation and the notification of another candidate. It also checks that hiding the organization, revoking C4, and withdrawing C2 close the next card, evidence, draft, search, and contact read through the handles of an earlier search, that neither a new C2 nor a new publication revives a grant that C4 revocation closed, that the MVP serves no PDF, selection snapshot, or stored search result, and that the server log, the outbox payloads, the inbox rows, and the stored email requests carry no contact, name, or profile value of the candidates.
|
||||
|
||||
|
||||
## Frontend
|
||||
|
||||
@@ -431,6 +431,8 @@ Unit tests (`make -C backend test`) cover the organization rules without a datab
|
||||
|
||||
`TestOrganizationCreationAndOwnerEditingOverHTTP` and `TestCompanyContextChecksLiveOwnerMembershipAndListsOwnOrganizations` exercise organization creation and editing, idempotent replay, the caller's paginated directory, owner-only actions, foreign organizations, and revoked membership over real HTTP and PostgreSQL. Revoking a second owner closes the profile and tenant operations for the same cookie while preserving another owner's access. Middleware tests enumerate every tenant operation in the contract.
|
||||
|
||||
`TestCompanyIsolationAndRevocationOverHTTP` (`backend/integration_test/company_isolation_http_test.go`) checks company isolation and revocation across the minimal path over real HTTP and PostgreSQL. Company A runs a need, a search, a card with its evidence, an invitation accepted with C4, the contact read, and an inbox item. Company B, and a second company of A's own owner in the same holding, then call every organization-scoped operation with a valid session, on A's path and on their own path with the identifiers from A's responses. Each call must answer the documented refusal, identical to the answer for a random identifier, and A's objects must stay unchanged. A candidate gets the same check against another candidate's invitation and notification. The test also checks that hiding the organization, revoking C4, and withdrawing C2 close the very next read through the handles of an earlier search, the invitation page, and the contact read. A new C2 or a new publication must not revive a grant that C4 revocation closed. The MVP must serve no PDF, selection snapshot, or stored search result, and the server log, outbox payloads, inbox rows, and stored email requests must carry no contact, name, or profile value. It does not cover Kafka, the browser, or roles other than the owner.
|
||||
|
||||
## Candidate profile tests
|
||||
|
||||
Unit tests (`make -C backend test`) check the profile rules without a database:
|
||||
|
||||
@@ -1101,7 +1101,7 @@ Middleware `backend/internal/adapter/primary/http/company_context.go` прове
|
||||
- Квота и аудит. Успешное чтение записывает одну строку `contact_read` в `candidate_card_access_events` в той же транзакции, с выданными видами и никогда без значения. Чтение не расходует квоту просмотров карточек, потому что контракт не засчитывает чтение контактов в эту квоту. Собственное чтение истории кандидатом остается операцией только контракта.
|
||||
- Не реализовано: отмена кандидатом и отзыв приглашения организацией. `CurrentContactFields` в `usecase/candidateview` остается закрытым, потому что чтение по дескриптору карточки не имеет операции контракта.
|
||||
|
||||
Тесты: `domain/contact_disclosure_test.go` (значения только подтвержденных видов, отказ для отозванного разрешения, редактирование при выводе), `usecase/invitation/contacts_test.go` (проверки владельца и роли, видимость, отозванное разрешение и запись C4, неизвестные приглашения) `usecase/invitation/contact_access_test.go` (состояния разрешения для организации, их согласие с чтением в каждом закрывающем состоянии, заблокированное разрешение, которое открывается, когда становится видимым, и отозванное разрешение, которое никогда не открывается заново) и интеграционный тест `TestOrganizationContactReadsAndRevocationOverHTTP` через настоящий роутер и PostgreSQL. Он покрывает чтение только email, повторное чтение, отказы для другой организации, участника и кандидата, отзыв C4 при независимой организации, скрытие и снятие скрытия без повторного открытия, отзыв C2 с повторной публикацией, закрытие публикации и индекс. Он также проверяет `contact_access` в одиночном чтении и в списке после каждого изменения, отклоненное приглашение и истекшее; истекшее идет последним, потому что переводит часы.
|
||||
Тесты: `domain/contact_disclosure_test.go` (значения только подтвержденных видов, отказ для отозванного разрешения, редактирование при выводе), `usecase/invitation/contacts_test.go` (проверки владельца и роли, видимость, отозванное разрешение и запись C4, неизвестные приглашения) `usecase/invitation/contact_access_test.go` (состояния разрешения для организации, их согласие с чтением в каждом закрывающем состоянии, заблокированное разрешение, которое открывается, когда становится видимым, и отозванное разрешение, которое никогда не открывается заново) и интеграционный тест `TestOrganizationContactReadsAndRevocationOverHTTP` через настоящий роутер и PostgreSQL. Он покрывает чтение только email, повторное чтение, отказы для другой организации, участника и кандидата, отзыв C4 при независимой организации, скрытие и снятие скрытия без повторного открытия, отзыв C2 с повторной публикацией, закрытие публикации и индекс. Он также проверяет `contact_access` в одиночном чтении и в списке после каждого изменения, отклоненное приглашение и истекшее; истекшее идет последним, потому что переводит часы. `TestCompanyIsolationAndRevocationOverHTTP` проходит все операции минимального пути в контексте организации с действующей сессией другой компании: по пути компании-владельца и по своему пути с идентификаторами из ответов владельца. Он проверяет, что каждая операция отвечает документированным отказом, таким же, как для несуществующего идентификатора, и ничего не меняет. То же он делает для кандидата с приглашением и уведомлением другого кандидата. Тест также проверяет, что скрытие организации, отзыв C4 и отзыв C2 закрывают следующее чтение карточки, доказательств, черновика, поиска и контактов через handle прежней выдачи, что ни новое C2, ни новая публикация не возвращают разрешение, закрытое отзывом C4, что MVP не отдает PDF, snapshot выдачи или сохраненный результат поиска и что лог сервера, payload outbox, строки входящих уведомлений и сохраненные запросы писем не содержат контактов, имени и значений профиля кандидатов.
|
||||
|
||||
|
||||
## Frontend
|
||||
|
||||
@@ -431,6 +431,8 @@ Unit-тесты (`make -C backend test`) проверяют правила жу
|
||||
|
||||
`TestOrganizationCreationAndOwnerEditingOverHTTP` и `TestCompanyContextChecksLiveOwnerMembershipAndListsOwnOrganizations` проверяют создание и изменение организации, идемпотентный повтор, свою постраничную директорию, owner-only действия, чужие организации и прекращенное членство через настоящий HTTP и PostgreSQL. Отзыв второго владельца закрывает профиль и tenant-операции для той же cookie, не закрывая доступ другого владельца. Проверки middleware перечисляют все tenant operations контракта.
|
||||
|
||||
`TestCompanyIsolationAndRevocationOverHTTP` (`backend/integration_test/company_isolation_http_test.go`) проверяет изоляцию компаний и отзыв на минимальном пути через настоящий HTTP и PostgreSQL. Компания A проходит потребность, поиск, карточку с доказательствами, приглашение, принятое с C4, чтение контактов и уведомление. Затем компания B и вторая компания того же владельца A в том же холдинге вызывают каждую операцию в контексте организации с действующей сессией: по пути A и по своему пути с идентификаторами из ответов A. Каждый вызов должен отвечать документированным отказом, таким же, как для случайного идентификатора, а объекты A должны остаться без изменений. Ту же проверку получает кандидат с приглашением и уведомлением другого кандидата. Тест также проверяет, что скрытие организации, отзыв C4 и отзыв C2 закрывают следующее же чтение через handle прежней выдачи, страницу приглашения и чтение контактов. Новое C2 или новая публикация не должны возвращать разрешение, закрытое отзывом C4. MVP не должен отдавать PDF, snapshot выдачи или сохраненный результат поиска, а лог сервера, payload outbox, строки входящих уведомлений и сохраненные запросы писем не должны содержать контактов, имени и значений профиля. Kafka, браузер и роли, кроме владельца, он не покрывает.
|
||||
|
||||
## Тесты профиля кандидата
|
||||
|
||||
Модульные тесты (`make -C backend test`) проверяют правила профиля без базы данных:
|
||||
|
||||
Reference in new issue
Block a user