Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gi8lino committed Aug 7, 2023
1 parent 898df90 commit 5a77325
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 9 deletions.
5 changes: 5 additions & 0 deletions hack/p12.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ done
# create broken p12 file
echo "broken" > broken.p12

# create file with invalid extension
echo "invalid" > cert.invalid

# create file with no extension
echo "no extension" > no_extension

# create p12 file with a certificate chain
cat final.crt intermediate.crt root.crt > chain.crt
Expand Down
6 changes: 6 additions & 0 deletions hack/pem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ done
# create broken pem file
echo "broken" > broken.pem

# create file with invalid extension
echo "invalid" > cert.invalid

# create file with no extension
echo "no extension" > no_extension

# create pem file with a certificate chain
cat final.crt intermediate.crt root.crt > chain.crt
# create pem file with a certificate chain and private key
Expand Down
16 changes: 7 additions & 9 deletions internal/config/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestParseConfig(t *testing.T) {
Certs: []certificates.Certificate{
{
Name: "test_cert",
Path: "path/to/cert.pem",
Path: "../../tests/certs/pem/chain.pem",
Type: "pem",
Password: fmt.Sprintf("file:%s", passwordFileName),
Enabled: &trueVar,
Expand Down Expand Up @@ -101,7 +101,7 @@ func TestParseConfig(t *testing.T) {
{
Name: "test_cert",
Enabled: &trueVar,
Path: "path/to/cert.pem",
Path: "../../tests/certs/p12/root.p12",
Type: "pem",
Password: "file:INVALID_FILE",
},
Expand All @@ -115,8 +115,7 @@ func TestParseConfig(t *testing.T) {
Certs: []certificates.Certificate{
{
Enabled: &trueVar,
Path: "path/to/cert-with_special chars.pem",
Name: "cert-with-special-chars-pem",
Path: "../../tests/certs/pem/final.pem",
},
},
},
Expand All @@ -143,7 +142,7 @@ func TestParseConfig(t *testing.T) {
{
Name: "test_cert",
Enabled: &trueVar,
Path: "path/to/cert",
Path: "../../tests/certs/p12/no_extension",
},
},
},
Expand All @@ -156,7 +155,7 @@ func TestParseConfig(t *testing.T) {
{
Name: "test_cert",
Enabled: &trueVar,
Path: "path/to/cert.invalid",
Path: "../../tests/certs/pem/without_password.pem",
Type: "invalid",
},
},
Expand All @@ -170,7 +169,7 @@ func TestParseConfig(t *testing.T) {
{
Name: "test_cert",
Enabled: &trueVar,
Path: "path/to/cert.invalid",
Path: "../../tests/certs/pem/cert.invalid",
},
},
},
Expand All @@ -183,7 +182,7 @@ func TestParseConfig(t *testing.T) {
{
Name: "test_cert",
Enabled: &trueVar,
Path: "path/to/cert.p12",
Path: "../../tests/certs/p12/chain.p12",
},
},
},
Expand All @@ -195,7 +194,6 @@ func TestParseConfig(t *testing.T) {
t.Run(testCase.name, func(t *testing.T) {
setEnvVars(envs)

fmt.Println("test name:", testCase.name)
err := ParseConfig(testCase.config)

unsetEnvVars(envs)
Expand Down
1 change: 1 addition & 0 deletions tests/certs/p12/cert.invalid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invalid
1 change: 1 addition & 0 deletions tests/certs/p12/no_extension
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
no extension
1 change: 1 addition & 0 deletions tests/certs/pem/cert.invalid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invalid
1 change: 1 addition & 0 deletions tests/certs/pem/no_extension
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
no extension

0 comments on commit 5a77325

Please sign in to comment.