kubernetes/pkg/util/certificates/csr_test.go
Yifan Gu 26babd4eba kubelet: Add --bootstrap-kubeconfig to get TLS client cert.
Add --bootstrap-kubeconfig flag to kubelet. If the flag is non-empty
and --kubeconfig doesn't exist, then the kubelet will use the bootstrap
kubeconfig to create rest client and generate certificate signing request
to request a client cert from API server.

Once succeeds, the result cert will be written down to
--cert-dir/kubelet-client.crt, and the kubeconfig will be populated with
certfile, keyfile path pointing to the result certificate file, key file.
(The key file is generated before creating the CSR).
2016-08-19 13:51:33 -07:00

27 lines
495 B
Go

package certificates
import (
"crypto/x509/pkix"
"io/ioutil"
"net"
"testing"
)
func TestNewCertificateRequest(t *testing.T) {
keyFile := "testdata/dontUseThisKey.pem"
subject := &pkix.Name{
CommonName: "kube-worker",
}
dnsSANs := []string{"localhost"}
ipSANs := []net.IP{net.ParseIP("127.0.0.1")}
keyData, err := ioutil.ReadFile(keyFile)
if err != nil {
t.Fatal(err)
}
_, _, err = NewCertificateRequest(keyData, subject, dnsSANs, ipSANs)
if err != nil {
t.Error(err)
}
}