Add tests for ssl params
This commit is contained in:
parent
ce4aea8da1
commit
e2217e5f71
@ -90,6 +90,14 @@ func Test_Localhost_Url_And_Ssl_Arg(t *testing.T) {
|
|||||||
assert.Equal(t, "postgres://127.0.0.1/database?sslmode=require", str)
|
assert.Equal(t, "postgres://127.0.0.1/database?sslmode=require", str)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ExtendedSSLFlags(t *testing.T) {
|
||||||
|
str, err := BuildStringFromOptions(command.Options{
|
||||||
|
URL: "postgres://localhost/database?sslmode=require&sslcert=cert&sslkey=key&sslrootcert=ca",
|
||||||
|
})
|
||||||
|
assert.Equal(t, nil, err)
|
||||||
|
assert.Equal(t, "postgres://localhost/database?sslcert=cert&sslkey=key&sslmode=require&sslrootcert=ca", str)
|
||||||
|
}
|
||||||
|
|
||||||
func Test_Flag_Args(t *testing.T) {
|
func Test_Flag_Args(t *testing.T) {
|
||||||
str, err := BuildStringFromOptions(command.Options{
|
str, err := BuildStringFromOptions(command.Options{
|
||||||
Host: "host",
|
Host: "host",
|
||||||
@ -124,17 +132,20 @@ func Test_Localhost(t *testing.T) {
|
|||||||
|
|
||||||
func Test_Localhost_And_Ssl(t *testing.T) {
|
func Test_Localhost_And_Ssl(t *testing.T) {
|
||||||
opts := command.Options{
|
opts := command.Options{
|
||||||
Host: "localhost",
|
Host: "localhost",
|
||||||
Port: 5432,
|
Port: 5432,
|
||||||
User: "user",
|
User: "user",
|
||||||
Pass: "password",
|
Pass: "password",
|
||||||
DbName: "db",
|
DbName: "db",
|
||||||
Ssl: "require",
|
Ssl: "require",
|
||||||
|
SslKey: "keyPath",
|
||||||
|
SslCert: "certPath",
|
||||||
|
SslRootCert: "caPath",
|
||||||
}
|
}
|
||||||
|
|
||||||
str, err := BuildStringFromOptions(opts)
|
str, err := BuildStringFromOptions(opts)
|
||||||
assert.Equal(t, nil, err)
|
assert.Equal(t, nil, err)
|
||||||
assert.Equal(t, "postgres://user:password@localhost:5432/db?sslmode=require", str)
|
assert.Equal(t, "postgres://user:password@localhost:5432/db?sslcert=certPath&sslkey=keyPath&sslmode=require&sslrootcert=caPath", str)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_No_User(t *testing.T) {
|
func Test_No_User(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user