Skip to content

Commit

Permalink
Merge pull request #21 from RedHatInsights/psav/fix_rdsbug
Browse files Browse the repository at this point in the history
RDS bug if content blank
  • Loading branch information
psav authored Apr 29, 2022
2 parents 1eae41e + ec2faf2 commit a56119b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
run: |
sudo apt-get install golang-1.13
- name: Run Tests
run: ACG_CONFIG="../../../test.json" go test -v ./pkg/api/v1/...
run: ACG_CONFIG="../../../tests/test.json" go test -v ./pkg/api/v1/...
4 changes: 4 additions & 0 deletions pkg/api/v1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ func writeContent(dir string, file string, contentString *string) (string, error
return "", err
}

if contentString == nil {
return "", fmt.Errorf("No RDS available")
}

content := []byte(*contentString)

fil, err := ioutil.TempFile(dir, file)
Expand Down
15 changes: 15 additions & 0 deletions pkg/api/v1/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ func TestClientLoad(t *testing.T) {
if LoadedConfig == nil {
log.Fatal("Config didn't load in init()")
}

if len(LoadedConfig.Kafka.Brokers) < 1 {
log.Fatal("Kafka brokers not loaded")
}
Expand Down Expand Up @@ -70,3 +71,17 @@ func TestClientLoad(t *testing.T) {
log.Fatal("ca didn't match")
}
}

func TestEmptyRDSCa(t *testing.T) {
cfg, err := loadConfig("../../../tests/nordsca.json")
if err != nil {
log.Fatalf("can't load config: %s", err)
}

_, err = cfg.RdsCa()

if err == nil {
log.Fatal("error should have been created")
}

}
27 changes: 27 additions & 0 deletions tests/nordsca.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"BOPURL": "bopurl",
"database": {
"adminPassword": "pass",
"adminUsername": "user",
"hostname": "dbhost",
"name": "dbname",
"password": "dbpass",
"port": 5432,
"sslMode": "disable",
"username": "dbuser"
},
"logging": {
"cloudwatch": {
"accessKeyId": "",
"logGroup": "",
"region": "",
"secretAccessKey": ""
},
"type": "null"
},
"metricsPath": "/metrics",
"metricsPort": 9000,
"privatePort": 10000,
"publicPort": 8000,
"webPort": 8000
}
File renamed without changes.

0 comments on commit a56119b

Please sign in to comment.