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