示例#1
0
文件: common.go 项目: nanopack/portal
func DeleteCert(cert core.CertBundle) error {
	// in case of failure
	oldCerts, err := database.GetCerts()
	if err != nil {
		return err
	}

	// apply to proxymgr
	err = proxymgr.DeleteCert(cert)
	if err != nil {
		return err
	}

	if !database.CentralStore {
		// save to backend
		err = database.DeleteCert(cert)
		if err != nil {
			// undo proxymgr action
			if uerr := proxymgr.SetCerts(oldCerts); uerr != nil {
				err = fmt.Errorf("%v - %v", err.Error(), uerr.Error())
			}
			return err
		}
	}
	return nil
}
示例#2
0
func TestDeleteCert(t *testing.T) {
	if err := proxymgr.DeleteCert(testCert); err != nil {
		t.Errorf("Failed to DELETE cert - %v", err)
	}

	certs, err := proxymgr.GetCerts()
	if err != nil {
		t.Error(err)
	}

	if len(certs) != 0 {
		t.Errorf("Failed to DELETE cert")
	}
}