Skip to content

Commit

Permalink
chore: adding invalid domain test
Browse files Browse the repository at this point in the history
  • Loading branch information
jackwotherspoon committed Jan 29, 2025
1 parent 9856409 commit 083a622
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions tests/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,6 @@ func TestPostgresCustomerCAS(t *testing.T) {
if *postgresCustomerCASDomain == "" {
t.Fatal("'postgres_customer_cas_domain' not set")
}
if *postgresCustomerCASInvalidDomain == "" {
t.Fatal("'postgres_customer_cas_invalid_domain' not set")
}

defaultDSN := fmt.Sprintf("host=localhost user=%s password=%s database=%s sslmode=disable",
*postgresUser, *postgresCustomerCASPass, *postgresDB)
Expand All @@ -264,7 +261,7 @@ func TestPostgresCustomerCAS(t *testing.T) {
args []string
}{
{
desc: "using default usage",
desc: "using customer CAS default",
args: []string{*postgresCustomerCASConnName},
dsn: defaultDSN,
},
Expand All @@ -281,6 +278,39 @@ func TestPostgresCustomerCAS(t *testing.T) {
}
}

func TestPostgresCustomerCASInvalidSAN(t *testing.T) {
if testing.Short() {
t.Skip("skipping Postgres integration tests")
}
requirePostgresVars(t)
if *postgresCustomerCASPass == "" {
t.Fatal("'postgres_customer_cas_pass' not set")
}
if *postgresCustomerCASInvalidDomain == "" {
t.Fatal("'postgres_customer_cas_invalid_domain' not set")
}

defaultDSN := fmt.Sprintf("host=localhost user=%s password=%s database=%s sslmode=disable",
*postgresUser, *postgresCustomerCASPass, *postgresDB)

tcs := []struct {
desc string
dsn string
args []string
}{
{
desc: "using invalid customer CAS domain (not in SAN)",
args: []string{*postgresCustomerCASInvalidDomain},
dsn: defaultDSN,
},
}
for _, tc := range tcs {
t.Run(tc.desc, func(t *testing.T) {
proxyConnTest(t, tc.args, "pgx", tc.dsn)
})
}
}

func TestPostgresHealthCheck(t *testing.T) {
if testing.Short() {
t.Skip("skipping Postgres integration tests")
Expand Down

0 comments on commit 083a622

Please sign in to comment.