// TestDatabaseAccessRootCluster tests a scenario where a user connects to a
// database service running in a root cluster.
TestDatabaseAccessRootCluster tests a scenario where a user connects to a
database service running in a root cluster.
// TestDatabaseAccessRootCluster tests a scenario where a user connects to a // database service running in a root cluster .
func TestDatabaseAccessRootCluster(t *testing.T) {
	pack := setupDatabaseTest(t)
	client, err := postgres.MakeTestClient(context.Background(), postgres.TestClientConfig{
		AuthClient: pack.root.cluster.GetSiteAPI(pack.root.cluster.Secrets.SiteName),
		AuthServer: pack.root.cluster.Process.GetAuthServer(),
		Address:    fmt.Sprintf("%v:%v", Loopback, pack.root.cluster.GetPortWeb()),
		Cluster:    pack.root.cluster.Secrets.SiteName,
		Username:   pack.root.user.GetName(),
		RouteToDatabase: tlsca.RouteToDatabase{
			ServiceName: pack.root.dbService.Name,
			Protocol:    pack.root.dbService.Protocol,
			Username:    "postgres",
			Database:    "test",
		},
	})
	require.NoError(t, err)
	result, err := client.Exec(context.Background(), "select 1").ReadAll()
	require.NoError(t, err)
	require.Equal(t, []*pgconn.Result{postgres.TestQueryResponse}, result)
	require.Equal(t, uint32(1), pack.root.postgres.QueryCount())
	require.Equal(t, uint32(0), pack.leaf.postgres.QueryCount())
	err = client.Close(context.Background())
	require.NoError(t, err)
}
func TestDatabaseAccessRootCluster ( t * testing . T ) { pack := setupDatabaseTest ( t ) client , err := postgres . MakeTestClient ( context . Background ( ) , postgres . TestClientConfig { AuthClient : pack . root . cluster . GetSiteAPI ( pack . root . cluster . Secrets . SiteName ) , AuthServer : pack . root . cluster . Process . GetAuthServer ( ) , Address : fmt . Sprintf ( " " , Loopback , pack . root . cluster . GetPortWeb ( ) ) , Cluster : pack . root . cluster . Secrets . SiteName , Username : pack . root . user . GetName ( ) , RouteToDatabase : tlsca . RouteToDatabase { ServiceName : pack . root . dbService . Name , Protocol : pack . root . dbService . Protocol , Username : " " , Database : " " , } , } ) require . NoError ( t , err ) result , err := client . Exec ( context . Background ( ) , " " ) . ReadAll ( ) require . NoError ( t , err ) require . Equal ( t , [ ] * pgconn . Result { postgres . TestQueryResponse } , result ) require . Equal ( t , uint32 ( 1 ) , pack . root . postgres . QueryCount ( ) ) require . Equal ( t , uint32 ( 0 ) , pack . leaf . postgres . QueryCount ( ) ) err = client . Close ( context . Background ( ) ) require . NoError ( t , err ) }
TestDatabaseAccessRootCluster tests a scenario where a user connects to a
database service running in a root cluster.
TestDatabaseAccessRootCluster tests a scenario where a user connects to a database service running in a root cluster .
// Connect to the database service in root cluster. // Execute a query. // Disconnect.