示例#1
0
func TestGetCerts(t *testing.T) {
	certs, err := proxymgr.GetCerts()
	if err != nil {
		t.Errorf("Failed to GET certs - %v", err)
		t.FailNow()
	}

	if certs[0].Cert != testCert.Cert {
		t.Errorf("Read cert differs from written cert")
	}
}
示例#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")
	}
}
示例#3
0
////////////////////////////////////////////////////////////////////////////////
// CERTS
////////////////////////////////////////////////////////////////////////////////
func TestSetCert(t *testing.T) {
	if err := proxymgr.SetCert(testCert); err != nil {
		t.Errorf("Failed to SET cert - %v", err)
		t.FailNow()
	}

	// test idempotency
	if err := proxymgr.SetCert(testCert); err != nil {
		t.Errorf("Failed to SET cert - %v", err)
		t.FailNow()
	}

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

	if len(certs) == 1 && certs[0].Cert != testCert.Cert {
		t.Errorf("Read cert differs from written cert")
	}
}
示例#4
0
func TestSetCerts(t *testing.T) {
	if err := proxymgr.SetCerts([]core.CertBundle{testCert}); err != nil {
		t.Errorf("Failed to SET certs - %v", err)
		t.FailNow()
	}

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

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

	// test bad tls start (certs must be in place)
	config.RouteHttp = "0.0.0.0:9084"
	config.RouteTls = "!@#$%^&*"
	err = proxymgr.Init()
	if err == nil {
		fmt.Printf("Proxymgr init succeeded when it should have failed\n")
		os.Exit(1)
	}
}