Skip to content

Commit fedaa27

Browse files
feat(pam): add e2e tests for redis (#181)
* feat(pam): add end-to-end tests for Redis resource Add Redis PAM e2e tests covering no-auth, ACL user+password, ACL over SSL, and multiple concurrent connections through the proxy. Also regenerate the OpenAPI client from the latest backend spec, which required removing the dropped RotationEnabled field from the Postgres account creation test. * docs: add Redis to PAM test examples in README * fix(e2e): add missing DnsResolver field to ACME CA test helpers The backend added a DnsResolver field to the ACME certificate authority configuration. Update the agent test helpers to include it so the regenerated client compiles. * fix(e2e): use NODE_ENV=test for PAM tests to prevent EPIPE crashes In development mode, the backend's global uncaughtException handler is not registered. This causes intermittent EPIPE crashes during bidirectional socket teardown in the gateway proxy, killing the backend process and failing subsequent PAM SSH subtests. Setting NODE_ENV=test enables the exception handler while keeping test-appropriate behavior (relaxed host validation, no production restrictions). --------- Co-authored-by: saif <11242541+saifsmailbox98@users.noreply.github.com>
1 parent 04bf737 commit fedaa27

7 files changed

Lines changed: 925 additions & 63 deletions

File tree

e2e/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,19 +187,21 @@ cd e2e
187187
go test -v -timeout 30m -count=1 github.com/infisical/cli/e2e-tests/pam
188188
```
189189

190-
To run a specific test (e.g., only SSH or only Postgres):
190+
To run a specific test (e.g., only SSH, Postgres, or Redis):
191191

192192
```bash
193193
cd e2e
194194
go test -v -timeout 30m -count=1 -run TestPAM_SSH github.com/infisical/cli/e2e-tests/pam
195195
go test -v -timeout 30m -count=1 -run TestPAM_Postgres github.com/infisical/cli/e2e-tests/pam
196+
go test -v -timeout 5m -count=1 -run TestPAM_Redis github.com/infisical/cli/e2e-tests/pam
196197
```
197198

198-
To run a specific sub-test (e.g., only certificate auth within SSH):
199+
To run a specific sub-test (e.g., only certificate auth within SSH, or ACL over SSL within Redis):
199200

200201
```bash
201202
cd e2e
202203
go test -v -timeout 30m -count=1 -run TestPAM_SSH/certificate github.com/infisical/cli/e2e-tests/pam
204+
go test -v -timeout 5m -count=1 -run TestPAM_Redis/acl-over-ssl github.com/infisical/cli/e2e-tests/pam
203205
```
204206

205207
**Prerequisites:**

e2e/agent/agent_helpers.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,13 @@ func (h *CertAgentTestHelper) CreateAcmeCA(dnsConnectionID, directoryUrl string)
302302
AccountEmail string `json:"accountEmail"`
303303
DirectoryUrl string `json:"directoryUrl"`
304304
DnsAppConnectionId openapi_types.UUID `json:"dnsAppConnectionId"`
305-
DnsProviderConfig struct {
305+
DnsProviderConfig struct {
306306
HostedZoneId string `json:"hostedZoneId"`
307307
Provider client.CreateAcmeCertificateAuthorityV1JSONBodyConfigurationDnsProviderConfigProvider `json:"provider"`
308308
} `json:"dnsProviderConfig"`
309-
EabHmacKey *string `json:"eabHmacKey,omitempty"`
310-
EabKid *string `json:"eabKid,omitempty"`
309+
DnsResolver *string `json:"dnsResolver,omitempty"`
310+
EabHmacKey *string `json:"eabHmacKey,omitempty"`
311+
EabKid *string `json:"eabKid,omitempty"`
311312
}{
312313
DnsAppConnectionId: uuid.MustParse(dnsConnectionID),
313314
DnsProviderConfig: struct {
@@ -380,12 +381,13 @@ func (h *CertAgentTestHelper) CreateAcmeCARaw(name, dnsConnectionID, directoryUr
380381
AccountEmail string `json:"accountEmail"`
381382
DirectoryUrl string `json:"directoryUrl"`
382383
DnsAppConnectionId openapi_types.UUID `json:"dnsAppConnectionId"`
383-
DnsProviderConfig struct {
384+
DnsProviderConfig struct {
384385
HostedZoneId string `json:"hostedZoneId"`
385386
Provider client.CreateAcmeCertificateAuthorityV1JSONBodyConfigurationDnsProviderConfigProvider `json:"provider"`
386387
} `json:"dnsProviderConfig"`
387-
EabHmacKey *string `json:"eabHmacKey,omitempty"`
388-
EabKid *string `json:"eabKid,omitempty"`
388+
DnsResolver *string `json:"dnsResolver,omitempty"`
389+
EabHmacKey *string `json:"eabHmacKey,omitempty"`
390+
EabKid *string `json:"eabKid,omitempty"`
389391
}{
390392
DnsAppConnectionId: uuid.MustParse(dnsConnectionID),
391393
DnsProviderConfig: struct {

e2e/openapi-cfg.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ output-options:
3636
- createPostgresPamAccount
3737
- createSshPamResource
3838
- createSshPamAccount
39+
- createRedisPamAccount

e2e/packages/client/client.gen.go

Lines changed: 465 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e/pam/pam_helpers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func SetupPAMInfra(t *testing.T, ctx context.Context) *PAMTestInfra {
5252
infisical := helpers.NewInfisicalService().
5353
WithBackendEnvironment(types.NewMappingWithEquals([]string{
5454
"ALLOW_INTERNAL_IP_CONNECTIONS=true",
55+
"NODE_ENV=test",
5556
})).
5657
Up(t, ctx)
5758

e2e/pam/postgres_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,8 @@ func TestPAM_Postgres_ConnectToDatabase(t *testing.T) {
9595
pgAcctResp, err := infra.ApiClient.CreatePostgresPamAccountWithResponse(
9696
ctx,
9797
client.CreatePostgresPamAccountJSONRequestBody{
98-
ResourceId: resourceId,
99-
Name: accountName,
100-
RotationEnabled: false,
98+
ResourceId: resourceId,
99+
Name: accountName,
101100
Credentials: struct {
102101
Password string `json:"password"`
103102
Username string `json:"username"`

0 commit comments

Comments
 (0)