35 printf(
"usage: %s [flags] CONNINFO\n\n", argv[0]);
37 printf(
"recognized flags:\n");
38 printf(
" -h, --help show this message\n");
39 printf(
" -v VERSION select the hook API version (default 2)\n");
40 printf(
" --expected-scope SCOPE fail if received scopes do not match SCOPE\n");
41 printf(
" --expected-uri URI fail if received configuration link does not match URI\n");
42 printf(
" --expected-issuer ISS fail if received issuer does not match ISS (v2 only)\n");
43 printf(
" --misbehave=MODE have the hook fail required postconditions\n"
44 " (MODEs: no-hook, fail-async, no-token, no-socket)\n");
45 printf(
" --no-hook don't install OAuth hooks\n");
46 printf(
" --hang-forever don't ever return a token (combine with connect_timeout)\n");
47 printf(
" --token TOKEN use the provided TOKEN value\n");
48 printf(
" --error ERRMSG fail instead, with the given ERRMSG (v2 only)\n");
49 printf(
" --stress-async busy-loop on PQconnectPoll rather than polling\n");
65main(
int argc,
char *argv[])
191 printf(
"connection succeeded\n");
232 if (!
req->openid_configuration)
264 fprintf(
stderr,
"--expected-issuer cannot be combined with -v1\n");
285 fprintf(
stderr,
"--error cannot be combined with --token\n");
323 perror(
"WSAStartup failed");
330 perror(
"failed to create datagram socket");
#define Assert(condition)
#define fprintf(file, fmt, msg)
void err(int eval, const char *fmt,...)
void PQsetAuthDataHook(PQauthDataHook_type hook)
PGconn * PQconnectdb(const char *conninfo)
PostgresPollingStatusType PQconnectPoll(PGconn *conn)
ConnStatusType PQstatus(const PGconn *conn)
PGconn * PQconnectStart(const char *conninfo)
void PQfinish(PGconn *conn)
char * PQerrorMessage(const PGconn *conn)
int getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex)
#define required_argument
PostgresPollingStatusType
@ PQAUTHDATA_OAUTH_BEARER_TOKEN
@ PQAUTHDATA_OAUTH_BEARER_TOKEN_V2
static PostgresPollingStatusType misbehave_cb(PGconn *conn, PGoauthBearerRequest *req, pgsocket *altsock)
static const char * expected_scope
static const char * expected_issuer
static const char * expected_uri
static const char * misbehave_mode
static PostgresPollingStatusType async_cb(PGconn *conn, PGoauthBearerRequest *req, pgsocket *altsock)
static int handle_auth_data(PGauthData type, PGconn *conn, void *data)
PGDLLIMPORT char * optarg
#define socket(af, type, protocol)