Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
chore: fixed rebase issue
=44380c414ffe
diff --git a/tests/CLAUDE.md b/tests/CLAUDE.mdindex 1704a1a15e..4e6972be2d 100644--- a/tests/CLAUDE.md+++ b/tests/CLAUDE.md@@ -190,7 +190,8 @@ test in the wrong package.deletion on `t.Cleanup`. Everything a test touches lives under that organization.Choosing the org as the boundary is what makes `t.Parallel()` the default.-`tn.Admin` is a real invited user, not the instance root, and holds no super-admin flag.+`tn.Admin` signed up and created the organization the way a customer does, so it is+the org's creator, not the instance root, and holds no super-admin flag.## 5. Namingdiff --git a/tests/clients/api/api.gen.go b/tests/clients/api/api.gen.goindex a7bad7d10e..4c7dc78a9d 100644--- a/tests/clients/api/api.gen.go+++ b/tests/clients/api/api.gen.go@@ -4914,6 +4914,9 @@ type UpdateAdminConfigJSONBody struct {INFAPPCONNECTIONGITLABOAUTHCLIENTSECRET string `json:"INF_APP_CONNECTION_GITLAB_OAUTH_CLIENT_SECRET"`INFAPPCONNECTIONHEROKUOAUTHCLIENTID string `json:"INF_APP_CONNECTION_HEROKU_OAUTH_CLIENT_ID"`INFAPPCONNECTIONHEROKUOAUTHCLIENTSECRET string `json:"INF_APP_CONNECTION_HEROKU_OAUTH_CLIENT_SECRET"`+ INFAPPCONNECTIONSTRIPEOAUTHAUTHORIZEURL string `json:"INF_APP_CONNECTION_STRIPE_OAUTH_AUTHORIZE_URL"`+ INFAPPCONNECTIONSTRIPEOAUTHCLIENTID string `json:"INF_APP_CONNECTION_STRIPE_OAUTH_CLIENT_ID"`+ INFAPPCONNECTIONSTRIPESECRETKEY string `json:"INF_APP_CONNECTION_STRIPE_SECRET_KEY"`} `json:"envOverrides,omitempty"`GitHubAppConnectionClientId *string `json:"gitHubAppConnectionClientId,omitempty"`GitHubAppConnectionClientSecret *string `json:"gitHubAppConnectionClientSecret,omitempty"`@@ -6137,6 +6140,9 @@ type CreateGitHubSecretSyncJSONBody struct {// DisableSecretDeletion Enable this flag to prevent removal of secrets from the GitHub destination when syncing.DisableSecretDeletion *bool `json:"disableSecretDeletion,omitempty"`+ // IncludeAllSubFolders Whether to sync secrets from folders beneath the source path as well.+ IncludeAllSubFolders *bool `json:"includeAllSubFolders,omitempty"`+// InitialSyncBehavior Specify how Infisical should resolve the initial sync to the GitHub destination.InitialSyncBehavior CreateGitHubSecretSyncJSONBodySyncOptionsInitialSyncBehavior `json:"initialSyncBehavior"`@@ -14615,9 +14621,11 @@ type CreateProjectResponse struct {Id string `json:"id"`IsLegacyAdditionalPrivilegesEnabled *bool `json:"isLegacyAdditionalPrivilegesEnabled,omitempty"`KmsCertificateKeyId *openapi_types.UUID `json:"kmsCertificateKeyId,omitempty"`+ KmsSecretManagerKeyId *openapi_types.UUID `json:"kmsSecretManagerKeyId,omitempty"`Name string `json:"name"`OrgId openapi_types.UUID `json:"orgId"`PitVersionLimit *float32 `json:"pitVersionLimit,omitempty"`+ SecretBlindIndexEnabled *bool `json:"secretBlindIndexEnabled,omitempty"`SecretDetectionIgnoreValues *[]string `json:"secretDetectionIgnoreValues,omitempty"`SecretSharing *bool `json:"secretSharing,omitempty"`ShowSnapshotsLegacy *bool `json:"showSnapshotsLegacy,omitempty"`@@ -14701,9 +14709,11 @@ func (r CreateProjectResponse) GetJSON200() *struct {Id string `json:"id"`IsLegacyAdditionalPrivilegesEnabled *bool `json:"isLegacyAdditionalPrivilegesEnabled,omitempty"`KmsCertificateKeyId *openapi_types.UUID `json:"kmsCertificateKeyId,omitempty"`+ KmsSecretManagerKeyId *openapi_types.UUID `json:"kmsSecretManagerKeyId,omitempty"`Name string `json:"name"`OrgId openapi_types.UUID `json:"orgId"`PitVersionLimit *float32 `json:"pitVersionLimit,omitempty"`+ SecretBlindIndexEnabled *bool `json:"secretBlindIndexEnabled,omitempty"`SecretDetectionIgnoreValues *[]string `json:"secretDetectionIgnoreValues,omitempty"`SecretSharing *bool `json:"secretSharing,omitempty"`ShowSnapshotsLegacy *bool `json:"showSnapshotsLegacy,omitempty"`@@ -15545,6 +15555,9 @@ type CreateGitHubSecretSyncResponse struct {// DisableSecretDeletion Enable this flag to prevent removal of secrets from the GitHub destination when syncing.DisableSecretDeletion *bool `json:"disableSecretDeletion,omitempty"`+ // IncludeAllSubFolders Whether to sync secrets from folders beneath the source path as well.+ IncludeAllSubFolders *bool `json:"includeAllSubFolders,omitempty"`+// InitialSyncBehavior Specify how Infisical should resolve the initial sync to the GitHub destination.InitialSyncBehavior CreateGitHubSecretSync200JSONResponseBodySecretSyncSyncOptionsInitialSyncBehavior `json:"initialSyncBehavior"`@@ -15646,6 +15659,9 @@ func (r CreateGitHubSecretSyncResponse) GetJSON200() *struct {// DisableSecretDeletion Enable this flag to prevent removal of secrets from the GitHub destination when syncing.DisableSecretDeletion *bool `json:"disableSecretDeletion,omitempty"`+ // IncludeAllSubFolders Whether to sync secrets from folders beneath the source path as well.+ IncludeAllSubFolders *bool `json:"includeAllSubFolders,omitempty"`+// InitialSyncBehavior Specify how Infisical should resolve the initial sync to the GitHub destination.InitialSyncBehavior CreateGitHubSecretSync200JSONResponseBodySecretSyncSyncOptionsInitialSyncBehavior `json:"initialSyncBehavior"`@@ -15798,6 +15814,9 @@ type DeleteGitHubSecretSyncResponse struct {// DisableSecretDeletion Enable this flag to prevent removal of secrets from the GitHub destination when syncing.DisableSecretDeletion *bool `json:"disableSecretDeletion,omitempty"`+ // IncludeAllSubFolders Whether to sync secrets from folders beneath the source path as well.+ IncludeAllSubFolders *bool `json:"includeAllSubFolders,omitempty"`+// InitialSyncBehavior Specify how Infisical should resolve the initial sync to the GitHub destination.InitialSyncBehavior DeleteGitHubSecretSync200JSONResponseBodySecretSyncSyncOptionsInitialSyncBehavior `json:"initialSyncBehavior"`@@ -15899,6 +15918,9 @@ func (r DeleteGitHubSecretSyncResponse) GetJSON200() *struct {// DisableSecretDeletion Enable this flag to prevent removal of secrets from the GitHub destination when syncing.DisableSecretDeletion *bool `json:"disableSecretDeletion,omitempty"`+ // IncludeAllSubFolders Whether to sync secrets from folders beneath the source path as well.+ IncludeAllSubFolders *bool `json:"includeAllSubFolders,omitempty"`+// InitialSyncBehavior Specify how Infisical should resolve the initial sync to the GitHub destination.InitialSyncBehavior DeleteGitHubSecretSync200JSONResponseBodySecretSyncSyncOptionsInitialSyncBehavior `json:"initialSyncBehavior"`@@ -16051,6 +16073,9 @@ type GetGitHubSecretSyncResponse struct {// DisableSecretDeletion Enable this flag to prevent removal of secrets from the GitHub destination when syncing.DisableSecretDeletion *bool `json:"disableSecretDeletion,omitempty"`+ // IncludeAllSubFolders Whether to sync secrets from folders beneath the source path as well.+ IncludeAllSubFolders *bool `json:"includeAllSubFolders,omitempty"`+// InitialSyncBehavior Specify how Infisical should resolve the initial sync to the GitHub destination.InitialSyncBehavior GetGitHubSecretSync200JSONResponseBodySecretSyncSyncOptionsInitialSyncBehavior `json:"initialSyncBehavior"`@@ -16152,6 +16177,9 @@ func (r GetGitHubSecretSyncResponse) GetJSON200() *struct {// DisableSecretDeletion Enable this flag to prevent removal of secrets from the GitHub destination when syncing.DisableSecretDeletion *bool `json:"disableSecretDeletion,omitempty"`+ // IncludeAllSubFolders Whether to sync secrets from folders beneath the source path as well.+ IncludeAllSubFolders *bool `json:"includeAllSubFolders,omitempty"`+// InitialSyncBehavior Specify how Infisical should resolve the initial sync to the GitHub destination.InitialSyncBehavior GetGitHubSecretSync200JSONResponseBodySecretSyncSyncOptionsInitialSyncBehavior `json:"initialSyncBehavior"`@@ -16304,6 +16332,9 @@ type RemoveGitHubSecretSyncSecretsResponse struct {// DisableSecretDeletion Enable this flag to prevent removal of secrets from the GitHub destination when syncing.DisableSecretDeletion *bool `json:"disableSecretDeletion,omitempty"`+ // IncludeAllSubFolders Whether to sync secrets from folders beneath the source path as well.+ IncludeAllSubFolders *bool `json:"includeAllSubFolders,omitempty"`+// InitialSyncBehavior Specify how Infisical should resolve the initial sync to the GitHub destination.InitialSyncBehavior RemoveGitHubSecretSyncSecrets200JSONResponseBodySecretSyncSyncOptionsInitialSyncBehavior `json:"initialSyncBehavior"`@@ -16405,6 +16436,9 @@ func (r RemoveGitHubSecretSyncSecretsResponse) GetJSON200() *struct {// DisableSecretDeletion Enable this flag to prevent removal of secrets from the GitHub destination when syncing.DisableSecretDeletion *bool `json:"disableSecretDeletion,omitempty"`+ // IncludeAllSubFolders Whether to sync secrets from folders beneath the source path as well.+ IncludeAllSubFolders *bool `json:"includeAllSubFolders,omitempty"`+// InitialSyncBehavior Specify how Infisical should resolve the initial sync to the GitHub destination.InitialSyncBehavior RemoveGitHubSecretSyncSecrets200JSONResponseBodySecretSyncSyncOptionsInitialSyncBehavior `json:"initialSyncBehavior"`@@ -16557,6 +16591,9 @@ type SyncGitHubSecretSyncResponse struct {// DisableSecretDeletion Enable this flag to prevent removal of secrets from the GitHub destination when syncing.DisableSecretDeletion *bool `json:"disableSecretDeletion,omitempty"`+ // IncludeAllSubFolders Whether to sync secrets from folders beneath the source path as well.+ IncludeAllSubFolders *bool `json:"includeAllSubFolders,omitempty"`+// InitialSyncBehavior Specify how Infisical should resolve the initial sync to the GitHub destination.InitialSyncBehavior SyncGitHubSecretSync200JSONResponseBodySecretSyncSyncOptionsInitialSyncBehavior `json:"initialSyncBehavior"`@@ -16658,6 +16695,9 @@ func (r SyncGitHubSecretSyncResponse) GetJSON200() *struct {// DisableSecretDeletion Enable this flag to prevent removal of secrets from the GitHub destination when syncing.DisableSecretDeletion *bool `json:"disableSecretDeletion,omitempty"`+ // IncludeAllSubFolders Whether to sync secrets from folders beneath the source path as well.+ IncludeAllSubFolders *bool `json:"includeAllSubFolders,omitempty"`+// InitialSyncBehavior Specify how Infisical should resolve the initial sync to the GitHub destination.InitialSyncBehavior SyncGitHubSecretSync200JSONResponseBodySecretSyncSyncOptionsInitialSyncBehavior `json:"initialSyncBehavior"`@@ -20996,9 +21036,11 @@ func ParseCreateProjectResponse(rsp *http.Response) (*CreateProjectResponse, errId string `json:"id"`IsLegacyAdditionalPrivilegesEnabled *bool `json:"isLegacyAdditionalPrivilegesEnabled,omitempty"`KmsCertificateKeyId *openapi_types.UUID `json:"kmsCertificateKeyId,omitempty"`+ KmsSecretManagerKeyId *openapi_types.UUID `json:"kmsSecretManagerKeyId,omitempty"`Name string `json:"name"`OrgId openapi_types.UUID `json:"orgId"`PitVersionLimit *float32 `json:"pitVersionLimit,omitempty"`+ SecretBlindIndexEnabled *bool `json:"secretBlindIndexEnabled,omitempty"`SecretDetectionIgnoreValues *[]string `json:"secretDetectionIgnoreValues,omitempty"`SecretSharing *bool `json:"secretSharing,omitempty"`ShowSnapshotsLegacy *bool `json:"showSnapshotsLegacy,omitempty"`@@ -21602,6 +21644,9 @@ func ParseCreateGitHubSecretSyncResponse(rsp *http.Response) (*CreateGitHubSecre// DisableSecretDeletion Enable this flag to prevent removal of secrets from the GitHub destination when syncing.DisableSecretDeletion *bool `json:"disableSecretDeletion,omitempty"`+ // IncludeAllSubFolders Whether to sync secrets from folders beneath the source path as well.+ IncludeAllSubFolders *bool `json:"includeAllSubFolders,omitempty"`+// InitialSyncBehavior Specify how Infisical should resolve the initial sync to the GitHub destination.InitialSyncBehavior CreateGitHubSecretSync200JSONResponseBodySecretSyncSyncOptionsInitialSyncBehavior `json:"initialSyncBehavior"`@@ -21755,6 +21800,9 @@ func ParseDeleteGitHubSecretSyncResponse(rsp *http.Response) (*DeleteGitHubSecre// DisableSecretDeletion Enable this flag to prevent removal of secrets from the GitHub destination when syncing.DisableSecretDeletion *bool `json:"disableSecretDeletion,omitempty"`+ // IncludeAllSubFolders Whether to sync secrets from folders beneath the source path as well.+ IncludeAllSubFolders *bool `json:"includeAllSubFolders,omitempty"`+// InitialSyncBehavior Specify how Infisical should resolve the initial sync to the GitHub destination.InitialSyncBehavior DeleteGitHubSecretSync200JSONResponseBodySecretSyncSyncOptionsInitialSyncBehavior `json:"initialSyncBehavior"`@@ -21908,6 +21956,9 @@ func ParseGetGitHubSecretSyncResponse(rsp *http.Response) (*GetGitHubSecretSyncR// DisableSecretDeletion Enable this flag to prevent removal of secrets from the GitHub destination when syncing.DisableSecretDeletion *bool `json:"disableSecretDeletion,omitempty"`+ // IncludeAllSubFolders Whether to sync secrets from folders beneath the source path as well.+ IncludeAllSubFolders *bool `json:"includeAllSubFolders,omitempty"`+// InitialSyncBehavior Specify how Infisical should resolve the initial sync to the GitHub destination.InitialSyncBehavior GetGitHubSecretSync200JSONResponseBodySecretSyncSyncOptionsInitialSyncBehavior `json:"initialSyncBehavior"`@@ -22061,6 +22112,9 @@ func ParseRemoveGitHubSecretSyncSecretsResponse(rsp *http.Response) (*RemoveGitH// DisableSecretDeletion Enable this flag to prevent removal of secrets from the GitHub destination when syncing.DisableSecretDeletion *bool `json:"disableSecretDeletion,omitempty"`+ // IncludeAllSubFolders Whether to sync secrets from folders beneath the source path as well.+ IncludeAllSubFolders *bool `json:"includeAllSubFolders,omitempty"`+// InitialSyncBehavior Specify how Infisical should resolve the initial sync to the GitHub destination.InitialSyncBehavior RemoveGitHubSecretSyncSecrets200JSONResponseBodySecretSyncSyncOptionsInitialSyncBehavior `json:"initialSyncBehavior"`@@ -22214,6 +22268,9 @@ func ParseSyncGitHubSecretSyncResponse(rsp *http.Response) (*SyncGitHubSecretSyn// DisableSecretDeletion Enable this flag to prevent removal of secrets from the GitHub destination when syncing.DisableSecretDeletion *bool `json:"disableSecretDeletion,omitempty"`+ // IncludeAllSubFolders Whether to sync secrets from folders beneath the source path as well.+ IncludeAllSubFolders *bool `json:"includeAllSubFolders,omitempty"`+// InitialSyncBehavior Specify how Infisical should resolve the initial sync to the GitHub destination.InitialSyncBehavior SyncGitHubSecretSync200JSONResponseBodySecretSyncSyncOptionsInitialSyncBehavior `json:"initialSyncBehavior"`diff --git a/tests/harness/principal.go b/tests/harness/principal.goindex ac684f642d..038aa886ff 100644--- a/tests/harness/principal.go+++ b/tests/harness/principal.go@@ -78,14 +78,6 @@ func (t *Tenant) Mail(tt *testing.T) *smtp.Inbox {func (t *Tenant) NewUser(tt *testing.T, opts ...PrincipalOption) *Principal {tt.Helper()cfg := newPrincipalConfig("u", opts)- return t.newUser(tt, cfg, t.Admin.Token)-}--// newUser runs the invitation flow. inviterToken is normally the tenant's own-// administrator; creating that administrator is the one case where it is the root,-// because there is nobody else in the organization yet.-func (t *Tenant) newUser(tt *testing.T, cfg principalConfig, inviterToken string) *Principal {- tt.Helper()ctx := tt.Context()addr := t.Address(cfg.name)@@ -93,7 +85,7 @@ func (t *Tenant) newUser(tt *testing.T, cfg principalConfig, inviterToken string// smtpRateLimit, which is a hardcoded two per forty seconds keyed on the source// address and is not raisable through the plan.ip := newIP()- inviter := t.stack.client(tt, inviterToken, ip)+ inviter := t.stack.client(tt, t.Admin.Token, ip)invited, err := inviter.InviteUsersToOrganizationWithResponse(ctx, api.InviteUsersToOrganizationJSONRequestBody{InviteeEmails: []openapi_types.Email{openapi_types.Email(addr)},@@ -130,13 +122,32 @@ func (t *Tenant) newUser(tt *testing.T, cfg principalConfig, inviterToken stringaddr, verified.StatusCode(), apierr.Body(verified.Body))}- var signupBody api.CompleteAccountSignupV3JSONBody- if err := signupBody.FromCompleteAccountSignupV3JSONBody0(api.CompleteAccountSignupV3JSONBody0{+ userID, unscoped := t.stack.completeAccount(tt, *verified.JSON200.Token, ip, api.CompleteAccountSignupV3JSONBody0{Type: api.CompleteAccountSignupV3JSONBody0TypeEmail,Email: addr,FirstName: cfg.name,Password: UserPassword,- }); err != nil {+ })++ scoped := t.stack.scopeToOrg(tt, unscoped, t.OrgID, ip)+ return &Principal{+ Kind: User,+ ID: userID,+ Name: cfg.name,+ Email: addr,+ Token: scoped,+ API: t.stack.client(tt, scoped, ip),+ ip: ip,+ }+}++// completeAccount finishes an email signup or an accepted invitation, returning the+// user and a session token.+func (s *Stack) completeAccount(tt *testing.T, verifiedToken, ip string, body api.CompleteAccountSignupV3JSONBody0) (uuid.UUID, string) {+ tt.Helper()++ var union api.CompleteAccountSignupV3JSONBody+ if err := union.FromCompleteAccountSignupV3JSONBody0(body); err != nil {tt.Fatalf("harness: %v", err)}@@ -145,30 +156,21 @@ func (t *Tenant) newUser(tt *testing.T, cfg principalConfig, inviterToken string// and a defined type does not inherit methods -- so the generated MarshalJSON is// lost and the discriminated union serialises as {}. Encoding the union itself and// posting the bytes is the only shape that survives.- raw, err := json.Marshal(signupBody)+ raw, err := json.Marshal(union)if err != nil {tt.Fatalf("harness: %v", err)}- completed, err := t.stack.client(tt, *verified.JSON200.Token, ip).- CompleteAccountSignupV3WithBodyWithResponse(ctx, "application/json", bytes.NewReader(raw))+ res, err := s.client(tt, verifiedToken, ip).+ CompleteAccountSignupV3WithBodyWithResponse(tt.Context(), "application/json", bytes.NewReader(raw))if err != nil {- tt.Fatalf("harness: completing the account for %s: %v", addr, err)+ tt.Fatalf("harness: completing the account for %s: %v", body.Email, err)}- if completed.JSON200 == nil {+ if res.JSON200 == nil {tt.Fatalf("harness: completing the account for %s returned %d: %s",- addr, completed.StatusCode(), apierr.Body(completed.Body))+ body.Email, res.StatusCode(), apierr.Body(res.Body))}- scoped := t.stack.scopeToOrg(tt, completed.JSON200.Token, t.OrgID, ip)- return &Principal{- Kind: User,- ID: completed.JSON200.User.Id,- Name: cfg.name,- Email: addr,- Token: scoped,- API: t.stack.client(tt, scoped, ip),- ip: ip,- }+ return res.JSON200.User.Id, res.JSON200.Token}// NewIdentity creates a machine identity with universal auth and logs it in.diff --git a/tests/harness/tenant.go b/tests/harness/tenant.goindex bd13df7e25..796b6db938 100644--- a/tests/harness/tenant.go+++ b/tests/harness/tenant.go@@ -16,7 +16,9 @@ import ("github.com/Infisical/infisical/tests/infra/fakenet""github.com/Infisical/infisical/tests/internal/apierr""github.com/Infisical/infisical/tests/internal/id"+ "github.com/Infisical/infisical/tests/internal/mail""github.com/google/uuid"+ openapi_types "github.com/oapi-codegen/runtime/types")// Tenant is one organization and everything under it. It is the unit of isolation:@@ -98,48 +100,27 @@ func WithTenantName(name string) TenantOption { return func(c *tenantConfig) { c// WithPlan gives the tenant entitlements other than the default.func WithPlan(p license.Plan) TenantOption { return func(c *tenantConfig) { c.plan = &p } }-// NewTenant creates an organization with its own administrator.+// NewTenant creates an organization the way a customer does: its administrator signs+// up, then creates the organization.//-// The instance root has to do the creating: POST /api/v2/organizations refuses any-// actor that is not a USER, so the bootstrap identity token cannot mint tenants and-// the root password is the only thing that can. That password stays inside the-// harness; what a test gets back is an ordinary org admin.-//-// One login, not two. Every round trip here comes out of authRateLimit's 60 per-// minute, which is not an entitlement and cannot be raised through the plan.+// The instance root cannot do it for them. On cloud, which the License Server key+// makes this instance, a user may create only one organization they still belong to,+// so a root minting every tenant is refused from the second one on.func (s *Stack) NewTenant(t *testing.T, opts ...TenantOption) *Tenant {t.Helper()- ctx := t.Context()cfg := tenantConfig{name: "t-" + strings.ToLower(uuid.NewString()[:8])}for _, o := range opts {o(&cfg)}- ip := newIP()- rootUnscoped := s.rootToken(t, ip)-- created, err := s.client(t, rootUnscoped, ip).CreateOrganizationWithResponse(ctx,- api.CreateOrganizationJSONRequestBody{Name: cfg.name})- if err != nil {- t.Fatalf("harness: creating an organization: %v", err)- }- if created.JSON200 == nil {- t.Fatalf("harness: creating an organization returned %d: %s", created.StatusCode(), apierr.Body(created.Body))- }-- org := created.JSON200.Organization// A nonce rather than the org slug: the event stream only carries scopes that// start with this binary's prefix, and the server picks the slug.mailDomain := id.Nonce() + ".test"smtp.Track(t, s.Require(t, fakenet.Key, "harness.Shared").(*fakenet.Handle).AdminURL(), mailDomain)- tenant := &Tenant{OrgID: org.Id, OrgSlug: org.Slug, mailDomain: mailDomain, ip: ip, stack: s, plan: cfg.plan}- // The root binds itself to the new organization only to invite its administrator,- // and its token goes no further than this function. What a test receives is an- // ordinary user at admin@<tenant-nonce>.test, unique to this tenant.- rootScoped := s.scopeToOrg(t, rootUnscoped, org.Id, ip)- tenant.Admin = tenant.newUser(t, principalConfig{name: "admin", orgRole: "admin"}, rootScoped)+ tenant := &Tenant{mailDomain: mailDomain, ip: newIP(), stack: s, plan: cfg.plan}+ tenant.Admin = tenant.signUpAdmin(t, cfg.name)if cfg.plan != nil {tenant.SetPlan(t, *cfg.plan)@@ -149,6 +130,77 @@ func (s *Stack) NewTenant(t *testing.T, opts ...TenantOption) *Tenant {return tenant}+// signUpAdmin registers admin@<tenant-nonce>.test, has it create the organization,+// and fills in the tenant's org id and slug.+func (t *Tenant) signUpAdmin(tt *testing.T, orgName string) *Principal {+ tt.Helper()+ ctx := tt.Context()+ addr := t.Address("admin")++ // Its own bucket: the signup mail goes through smtpRateLimit.+ ip := newIP()+ anon, err := infisical.NewClient(t.stack.app.BaseURL(infra.External), infisical.ForwardedFor(ip))+ if err != nil {+ tt.Fatalf("harness: %v", err)+ }++ begun, err := anon.BeginEmailSignupV3WithResponse(ctx, api.BeginEmailSignupV3JSONRequestBody{Email: openapi_types.Email(addr)})+ if err != nil {+ tt.Fatalf("harness: signing up %s: %v", addr, err)+ }+ if begun.JSON200 == nil {+ tt.Fatalf("harness: signing up %s returned %d: %s", addr, begun.StatusCode(), apierr.Body(begun.Body))+ }++ msg := t.Mail(tt).Expect(tt, addr, smtp.Subject("confirmation code"))+ code, err := mail.Code(msg, 6)+ if err != nil {+ tt.Fatalf("harness: %v", err)+ }++ verified, err := anon.VerifyEmailSignupV3WithResponse(ctx, api.VerifyEmailSignupV3JSONRequestBody{Email: openapi_types.Email(addr), Code: code})+ if err != nil {+ tt.Fatalf("harness: verifying the signup for %s: %v", addr, err)+ }+ if verified.JSON200 == nil {+ tt.Fatalf("harness: verifying the signup for %s returned %d: %s",+ addr, verified.StatusCode(), apierr.Body(verified.Body))+ }++ userID, unscoped := t.stack.completeAccount(tt, verified.JSON200.Token, ip, api.CompleteAccountSignupV3JSONBody0{+ Type: api.CompleteAccountSignupV3JSONBody0TypeEmail,+ Email: addr,+ FirstName: "admin",+ Password: UserPassword,+ })++ // A separate call rather than organizationName on complete-account, as the+ // frontend does. That field creates the org inside the signup transaction, and+ // the plan refresh that follows reads on a second pool connection, so parallel+ // tenants exhaust the pool.+ created, err := t.stack.client(tt, unscoped, ip).CreateOrganizationWithResponse(ctx,+ api.CreateOrganizationJSONRequestBody{Name: orgName})+ if err != nil {+ tt.Fatalf("harness: creating an organization for %s: %v", addr, err)+ }+ if created.JSON200 == nil {+ tt.Fatalf("harness: creating an organization for %s returned %d: %s",+ addr, created.StatusCode(), apierr.Body(created.Body))+ }+ t.OrgID, t.OrgSlug = created.JSON200.Organization.Id, created.JSON200.Organization.Slug++ scoped := t.stack.scopeToOrg(tt, unscoped, t.OrgID, ip)+ return &Principal{+ Kind: User,+ ID: userID,+ Name: "admin",+ Email: addr,+ Token: scoped,+ API: t.stack.client(tt, scoped, ip),+ ip: ip,+ }+}+// SetPlan changes this tenant's entitlements, and proves the change took effect.//// A stub on its own does nothing: getPlan caches per organization in Redis for 900