mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-18 13:27:56 +01:00
cert: use T.TempDir
to create temporary test directory
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
parent
1cd7e3aee6
commit
994f4d67a1
@ -1,7 +1,6 @@
|
||||
package cert_test
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -21,16 +20,13 @@ var (
|
||||
// TestIsOutdatedCert checks that we'll consider the TLS certificate outdated
|
||||
// if the ip addresses or dns names don't match.
|
||||
func TestIsOutdatedCert(t *testing.T) {
|
||||
tempDir, err := ioutil.TempDir("", "certtest")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tempDir := t.TempDir()
|
||||
|
||||
certPath := tempDir + "/tls.cert"
|
||||
keyPath := tempDir + "/tls.key"
|
||||
|
||||
// Generate TLS files with two extra IPs and domains.
|
||||
err = cert.GenCertPair(
|
||||
err := cert.GenCertPair(
|
||||
"lnd autogenerated cert", certPath, keyPath, extraIPs[:2],
|
||||
extraDomains[:2], false, testTLSCertDuration,
|
||||
)
|
||||
@ -76,16 +72,13 @@ func TestIsOutdatedCert(t *testing.T) {
|
||||
// nor dulicates in the lists, matter for whether we consider the certificate
|
||||
// outdated.
|
||||
func TestIsOutdatedPermutation(t *testing.T) {
|
||||
tempDir, err := ioutil.TempDir("", "certtest")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tempDir := t.TempDir()
|
||||
|
||||
certPath := tempDir + "/tls.cert"
|
||||
keyPath := tempDir + "/tls.key"
|
||||
|
||||
// Generate TLS files from the IPs and domains.
|
||||
err = cert.GenCertPair(
|
||||
err := cert.GenCertPair(
|
||||
"lnd autogenerated cert", certPath, keyPath, extraIPs[:],
|
||||
extraDomains[:], false, testTLSCertDuration,
|
||||
)
|
||||
@ -143,16 +136,13 @@ func TestIsOutdatedPermutation(t *testing.T) {
|
||||
// TestTLSDisableAutofill checks that setting the --tlsdisableautofill flag
|
||||
// does not add interface ip addresses or hostnames to the cert.
|
||||
func TestTLSDisableAutofill(t *testing.T) {
|
||||
tempDir, err := ioutil.TempDir("", "certtest")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tempDir := t.TempDir()
|
||||
|
||||
certPath := tempDir + "/tls.cert"
|
||||
keyPath := tempDir + "/tls.key"
|
||||
|
||||
// Generate TLS files with two extra IPs and domains and no interface IPs.
|
||||
err = cert.GenCertPair(
|
||||
err := cert.GenCertPair(
|
||||
"lnd autogenerated cert", certPath, keyPath, extraIPs[:2],
|
||||
extraDomains[:2], true, testTLSCertDuration,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user