-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cert/tests: fix tests due to cert expiry (#6647)
- Loading branch information
Showing
9 changed files
with
44 additions
and
250 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1112,18 +1112,34 @@ func TestBackend_ext_singleCert(t *testing.T) { | |
|
||
// Test a self-signed client with URI alt names (root CA) that is trusted | ||
func TestBackend_dns_singleCert(t *testing.T) { | ||
connState, err := testConnState( | ||
"test-fixtures/root/rootcawdnscert.pem", | ||
"test-fixtures/root/rootcawdnskey.pem", | ||
"test-fixtures/root/rootcacert.pem", | ||
) | ||
certTemplate := &x509.Certificate{ | ||
Subject: pkix.Name{ | ||
CommonName: "example.com", | ||
}, | ||
DNSNames: []string{"example.com"}, | ||
IPAddresses: []net.IP{net.ParseIP("127.0.0.1")}, | ||
ExtKeyUsage: []x509.ExtKeyUsage{ | ||
x509.ExtKeyUsageServerAuth, | ||
x509.ExtKeyUsageClientAuth, | ||
}, | ||
KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment | x509.KeyUsageKeyAgreement, | ||
SerialNumber: big.NewInt(mathrand.Int63()), | ||
NotBefore: time.Now().Add(-30 * time.Second), | ||
NotAfter: time.Now().Add(262980 * time.Hour), | ||
} | ||
|
||
tempDir, connState, err := generateTestCertAndConnState(t, certTemplate) | ||
if tempDir != "" { | ||
defer os.RemoveAll(tempDir) | ||
} | ||
if err != nil { | ||
t.Fatalf("error testing connection state: %v", err) | ||
} | ||
ca, err := ioutil.ReadFile("test-fixtures/root/rootcacert.pem") | ||
ca, err := ioutil.ReadFile(filepath.Join(tempDir, "ca_cert.pem")) | ||
if err != nil { | ||
t.Fatalf("err: %v", err) | ||
} | ||
|
||
logicaltest.Test(t, logicaltest.TestCase{ | ||
CredentialBackend: testFactory(t), | ||
Steps: []logicaltest.TestStep{ | ||
|
@@ -1143,18 +1159,34 @@ func TestBackend_dns_singleCert(t *testing.T) { | |
|
||
// Test a self-signed client with URI alt names (root CA) that is trusted | ||
func TestBackend_email_singleCert(t *testing.T) { | ||
connState, err := testConnState( | ||
"test-fixtures/root/rootcawemailcert.pem", | ||
"test-fixtures/root/rootcawemailkey.pem", | ||
"test-fixtures/root/rootcacert.pem", | ||
) | ||
certTemplate := &x509.Certificate{ | ||
Subject: pkix.Name{ | ||
CommonName: "example.com", | ||
}, | ||
EmailAddresses: []string{"[email protected]"}, | ||
IPAddresses: []net.IP{net.ParseIP("127.0.0.1")}, | ||
ExtKeyUsage: []x509.ExtKeyUsage{ | ||
x509.ExtKeyUsageServerAuth, | ||
x509.ExtKeyUsageClientAuth, | ||
}, | ||
KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment | x509.KeyUsageKeyAgreement, | ||
SerialNumber: big.NewInt(mathrand.Int63()), | ||
NotBefore: time.Now().Add(-30 * time.Second), | ||
NotAfter: time.Now().Add(262980 * time.Hour), | ||
} | ||
|
||
tempDir, connState, err := generateTestCertAndConnState(t, certTemplate) | ||
if tempDir != "" { | ||
defer os.RemoveAll(tempDir) | ||
} | ||
if err != nil { | ||
t.Fatalf("error testing connection state: %v", err) | ||
} | ||
ca, err := ioutil.ReadFile("test-fixtures/root/rootcacert.pem") | ||
ca, err := ioutil.ReadFile(filepath.Join(tempDir, "ca_cert.pem")) | ||
if err != nil { | ||
t.Fatalf("err: %v", err) | ||
} | ||
|
||
logicaltest.Test(t, logicaltest.TestCase{ | ||
CredentialBackend: testFactory(t), | ||
Steps: []logicaltest.TestStep{ | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
builtin/credential/cert/test-fixtures/root/rootcawdnscert.pem
This file was deleted.
Oops, something went wrong.
52 changes: 0 additions & 52 deletions
52
builtin/credential/cert/test-fixtures/root/rootcawdnskey.pem
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
builtin/credential/cert/test-fixtures/root/rootcawemail.cnf
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
builtin/credential/cert/test-fixtures/root/rootcawemail.csr
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
builtin/credential/cert/test-fixtures/root/rootcawemailcert.pem
This file was deleted.
Oops, something went wrong.
52 changes: 0 additions & 52 deletions
52
builtin/credential/cert/test-fixtures/root/rootcawemailkey.pem
This file was deleted.
Oops, something went wrong.