Skip to content

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

chore(tests): keep the generated client out of lint; accept either max-TTL refusal

Claude8c2d67341754
diff --git a/tests/AGENTS.md b/tests/AGENTS.md
index dbb9ebc919..94fbe50201 100644
--- a/tests/AGENTS.md
+++ b/tests/AGENTS.md
@@ -64,7 +64,8 @@ fixture/<product>/ one package per product: secretmanager, pki, pam
fixture/sso/ SAML and OIDC logins, for any suite whose claim needs an SSO session
fakes/ one package per external provider
internal/ wait, mail, id, apierr, spec
-clients/api/ generated client; never edit by hand
+clients/api/ generated client; never edit by hand. Its own Go module (required through
+ a replace in go.mod), so `./...` leaves it out of vet, staticcheck and test
```
- Platform fixtures live in `fixture`; each product's fixtures live in
diff --git a/tests/Makefile b/tests/Makefile
index 3f94db8d57..f0bcad927b 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -10,11 +10,17 @@ INFISICAL_OPENAPI_URL ?= http://localhost:8080
.PHONY: fmt lint test test-unit test-docker test-suites test-isolated test-harness test-all up down status generate-client
+# The generated client (clients/api) is its own Go module, so ./... leaves it out of vet,
+# staticcheck and test: regenerating fixes it, nothing in it is for a person to correct, and
+# analysing its 400k lines was most of lint's run time. gofmt walks folders rather than
+# modules, so it is given this module's package folders.
+GO_DIRS = $$(go list -f '{{.Dir}}' ./...)
+
fmt:
- $(GOFMT) -w .
+ $(GOFMT) -w $(GO_DIRS)
lint:
- @out="$$($(GOFMT) -l .)"; \
+ @out="$$($(GOFMT) -l $(GO_DIRS))"; \
if [ -n "$$out" ]; then echo "gofmt needed:"; echo "$$out"; exit 1; fi
go vet ./...
go tool staticcheck ./...
diff --git a/tests/clients/api/go.mod b/tests/clients/api/go.mod
new file mode 100644
index 0000000000..0b393491c5
--- /dev/null
+++ b/tests/clients/api/go.mod
@@ -0,0 +1,10 @@
+module github.com/Infisical/infisical/tests/clients/api
+
+go 1.27.0
+
+require github.com/oapi-codegen/runtime v1.7.0
+
+require (
+ github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
+ github.com/google/uuid v1.6.0 // indirect
+)
diff --git a/tests/clients/api/go.sum b/tests/clients/api/go.sum
new file mode 100644
index 0000000000..8822a17fe3
--- /dev/null
+++ b/tests/clients/api/go.sum
@@ -0,0 +1,23 @@
+github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk=
+github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ=
+github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk=
+github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
+github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE=
+github.com/oapi-codegen/nullable v1.1.0 h1:eAh8JVc5430VtYVnq00Hrbpag9PFRGWLjxR1/3KntMs=
+github.com/oapi-codegen/nullable v1.1.0/go.mod h1:KUZ3vUzkmEKY90ksAmit2+5juDIhIZhfDl+0PwOQlFY=
+github.com/oapi-codegen/runtime v1.7.0 h1:t7358VYPvNbWJ9gdAkIK/smVeHpBf6yp8VTsaZsb/7k=
+github.com/oapi-codegen/runtime v1.7.0/go.mod h1:GwV7hC2hviaMzj+ITfHVRESK5J2W/GefVwIND/bMGvU=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
+github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
+github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/tests/docs/client.md b/tests/docs/client.md
index 0ee99dafb9..7c69791d42 100644
--- a/tests/docs/client.md
+++ b/tests/docs/client.md
@@ -5,6 +5,11 @@ Read this when a test needs an endpoint the client does not have.
Every call goes through `clients/api`. A route the client cannot reach is missing an
`operationId`; fix the router, not the test.
+`clients/api` is a Go module of its own, required from `tests/go.mod` through a `replace`
+to the folder. That keeps the generated code out of `./...`, so lint, vet and test do not
+analyse it; the suites still compile against it. A new import in the generated code goes in
+`clients/api/go.mod` (`go mod tidy` there), at the version `tests/go.mod` already uses.
+
## Adding an endpoint
1. Add the `operationId` to `include-operation-ids` in `clients/api/oapi-codegen.yaml`.
diff --git a/tests/go.mod b/tests/go.mod
index bf8a9b34ac..32df763b52 100644
--- a/tests/go.mod
+++ b/tests/go.mod
@@ -3,6 +3,7 @@ module github.com/Infisical/infisical/tests
go 1.27.0
require (
+ github.com/Infisical/infisical/tests/clients/api v0.0.0
github.com/beevik/etree v1.8.1
github.com/google/uuid v1.6.0
github.com/jackc/pgx/v5 v5.9.2
@@ -99,3 +100,5 @@ tool (
github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen
honnef.co/go/tools/cmd/staticcheck
)
+
+replace github.com/Infisical/infisical/tests/clients/api => ./clients/api
diff --git a/tests/suites/machineidentity/accesstoken_test.go b/tests/suites/machineidentity/accesstoken_test.go
index 7fcfdd2c55..8b5051b7ee 100644
--- a/tests/suites/machineidentity/accesstoken_test.go
+++ b/tests/suites/machineidentity/accesstoken_test.go
@@ -213,10 +213,14 @@ func TestAccessToken_TTL(t *testing.T) {
require.LessOrEqual(t, exp, deadline+1, "a renewed token outlived the max TTL")
}
require.GreaterOrEqual(t, time.Now().Unix(), deadline-1, "renewal was refused before the max TTL ran out: %s", refused.Body)
- // A renewed token never outlives the budget, so once it runs out the presented token has
- // itself expired and is refused before the max TTL check could name the budget.
- requireStatus(t, http.StatusForbidden, refused.StatusCode(), refused.Body)
- require.Contains(t, string(refused.Body), "Your token has expired")
+ // A renewed token expires exactly when the budget does, so which check refuses depends on
+ // the second the last renewal lands: still inside it, the budget check answers 401; past
+ // it, the token has itself expired and is refused first with 403. Both mean the budget ran out.
+ budgetSpent := refused.StatusCode() == http.StatusUnauthorized &&
+ strings.Contains(string(refused.Body), "reached its max TTL")
+ tokenExpired := refused.StatusCode() == http.StatusForbidden &&
+ strings.Contains(string(refused.Body), "Your token has expired")
+ require.Truef(t, budgetSpent || tokenExpired, "renewal past the max TTL answered %d: %s", refused.StatusCode(), apierr.Body(refused.Body))
})
t.Run("should cap expiresIn at the remaining max TTL budget", func(t *testing.T) {