Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat: moved integration test to top folder

=4f6b7c1a17b4
diff --git a/backend-go/CLAUDE.md b/backend-go/CLAUDE.md
index 01c85902d8..e4b6773344 100644
--- a/backend-go/CLAUDE.md
+++ b/backend-go/CLAUDE.md
@@ -5,12 +5,15 @@ Partial Go rewrite of the Node.js backend using chi + oapi-codegen + raw pgx que
## Commands
```
-make build # build binary
-make dev # hot-reload via docker-compose + air
-make test # integration tests (testcontainers, -race)
-make lint # must pass before submission
-make lint-fix # auto-fix linting issues
-make generate # run go generate ./... for oapi-codegen
+make build # build binary
+make dev # hot-reload via docker-compose + air
+make test # run all tests (unit + integration)
+make test-unit # unit tests only (./internal/...)
+make test-integration # integration tests only (./tests/..., testcontainers)
+make test-hsm # HSM tests (requires Docker, builds test container)
+make lint # must pass before submission
+make lint-fix # auto-fix linting issues
+make generate # run go generate ./... for oapi-codegen
```
## Code Rules
@@ -49,8 +52,19 @@ internal/
│ │ └── secretmanager/ # Secret manager handlers
│ └── middlewares/ # HTTP middlewares (RequireAuth, etc.)
├── services/ # Shared business logic (auth, permission, kms, ...)
-├── keystore/ # Redis key-value operations
-└── testutil/ # Test infra (testcontainers)
+└── keystore/ # Redis key-value operations
+tests/ # Integration tests (external test packages)
+├── infra/ # Test infrastructure (testcontainers, helpers)
+├── platform/ # Platform service tests
+│ ├── auth/ # Authentication handler tests
+│ ├── externalkms/ # External KMS (AWS/GCP) tests
+│ ├── hsm/ # HSM tests (container-based)
+│ ├── kms/ # KMS service tests
+│ ├── permission/ # Permission system tests
+│ ├── projects/ # Projects handler tests
+│ └── ratelimit/ # Rate limiting tests
+└── secretmanager/
+ └── secrets/ # Secrets API tests (list, get, permissions)
```
**Two tiers:**
diff --git a/backend-go/Makefile b/backend-go/Makefile
index 59ff6ce0dd..d5c91cfa5e 100644
--- a/backend-go/Makefile
+++ b/backend-go/Makefile
@@ -1,4 +1,4 @@
-.PHONY: lint lint-fix test test-integration test-all dev build generate test-hsm-image test-hsm
+.PHONY: lint lint-fix test test-unit test-integration dev build generate test-hsm-image test-hsm
# Run linters
lint:
@@ -7,12 +7,16 @@ lint:
lint-fix:
go fix ./... && golangci-lint run --build-tags integration --fix
+# Run unit tests only (no testcontainers)
test-unit:
go test -v ./internal/... -count=1 -race -timeout 120s
-# Run integration tests — testcontainers spins up isolated containers per package
-test:
- go test -v -tags integration ./internal/... -count=1 -race -timeout 300s
+# Run integration tests only — testcontainers spins up isolated containers per package
+test-integration:
+ go test -v -tags integration ./tests/... -count=1 -race -timeout 300s
+
+# Run all tests (unit + integration)
+test: test-unit test-integration
# Start Go backend with hot-reload (uses root docker-compose.dev.yml)
dev:
@@ -32,4 +36,4 @@ test-hsm-image:
# Run HSM integration tests (requires test-hsm-image to be built first)
test-hsm: test-hsm-image
- INFISICAL_RUN_HSM_CONTAINER_TEST=1 go test -v -tags integration ./internal/ee/services/hsm/... -count=1 -timeout 300s
+ INFISICAL_RUN_HSM_CONTAINER_TEST=1 go test -v -tags integration ./tests/platform/hsm/... -count=1 -timeout 300s
diff --git a/backend-go/internal/testutil/infra/builder.go b/backend-go/tests/infra/builder.go
similarity index 100%
rename from backend-go/internal/testutil/infra/builder.go
rename to backend-go/tests/infra/builder.go
diff --git a/backend-go/internal/testutil/infra/constants.go b/backend-go/tests/infra/constants.go
similarity index 100%
rename from backend-go/internal/testutil/infra/constants.go
rename to backend-go/tests/infra/constants.go
diff --git a/backend-go/internal/testutil/infra/container.go b/backend-go/tests/infra/container.go
similarity index 100%
rename from backend-go/internal/testutil/infra/container.go
rename to backend-go/tests/infra/container.go
diff --git a/backend-go/internal/testutil/infra/infisical_secrets.go b/backend-go/tests/infra/infisical_secrets.go
similarity index 100%
rename from backend-go/internal/testutil/infra/infisical_secrets.go
rename to backend-go/tests/infra/infisical_secrets.go
diff --git a/backend-go/internal/testutil/logger.go b/backend-go/tests/infra/logger.go
similarity index 80%
rename from backend-go/internal/testutil/logger.go
rename to backend-go/tests/infra/logger.go
index e0e5c28a58..67bd3db7db 100644
--- a/backend-go/internal/testutil/logger.go
+++ b/backend-go/tests/infra/logger.go
@@ -1,4 +1,6 @@
-package testutil
+//go:build integration
+
+package infra
import (
"log/slog"
diff --git a/backend-go/internal/testutil/infra/nodejs.go b/backend-go/tests/infra/nodejs.go
similarity index 100%
rename from backend-go/internal/testutil/infra/nodejs.go
rename to backend-go/tests/infra/nodejs.go
diff --git a/backend-go/internal/testutil/infra/nodejs_types.go b/backend-go/tests/infra/nodejs_types.go
similarity index 100%
rename from backend-go/internal/testutil/infra/nodejs_types.go
rename to backend-go/tests/infra/nodejs_types.go
diff --git a/backend-go/internal/testutil/infra/postgres.go b/backend-go/tests/infra/postgres.go
similarity index 100%
rename from backend-go/internal/testutil/infra/postgres.go
rename to backend-go/tests/infra/postgres.go
diff --git a/backend-go/internal/testutil/infra/redis.go b/backend-go/tests/infra/redis.go
similarity index 100%
rename from backend-go/internal/testutil/infra/redis.go
rename to backend-go/tests/infra/redis.go
diff --git a/backend-go/internal/testutil/infra/stack.go b/backend-go/tests/infra/stack.go
similarity index 100%
rename from backend-go/internal/testutil/infra/stack.go
rename to backend-go/tests/infra/stack.go
diff --git a/backend-go/internal/services/auth/handler_integration_test.go b/backend-go/tests/platform/auth/handler_test.go
similarity index 86%
rename from backend-go/internal/services/auth/handler_integration_test.go
rename to backend-go/tests/platform/auth/handler_test.go
index 907aadb38b..145b09367f 100644
--- a/backend-go/internal/services/auth/handler_integration_test.go
+++ b/backend-go/tests/platform/auth/handler_test.go
@@ -22,7 +22,7 @@ import (
"github.com/infisical/api/internal/libs/errutil"
"github.com/infisical/api/internal/services/auth"
"github.com/infisical/api/internal/services/auth/apiauth"
- "github.com/infisical/api/internal/testutil/infra"
+ "github.com/infisical/api/tests/infra"
)
var (
@@ -217,9 +217,6 @@ func TestValidateJWT_UserToken_Errors(t *testing.T) {
}
func TestValidateJWT_UserToken_StaleAccessVersion(t *testing.T) {
- // This test requires DB manipulation to create a session with a different access version
- // We create a valid token but modify the session's access version in DB
-
userID := uuid.MustParse(stack.NodeJS().UserID())
sessionID := uuid.New()
@@ -249,7 +246,6 @@ func TestValidateJWT_UserToken_StaleAccessVersion(t *testing.T) {
}
func TestValidateJWT_UserToken_UserLocked(t *testing.T) {
- // Create a user that is permanently locked
lockedUserID := uuid.New()
testEmail := "locked-" + uuid.New().String() + "@test.com"
_, err := stack.DB().Primary().Exec(context.Background(), `
@@ -263,7 +259,6 @@ func TestValidateJWT_UserToken_UserLocked(t *testing.T) {
pgx.NamedArgs{"userID": lockedUserID})
})
- // Create a session for the locked user
sessionID := uuid.New()
_, err = stack.DB().Primary().Exec(context.Background(), `
INSERT INTO auth_token_sessions (id, "userId", "accessVersion", "refreshVersion", ip, "userAgent", "lastUsed", "createdAt", "updatedAt")
@@ -289,10 +284,9 @@ func TestValidateJWT_UserToken_UserLocked(t *testing.T) {
}
func TestValidateJWT_UserToken_UserTemporarilyLocked(t *testing.T) {
- // Create a user that is temporarily locked (lock expires in the future)
tempLockedUserID := uuid.New()
testEmail := "templocked-" + uuid.New().String() + "@test.com"
- lockEnd := time.Now().Add(time.Hour) // Locked for another hour
+ lockEnd := time.Now().Add(time.Hour)
_, err := stack.DB().Primary().Exec(context.Background(), `
INSERT INTO users (id, email, username, "isAccepted", "temporaryLockDateEnd", "createdAt", "updatedAt")
VALUES (@userID, @email, @username, true, @lockEnd, NOW(), NOW())
@@ -304,7 +298,6 @@ func TestValidateJWT_UserToken_UserTemporarilyLocked(t *testing.T) {
pgx.NamedArgs{"userID": tempLockedUserID})
})
- // Create a session for the temp-locked user
sessionID := uuid.New()
_, err = stack.DB().Primary().Exec(context.Background(), `
INSERT INTO auth_token_sessions (id, "userId", "accessVersion", "refreshVersion", ip, "userAgent", "lastUsed", "createdAt", "updatedAt")
@@ -330,7 +323,6 @@ func TestValidateJWT_UserToken_UserTemporarilyLocked(t *testing.T) {
}
func TestValidateJWT_UserToken_UserNotAccepted(t *testing.T) {
- // Create a user that has not accepted
notAcceptedUserID := uuid.New()
testEmail := "notaccepted-" + uuid.New().String() + "@test.com"
_, err := stack.DB().Primary().Exec(context.Background(), `
@@ -344,7 +336,6 @@ func TestValidateJWT_UserToken_UserNotAccepted(t *testing.T) {
pgx.NamedArgs{"userID": notAcceptedUserID})
})
- // Create a session for the not-accepted user
sessionID := uuid.New()
_, err = stack.DB().Primary().Exec(context.Background(), `
INSERT INTO auth_token_sessions (id, "userId", "accessVersion", "refreshVersion", ip, "userAgent", "lastUsed", "createdAt", "updatedAt")
@@ -383,7 +374,6 @@ func TestValidateIdentityAccessToken_Valid(t *testing.T) {
assert.Equal(t, auth.ActorTypeIdentity, identity.Actor)
assert.NotEqual(t, uuid.Nil, identity.ActorID)
assert.Equal(t, uuid.MustParse(stack.NodeJS().OrgID()), identity.OrgID)
- // Verify identity-specific fields
require.NotNil(t, identity.IdentityAuthInfo)
assert.NotEqual(t, uuid.Nil, identity.IdentityAuthInfo.IdentityID)
}
@@ -451,7 +441,6 @@ func TestValidateIdentityAccessToken_Errors(t *testing.T) {
func TestValidateIdentityAccessToken_CustomIdentity(t *testing.T) {
nodejs := stack.NodeJS()
- // Create unique project and identity for this test
projName := "test-" + uuid.New().String()[:8]
proj := nodejs.CreateProject(t, projName)
t.Cleanup(func() {
@@ -475,7 +464,6 @@ func TestValidateIdentityAccessToken_CustomIdentity(t *testing.T) {
func TestValidateIdentityAccessToken_Revoked(t *testing.T) {
nodejs := stack.NodeJS()
- // Create identity and get token
projName := "test-revoke-" + uuid.New().String()[:8]
proj := nodejs.CreateProject(t, projName)
t.Cleanup(func() {
@@ -487,7 +475,6 @@ func TestValidateIdentityAccessToken_Revoked(t *testing.T) {
token := nodejs.GetIdentityAccessToken(t, identity.ID)
- // Revoke the token via Node.js API
nodejs.RevokeAccessToken(t, token)
_, err := authenticator.ValidateIdentityAccessToken(context.Background(), token, "")
@@ -499,7 +486,6 @@ func TestValidateIdentityAccessToken_Revoked(t *testing.T) {
func TestValidateIdentityAccessToken_IdentityDeleted(t *testing.T) {
nodejs := stack.NodeJS()
- // Create identity and get token
projName := "test-idelete-" + uuid.New().String()[:8]
proj := nodejs.CreateProject(t, projName)
t.Cleanup(func() {
@@ -511,12 +497,10 @@ func TestValidateIdentityAccessToken_IdentityDeleted(t *testing.T) {
token := nodejs.GetIdentityAccessToken(t, identity.ID)
- // Delete the identity - this revokes all tokens for the identity
nodejs.DeleteIdentity(t, identity.ID)
_, err := authenticator.ValidateIdentityAccessToken(context.Background(), token, "")
- // Token should fail - either as revoked or identity not found
require.Error(t, err)
}
@@ -564,14 +548,12 @@ func TestValidateServiceToken_Errors(t *testing.T) {
func TestValidateServiceToken_Valid(t *testing.T) {
nodejs := stack.NodeJS()
- // Create a project with an environment
projName := "test-st-valid-" + uuid.New().String()[:8]
proj := nodejs.CreateProject(t, projName)
t.Cleanup(func() {
nodejs.DeleteProject(t, proj.ID)
})
- // Create a service token (no expiry)
st := nodejs.CreateServiceToken(t, proj.ID, "dev", nil)
t.Cleanup(func() {
nodejs.DeleteServiceToken(t, st.ID)
@@ -589,7 +571,6 @@ func TestValidateServiceToken_Valid(t *testing.T) {
func TestValidateServiceToken_WrongSecret(t *testing.T) {
nodejs := stack.NodeJS()
- // Create a project and service token
projName := "test-st-wrongsec-" + uuid.New().String()[:8]
proj := nodejs.CreateProject(t, projName)
t.Cleanup(func() {
@@ -601,8 +582,6 @@ func TestValidateServiceToken_WrongSecret(t *testing.T) {
nodejs.DeleteServiceToken(t, st.ID)
})
- // Extract the token ID and use a wrong secret
- // Token format: st.<id>.<secret>
parts := strings.SplitN(st.Token, ".", 3)
require.Len(t, parts, 3)
wrongToken := "st." + parts[1] + ".wrong-secret-here"
@@ -616,24 +595,19 @@ func TestValidateServiceToken_WrongSecret(t *testing.T) {
func TestValidateServiceToken_Expired(t *testing.T) {
nodejs := stack.NodeJS()
- // Create a project
projName := "test-st-expired-" + uuid.New().String()[:8]
proj := nodejs.CreateProject(t, projName)
t.Cleanup(func() {
nodejs.DeleteProject(t, proj.ID)
})
- // Create a service token that expires in 1 second
expiresIn := 1
st := nodejs.CreateServiceToken(t, proj.ID, "dev", &expiresIn)
- // No cleanup needed - token is auto-deleted when expired
- // Wait for expiration
time.Sleep(2 * time.Second)
_, err := authenticator.ValidateServiceToken(context.Background(), st.Token)
- // Should fail - token is expired (and possibly deleted)
require.Error(t, err)
}
@@ -644,7 +618,6 @@ func TestValidateServiceToken_Expired(t *testing.T) {
func TestValidateIdentityAccessToken_NumUsesLimitExhausted(t *testing.T) {
nodejs := stack.NodeJS()
- // Create identity with numUsesLimit
projName := "test-numlimit-" + uuid.New().String()[:8]
proj := nodejs.CreateProject(t, projName)
t.Cleanup(func() {
@@ -654,11 +627,8 @@ func TestValidateIdentityAccessToken_NumUsesLimitExhausted(t *testing.T) {
identity := nodejs.CreateIdentity(t, "identity-numlimit-"+uuid.New().String()[:8])
nodejs.AddIdentityToProject(t, proj.ID, identity.ID, infra.Role("admin"))
- // Get token - this creates universal auth with default settings (no limit)
- // We need to set up the limit in Redis manually since the token is already issued
token := nodejs.GetIdentityAccessToken(t, identity.ID)
- // Parse to get token ID
claims := &apiauth.IdentityJWTClaims{}
_, _ = jwt.ParseWithClaims(token, claims, func(_ *jwt.Token) (any, error) {
return []byte(infra.AuthSecret), nil
@@ -669,13 +639,10 @@ func TestValidateIdentityAccessToken_NumUsesLimitExhausted(t *testing.T) {
tokenID = claims.IdentityAccessTokenID
}
- // Set uses remaining to 0 in keystore (simulating exhausted limit)
key := "identity-token-uses-remaining:" + identity.ID + ":" + tokenID
err := memKeyStore.SetItem(context.Background(), key, "0")
require.NoError(t, err)
- // Create a new authenticator that checks numUsesLimit
- // We need to sign a token WITH numUsesLimit claim
tokenWithLimit := signIdentityJWT(t, infra.AuthSecret, func(c *apiauth.IdentityJWTClaims) {
c.IdentityID = uuid.MustParse(identity.ID)
c.OrgID = uuid.MustParse(stack.NodeJS().OrgID())
@@ -683,7 +650,7 @@ func TestValidateIdentityAccessToken_NumUsesLimitExhausted(t *testing.T) {
c.ParentOrgID = uuid.MustParse(stack.NodeJS().OrgID())
c.AuthMethod = "universal-auth"
c.AccessTokenTTL = 3600
- c.NumUsesLimit = 5 // Has a limit
+ c.NumUsesLimit = 5
c.ID = tokenID
})
@@ -698,8 +665,6 @@ func TestValidateIdentityAccessToken_NumUsesLimitExhausted(t *testing.T) {
// =============================================================================
func TestValidateJWT_UserToken_AlgNoneAttack(t *testing.T) {
- // Create a token with alg=none - this should be rejected
- // JWT with alg:none has no signature
header := base64URLEncode(`{"alg":"none","typ":"JWT"}`)
payload := base64URLEncode(`{"authTokenType":"accessToken","userId":"` + stack.NodeJS().UserID() + `"}`)
algNoneToken := header + "." + payload + "."
@@ -710,8 +675,6 @@ func TestValidateJWT_UserToken_AlgNoneAttack(t *testing.T) {
}
func TestValidateJWT_UserToken_WrongAlgorithm(t *testing.T) {
- // Try to use RS256 when the server expects HS256
- // This tests that the server properly validates the algorithm
token := jwt.NewWithClaims(jwt.SigningMethodHS384, &apiauth.UserJWTClaims{
AuthTokenType: auth.AuthTokenTypeAccessToken,
UserID: uuid.MustParse(stack.NodeJS().UserID()),
@@ -723,13 +686,11 @@ func TestValidateJWT_UserToken_WrongAlgorithm(t *testing.T) {
IssuedAt: jwt.NewNumericDate(time.Now()),
},
})
- // Sign with the correct secret but wrong algorithm
tokenString, err := token.SignedString([]byte(infra.AuthSecret))
require.NoError(t, err)
_, err = authenticator.ValidateJWT(context.Background(), tokenString)
- // Should fail because algorithm doesn't match
assertUnauthorized(t, err)
}
@@ -740,7 +701,6 @@ func TestValidateJWT_UserToken_WrongAlgorithm(t *testing.T) {
func TestValidateIdentityAccessToken_LegacyRevoked(t *testing.T) {
nodejs := stack.NodeJS()
- // Create identity
projName := "test-legacy-rev-" + uuid.New().String()[:8]
proj := nodejs.CreateProject(t, projName)
t.Cleanup(func() {
@@ -750,8 +710,6 @@ func TestValidateIdentityAccessToken_LegacyRevoked(t *testing.T) {
identity := nodejs.CreateIdentity(t, "identity-legacy-"+uuid.New().String()[:8])
nodejs.AddIdentityToProject(t, proj.ID, identity.ID, infra.Role("admin"))
- // Create a legacy-style token (without full renew claims) that points to a DB row
- // Insert a revoked token row directly into DB
tokenID := uuid.New()
identityID := uuid.MustParse(identity.ID)
@@ -770,12 +728,9 @@ func TestValidateIdentityAccessToken_LegacyRevoked(t *testing.T) {
pgx.NamedArgs{"tokenID": tokenID})
})
- // Create a legacy token (no full renew claims) pointing to this DB row
legacyToken := signIdentityJWT(t, infra.AuthSecret, func(c *apiauth.IdentityJWTClaims) {
c.IdentityID = identityID
c.IdentityAccessTokenID = tokenID.String()
- // Don't set OrgID, RootOrgID, ParentOrgID, AuthMethod, AccessTokenTTL
- // This makes HasFullRenewClaims() return false, triggering legacy DB lookup
c.OrgID = uuid.Nil
c.RootOrgID = uuid.Nil
c.ParentOrgID = uuid.Nil
@@ -825,31 +780,3 @@ func TestValidateJWT_MalformedTokens(t *testing.T) {
})
}
}
-
-// =============================================================================
-// TODO(go:akhilmhdh): Missing Edge Cases
-// =============================================================================
-//
-// The following edge cases are not yet covered by tests. They require additional
-// setup (EE features, complex fixtures) or test infrastructure not yet available.
-//
-// JWT/User Token:
-// - TODO: Sub-organization scoping (claims.SubOrganizationID set) - requires EE sub-org feature
-// - TODO: Sub-org doesn't belong to root org (forbidden case)
-// - TODO: Org membership inactive
-// - TODO: Group-based org membership (actorGroupId IN (...) branch)
-// - TODO: SuperAdmin field propagation onto Identity
-// - TODO: IsMfaVerified/MfaMethod field propagation onto Identity
-// - TODO: AuthMethod field propagation onto Identity
-//
-// Identity Access Token:
-// - TODO: IdentityAuth claims propagation (OIDC details)
-// - TODO: IdentityAuth claims propagation (Kubernetes details)
-// - TODO: IdentityAuth claims propagation (AWS details)
-// - TODO: Sub-org scoping for identity tokens
-// - TODO: Explicit test for new-format token path (HasFullRenewClaims=true)
-// - TODO: Explicit test for legacy DB-lookup path (HasFullRenewClaims=false)
-//
-// Cross-cutting:
-// - TODO: HTTPInfoMiddleware propagation (IPAddress/UserAgent onto Identity)
-// - TODO: IP blocklist check (currently bypassed with empty string)
diff --git a/backend-go/internal/ee/services/externalkms/externalkms_integration_test.go b/backend-go/tests/platform/externalkms/externalkms_test.go
similarity index 98%
rename from backend-go/internal/ee/services/externalkms/externalkms_integration_test.go
rename to backend-go/tests/platform/externalkms/externalkms_test.go
index 52e9e594a7..7fd13fde24 100644
--- a/backend-go/internal/ee/services/externalkms/externalkms_integration_test.go
+++ b/backend-go/tests/platform/externalkms/externalkms_test.go
@@ -10,8 +10,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/infisical/api/internal/ee/services/externalkms"
- "github.com/infisical/api/internal/testutil"
- "github.com/infisical/api/internal/testutil/infra"
+ "github.com/infisical/api/tests/infra"
)
// Secret keys in Infisical /platform folder.
@@ -33,7 +32,7 @@ const (
func newService(t *testing.T) *externalkms.Service {
t.Helper()
- svc, err := externalkms.NewService(context.Background(), testutil.NopLogger(), &externalkms.Deps{})
+ svc, err := externalkms.NewService(context.Background(), infra.NopLogger(), &externalkms.Deps{})
require.NoError(t, err)
return svc
}
diff --git a/backend-go/internal/ee/services/hsm/hsm_integration_test.go b/backend-go/tests/platform/hsm/hsm_test.go
similarity index 97%
rename from backend-go/internal/ee/services/hsm/hsm_integration_test.go
rename to backend-go/tests/platform/hsm/hsm_test.go
index 0f7ed3e4ba..f2ff65cfd9 100644
--- a/backend-go/internal/ee/services/hsm/hsm_integration_test.go
+++ b/backend-go/tests/platform/hsm/hsm_test.go
@@ -12,7 +12,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/infisical/api/internal/ee/services/hsm"
- "github.com/infisical/api/internal/testutil/infra"
+ "github.com/infisical/api/tests/infra"
)
var runner = infra.NewContainerTest(
@@ -20,7 +20,7 @@ var runner = infra.NewContainerTest(
"INFISICAL_HSM_TEST_INSIDE",
"INFISICAL_RUN_HSM_CONTAINER_TEST",
).
- WithTestPath("./internal/ee/services/hsm/...").
+ WithTestPath("./tests/platform/hsm/...").
WithBuildTags("integration").
WithEnv("SOFTHSM2_LIB", "/usr/lib/softhsm/libsofthsm2.so")
diff --git a/backend-go/internal/services/kms/kms_integration_test.go b/backend-go/tests/platform/kms/kms_test.go
similarity index 98%
rename from backend-go/internal/services/kms/kms_integration_test.go
rename to backend-go/tests/platform/kms/kms_test.go
index e86ae22816..6639c63fc3 100644
--- a/backend-go/internal/services/kms/kms_integration_test.go
+++ b/backend-go/tests/platform/kms/kms_test.go
@@ -15,8 +15,7 @@ import (
"github.com/infisical/api/internal/ee/services/externalkms"
"github.com/infisical/api/internal/services/kms"
- "github.com/infisical/api/internal/testutil"
- "github.com/infisical/api/internal/testutil/infra"
+ "github.com/infisical/api/tests/infra"
)
var stack *infra.Stack
@@ -35,7 +34,7 @@ func TestMain(m *testing.M) {
func startedService(t *testing.T) *kms.Service {
t.Helper()
- svc, err := kms.NewService(context.Background(), testutil.NopLogger(), &kms.Deps{
+ svc, err := kms.NewService(context.Background(), infra.NopLogger(), &kms.Deps{
DB: stack.DB(),
HSM: nil,
ExternalKms: nil,
@@ -276,7 +275,7 @@ func TestCreateCipherPair_EmptyProjectIDFails(t *testing.T) {
func startedServiceWithExternalKms(t *testing.T, extKms kms.ExternalKmsService) *kms.Service {
t.Helper()
- svc, err := kms.NewService(context.Background(), testutil.NopLogger(), &kms.Deps{
+ svc, err := kms.NewService(context.Background(), infra.NopLogger(), &kms.Deps{
DB: stack.DB(),
HSM: nil,
ExternalKms: extKms,
diff --git a/backend-go/internal/services/permission/permission_integration_test.go b/backend-go/tests/platform/permission/permission_test.go
similarity index 64%
rename from backend-go/internal/services/permission/permission_integration_test.go
rename to backend-go/tests/platform/permission/permission_test.go
index 561314707e..39c0e3e914 100644
--- a/backend-go/internal/services/permission/permission_integration_test.go
+++ b/backend-go/tests/platform/permission/permission_test.go
@@ -16,8 +16,7 @@ import (
"github.com/infisical/api/internal/services/auth"
"github.com/infisical/api/internal/services/permission"
"github.com/infisical/api/internal/services/permission/project"
- "github.com/infisical/api/internal/testutil"
- "github.com/infisical/api/internal/testutil/infra"
+ "github.com/infisical/api/tests/infra"
)
var (
@@ -40,7 +39,7 @@ func TestMain(m *testing.M) {
}
func newPermissionService() *permission.Service {
- return permission.NewService(context.Background(), testutil.NopLogger(), &permission.Deps{DB: stack.DB()})
+ return permission.NewService(context.Background(), infra.NopLogger(), &permission.Deps{DB: stack.DB()})
}
func getProjectPermission(t *testing.T, actorType auth.ActorType, actorID string) *permission.GetProjectPermissionResult {
@@ -73,42 +72,34 @@ func TestIdentityAdmin_CanDoEverything(t *testing.T) {
result := getProjectPermission(t, auth.ActorTypeIdentity, identity.ID)
ability := result.Permission.Ability
- // Secrets CRUD
assert.True(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{}))
assert.True(t, gocasl.Can(ability, project.SecretActionCreate, project.SecretSubject{}))
assert.True(t, gocasl.Can(ability, project.SecretActionEdit, project.SecretSubject{}))
assert.True(t, gocasl.Can(ability, project.SecretActionDelete, project.SecretSubject{}))
- // Secret folders CRUD
assert.True(t, gocasl.Can(ability, project.SecretFolderActionRead, project.SecretFolderSubject{}))
assert.True(t, gocasl.Can(ability, project.SecretFolderActionCreate, project.SecretFolderSubject{}))
assert.True(t, gocasl.Can(ability, project.SecretFolderActionEdit, project.SecretFolderSubject{}))
assert.True(t, gocasl.Can(ability, project.SecretFolderActionDelete, project.SecretFolderSubject{}))
- // Members
assert.True(t, gocasl.Can(ability, project.MemberActionRead, project.MemberSubject{}))
assert.True(t, gocasl.Can(ability, project.MemberActionCreate, project.MemberSubject{}))
assert.True(t, gocasl.Can(ability, project.MemberActionEdit, project.MemberSubject{}))
assert.True(t, gocasl.Can(ability, project.MemberActionDelete, project.MemberSubject{}))
- // Project management
assert.True(t, gocasl.Can(ability, project.ProjectActionEdit, project.ProjectSubject{}))
assert.True(t, gocasl.Can(ability, project.ProjectActionDelete, project.ProjectSubject{}))
- // Roles
assert.True(t, gocasl.Can(ability, project.RoleActionRead, project.RoleSubject{}))
assert.True(t, gocasl.Can(ability, project.RoleActionCreate, project.RoleSubject{}))
- // Identity management
assert.True(t, gocasl.Can(ability, project.IdentityActionRead, project.IdentitySubject{}))
assert.True(t, gocasl.Can(ability, project.IdentityActionCreate, project.IdentitySubject{}))
assert.True(t, gocasl.Can(ability, project.IdentityActionGrantPrivileges, project.IdentitySubject{}))
- // Environments
assert.True(t, gocasl.Can(ability, project.EnvironmentsActionRead, project.EnvironmentsSubject{}))
assert.True(t, gocasl.Can(ability, project.EnvironmentsActionCreate, project.EnvironmentsSubject{}))
- // HasRole
assert.True(t, result.HasRole("admin"))
assert.False(t, result.HasRole("viewer"))
}
@@ -121,24 +112,19 @@ func TestIdentityMember_LimitedAccess(t *testing.T) {
result := getProjectPermission(t, auth.ActorTypeIdentity, identity.ID)
ability := result.Permission.Ability
- // Members CAN read/create/edit/delete secrets
assert.True(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{}))
assert.True(t, gocasl.Can(ability, project.SecretActionCreate, project.SecretSubject{}))
assert.True(t, gocasl.Can(ability, project.SecretActionEdit, project.SecretSubject{}))
assert.True(t, gocasl.Can(ability, project.SecretActionDelete, project.SecretSubject{}))
- // Members CAN manage secret folders
assert.True(t, gocasl.Can(ability, project.SecretFolderActionRead, project.SecretFolderSubject{}))
assert.True(t, gocasl.Can(ability, project.SecretFolderActionCreate, project.SecretFolderSubject{}))
- // Members CANNOT delete project
assert.False(t, gocasl.Can(ability, project.ProjectActionDelete, project.ProjectSubject{}))
- // Members CANNOT grant privileges
assert.False(t, gocasl.Can(ability, project.MemberActionGrantPrivileges, project.MemberSubject{}))
assert.False(t, gocasl.Can(ability, project.IdentityActionGrantPrivileges, project.IdentitySubject{}))
- // HasRole
assert.True(t, result.HasRole("member"))
assert.False(t, result.HasRole("admin"))
}
@@ -151,7 +137,6 @@ func TestIdentityViewer_ReadOnly(t *testing.T) {
result := getProjectPermission(t, auth.ActorTypeIdentity, identity.ID)
ability := result.Permission.Ability
- // Viewers CAN read (viewer has describeSecret + readValue, not the combined "read" action)
assert.True(t, gocasl.Can(ability, project.SecretActionDescribeSecret, project.SecretSubject{}))
assert.True(t, gocasl.Can(ability, project.SecretActionReadValue, project.SecretSubject{}))
assert.True(t, gocasl.Can(ability, project.SecretFolderActionRead, project.SecretFolderSubject{}))
@@ -162,30 +147,23 @@ func TestIdentityViewer_ReadOnly(t *testing.T) {
assert.True(t, gocasl.Can(ability, project.RoleActionRead, project.RoleSubject{}))
assert.True(t, gocasl.Can(ability, project.AuditLogsActionRead, project.AuditLogsSubject{}))
- // Viewer does NOT have the combined "read" (describeAndReadValue) action
assert.False(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{}))
- // Viewers CANNOT write secrets
assert.False(t, gocasl.Can(ability, project.SecretActionCreate, project.SecretSubject{}))
assert.False(t, gocasl.Can(ability, project.SecretActionEdit, project.SecretSubject{}))
assert.False(t, gocasl.Can(ability, project.SecretActionDelete, project.SecretSubject{}))
- // Viewers CANNOT write folders
assert.False(t, gocasl.Can(ability, project.SecretFolderActionCreate, project.SecretFolderSubject{}))
assert.False(t, gocasl.Can(ability, project.SecretFolderActionEdit, project.SecretFolderSubject{}))
assert.False(t, gocasl.Can(ability, project.SecretFolderActionDelete, project.SecretFolderSubject{}))
- // Viewers CANNOT manage members
assert.False(t, gocasl.Can(ability, project.MemberActionCreate, project.MemberSubject{}))
assert.False(t, gocasl.Can(ability, project.MemberActionDelete, project.MemberSubject{}))
- // Viewers CANNOT delete project
assert.False(t, gocasl.Can(ability, project.ProjectActionDelete, project.ProjectSubject{}))
- // Viewers CANNOT manage dynamic secrets
assert.False(t, gocasl.Can(ability, project.DynamicSecretActionCreateRootCredential, project.DynamicSecretSubject{}))
- // HasRole
assert.True(t, result.HasRole("viewer"))
}
@@ -197,7 +175,6 @@ func TestIdentityNoAccess_DeniedEverything(t *testing.T) {
result := getProjectPermission(t, auth.ActorTypeIdentity, identity.ID)
ability := result.Permission.Ability
- // No-access CANNOT do anything
assert.False(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{}))
assert.False(t, gocasl.Can(ability, project.SecretActionCreate, project.SecretSubject{}))
assert.False(t, gocasl.Can(ability, project.SecretFolderActionRead, project.SecretFolderSubject{}))
@@ -205,13 +182,11 @@ func TestIdentityNoAccess_DeniedEverything(t *testing.T) {
assert.False(t, gocasl.Can(ability, project.ProjectActionDelete, project.ProjectSubject{}))
assert.False(t, gocasl.Can(ability, project.IdentityActionRead, project.IdentitySubject{}))
- // HasRole
assert.True(t, result.HasRole("no-access"))
}
func TestIdentityNotMember_Forbidden(t *testing.T) {
nodejs := stack.NodeJS()
- // Create identity but do NOT add to project
identity := nodejs.CreateIdentity(t, "outsider-identity")
ctx := context.Background()
@@ -241,7 +216,6 @@ func TestUserAdmin_CanDoEverything(t *testing.T) {
result := getProjectPermission(t, auth.ActorTypeUser, user.ID)
ability := result.Permission.Ability
- // Admin can do everything
assert.True(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{}))
assert.True(t, gocasl.Can(ability, project.SecretActionCreate, project.SecretSubject{}))
assert.True(t, gocasl.Can(ability, project.SecretActionEdit, project.SecretSubject{}))
@@ -263,13 +237,11 @@ func TestUserViewer_ReadOnly(t *testing.T) {
result := getProjectPermission(t, auth.ActorTypeUser, user.ID)
ability := result.Permission.Ability
- // Can read (viewer has describeSecret + readValue, not combined "read")
assert.True(t, gocasl.Can(ability, project.SecretActionDescribeSecret, project.SecretSubject{}))
assert.True(t, gocasl.Can(ability, project.SecretActionReadValue, project.SecretSubject{}))
assert.True(t, gocasl.Can(ability, project.SecretFolderActionRead, project.SecretFolderSubject{}))
assert.True(t, gocasl.Can(ability, project.MemberActionRead, project.MemberSubject{}))
- // Cannot write
assert.False(t, gocasl.Can(ability, project.SecretActionCreate, project.SecretSubject{}))
assert.False(t, gocasl.Can(ability, project.SecretActionEdit, project.SecretSubject{}))
assert.False(t, gocasl.Can(ability, project.SecretActionDelete, project.SecretSubject{}))
@@ -311,7 +283,6 @@ func TestWrongProjectType_BadRequest(t *testing.T) {
ctx := context.Background()
svc := newPermissionService()
- // Project is secret-manager, but we request certificate-manager
_, err := svc.GetProjectPermission(ctx, &permission.GetProjectPermissionArgs{
Actor: auth.ActorTypeIdentity,
ActorID: uuid.MustParse(identity.ID),
@@ -330,8 +301,6 @@ func TestProjectTypeAny_Allowed(t *testing.T) {
nodejs.AddIdentityToProject(t, proj.ID, identity.ID, infra.Role("viewer"))
result := getProjectPermission(t, auth.ActorTypeIdentity, identity.ID)
- // ActionProjectTypeAny is used by getProjectPermission helper via ActionProjectTypeSecretManager,
- // but let's test Any explicitly
ctx := context.Background()
svc := newPermissionService()
resultAny, err := svc.GetProjectPermission(ctx, &permission.GetProjectPermissionArgs{
@@ -345,7 +314,6 @@ func TestProjectTypeAny_Allowed(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, resultAny)
- // Both should produce same abilities (viewer has describeSecret, not combined "read")
assert.True(t, gocasl.Can(result.Permission.Ability, project.SecretActionDescribeSecret, project.SecretSubject{}))
assert.True(t, gocasl.Can(resultAny.Permission.Ability, project.SecretActionDescribeSecret, project.SecretSubject{}))
}
@@ -402,9 +370,7 @@ func TestHasProjectEnforcement_ReturnsFunction(t *testing.T) {
result := getProjectPermission(t, auth.ActorTypeIdentity, identity.ID)
require.NotNil(t, result.HasProjectEnforcement)
- // Default project should not have encrypted metadata enforcement
assert.False(t, result.HasProjectEnforcement("enforceEncryptedSecretManagerSecretMetadata"))
- // Unknown enforcement should return false
assert.False(t, result.HasProjectEnforcement("nonExistentEnforcement"))
}
@@ -415,7 +381,6 @@ func TestHasProjectEnforcement_ReturnsFunction(t *testing.T) {
func TestIdentityCustomRole_SecretsReadCreateOnly(t *testing.T) {
nodejs := stack.NodeJS()
- // Create a custom role that allows only reading and creating secrets
customRole := nodejs.CreateCustomProjectRole(t, proj.ID, "secrets-read-create", "Secrets Read Create", []infra.Permission{
{
Subject: "secrets",
@@ -429,62 +394,25 @@ func TestIdentityCustomRole_SecretsReadCreateOnly(t *testing.T) {
result := getProjectPermission(t, auth.ActorTypeIdentity, identity.ID)
ability := result.Permission.Ability
- // CAN read and create secrets
assert.True(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{}))
assert.True(t, gocasl.Can(ability, project.SecretActionCreate, project.SecretSubject{}))
- // CANNOT edit or delete secrets
assert.False(t, gocasl.Can(ability, project.SecretActionEdit, project.SecretSubject{}))
assert.False(t, gocasl.Can(ability, project.SecretActionDelete, project.SecretSubject{}))
- // CANNOT do anything else
assert.False(t, gocasl.Can(ability, project.SecretFolderActionRead, project.SecretFolderSubject{}))
assert.False(t, gocasl.Can(ability, project.MemberActionRead, project.MemberSubject{}))
assert.False(t, gocasl.Can(ability, project.ProjectActionEdit, project.ProjectSubject{}))
assert.False(t, gocasl.Can(ability, project.IdentityActionRead, project.IdentitySubject{}))
- // HasRole returns the custom role slug
assert.True(t, result.HasRole(customRole.Slug))
assert.False(t, result.HasRole("admin"))
assert.False(t, result.HasRole("member"))
}
-func TestUserCustomRole_SecretsReadCreateOnly(t *testing.T) {
- nodejs := stack.NodeJS()
-
- customRole := nodejs.CreateCustomProjectRole(t, proj.ID, "user-secrets-rc", "User Secrets Read Create", []infra.Permission{
- {
- Subject: "secrets",
- Action: []string{"read", "create"},
- },
- })
-
- user := nodejs.InviteAndCreateUser(t, "[email protected]")
- nodejs.AddUserToProject(t, proj.ID, user.Email, []string{customRole.Slug})
-
- result := getProjectPermission(t, auth.ActorTypeUser, user.ID)
- ability := result.Permission.Ability
-
- // CAN read and create secrets
- assert.True(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{}))
- assert.True(t, gocasl.Can(ability, project.SecretActionCreate, project.SecretSubject{}))
-
- // CANNOT edit or delete secrets
- assert.False(t, gocasl.Can(ability, project.SecretActionEdit, project.SecretSubject{}))
- assert.False(t, gocasl.Can(ability, project.SecretActionDelete, project.SecretSubject{}))
-
- // CANNOT do anything else
- assert.False(t, gocasl.Can(ability, project.SecretFolderActionRead, project.SecretFolderSubject{}))
- assert.False(t, gocasl.Can(ability, project.MemberActionRead, project.MemberSubject{}))
- assert.False(t, gocasl.Can(ability, project.ProjectActionDelete, project.ProjectSubject{}))
-
- assert.True(t, result.HasRole(customRole.Slug))
-}
-
func TestIdentityCustomRole_EnvironmentScoped(t *testing.T) {
nodejs := stack.NodeJS()
- // Create a custom role that allows reading secrets only in "dev" environment
customRole := nodejs.CreateCustomProjectRole(t, proj.ID, "dev-reader", "Dev Secret Reader", []infra.Permission{
{
Subject: "secrets",
@@ -501,17 +429,13 @@ func TestIdentityCustomRole_EnvironmentScoped(t *testing.T) {
result := getProjectPermission(t, auth.ActorTypeIdentity, identity.ID)
ability := result.Permission.Ability
- // CAN read secrets in "dev" environment
assert.True(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{Environment: "dev"}))
- // CANNOT read secrets in other environments
assert.False(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{Environment: "production"}))
assert.False(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{Environment: "staging"}))
- // CANNOT read secrets without specifying environment (empty doesn't match "dev")
assert.False(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{}))
- // CANNOT create/edit/delete even in dev
assert.False(t, gocasl.Can(ability, project.SecretActionCreate, project.SecretSubject{Environment: "dev"}))
assert.False(t, gocasl.Can(ability, project.SecretActionEdit, project.SecretSubject{Environment: "dev"}))
assert.False(t, gocasl.Can(ability, project.SecretActionDelete, project.SecretSubject{Environment: "dev"}))
@@ -520,7 +444,6 @@ func TestIdentityCustomRole_EnvironmentScoped(t *testing.T) {
func TestIdentityCustomRole_GlobSecretPath(t *testing.T) {
nodejs := stack.NodeJS()
- // Create a custom role with $glob condition on secretPath
customRole := nodejs.CreateCustomProjectRole(t, proj.ID, "path-reader", "Path Scoped Reader", []infra.Permission{
{
Subject: "secrets",
@@ -539,15 +462,12 @@ func TestIdentityCustomRole_GlobSecretPath(t *testing.T) {
result := getProjectPermission(t, auth.ActorTypeIdentity, identity.ID)
ability := result.Permission.Ability
- // CAN read secrets under /app/
assert.True(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{SecretPath: "/app/config"}))
assert.True(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{SecretPath: "/app/nested/deep"}))
- // CANNOT read secrets outside /app/
assert.False(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{SecretPath: "/other/path"}))
assert.False(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{SecretPath: "/"}))
- // CANNOT read without path (empty doesn't match /app/**)
assert.False(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{}))
}
@@ -566,7 +486,6 @@ func TestGroupAdmin_UserInheritsFullAccess(t *testing.T) {
result := getProjectPermission(t, auth.ActorTypeUser, user.ID)
ability := result.Permission.Ability
- // User inherits admin permissions through group
assert.True(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{}))
assert.True(t, gocasl.Can(ability, project.SecretActionCreate, project.SecretSubject{}))
assert.True(t, gocasl.Can(ability, project.SecretActionEdit, project.SecretSubject{}))
@@ -589,83 +508,17 @@ func TestGroupViewer_UserInheritsReadOnly(t *testing.T) {
result := getProjectPermission(t, auth.ActorTypeUser, user.ID)
ability := result.Permission.Ability
- // User inherits viewer permissions through group (describeSecret + readValue, not combined "read")
assert.True(t, gocasl.Can(ability, project.SecretActionDescribeSecret, project.SecretSubject{}))
assert.True(t, gocasl.Can(ability, project.SecretActionReadValue, project.SecretSubject{}))
assert.True(t, gocasl.Can(ability, project.SecretFolderActionRead, project.SecretFolderSubject{}))
assert.True(t, gocasl.Can(ability, project.MemberActionRead, project.MemberSubject{}))
- // Cannot write
assert.False(t, gocasl.Can(ability, project.SecretActionCreate, project.SecretSubject{}))
assert.False(t, gocasl.Can(ability, project.SecretActionEdit, project.SecretSubject{}))
assert.False(t, gocasl.Can(ability, project.SecretActionDelete, project.SecretSubject{}))
assert.False(t, gocasl.Can(ability, project.ProjectActionDelete, project.ProjectSubject{}))
}
-func TestGroupCustomRole_UserInheritsCustomPermissions(t *testing.T) {
- nodejs := stack.NodeJS()
-
- customRole := nodejs.CreateCustomProjectRole(t, proj.ID, "group-secrets-ro", "Group Secrets ReadOnly", []infra.Permission{
- {
- Subject: "secrets",
- Action: []string{"read"},
- },
- {
- Subject: "secret-folders",
- Action: []string{"read"},
- },
- })
-
- group := nodejs.CreateGroup(t, "custom-role-group")
- user := nodejs.InviteAndCreateUser(t, "[email protected]")
- nodejs.AddUserToGroup(t, group.ID, user.Email)
- nodejs.AddGroupToProject(t, proj.ID, group.ID, customRole.Slug)
-
- result := getProjectPermission(t, auth.ActorTypeUser, user.ID)
- ability := result.Permission.Ability
-
- // CAN read secrets and folders through group's custom role
- assert.True(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{}))
- assert.True(t, gocasl.Can(ability, project.SecretFolderActionRead, project.SecretFolderSubject{}))
-
- // CANNOT write secrets or folders
- assert.False(t, gocasl.Can(ability, project.SecretActionCreate, project.SecretSubject{}))
- assert.False(t, gocasl.Can(ability, project.SecretActionEdit, project.SecretSubject{}))
- assert.False(t, gocasl.Can(ability, project.SecretActionDelete, project.SecretSubject{}))
- assert.False(t, gocasl.Can(ability, project.SecretFolderActionCreate, project.SecretFolderSubject{}))
-
- // CANNOT do anything else
- assert.False(t, gocasl.Can(ability, project.MemberActionRead, project.MemberSubject{}))
- assert.False(t, gocasl.Can(ability, project.ProjectActionEdit, project.ProjectSubject{}))
- assert.False(t, gocasl.Can(ability, project.IdentityActionRead, project.IdentitySubject{}))
-
- assert.True(t, result.HasRole(customRole.Slug))
-}
-
-func TestGroupNotMember_UserDenied(t *testing.T) {
- nodejs := stack.NodeJS()
-
- // Create group and add to project, but user is NOT in the group
- group := nodejs.CreateGroup(t, "exclusive-group")
- nodejs.AddGroupToProject(t, proj.ID, group.ID, "admin")
-
- user := nodejs.InviteAndCreateUser(t, "[email protected]")
-
- ctx := context.Background()
- svc := newPermissionService()
-
- _, err := svc.GetProjectPermission(ctx, &permission.GetProjectPermissionArgs{
- Actor: auth.ActorTypeUser,
- ActorID: uuid.MustParse(user.ID),
- ProjectID: proj.ID,
- ActorAuthMethod: "",
- ActorOrgID: uuid.MustParse(nodejs.OrgID()),
- ActionProjectType: permission.ActionProjectTypeSecretManager,
- })
- require.Error(t, err)
- assert.Contains(t, err.Error(), "not a member")
-}
-
// ===========================
// Additional privilege tests
// ===========================
@@ -673,7 +526,6 @@ func TestGroupNotMember_UserDenied(t *testing.T) {
func TestIdentityAdditionalPrivilege_ExtendsRole(t *testing.T) {
nodejs := stack.NodeJS()
- // Give identity viewer role (read-only) then add additional privilege for secret creation
identity := nodejs.CreateIdentity(t, "addl-priv-identity")
nodejs.AddIdentityToProject(t, proj.ID, identity.ID, infra.Role("viewer"))
nodejs.CreateIdentityAdditionalPrivilege(t, identity.ID, proj.ID, []infra.Permission{
@@ -686,123 +538,16 @@ func TestIdentityAdditionalPrivilege_ExtendsRole(t *testing.T) {
result := getProjectPermission(t, auth.ActorTypeIdentity, identity.ID)
ability := result.Permission.Ability
- // Base viewer permissions still work
assert.True(t, gocasl.Can(ability, project.SecretActionDescribeSecret, project.SecretSubject{}))
assert.True(t, gocasl.Can(ability, project.SecretActionReadValue, project.SecretSubject{}))
assert.True(t, gocasl.Can(ability, project.SecretFolderActionRead, project.SecretFolderSubject{}))
- // Additional privilege grants create
assert.True(t, gocasl.Can(ability, project.SecretActionCreate, project.SecretSubject{}))
- // Still cannot edit/delete (not in viewer or additional privilege)
assert.False(t, gocasl.Can(ability, project.SecretActionEdit, project.SecretSubject{}))
assert.False(t, gocasl.Can(ability, project.SecretActionDelete, project.SecretSubject{}))
}
-func TestIdentityAdditionalPrivilege_WithConditions(t *testing.T) {
- nodejs := stack.NodeJS()
-
- // Give identity no-access role, then add scoped additional privilege
- identity := nodejs.CreateIdentity(t, "addl-priv-scoped-identity")
- nodejs.AddIdentityToProject(t, proj.ID, identity.ID, infra.Role("no-access"))
- nodejs.CreateIdentityAdditionalPrivilege(t, identity.ID, proj.ID, []infra.Permission{
- {
- Subject: "secrets",
- Action: "read",
- Conditions: map[string]any{
- "environment": "dev",
- },
- },
- }, nil)
-
- result := getProjectPermission(t, auth.ActorTypeIdentity, identity.ID)
- ability := result.Permission.Ability
-
- // CAN read secrets in dev via additional privilege
- assert.True(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{Environment: "dev"}))
-
- // CANNOT read in other environments
- assert.False(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{Environment: "production"}))
- assert.False(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{}))
-
- // CANNOT write even in dev
- assert.False(t, gocasl.Can(ability, project.SecretActionCreate, project.SecretSubject{Environment: "dev"}))
-}
-
-func TestUserAdditionalPrivilege_ExtendsRole(t *testing.T) {
- nodejs := stack.NodeJS()
-
- // Create project using user JWT so bootstrap user is automatically a member.
- // This is needed because the user additional privilege API requires user JWT auth.
- testProj := nodejs.CreateProject(t, "user-addl-priv-test")
-
- // Give user viewer role, then add additional privilege for secret edit
- user := nodejs.InviteAndCreateUser(t, "[email protected]")
- nodejs.AddUserToProject(t, testProj.ID, user.Email, []string{"viewer"})
- nodejs.CreateUserAdditionalPrivilege(t, user.ID, testProj.ID, []infra.Permission{
- {
- Subject: "secrets",
- Action: "edit",
- },
- })
-
- // Use testProj.ID instead of the shared proj.ID
- svc := newPermissionService()
- result, err := svc.GetProjectPermission(context.Background(), &permission.GetProjectPermissionArgs{
- Actor: auth.ActorTypeUser,
- ActorID: uuid.MustParse(user.ID),
- ProjectID: testProj.ID,
- ActorAuthMethod: "",
- ActorOrgID: uuid.MustParse(nodejs.OrgID()),
- ActionProjectType: permission.ActionProjectTypeSecretManager,
- })
- require.NoError(t, err)
- ability := result.Permission.Ability
-
- // Base viewer permissions
- assert.True(t, gocasl.Can(ability, project.SecretActionDescribeSecret, project.SecretSubject{}))
- assert.True(t, gocasl.Can(ability, project.SecretActionReadValue, project.SecretSubject{}))
-
- // Additional privilege grants edit
- assert.True(t, gocasl.Can(ability, project.SecretActionEdit, project.SecretSubject{}))
-
- // Still cannot create/delete
- assert.False(t, gocasl.Can(ability, project.SecretActionCreate, project.SecretSubject{}))
- assert.False(t, gocasl.Can(ability, project.SecretActionDelete, project.SecretSubject{}))
-}
-
-func TestIdentityMultipleAdditionalPrivileges_Merge(t *testing.T) {
- nodejs := stack.NodeJS()
-
- // Give identity no-access role, add two separate additional privileges
- identity := nodejs.CreateIdentity(t, "multi-addl-priv-identity")
- nodejs.AddIdentityToProject(t, proj.ID, identity.ID, infra.Role("no-access"))
-
- nodejs.CreateIdentityAdditionalPrivilege(t, identity.ID, proj.ID, []infra.Permission{
- {
- Subject: "secrets",
- Action: "read",
- },
- }, nil)
- nodejs.CreateIdentityAdditionalPrivilege(t, identity.ID, proj.ID, []infra.Permission{
- {
- Subject: "secret-folders",
- Action: "read",
- },
- }, nil)
-
- result := getProjectPermission(t, auth.ActorTypeIdentity, identity.ID)
- ability := result.Permission.Ability
-
- // Both additional privileges are merged
- assert.True(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{}))
- assert.True(t, gocasl.Can(ability, project.SecretFolderActionRead, project.SecretFolderSubject{}))
-
- // Nothing else
- assert.False(t, gocasl.Can(ability, project.SecretActionCreate, project.SecretSubject{}))
- assert.False(t, gocasl.Can(ability, project.MemberActionRead, project.MemberSubject{}))
-}
-
// ===========================
// Temporary role tests
// ===========================
@@ -811,7 +556,6 @@ func TestIdentityTemporaryRole_ActiveGrantsAccess(t *testing.T) {
nodejs := stack.NodeJS()
identity := nodejs.CreateIdentity(t, "temp-role-active-identity")
- // API requires at least one permanent role; use no-access as the permanent base
nodejs.AddIdentityToProject(t, proj.ID, identity.ID, []infra.RoleAssignment{
{
Role: "no-access",
@@ -829,7 +573,6 @@ func TestIdentityTemporaryRole_ActiveGrantsAccess(t *testing.T) {
result := getProjectPermission(t, auth.ActorTypeIdentity, identity.ID)
ability := result.Permission.Ability
- // Active temporary admin role grants full access
assert.True(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{}))
assert.True(t, gocasl.Can(ability, project.SecretActionCreate, project.SecretSubject{}))
assert.True(t, gocasl.Can(ability, project.SecretActionEdit, project.SecretSubject{}))
@@ -841,7 +584,6 @@ func TestIdentityTemporaryRole_ExpiredDeniesAccess(t *testing.T) {
nodejs := stack.NodeJS()
identity := nodejs.CreateIdentity(t, "temp-role-expired-identity")
- // Permanent no-access + expired temporary admin (started 2h ago, range 1h)
nodejs.AddIdentityToProject(t, proj.ID, identity.ID, []infra.RoleAssignment{
{
Role: "no-access",
@@ -856,7 +598,6 @@ func TestIdentityTemporaryRole_ExpiredDeniesAccess(t *testing.T) {
},
})
- // Identity is a project member but the only role is expired → no permissions
ctx := context.Background()
svc := newPermissionService()
result, err := svc.GetProjectPermission(ctx, &permission.GetProjectPermissionArgs{
@@ -870,90 +611,8 @@ func TestIdentityTemporaryRole_ExpiredDeniesAccess(t *testing.T) {
require.NoError(t, err)
ability := result.Permission.Ability
- // Expired temporary role grants nothing
assert.False(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{}))
assert.False(t, gocasl.Can(ability, project.SecretActionCreate, project.SecretSubject{}))
assert.False(t, gocasl.Can(ability, project.ProjectActionDelete, project.ProjectSubject{}))
assert.False(t, gocasl.Can(ability, project.MemberActionRead, project.MemberSubject{}))
}
-
-func TestIdentityTemporaryRole_MixedWithPermanent(t *testing.T) {
- nodejs := stack.NodeJS()
-
- identity := nodejs.CreateIdentity(t, "temp-role-mixed-identity")
- // Permanent viewer + expired temporary admin
- nodejs.AddIdentityToProject(t, proj.ID, identity.ID, []infra.RoleAssignment{
- {
- Role: "viewer",
- IsTemporary: false,
- },
- {
- Role: "admin",
- IsTemporary: true,
- TemporaryMode: "relative",
- TemporaryRange: "1h",
- TemporaryAccessStartTime: time.Now().Add(-2 * time.Hour).UTC().Format(time.RFC3339),
- },
- })
-
- result := getProjectPermission(t, auth.ActorTypeIdentity, identity.ID)
- ability := result.Permission.Ability
-
- // Permanent viewer permissions still work
- assert.True(t, gocasl.Can(ability, project.SecretActionDescribeSecret, project.SecretSubject{}))
- assert.True(t, gocasl.Can(ability, project.SecretActionReadValue, project.SecretSubject{}))
- assert.True(t, gocasl.Can(ability, project.SecretFolderActionRead, project.SecretFolderSubject{}))
-
- // Expired admin does NOT contribute write permissions
- assert.False(t, gocasl.Can(ability, project.SecretActionCreate, project.SecretSubject{}))
- assert.False(t, gocasl.Can(ability, project.SecretActionEdit, project.SecretSubject{}))
- assert.False(t, gocasl.Can(ability, project.ProjectActionDelete, project.ProjectSubject{}))
-}
-
-// ===========================
-// Temporary additional privilege tests
-// ===========================
-
-func TestIdentityTemporaryAdditionalPrivilege_ActiveGrantsAccess(t *testing.T) {
- nodejs := stack.NodeJS()
-
- identity := nodejs.CreateIdentity(t, "temp-addl-active-identity")
- nodejs.AddIdentityToProject(t, proj.ID, identity.ID, infra.Role("no-access"))
- nodejs.CreateIdentityAdditionalPrivilege(t, identity.ID, proj.ID, []infra.Permission{
- {
- Subject: "secrets",
- Action: "read",
- },
- }, &infra.IdentityPrivilegeOpts{TemporaryRange: "1h", TemporaryAccessStartTime: time.Now().UTC().Format(time.RFC3339)})
-
- result := getProjectPermission(t, auth.ActorTypeIdentity, identity.ID)
- ability := result.Permission.Ability
-
- // Active temporary additional privilege grants read
- assert.True(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{}))
-
- // But not write
- assert.False(t, gocasl.Can(ability, project.SecretActionCreate, project.SecretSubject{}))
-}
-
-func TestIdentityTemporaryAdditionalPrivilege_ExpiredDeniesAccess(t *testing.T) {
- nodejs := stack.NodeJS()
-
- identity := nodejs.CreateIdentity(t, "temp-addl-expired-identity")
- nodejs.AddIdentityToProject(t, proj.ID, identity.ID, infra.Role("no-access"))
- // Start 2h ago, range 1h → expired
- nodejs.CreateIdentityAdditionalPrivilege(t, identity.ID, proj.ID, []infra.Permission{
- {
- Subject: "secrets",
- Action: "read",
- },
- }, &infra.IdentityPrivilegeOpts{TemporaryRange: "1h", TemporaryAccessStartTime: time.Now().Add(-2 * time.Hour).UTC().Format(time.RFC3339)})
-
- result := getProjectPermission(t, auth.ActorTypeIdentity, identity.ID)
- ability := result.Permission.Ability
-
- // Expired temporary additional privilege grants nothing (base role is no-access)
- assert.False(t, gocasl.Can(ability, project.SecretActionDescribeAndReadValue, project.SecretSubject{}))
- assert.False(t, gocasl.Can(ability, project.SecretActionCreate, project.SecretSubject{}))
- assert.False(t, gocasl.Can(ability, project.MemberActionRead, project.MemberSubject{}))
-}
diff --git a/backend-go/internal/server/api/platform/projects/projects_integration_test.go b/backend-go/tests/platform/projects/projects_test.go
similarity index 89%
rename from backend-go/internal/server/api/platform/projects/projects_integration_test.go
rename to backend-go/tests/platform/projects/projects_test.go
index 0c14885178..4b1c1c92d8 100644
--- a/backend-go/internal/server/api/platform/projects/projects_integration_test.go
+++ b/backend-go/tests/platform/projects/projects_test.go
@@ -15,8 +15,7 @@ import (
"github.com/infisical/api/internal/server/api/platform/projects"
"github.com/infisical/api/internal/services/permission"
- "github.com/infisical/api/internal/testutil"
- "github.com/infisical/api/internal/testutil/infra"
+ "github.com/infisical/api/tests/infra"
)
var stack *infra.Stack
@@ -38,10 +37,10 @@ func newProjectsRouter(t *testing.T) http.Handler {
t.Helper()
ctx := t.Context()
- permLib := permission.NewService(ctx, testutil.NopLogger(), &permission.Deps{DB: stack.DB()})
+ permLib := permission.NewService(ctx, infra.NopLogger(), &permission.Deps{DB: stack.DB()})
handler := projects.NewHandler(&projects.Deps{
- Logger: testutil.NopLogger(),
+ Logger: infra.NopLogger(),
Permission: permLib,
})
diff --git a/backend-go/internal/ee/services/ratelimit/ratelimit_integration_test.go b/backend-go/tests/platform/ratelimit/ratelimit_test.go
similarity index 96%
rename from backend-go/internal/ee/services/ratelimit/ratelimit_integration_test.go
rename to backend-go/tests/platform/ratelimit/ratelimit_test.go
index 9110fdae49..77003c2889 100644
--- a/backend-go/internal/ee/services/ratelimit/ratelimit_integration_test.go
+++ b/backend-go/tests/platform/ratelimit/ratelimit_test.go
@@ -18,8 +18,7 @@ import (
"github.com/infisical/api/internal/ee/services/license"
"github.com/infisical/api/internal/ee/services/ratelimit"
"github.com/infisical/api/internal/services/auth"
- "github.com/infisical/api/internal/testutil"
- "github.com/infisical/api/internal/testutil/infra"
+ "github.com/infisical/api/tests/infra"
)
var stack *infra.Stack
@@ -59,7 +58,7 @@ func (m *mockLicenseService) GetPlan(ctx context.Context, orgID string) (*licens
func newTestService(t *testing.T, isCloud bool) *ratelimit.Service {
t.Helper()
- return ratelimit.NewService(context.Background(), testutil.NopLogger(), &ratelimit.Deps{
+ return ratelimit.NewService(context.Background(), infra.NopLogger(), &ratelimit.Deps{
Redis: stack.Redis().Client(),
LicenseSvc: &mockLicenseService{},
IsCloud: isCloud,
@@ -78,7 +77,7 @@ func TestRedisCounter_IncrementAndGet_BasicFlow(t *testing.T) {
counter := ratelimit.NewRedisCounter(&ratelimit.RedisCounterConfig{
Client: client,
PrefixKey: "test-basic-" + t.Name(),
- Logger: testutil.NopLogger(),
+ Logger: infra.NopLogger(),
})
counter.Config(100, time.Minute)
@@ -105,7 +104,7 @@ func TestRedisCounter_Get_ReturnsZeroForNewKey(t *testing.T) {
counter := ratelimit.NewRedisCounter(&ratelimit.RedisCounterConfig{
Client: client,
PrefixKey: "test-zero-" + t.Name(),
- Logger: testutil.NopLogger(),
+ Logger: infra.NopLogger(),
})
counter.Config(100, time.Minute)
@@ -126,7 +125,7 @@ func TestRedisCounter_SeparateWindows_HaveIndependentCounts(t *testing.T) {
counter := ratelimit.NewRedisCounter(&ratelimit.RedisCounterConfig{
Client: client,
PrefixKey: "test-windows-" + t.Name(),
- Logger: testutil.NopLogger(),
+ Logger: infra.NopLogger(),
})
counter.Config(100, time.Minute)
@@ -157,7 +156,7 @@ func TestRedisCounter_DifferentKeys_HaveIndependentCounts(t *testing.T) {
counter := ratelimit.NewRedisCounter(&ratelimit.RedisCounterConfig{
Client: client,
PrefixKey: "test-keys-" + t.Name(),
- Logger: testutil.NopLogger(),
+ Logger: infra.NopLogger(),
})
counter.Config(100, time.Minute)
@@ -188,7 +187,7 @@ func TestRedisCounter_IncrementBy_IncrementsCorrectAmount(t *testing.T) {
counter := ratelimit.NewRedisCounter(&ratelimit.RedisCounterConfig{
Client: client,
PrefixKey: "test-incrby-" + t.Name(),
- Logger: testutil.NopLogger(),
+ Logger: infra.NopLogger(),
})
counter.Config(100, time.Minute)
@@ -339,7 +338,7 @@ func TestRateLimitMiddleware_UsesDynamicLimitFromPlan(t *testing.T) {
},
}
- svc := ratelimit.NewService(context.Background(), testutil.NopLogger(), &ratelimit.Deps{
+ svc := ratelimit.NewService(context.Background(), infra.NopLogger(), &ratelimit.Deps{
Redis: stack.Redis().Client(),
LicenseSvc: licenseSvc,
IsCloud: true,
diff --git a/backend-go/internal/server/api/secretmanager/secret/get_secret_by_name_integration_test.go b/backend-go/tests/secretmanager/secrets/get_secret_by_name_integration_test.go
similarity index 99%
rename from backend-go/internal/server/api/secretmanager/secret/get_secret_by_name_integration_test.go
rename to backend-go/tests/secretmanager/secrets/get_secret_by_name_integration_test.go
index 0195c03d2d..e18ce6a9a4 100644
--- a/backend-go/internal/server/api/secretmanager/secret/get_secret_by_name_integration_test.go
+++ b/backend-go/tests/secretmanager/secrets/get_secret_by_name_integration_test.go
@@ -1,6 +1,6 @@
//go:build integration
-package secret_test
+package secrets_test
import (
"encoding/json"
@@ -16,7 +16,7 @@ import (
"github.com/infisical/api/internal/server/api/secretmanager/secret"
"github.com/infisical/api/internal/server/api/shared"
"github.com/infisical/api/internal/services/auth"
- "github.com/infisical/api/internal/testutil/infra"
+ "github.com/infisical/api/tests/infra"
)
// httpGetSecretV4 makes a direct HTTP GET request to /api/v4/secrets/{secretName}
diff --git a/backend-go/internal/server/api/secretmanager/secret/get_secret_by_name_permission_integration_test.go b/backend-go/tests/secretmanager/secrets/get_secret_by_name_permission_integration_test.go
similarity index 98%
rename from backend-go/internal/server/api/secretmanager/secret/get_secret_by_name_permission_integration_test.go
rename to backend-go/tests/secretmanager/secrets/get_secret_by_name_permission_integration_test.go
index f42e8264ba..56de3fd012 100644
--- a/backend-go/internal/server/api/secretmanager/secret/get_secret_by_name_permission_integration_test.go
+++ b/backend-go/tests/secretmanager/secrets/get_secret_by_name_permission_integration_test.go
@@ -1,6 +1,6 @@
//go:build integration
-package secret_test
+package secrets_test
import (
"testing"
@@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/infisical/api/internal/services/auth"
- "github.com/infisical/api/internal/testutil/infra"
+ "github.com/infisical/api/tests/infra"
)
// =============================================================================
diff --git a/backend-go/internal/server/api/secretmanager/secret/list_secrets_integration_test.go b/backend-go/tests/secretmanager/secrets/list_secrets_integration_test.go
similarity index 99%
rename from backend-go/internal/server/api/secretmanager/secret/list_secrets_integration_test.go
rename to backend-go/tests/secretmanager/secrets/list_secrets_integration_test.go
index 84c842fe8b..ea71d22507 100644
--- a/backend-go/internal/server/api/secretmanager/secret/list_secrets_integration_test.go
+++ b/backend-go/tests/secretmanager/secrets/list_secrets_integration_test.go
@@ -1,6 +1,6 @@
//go:build integration
-package secret_test
+package secrets_test
import (
"encoding/json"
@@ -16,7 +16,7 @@ import (
"github.com/infisical/api/internal/server/api/secretmanager/secret"
"github.com/infisical/api/internal/server/api/shared"
"github.com/infisical/api/internal/services/auth"
- "github.com/infisical/api/internal/testutil/infra"
+ "github.com/infisical/api/tests/infra"
)
// httpListSecretsV4 makes a direct HTTP GET request to /api/v4/secrets
diff --git a/backend-go/internal/server/api/secretmanager/secret/list_secrets_permission_integration_test.go b/backend-go/tests/secretmanager/secrets/list_secrets_permission_integration_test.go
similarity index 99%
rename from backend-go/internal/server/api/secretmanager/secret/list_secrets_permission_integration_test.go
rename to backend-go/tests/secretmanager/secrets/list_secrets_permission_integration_test.go
index c88e1fd1e6..eb9d4def69 100644
--- a/backend-go/internal/server/api/secretmanager/secret/list_secrets_permission_integration_test.go
+++ b/backend-go/tests/secretmanager/secrets/list_secrets_permission_integration_test.go
@@ -1,6 +1,6 @@
//go:build integration
-package secret_test
+package secrets_test
import (
"testing"
@@ -10,7 +10,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/infisical/api/internal/services/auth"
- "github.com/infisical/api/internal/testutil/infra"
+ "github.com/infisical/api/tests/infra"
)
// =============================================================================
diff --git a/backend-go/internal/server/api/secretmanager/secret/main_test.go b/backend-go/tests/secretmanager/secrets/main_test.go
similarity index 92%
rename from backend-go/internal/server/api/secretmanager/secret/main_test.go
rename to backend-go/tests/secretmanager/secrets/main_test.go
index 01e71c4363..9a2492a9ba 100644
--- a/backend-go/internal/server/api/secretmanager/secret/main_test.go
+++ b/backend-go/tests/secretmanager/secrets/main_test.go
@@ -1,6 +1,6 @@
//go:build integration
-package secret_test
+package secrets_test
import (
"encoding/json"
@@ -28,8 +28,7 @@ import (
secretSvc "github.com/infisical/api/internal/services/secretmanager/secret"
"github.com/infisical/api/internal/services/secretmanager/secretfolder"
"github.com/infisical/api/internal/services/secretmanager/secretimport"
- "github.com/infisical/api/internal/testutil"
- "github.com/infisical/api/internal/testutil/infra"
+ "github.com/infisical/api/tests/infra"
)
var (
@@ -57,12 +56,12 @@ func newSecretsHandler(t *testing.T) *secret.Handler {
ctx := t.Context()
- permSvc := permission.NewService(ctx, testutil.NopLogger(), &permission.Deps{DB: stack.DB()})
+ permSvc := permission.NewService(ctx, infra.NopLogger(), &permission.Deps{DB: stack.DB()})
redisClient := stack.Redis().Client()
t.Cleanup(func() { redisClient.Close() })
- kmsSvc, err := kms.NewService(ctx, testutil.NopLogger(), &kms.Deps{
+ kmsSvc, err := kms.NewService(ctx, infra.NopLogger(), &kms.Deps{
DB: stack.DB(),
HSM: nil,
ExternalKms: nil,
@@ -73,16 +72,16 @@ func newSecretsHandler(t *testing.T) *secret.Handler {
err = kmsSvc.Start(ctx, false)
require.NoError(t, err)
- projectSvc := project.NewService(ctx, testutil.NopLogger(), &project.Deps{DB: stack.DB()})
+ projectSvc := project.NewService(ctx, infra.NopLogger(), &project.Deps{DB: stack.DB()})
- queueSvc := queue.NewService(ctx, testutil.NopLogger(), redisClient)
+ queueSvc := queue.NewService(ctx, infra.NopLogger(), redisClient)
- auditLogSvc := auditlog.NewService(ctx, testutil.NopLogger(), &auditlog.Deps{Queue: queueSvc, Config: stack.Config()})
+ auditLogSvc := auditlog.NewService(ctx, infra.NopLogger(), &auditlog.Deps{Queue: queueSvc, Config: stack.Config()})
- secretFolderSvc := secretfolder.NewService(ctx, testutil.NopLogger(), &secretfolder.Deps{DB: stack.DB()})
- secretImportSvc := secretimport.NewService(ctx, testutil.NopLogger(), &secretimport.Deps{DB: stack.DB()})
+ secretFolderSvc := secretfolder.NewService(ctx, infra.NopLogger(), &secretfolder.Deps{DB: stack.DB()})
+ secretImportSvc := secretimport.NewService(ctx, infra.NopLogger(), &secretimport.Deps{DB: stack.DB()})
- secretsSvc := secretSvc.NewService(ctx, testutil.NopLogger(), &secretSvc.Deps{
+ secretsSvc := secretSvc.NewService(ctx, infra.NopLogger(), &secretSvc.Deps{
DB: stack.DB(),
SecretFolderService: secretFolderSvc,
SecretImportService: secretImportSvc,
@@ -90,7 +89,7 @@ func newSecretsHandler(t *testing.T) *secret.Handler {
})
return secret.NewHandler(&secret.Deps{
- Logger: testutil.NopLogger(),
+ Logger: infra.NopLogger(),
Permission: permSvc,
Project: projectSvc,
AuditLog: auditLogSvc,
@@ -394,7 +393,7 @@ func newTestServer(t *testing.T, handler *secret.Handler, actorType auth.ActorTy
router := secret.NewRouter(
handler,
secret.WithMiddleware(testAuthMiddleware(actorType, actorID, orgID)),
- secret.WithErrorHandler(shared.NewErrorHandler(testutil.NopLogger())),
+ secret.WithErrorHandler(shared.NewErrorHandler(infra.NopLogger())),
)
return httptest.NewServer(router)