-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
K8SPSMDB-813: Fail TLS configuration if provided certificates do not …
…exist (#1254) * Fail TLS configuration if provided certificates do not exist * Skip TLS config for probe when using unsafe config * Remove healthcheck ssl config from e2e where it was not expected * Revert ssl config removal for 'some-name' rs 'allowUnsafeConfigurations' is set for 'another-name' rs only * compare version fixes --------- Co-authored-by: Viacheslav Sarzhan <[email protected]> Co-authored-by: Andrii Dema <[email protected]> Co-authored-by: Inel Pandzic <[email protected]>
- Loading branch information
1 parent
3c58298
commit dcc31ae
Showing
10 changed files
with
128 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package db | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
) | ||
|
||
const ( | ||
notExistingFilePath = "not-existing-file-path" | ||
) | ||
|
||
func TestSSLNotEnabled(t *testing.T) { | ||
cfg := &Config{ | ||
SSL: &SSLConfig{ | ||
Enabled: false, | ||
}, | ||
} | ||
|
||
if err := cfg.configureTLS(); err != nil { | ||
t.Fatalf("TLS configuration failed: %s", err) | ||
} | ||
|
||
if cfg.TLSConf != nil { | ||
t.Error("Expected TLSConf to be nil") | ||
} | ||
} | ||
|
||
func TestSSLEnabled(t *testing.T) { | ||
cfg := &Config{ | ||
SSL: &SSLConfig{ | ||
Enabled: true, | ||
}, | ||
} | ||
|
||
if err := cfg.configureTLS(); err != nil { | ||
t.Fatalf("TLS configuration failed: %s", err) | ||
} | ||
|
||
if cfg.TLSConf == nil { | ||
t.Error("Expected TLSConf to not be nil") | ||
} | ||
} | ||
|
||
func TestPEMKeyFileDoesNotExists(t *testing.T) { | ||
cfg := &Config{ | ||
SSL: &SSLConfig{ | ||
Enabled: true, | ||
PEMKeyFile: notExistingFilePath, | ||
}, | ||
} | ||
|
||
err := cfg.configureTLS() | ||
if err == nil { | ||
t.Fatal("Expected TLS config to fail, but it returned no error") | ||
} | ||
|
||
expectedErrorMessage := fmt.Sprintf( | ||
"check if file with name %s exists: stat %s: no such file or directory", | ||
notExistingFilePath, notExistingFilePath, | ||
) | ||
if err.Error() != expectedErrorMessage { | ||
t.Errorf("error message '%s' does not match expected '%s'", err.Error(), expectedErrorMessage) | ||
} | ||
} | ||
|
||
func TestCAFileDoesNotExists(t *testing.T) { | ||
cfg := &Config{ | ||
SSL: &SSLConfig{ | ||
Enabled: true, | ||
CAFile: notExistingFilePath, | ||
}, | ||
} | ||
|
||
err := cfg.configureTLS() | ||
if err == nil { | ||
t.Fatal("Expected TLS config to fail, but it returned no error") | ||
} | ||
|
||
expectedErrorMessage := fmt.Sprintf( | ||
"check if file with name %s exists: stat %s: no such file or directory", | ||
notExistingFilePath, notExistingFilePath, | ||
) | ||
if err.Error() != expectedErrorMessage { | ||
t.Errorf("error message '%s' does not match expected '%s'", err.Error(), expectedErrorMessage) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters