(t *testing.T)
| 244 | } |
| 245 | |
| 246 | func TestPostgresIAMDBAuthn(t *testing.T) { |
| 247 | if testing.Short() { |
| 248 | t.Skip("skipping Postgres integration tests") |
| 249 | } |
| 250 | if os.Getenv("SKIP_FUSE_E2E_TESTS") == "true" { |
| 251 | t.Skip("skipping Postgres FUSE integration tests because SKIP_FUSE_E2E_TESTS is set") |
| 252 | } |
| 253 | requirePostgresVars(t) |
| 254 | if *postgresIAMUser == "" { |
| 255 | t.Fatal("'postgres_user_iam' not set") |
| 256 | } |
| 257 | |
| 258 | defaultDSN := fmt.Sprintf("host=localhost user=%s database=%s sslmode=disable", |
| 259 | *postgresIAMUser, *postgresDB) |
| 260 | impersonatedIAMUser := strings.ReplaceAll(*impersonatedUser, ".gserviceaccount.com", "") |
| 261 | |
| 262 | tcs := []struct { |
| 263 | desc string |
| 264 | dsn string |
| 265 | args []string |
| 266 | }{ |
| 267 | { |
| 268 | desc: "using default flag", |
| 269 | args: []string{"--auto-iam-authn", *postgresConnName}, |
| 270 | dsn: defaultDSN, |
| 271 | }, |
| 272 | { |
| 273 | desc: "using query param", |
| 274 | args: []string{fmt.Sprintf("%s?auto-iam-authn=true", *postgresConnName)}, |
| 275 | dsn: defaultDSN, |
| 276 | }, |
| 277 | { |
| 278 | desc: "using impersonation", |
| 279 | args: []string{ |
| 280 | "--auto-iam-authn", |
| 281 | "--impersonate-service-account", *impersonatedUser, |
| 282 | *postgresConnName}, |
| 283 | dsn: fmt.Sprintf("host=localhost user=%s database=%s sslmode=disable", |
| 284 | impersonatedIAMUser, *postgresDB), |
| 285 | }, |
| 286 | { |
| 287 | desc: "using impersonation with query param", |
| 288 | args: []string{ |
| 289 | "--impersonate-service-account", *impersonatedUser, |
| 290 | fmt.Sprintf("%s?auto-iam-authn=true", *postgresConnName)}, |
| 291 | dsn: fmt.Sprintf("host=localhost user=%s password=password database=%s sslmode=disable", |
| 292 | impersonatedIAMUser, *postgresDB), |
| 293 | }, |
| 294 | } |
| 295 | for _, tc := range tcs { |
| 296 | t.Run(tc.desc, func(t *testing.T) { |
| 297 | proxyConnTest(t, AddIPTypeFlag(tc.args), "pgx", tc.dsn) |
| 298 | }) |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | func TestPostgresCustomerCAS(t *testing.T) { |
| 303 | if testing.Short() { |
nothing calls this directly
no test coverage detected