Beispiel #1
0
func putCerts(rw http.ResponseWriter, req *http.Request) {
	var certs []core.CertBundle
	err := parseBody(req, &certs)
	if err != nil {
		writeError(rw, req, err, http.StatusBadRequest)
		return
	}

	// save to cluster
	err = cluster.SetCerts(certs)
	if err != nil {
		writeError(rw, req, err, http.StatusInternalServerError)
		return
	}

	writeBody(rw, req, certs, http.StatusOK)
}
Beispiel #2
0
func TestNoneSetCerts(t *testing.T) {
	certs := []core.CertBundle{testCert}

	if err := cluster.SetCerts(certs); err != nil {
		t.Errorf("Failed to SET certs - %v", err)
		t.FailNow()
	}

	// don't use cluster.GetCerts()
	certs, err := database.GetCerts()
	if err != nil {
		t.Error(err)
	}

	if len(certs) != 1 || certs[0].Cert != testCert.Cert {
		t.Errorf("Read cert differs from written cert")
	}
}