Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2023-03-13 12:05:37 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2023-03-16 14:46:26 +0300
commit8045fba37485694b8641902a7daa2fde7ba0483d (patch)
tree00b52d891c7ed9b7159e6ceb8c474427ce5c7244
parentfabe1695e5247ea69b2578a8b6b1436fc9ec764f (diff)
testhelper: Clarify variable names in certificate generation
The variable names used by the function to generate certificates are a bit confusing. Most importantly, using both "root" and "ca" for the certificate authority makes one think that those are two different things. Rename the variables to clarify that there really only are two entities: the "root" certificate that is supposed to sign the certificate of the actual "entity".
-rw-r--r--internal/testhelper/testhelper.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/internal/testhelper/testhelper.go b/internal/testhelper/testhelper.go
index 9d1ae6094..822972cfe 100644
--- a/internal/testhelper/testhelper.go
+++ b/internal/testhelper/testhelper.go
@@ -309,7 +309,7 @@ func Unsetenv(tb testing.TB, key string) {
func GenerateCerts(tb testing.TB) (string, string) {
tb.Helper()
- rootCA := &x509.Certificate{
+ rootCert := &x509.Certificate{
SerialNumber: big.NewInt(1),
NotBefore: time.Now(),
NotAfter: time.Now().AddDate(0, 0, 1),
@@ -320,20 +320,20 @@ func GenerateCerts(tb testing.TB) (string, string) {
KeyUsage: x509.KeyUsageCertSign,
}
- caKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
+ rootKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
require.NoError(tb, err)
- caCert, err := x509.CreateCertificate(rand.Reader, rootCA, rootCA, &caKey.PublicKey, caKey)
+ rootBytes, err := x509.CreateCertificate(rand.Reader, rootCert, rootCert, &rootKey.PublicKey, rootKey)
require.NoError(tb, err)
entityKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
require.NoError(tb, err)
- entityX509 := &x509.Certificate{
+ entityCert := &x509.Certificate{
SerialNumber: big.NewInt(2),
}
- entityCert, err := x509.CreateCertificate(rand.Reader, rootCA, entityX509, &entityKey.PublicKey, caKey)
+ entityBytes, err := x509.CreateCertificate(rand.Reader, rootCert, entityCert, &entityKey.PublicKey, rootKey)
require.NoError(tb, err)
certFile, err := os.CreateTemp(testDirectory, "")
@@ -344,7 +344,7 @@ func GenerateCerts(tb testing.TB) (string, string) {
})
// create chained PEM file with CA and entity cert
- for _, cert := range [][]byte{entityCert, caCert} {
+ for _, cert := range [][]byte{entityBytes, rootBytes} {
require.NoError(tb,
pem.Encode(certFile, &pem.Block{
Type: "CERTIFICATE",