-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
K8SPSMDB-813: Fail TLS configuration if provided certificates do not exist #1254
Merged
+128
−88
Merged
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
38b94d0
Fail TLS configuration if provided certificates do not exist
t-yrka 24b77a9
Skip TLS config for probe when using unsafe config
t-yrka 0ec0f3f
Remove healthcheck ssl config from e2e where it was not expected
t-yrka bca1337
Revert ssl config removal for 'some-name' rs
t-yrka be3e0fa
Merge branch 'main' into K8SPSMDB-813-healthcheck-tls
hors 791f8ef
Merge branch 'main' into K8SPSMDB-813-healthcheck-tls
t-yrka 2f868de
Merge branch 'main' into K8SPSMDB-813-healthcheck-tls
t-yrka 1abca95
Merge branch 'main' into K8SPSMDB-813-healthcheck-tls
t-yrka 44150f6
Merge branch 'main' into K8SPSMDB-813-healthcheck-tls
t-yrka 8881c07
Merge branch 'main' into K8SPSMDB-813-healthcheck-tls
hors 49dbd51
Merge remote-tracking branch 'origin/main' into pr/t-yrka/1254
pooknull 06c966e
compare version fixes
pooknull 7d8974c
Merge branch 'main' into K8SPSMDB-813-healthcheck-tls
inelpandzic 770935c
Merge branch 'main' into K8SPSMDB-813-healthcheck-tls
hors File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@egegunes, maybe we need to do it only for cr >= 1.15?