[GLBC] Support backside re-encryption (#519)
Support backside re-encryption
This commit is contained in:
parent
7f3763590a
commit
642cb74cc7
21 changed files with 1046 additions and 433 deletions
|
|
@ -17,47 +17,170 @@ limitations under the License.
|
|||
package healthchecks
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
compute "google.golang.org/api/compute/v1"
|
||||
|
||||
"k8s.io/ingress/controllers/gce/utils"
|
||||
)
|
||||
|
||||
func TestFakeHealthCheckActions(t *testing.T) {
|
||||
namer := &utils.Namer{}
|
||||
healthChecks := NewHealthChecker(NewFakeHealthChecks(), "/", namer)
|
||||
healthChecks.Init(&FakeHealthCheckGetter{DefaultHealthCheck: nil})
|
||||
func TestHealthCheckAdd(t *testing.T) {
|
||||
namer := utils.NewNamer("ABC", "XYZ")
|
||||
hcp := NewFakeHealthCheckProvider()
|
||||
healthChecks := NewHealthChecker(hcp, "/", namer)
|
||||
|
||||
err := healthChecks.Add(80)
|
||||
hc := healthChecks.New(80, utils.ProtocolHTTP)
|
||||
_, err := healthChecks.Sync(hc)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error")
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
_, err1 := healthChecks.Get(8080)
|
||||
if err1 == nil {
|
||||
t.Errorf("expected error")
|
||||
}
|
||||
|
||||
hc, err2 := healthChecks.Get(80)
|
||||
if err2 != nil {
|
||||
t.Errorf("unexpected error")
|
||||
} else {
|
||||
if hc == nil {
|
||||
t.Errorf("expected a *compute.HttpHealthCheck")
|
||||
}
|
||||
}
|
||||
|
||||
err = healthChecks.Delete(8080)
|
||||
if err == nil {
|
||||
t.Errorf("expected error")
|
||||
}
|
||||
|
||||
err = healthChecks.Delete(80)
|
||||
// Verify the health check exists
|
||||
_, err = hcp.GetHealthCheck(namer.BeName(80))
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error")
|
||||
t.Fatalf("expected the health check to exist, err: %v", err)
|
||||
}
|
||||
|
||||
_, err3 := healthChecks.Get(80)
|
||||
if err3 == nil {
|
||||
t.Errorf("expected error")
|
||||
hc = healthChecks.New(443, utils.ProtocolHTTPS)
|
||||
_, err = healthChecks.Sync(hc)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
// Verify the health check exists
|
||||
_, err = hcp.GetHealthCheck(namer.BeName(443))
|
||||
if err != nil {
|
||||
t.Fatalf("expected the health check to exist, err: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHealthCheckAddExisting(t *testing.T) {
|
||||
namer := &utils.Namer{}
|
||||
hcp := NewFakeHealthCheckProvider()
|
||||
healthChecks := NewHealthChecker(hcp, "/", namer)
|
||||
|
||||
// HTTP
|
||||
// Manually insert a health check
|
||||
httpHC := DefaultHealthCheck(3000, utils.ProtocolHTTP)
|
||||
httpHC.Name = namer.BeName(3000)
|
||||
httpHC.RequestPath = "/my-probes-health"
|
||||
hcp.CreateHealthCheck(httpHC.ToComputeHealthCheck())
|
||||
|
||||
// Should not fail adding the same type of health check
|
||||
hc := healthChecks.New(3000, utils.ProtocolHTTP)
|
||||
_, err := healthChecks.Sync(hc)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
// Verify the health check exists
|
||||
_, err = hcp.GetHealthCheck(httpHC.Name)
|
||||
if err != nil {
|
||||
t.Fatalf("expected the health check to continue existing, err: %v", err)
|
||||
}
|
||||
|
||||
// HTTPS
|
||||
// Manually insert a health check
|
||||
httpsHC := DefaultHealthCheck(4000, utils.ProtocolHTTPS)
|
||||
httpsHC.Name = namer.BeName(4000)
|
||||
httpsHC.RequestPath = "/my-probes-health"
|
||||
hcp.CreateHealthCheck(httpsHC.ToComputeHealthCheck())
|
||||
|
||||
hc = healthChecks.New(4000, utils.ProtocolHTTPS)
|
||||
_, err = healthChecks.Sync(hc)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
// Verify the health check exists
|
||||
_, err = hcp.GetHealthCheck(httpsHC.Name)
|
||||
if err != nil {
|
||||
t.Fatalf("expected the health check to continue existing, err: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHealthCheckDelete(t *testing.T) {
|
||||
namer := &utils.Namer{}
|
||||
hcp := NewFakeHealthCheckProvider()
|
||||
healthChecks := NewHealthChecker(hcp, "/", namer)
|
||||
|
||||
// Create HTTP HC for 1234
|
||||
hc := DefaultHealthCheck(1234, utils.ProtocolHTTP)
|
||||
hc.Name = namer.BeName(1234)
|
||||
hcp.CreateHealthCheck(hc.ToComputeHealthCheck())
|
||||
|
||||
// Create HTTPS HC for 1234)
|
||||
hc.Type = string(utils.ProtocolHTTPS)
|
||||
hcp.CreateHealthCheck(hc.ToComputeHealthCheck())
|
||||
|
||||
// Delete only HTTP 1234
|
||||
err := healthChecks.Delete(1234)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error when deleting health check, err: %v", err)
|
||||
}
|
||||
|
||||
// Validate port is deleted
|
||||
_, err = hcp.GetHealthCheck(hc.Name)
|
||||
if !utils.IsHTTPErrorCode(err, http.StatusNotFound) {
|
||||
t.Errorf("expected not-found error, actual: %v", err)
|
||||
}
|
||||
|
||||
// Delete only HTTP 1234
|
||||
err = healthChecks.Delete(1234)
|
||||
if err == nil {
|
||||
t.Errorf("expected not-found error when deleting health check, err: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHealthCheckUpdate(t *testing.T) {
|
||||
namer := &utils.Namer{}
|
||||
hcp := NewFakeHealthCheckProvider()
|
||||
healthChecks := NewHealthChecker(hcp, "/", namer)
|
||||
|
||||
// HTTP
|
||||
// Manually insert a health check
|
||||
hc := DefaultHealthCheck(3000, utils.ProtocolHTTP)
|
||||
hc.Name = namer.BeName(3000)
|
||||
hc.RequestPath = "/my-probes-health"
|
||||
hcp.CreateHealthCheck(hc.ToComputeHealthCheck())
|
||||
|
||||
// Verify the health check exists
|
||||
_, err := healthChecks.Get(3000)
|
||||
if err != nil {
|
||||
t.Fatalf("expected the health check to exist, err: %v", err)
|
||||
}
|
||||
|
||||
// Change to HTTPS
|
||||
hc.Type = string(utils.ProtocolHTTPS)
|
||||
_, err = healthChecks.Sync(hc)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected err while syncing healthcheck, err %v", err)
|
||||
}
|
||||
|
||||
// Verify the health check exists
|
||||
_, err = healthChecks.Get(3000)
|
||||
if err != nil {
|
||||
t.Fatalf("expected the health check to exist, err: %v", err)
|
||||
}
|
||||
|
||||
// Verify the check is now HTTPS
|
||||
if hc.Protocol() != utils.ProtocolHTTPS {
|
||||
t.Fatalf("expected check to be of type HTTPS")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHealthCheckDeleteLegacy(t *testing.T) {
|
||||
namer := &utils.Namer{}
|
||||
hcp := NewFakeHealthCheckProvider()
|
||||
healthChecks := NewHealthChecker(hcp, "/", namer)
|
||||
|
||||
err := hcp.CreateHttpHealthCheck(&compute.HttpHealthCheck{
|
||||
Name: namer.BeName(80),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("expected health check to be created, err: %v", err)
|
||||
}
|
||||
|
||||
err = healthChecks.DeleteLegacy(80)
|
||||
if err != nil {
|
||||
t.Fatalf("expected health check to be deleted, err: %v", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue