Skip to content

Commit

Permalink
Merge pull request #393 from untangle/MFW-4989
Browse files Browse the repository at this point in the history
Mfw 4989
  • Loading branch information
sumedha-game authored May 10, 2024
2 parents c2c0551 + 16f32b6 commit 2528e36
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
26 changes: 13 additions & 13 deletions services/settings/database_settings/database.go
Original file line number Diff line number Diff line change
@@ -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"`
}
20 changes: 12 additions & 8 deletions services/settings/database_settings/database_settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 2528e36

Please sign in to comment.