Files
ubicloud/spec/routes/api/cli/pg/pg_dumpall_spec.rb
Burak Yucesoy 0976ce107e Use sslmode=require for PostgreSQL connection strings
In the past, it was not possible download the CA certificates in any way, so we
used channel_binding as a way to verify the server identity. However, now we
give an option to download the CA certificates, so we can use sslmode=require
by default, which also works with pgBouncer as opposed to channel_binding.
Users that require higher security guarantees can download the CA certificates
and use sslmode=verify-ca or sslmode=verify-full.
2025-06-19 13:07:10 +03:00

38 lines
1.8 KiB
Ruby

# frozen_string_literal: true
require_relative "../spec_helper"
RSpec.describe Clover, "cli pg pg_dumpall" do
before do
expect(Config).to receive(:postgres_service_project_id).and_return(@project.id).at_least(:once)
@pg = Prog::Postgres::PostgresResourceNexus.assemble(
project_id: @project.id,
location_id: Location::HETZNER_FSN1_ID,
name: "test-pg",
target_vm_size: "standard-2",
target_storage_size_gib: 64
).subject
@ref = [@pg.display_location, @pg.name].join("/")
@conn_string = URI("postgres://postgres:#{@pg.superuser_password}@test-pg.#{@pg.ubid}.pg.example.com:5432/postgres?sslmode=require")
expect(Config).to receive(:postgres_service_hostname).and_return("pg.example.com").at_least(:once)
@dns_zone = DnsZone.new
expect(Prog::Postgres::PostgresResourceNexus).to receive(:dns_zone).and_return(@dns_zone).at_least(:once)
end
it "connects to database via pg_dumpall" do
expect(cli_exec(["pg", @ref, "pg_dumpall"])).to eq %W[pg_dumpall -dpostgres://postgres:#{@pg.superuser_password}@test-pg.#{@pg.ubid}.pg.example.com:5432/postgres?sslmode=require]
end
it "supports pg_dumpall options" do
expect(cli_exec(["pg", @ref, "pg_dumpall", "-a"])).to eq %W[pg_dumpall -a -dpostgres://postgres:#{@pg.superuser_password}@test-pg.#{@pg.ubid}.pg.example.com:5432/postgres?sslmode=require]
end
it "supports -U option for user name" do
expect(cli_exec(["pg", @ref, "-Ufoo", "pg_dumpall", "-a"])).to eq %W[pg_dumpall -a -dpostgres://foo@test-pg.#{@pg.ubid}.pg.example.com:5432/postgres?sslmode=require]
end
it "supports -d option for database name" do
expect(cli_exec(["pg", @ref, "-dfoo", "pg_dumpall", "-a"])).to eq %W[pg_dumpall -a -dpostgres://postgres:#{@pg.superuser_password}@test-pg.#{@pg.ubid}.pg.example.com:5432/foo?sslmode=require]
end
end