Пример #1
0
////////////////////////////////////////////////////////////////////////////////
// CERTS
////////////////////////////////////////////////////////////////////////////////
func TestNoneSetCert(t *testing.T) {
	if err := cluster.SetCert(testCert); err != nil {
		t.Errorf("Failed to SET cert - %v", err)
		t.FailNow()
	}

	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")
	}
}
Пример #2
0
func postCert(rw http.ResponseWriter, req *http.Request) {
	var cert core.CertBundle
	err := parseBody(req, &cert)
	if err != nil {
		writeError(rw, req, err, http.StatusBadRequest)
		return
	}

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

	writeBody(rw, req, cert, http.StatusOK)
}