MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/cloud-sql-proxy / TestPostgresAuthentication

Function TestPostgresAuthentication

tests/postgres_test.go:145–211  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

143}
144
145func TestPostgresAuthentication(t *testing.T) {
146 if testing.Short() {
147 t.Skip("skipping Postgres integration tests")
148 }
149 requirePostgresVars(t)
150
151 var creds string
152 if *ipType == "public" {
153 creds = keyfile(t)
154 }
155 tok, path, cleanup := removeAuthEnvVar(t)
156 defer cleanup()
157
158 tcs := []struct {
159 desc string
160 args []string
161 }{
162 {
163 desc: "with token",
164 args: []string{"--token", tok.AccessToken, *postgresConnName},
165 },
166 {
167 desc: "with token and impersonation",
168 args: []string{
169 "--token", tok.AccessToken,
170 "--impersonate-service-account", *impersonatedUser,
171 *postgresConnName},
172 },
173 }
174 if *ipType == "public" {
175 additionalTcs := []struct {
176 desc string
177 args []string
178 }{
179 {
180 desc: "with credentials file",
181 args: []string{"--credentials-file", path, *postgresConnName},
182 },
183 {
184 desc: "with credentials file and impersonation",
185 args: []string{
186 "--credentials-file", path,
187 "--impersonate-service-account", *impersonatedUser,
188 *postgresConnName,
189 },
190 },
191 {
192 desc: "with credentials JSON",
193 args: []string{"--json-credentials", string(creds), *postgresConnName},
194 },
195 {
196 desc: "with credentials JSON and impersonation",
197 args: []string{
198 "--json-credentials", string(creds),
199 "--impersonate-service-account", *impersonatedUser,
200 *postgresConnName,
201 },
202 },

Callers

nothing calls this directly

Calls 6

requirePostgresVarsFunction · 0.85
keyfileFunction · 0.85
removeAuthEnvVarFunction · 0.85
proxyConnTestFunction · 0.85
AddIPTypeFlagFunction · 0.85
postgresDSNFunction · 0.85

Tested by

no test coverage detected