From 99eb95621302ee040c6a1bdf943270e25fb05eee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Csumedha-game=E2=80=9D?= <“sumedha-game@arista.com”> Date: Fri, 10 May 2024 08:47:11 +0530 Subject: [PATCH 1/4] MFW-4989: Database port column values are zero for SQLite databases --- .../settings/database_settings/database.go | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/services/settings/database_settings/database.go b/services/settings/database_settings/database.go index 0508a705..ef5931f3 100644 --- a/services/settings/database_settings/database.go +++ b/services/settings/database_settings/database.go @@ -1,17 +1,17 @@ package database_settings type Database struct { - Enabled bool `json:"enabled"` - ID string `json:"id"` - Database string `json:"db_name"` - UserName string `json:"db_username"` - Password string `json:"db_password"` - PasswordEncrypted string `json:"db_password_encrypted"` - Server string `json:"db_server"` - Port int `json:"db_port"` - Description string `json:"description"` - Name string `json:"name"` - Type string `json:"type"` - ConnectionString string `json:"db_connection_string"` - Default bool `json:"default"` -} + Enabled bool `json:"enabled"` + ID string `json:"id"` + Database string `json:"db_name"` + UserName *string `json:"db_username,omitempty"` + Password *string `json:"db_password,omitempty"` + PasswordEncrypted *string `json:"db_password_encrypted,omitempty"` + Server *string `json:"db_server,omitempty"` + Port *int `json:"db_port,omitempty"` + Description string `json:"description"` + Name string `json:"name"` + Type string `json:"type"` + ConnectionString string `json:"db_connection_string"` + Default bool `json:"default"` +} \ No newline at end of file From c6075e17d21fb52b0dc9a7d1fee8bfe63fe7f542 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Csumedha-game=E2=80=9D?= <“sumedha-game@arista.com”> Date: Fri, 10 May 2024 08:48:11 +0530 Subject: [PATCH 2/4] MFW-4989: Database port column values are zero for SQLite databases --- services/settings/database_settings/database.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/settings/database_settings/database.go b/services/settings/database_settings/database.go index ef5931f3..37fba4d5 100644 --- a/services/settings/database_settings/database.go +++ b/services/settings/database_settings/database.go @@ -14,4 +14,4 @@ type Database struct { Type string `json:"type"` ConnectionString string `json:"db_connection_string"` Default bool `json:"default"` -} \ No newline at end of file +} From b9f4f41f17faf48004c425c102741c15abaa1ad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Csumedha-game=E2=80=9D?= <“sumedha-game@arista.com”> Date: Fri, 10 May 2024 12:27:21 +0530 Subject: [PATCH 3/4] test added --- .../database_settings_test.go | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/services/settings/database_settings/database_settings_test.go b/services/settings/database_settings/database_settings_test.go index a6871334..b0aaea6d 100644 --- a/services/settings/database_settings/database_settings_test.go +++ b/services/settings/database_settings/database_settings_test.go @@ -32,6 +32,10 @@ func runUnmarshalTest(t *testing.T, tests []unmarshalTest) { // TestDatabaseUnmarshal tests unmarshalling the database settings func TestDatabaseUnmarshal(t *testing.T) { + var userNames = []string{"test_user", ""} + var passwords = []string{"test_pw", ""} + var servers = []string{"test_server", ""} + var portValues = []int{5,0} tests := []unmarshalTest{ { name: "Generic database settings unmarshal test", @@ -53,10 +57,10 @@ func TestDatabaseUnmarshal(t *testing.T) { { Enabled: true, Database: "testingdb", - UserName: "test_user", - Password: "test_pw", - Server: "test_server", - Port: 5, + UserName: &userNames[0], + Password: &passwords[0], + Server: &servers[0], + Port: &portValues[0], Description: "Some desc", Name: "New DB Source", Type: "DB Type 5", @@ -90,10 +94,10 @@ func TestDatabaseUnmarshal(t *testing.T) { Enabled: true, ConnectionString: "sqlite:///tmp/reports.db", Database: "reports.db", - UserName: "", - Password: "", - Server: "", - Port: 0, + UserName: &userNames[1], + Password: &passwords[1], + Server: &servers[1], + Port: &portValues[1], Description: "Local reports database", Name: "Local DB", Type: "sqlite", From 16f32b66418ffa2f6edf263687d7f1034086af23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Csumedha-game=E2=80=9D?= <“sumedha-game@arista.com”> Date: Fri, 10 May 2024 16:54:27 +0530 Subject: [PATCH 4/4] removed space --- .../settings/database_settings/database_settings_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/settings/database_settings/database_settings_test.go b/services/settings/database_settings/database_settings_test.go index b0aaea6d..bca08c6b 100644 --- a/services/settings/database_settings/database_settings_test.go +++ b/services/settings/database_settings/database_settings_test.go @@ -32,10 +32,10 @@ func runUnmarshalTest(t *testing.T, tests []unmarshalTest) { // TestDatabaseUnmarshal tests unmarshalling the database settings func TestDatabaseUnmarshal(t *testing.T) { - var userNames = []string{"test_user", ""} - var passwords = []string{"test_pw", ""} - var servers = []string{"test_server", ""} - var portValues = []int{5,0} + var userNames = []string{"test_user", ""} + var passwords = []string{"test_pw", ""} + var servers = []string{"test_server", ""} + var portValues = []int{5, 0} tests := []unmarshalTest{ { name: "Generic database settings unmarshal test",