MCPcopy
hub / github.com/jackc/pgx / TestConnectOAuthError

Function TestConnectOAuthError

pgconn/pgconn_test.go:283–301  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

281}
282
283func TestConnectOAuthError(t *testing.T) {
284 if os.Getenv(runOAuthTestEnvVar) != "true" {
285 t.Skipf("Skipping as '%s=true' is not set", runOAuthTestEnvVar)
286 }
287
288 config, err := pgconn.ParseConfig("host=127.0.0.1 user=pgx_oauth dbname=pgx_test")
289 require.NoError(t, err)
290
291 // Configure OAuthTokenProvider for dummy validator.
292 // The dummy validator accepts any token and maps it to the user equal to the
293 // token string. In this case that token will be accepted but as there is no
294 // user 'INVALID_TOKEN' the connection should fail.
295 config.OAuthTokenProvider = func(ctx context.Context) (string, error) {
296 return "INVALID_TOKEN", nil
297 }
298
299 _, err = pgconn.ConnectConfig(context.Background(), config)
300 require.Error(t, err, "connect should return error for invalid token")
301}
302
303func TestConnectTLSPasswordProtectedClientCertWithSSLPassword(t *testing.T) {
304 t.Parallel()

Callers

nothing calls this directly

Calls 3

ParseConfigFunction · 0.92
ConnectConfigFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected