Add gibberish test key bytes to Helm tests

This commit is contained in:
Herman Slatman 2022-10-14 01:45:07 +02:00
parent 3262ffd43b
commit 459bfc4c4f
No known key found for this signature in database
GPG key ID: F4D8A44EA0A75A4F
6 changed files with 35 additions and 16 deletions

View file

@ -129,6 +129,10 @@ func TestPKI_WriteHelmTemplate(t *testing.T) {
// and `p.GenerateIntermediateCertificate`.
setFiles(t, p)
// setSSHSigningKeys sets predefined SSH user and host certificate and key bytes.
// This replaces the logic in `p.GenerateSSHSigningKeys`
setSSHSigningKeys(t, p)
w := &bytes.Buffer{}
if err := p.WriteHelmTemplate(w); (err != nil) != tt.wantErr {
t.Errorf("PKI.WriteHelmTemplate() error = %v, wantErr %v", err, tt.wantErr)
@ -197,6 +201,21 @@ func setKeyPair(t *testing.T, p *PKI) {
// setFiles sets some static, gibberish intermediate and root CA certificate bytes.
func setFiles(t *testing.T, p *PKI) {
p.Files["/home/step/certs/root_ca.crt"] = encodeCertificate(&x509.Certificate{Raw: []byte("these are just some fake root CA cert bytes")})
p.Files["/home/step/certs/intermediate_ca.crt"] = encodeCertificate(&x509.Certificate{Raw: []byte("these are just some fake intermediate CA cert bytes")})
p.Files[p.Root[0]] = encodeCertificate(&x509.Certificate{Raw: []byte("these are just some fake root CA cert bytes")})
p.Files[p.RootKey[0]] = []byte("these are just some fake root CA key bytes")
p.Files[p.Intermediate] = encodeCertificate(&x509.Certificate{Raw: []byte("these are just some fake intermediate CA cert bytes")})
p.Files[p.IntermediateKey] = []byte("these are just some fake intermediate CA key bytes")
}
// setSSHSigningKeys sets some static, gibberish ssh user and host CA certificate and key bytes.
func setSSHSigningKeys(t *testing.T, p *PKI) {
if !p.options.enableSSH {
return
}
p.Files[p.Ssh.HostKey] = []byte("fake ssh host key bytes")
p.Files[p.Ssh.HostPublicKey] = []byte("fake ssh host cert bytes")
p.Files[p.Ssh.UserKey] = []byte("fake ssh user key bytes")
p.Files[p.Ssh.UserPublicKey] = []byte("fake ssh user cert bytes")
}

View file

@ -64,11 +64,11 @@ inject:
x509:
# intermediate_ca_key contains the contents of your encrypted intermediate CA key
intermediate_ca_key: |
these are just some fake intermediate CA key bytes
# root_ca_key contains the contents of your encrypted root CA key
# Note that this value can be omitted without impacting the functionality of step-certificates
# If supplied, this should be encrypted using a unique password that is not used for encrypting
# the intermediate_ca_key, ssh.host_ca_key or ssh.user_ca_key.
root_ca_key: |
these are just some fake root CA key bytes

View file

@ -65,11 +65,11 @@ inject:
x509:
# intermediate_ca_key contains the contents of your encrypted intermediate CA key
intermediate_ca_key: |
these are just some fake intermediate CA key bytes
# root_ca_key contains the contents of your encrypted root CA key
# Note that this value can be omitted without impacting the functionality of step-certificates
# If supplied, this should be encrypted using a unique password that is not used for encrypting
# the intermediate_ca_key, ssh.host_ca_key or ssh.user_ca_key.
root_ca_key: |
these are just some fake root CA key bytes

View file

@ -64,11 +64,11 @@ inject:
x509:
# intermediate_ca_key contains the contents of your encrypted intermediate CA key
intermediate_ca_key: |
these are just some fake intermediate CA key bytes
# root_ca_key contains the contents of your encrypted root CA key
# Note that this value can be omitted without impacting the functionality of step-certificates
# If supplied, this should be encrypted using a unique password that is not used for encrypting
# the intermediate_ca_key, ssh.host_ca_key or ssh.user_ca_key.
root_ca_key: |
these are just some fake root CA key bytes

View file

@ -64,11 +64,11 @@ inject:
x509:
# intermediate_ca_key contains the contents of your encrypted intermediate CA key
intermediate_ca_key: |
these are just some fake intermediate CA key bytes
# root_ca_key contains the contents of your encrypted root CA key
# Note that this value can be omitted without impacting the functionality of step-certificates
# If supplied, this should be encrypted using a unique password that is not used for encrypting
# the intermediate_ca_key, ssh.host_ca_key or ssh.user_ca_key.
root_ca_key: |
these are just some fake root CA key bytes

View file

@ -56,10 +56,10 @@ inject:
-----END CERTIFICATE-----
# ssh_host_ca contains the text of the public ssh key for the SSH root CA
ssh_host_ca:
ssh_host_ca: fake ssh host cert bytes
# ssh_user_ca contains the text of the public ssh key for the SSH root CA
ssh_user_ca:
ssh_user_ca: fake ssh user cert bytes
# Secrets contains the root and intermediate keys and optionally the SSH
# private keys
@ -72,19 +72,19 @@ inject:
x509:
# intermediate_ca_key contains the contents of your encrypted intermediate CA key
intermediate_ca_key: |
these are just some fake intermediate CA key bytes
# root_ca_key contains the contents of your encrypted root CA key
# Note that this value can be omitted without impacting the functionality of step-certificates
# If supplied, this should be encrypted using a unique password that is not used for encrypting
# the intermediate_ca_key, ssh.host_ca_key or ssh.user_ca_key.
root_ca_key: |
these are just some fake root CA key bytes
ssh:
# ssh_host_ca_key contains the contents of your encrypted SSH Host CA key
host_ca_key: |
fake ssh host key bytes
# ssh_user_ca_key contains the contents of your encrypted SSH User CA key
user_ca_key: |
fake ssh user key bytes