feat(invitations): accept invitations with C4 consent and contact grants; share the E0 quota across holdings

This commit is contained in:
shira committed 2026-10-09 18:03:35 +03:00
1 parent a5990d3fc6
commit 676b3c6e24
59 files changed
+4926 -194

No files matched your search

+26 -7
View File
@@ -38,11 +38,10 @@ type companyQuotaFixture struct {
invitationCandidate uuid.UUID
}
func TestCompanyQuota(t *testing.T) {
env := bootstrap(t, postgresService)
ctx, cancel := context.WithTimeout(t.Context(), companyQuotaTestTimeout)
defer cancel()
databaseURL := env.createIsolatedDatabase(ctx, t)
// newCompanyQuotaFixture migrates the isolated database, publishes the demo
// product policy, and returns the fixture the quota tests share.
func newCompanyQuotaFixture(ctx context.Context, t *testing.T, databaseURL string) companyQuotaFixture {
t.Helper()
applyMigrations(ctx, t, databaseURL)
pool := newPoolFor(ctx, t, databaseURL)
@@ -60,13 +59,20 @@ func TestCompanyQuota(t *testing.T) {
if err != nil {
t.Fatalf("GetEffective(product) error = %v", err)
}
fixture := companyQuotaFixture{
return companyQuotaFixture{
ctx: ctx, pool: pool, clock: clock, transactor: transactor,
service: companyquota.NewService(clock.Now), organizations: organizationFixture,
policies: policyStore.Policies(), version: version,
invitationAuthor: organizationFixture.employer(t, "quota-invitation-author@example.test").ID,
invitationCandidate: identity.createUser(t, "quota-invitation-candidate@example.test", domain.ScenarioCandidate, clock.Now().Add(-time.Hour)).ID,
}
}
func TestCompanyQuota(t *testing.T) {
env := bootstrap(t, postgresService)
ctx, cancel := context.WithTimeout(t.Context(), companyQuotaTestTimeout)
defer cancel()
fixture := newCompanyQuotaFixture(ctx, t, env.createIsolatedDatabase(ctx, t))
t.Run("E0 shares limits across requests and concurrent final reservations", func(t *testing.T) {
organization, _ := fixture.newOrganization(t, "e0-boundary", domain.OrganizationVerificationE0)
@@ -381,6 +387,19 @@ func (fixture companyQuotaFixture) newOrganization(
) (domain.Organization, domain.User) {
t.Helper()
owner := fixture.organizations.employer(t, fmt.Sprintf("quota-%s-%s@example.test", name, uuid.NewString()))
return fixture.organizationOf(t, owner, name, level), owner
}
// organizationOf stores an organization of owner at the given verification
// level and returns it as read back from storage. Several organizations of one
// owner belong to one holding.
func (fixture companyQuotaFixture) organizationOf(
t *testing.T,
owner domain.User,
name string,
level domain.OrganizationVerificationLevel,
) domain.Organization {
t.Helper()
organization := fixture.organizations.create(t, owner, mustOrganizationProfile(t, domain.OrganizationProfileInput{Name: "Quota " + name}), fixture.clock.Now().Add(-time.Minute))
if level != domain.OrganizationVerificationE0 {
basis := domain.OrganizationBasisCorporateDomain
@@ -401,7 +420,7 @@ func (fixture companyQuotaFixture) newOrganization(
if err != nil {
t.Fatalf("read %s organization: %v", level, err)
}
return stored, owner
return stored
}
// newInvitationID stores a draft of the organization and returns its