Skip to content
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

add tls support and tests to connect-init command #459

Merged
merged 7 commits into from
Mar 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions namespaces/namespaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func TestEnsureExists_AlreadyExists(tt *testing.T) {
})
req.NoError(err)
defer consul.Stop()
consul.WaitForSerfCheck(t)
consulClient, err := capi.NewClient(&capi.Config{
Address: consul.HTTPAddr,
Token: masterToken,
Expand Down
10 changes: 4 additions & 6 deletions subcommand/common/test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import (
// and a server certificate and saves them to temp files.
// It returns file names in this order:
// CA certificate, server certificate, and server key.
// Note that it's the responsibility of the caller to
// remove the temporary files created by this function.
func GenerateServerCerts(t *testing.T) (string, string, string, func()) {
func GenerateServerCerts(t *testing.T) (string, string, string) {
require := require.New(t)

caFile, err := ioutil.TempFile("", "ca")
Expand Down Expand Up @@ -46,12 +44,12 @@ func GenerateServerCerts(t *testing.T) (string, string, string, func()) {
_, err = certKeyFile.WriteString(keyPem)
require.NoError(err)

cleanupFunc := func() {
t.Cleanup(func() {
os.Remove(caFile.Name())
os.Remove(certFile.Name())
os.Remove(certKeyFile.Name())
Comment on lines +47 to 50
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! I really like this pattern!

}
return caFile.Name(), certFile.Name(), certKeyFile.Name(), cleanupFunc
})
return caFile.Name(), certFile.Name(), certKeyFile.Name()
}

// WriteTempFile writes contents to a temporary file and returns the file
Expand Down
Loading