Skip to content

Commit a5e23fe

Browse files
committed
set sslmode by default to disable
esp for localhost
1 parent e2a1bae commit a5e23fe

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

app/database/connection.go

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ func (dbcon *Connection) pgConString() string {
5050

5151
if dbcon.SSLMode == true {
5252
params = append(params, "sslmode=require")
53+
} else {
54+
params = append(params, "sslmode=disable")
5355
}
5456

5557
return strings.Join(params, " ")

app/database/connection_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ func TestConnection(t *testing.T) {
3232
}
3333
Convey("It can build a connection string", func() {
3434
conStr, err := con.String()
35-
So(conStr, ShouldEqual, "host=localhost port=1234 user=root dbname=somedb")
35+
So(conStr, ShouldEqual, "host=localhost port=1234 user=root dbname=somedb sslmode=disable")
3636
So(err, ShouldBeNil)
3737
})
3838
Convey("It can build a connection string with password", func() {
3939
con.Password = "secret"
4040
conStr, err := con.String()
41-
So(conStr, ShouldEqual, "host=localhost port=1234 user=root password=secret dbname=somedb")
41+
So(conStr, ShouldEqual, "host=localhost port=1234 user=root password=secret dbname=somedb sslmode=disable")
4242
So(err, ShouldBeNil)
4343
})
4444
Convey("It can build a connection string with SSLMode", func() {

0 commit comments

Comments
 (0)