multi: repleace ioutil.ReadFile
This commit is contained in:
1 parent
619c8f4eb8
commit
ab83343c87
23 files changed
+55
-62
No files matched your search
+5
-4
@@ -12,6 +12,7 @@ import (
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
"net"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -199,7 +200,7 @@ func TestGenerateEphemeralCert(t *testing.T) {
|
||||
keyBytes, err := tlsManager.loadEphemeralCertificate()
|
||||
require.NoError(t, err, "failed to generate new certificate")
|
||||
|
||||
certBytes, err := ioutil.ReadFile(tmpCertPath)
|
||||
certBytes, err := os.ReadFile(tmpCertPath)
|
||||
require.NoError(t, err)
|
||||
|
||||
tlsr, err := cert.NewTLSReloader(certBytes, keyBytes)
|
||||
@@ -207,15 +208,15 @@ func TestGenerateEphemeralCert(t *testing.T) {
|
||||
tlsManager.tlsReloader = tlsr
|
||||
|
||||
// Make sure .tmp file is created at the tmp cert path.
|
||||
_, err = ioutil.ReadFile(tmpCertPath)
|
||||
_, err = os.ReadFile(tmpCertPath)
|
||||
require.NoError(t, err, "couldn't find temp cert file")
|
||||
|
||||
// But no key should be stored.
|
||||
_, err = ioutil.ReadFile(cfg.TLSKeyPath)
|
||||
_, err = os.ReadFile(cfg.TLSKeyPath)
|
||||
require.Error(t, err, "shouldn't have found file")
|
||||
|
||||
// And no permanent cert file should be stored.
|
||||
_, err = ioutil.ReadFile(cfg.TLSCertPath)
|
||||
_, err = os.ReadFile(cfg.TLSCertPath)
|
||||
require.Error(t, err, "shouldn't have found a permanent cert file")
|
||||
|
||||
// Now test that when we reload the certificate it generates the new
|
||||
|
||||
Reference in new issue
Block a user