feat(platform): add the notification inbox and deterministic match search
This commit is contained in:
1 parent
5edff21d2d
commit
0b11021b16
169 files changed
+17083
-443
No files matched your search
@@ -53,6 +53,9 @@ func TestCompanyContextMiddlewareFailsClosedAndExcludesOtherScopes(t *testing.T)
|
||||
// the owner-only capability does not apply to that operation.
|
||||
apiadapter.GetOrganizationCandidateCardOperation,
|
||||
apiadapter.GetOrganizationCandidateEvidenceOperation,
|
||||
// The inbox runs the membership check in the read transaction for any role.
|
||||
apiadapter.ListOrganizationNotificationsOperation,
|
||||
apiadapter.MarkOrganizationNotificationReadOperation,
|
||||
apiadapter.HideOrganizationOperation,
|
||||
apiadapter.UnhideOrganizationOperation,
|
||||
apiadapter.RevokeMyOrganizationContactConsentOperation,
|
||||
@@ -111,6 +114,13 @@ func TestCompanyContextMiddlewareMapsMembershipFailuresToPublicProblems(t *testi
|
||||
}
|
||||
}
|
||||
|
||||
// organizationNotificationPaths are the inbox operations of one organization,
|
||||
// which check the membership inside their own transaction.
|
||||
var organizationNotificationPaths = map[string]string{
|
||||
"ListOrganizationNotifications": "/api/v1/organizations/{org_id}/notifications",
|
||||
"MarkOrganizationNotificationRead": "/api/v1/organizations/{org_id}/notifications/{notification_id}/read",
|
||||
}
|
||||
|
||||
func TestCompanyContextOperationInventoryMatchesOpenAPI(t *testing.T) {
|
||||
const bundlePath = "../../../../../api/core/openapi.bundle.yml"
|
||||
data, err := os.ReadFile(bundlePath)
|
||||
@@ -137,6 +147,7 @@ func TestCompanyContextOperationInventoryMatchesOpenAPI(t *testing.T) {
|
||||
seenExceptions := make(map[string]bool, len(candidateExceptions))
|
||||
seenCardRead := false
|
||||
seenEvidenceRead := false
|
||||
seenNotifications := map[string]bool{}
|
||||
for path, methods := range document.Paths {
|
||||
for _, operation := range methods {
|
||||
if operation.OperationID == "" {
|
||||
@@ -170,6 +181,13 @@ func TestCompanyContextOperationInventoryMatchesOpenAPI(t *testing.T) {
|
||||
seenEvidenceRead = true
|
||||
continue
|
||||
}
|
||||
// The inbox of one organization authorizes any active membership and
|
||||
// the recipient together with the read, inside the read transaction;
|
||||
// the owner-only capability does not apply.
|
||||
if notificationPath, ok := organizationNotificationPaths[operation.OperationID]; ok && notificationPath == path {
|
||||
seenNotifications[operation.OperationID] = true
|
||||
continue
|
||||
}
|
||||
expectedPath, candidateOperation := candidateExceptions[operation.OperationID]
|
||||
if candidateOperation && expectedPath == path && strings.HasPrefix(path, "/api/v1/me/") {
|
||||
seenExceptions[operation.OperationID] = true
|
||||
@@ -194,6 +212,11 @@ func TestCompanyContextOperationInventoryMatchesOpenAPI(t *testing.T) {
|
||||
if !seenEvidenceRead {
|
||||
t.Error("transaction-authorized candidate evidence read is absent or moved")
|
||||
}
|
||||
for operation := range organizationNotificationPaths {
|
||||
if !seenNotifications[operation] {
|
||||
t.Errorf("transaction-authorized inbox operation %s is absent or moved", operation)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type companyContextAuthenticator struct {
|
||||
|
||||
Reference in new issue
Block a user