Support configurable TLS probes in the API and dashboard
This commit is contained in:
1 parent
0bde5627f0
commit
c7fdd2c430
38 files changed
+495
-203
No files matched your search
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
"cloudipvalidator/internal/config"
|
||||
"cloudipvalidator/internal/db"
|
||||
"cloudipvalidator/internal/inbound"
|
||||
"cloudipvalidator/internal/openstack"
|
||||
"cloudipvalidator/internal/orchestrator"
|
||||
)
|
||||
@@ -623,7 +624,9 @@ func TestInboundChecksReflectedInProberAssignmentsWithoutRestart(t *testing.T) {
|
||||
t.Fatalf("expected seeded {[22 80] true} before PUT, got %+v", assignments)
|
||||
}
|
||||
|
||||
resp, body = fc.do(http.MethodPut, "/api/v1/admin/config/inbound-checks", inboundChecksDTO{Ports: []int{8080}, ICMP: false})
|
||||
resp, body = fc.do(http.MethodPut, "/api/v1/admin/config/inbound-checks", inboundChecksDTO{
|
||||
Ports: []int{8080}, TLSChecks: []inbound.TLSCheck{{Port: 8443, Version: "1.2"}, {Port: 9443, Version: "1.3"}},
|
||||
})
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
t.Fatalf("put inbound checks: status=%d body=%s", resp.StatusCode, body)
|
||||
}
|
||||
@@ -638,6 +641,41 @@ func TestInboundChecksReflectedInProberAssignmentsWithoutRestart(t *testing.T) {
|
||||
if len(assignments) != 1 || len(assignments[0].Ports) != 1 || assignments[0].Ports[0] != 8080 || assignments[0].ICMP {
|
||||
t.Fatalf("expected updated {[8080] false} without restart, got %+v", assignments)
|
||||
}
|
||||
if checks := assignments[0].TLSChecks; len(checks) != 2 ||
|
||||
checks[0] != (inbound.TLSCheck{Port: 8443, Version: "1.2"}) ||
|
||||
checks[1] != (inbound.TLSCheck{Port: 9443, Version: "1.3"}) {
|
||||
t.Fatalf("unexpected TLS checks in assignment: %+v", checks)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInboundTLSModesAndValidation(t *testing.T) {
|
||||
fc, _, _, _ := newConfigTestHarness(t)
|
||||
const path = "/api/v1/admin/config/inbound-checks"
|
||||
for _, tc := range []struct {
|
||||
input, wantTLS string
|
||||
status int
|
||||
}{
|
||||
{`{"ports":[443],"tls_checks":[{"port":8443,"version":"1.2"}]}`, `[{"port":8443,"version":"1.2"}]`, http.StatusOK},
|
||||
{`{"ports":[22]}`, `[{"port":8443,"version":"1.2"}]`, http.StatusOK},
|
||||
{`{"ports":[443],"tls_checks":[{"port":0,"version":"1.2"}]}`, "", http.StatusBadRequest},
|
||||
{`{"ports":[443],"tls_checks":[{"port":8443,"version":"1.1"}]}`, "", http.StatusBadRequest},
|
||||
{`{"ports":[443],"tls_checks":[{"port":8443,"version":"1.2"},{"port":8443,"version":"1.3"}]}`, "", http.StatusBadRequest},
|
||||
{`{"ports":[443],"tls_checks":[]}`, "[]", http.StatusOK},
|
||||
{`{"ports":[443],"tls_checks":null}`, "null", http.StatusOK},
|
||||
} {
|
||||
resp, body := fc.do(http.MethodPut, path, json.RawMessage(tc.input))
|
||||
if resp.StatusCode != tc.status {
|
||||
t.Fatalf("%s: status=%d, body=%s", tc.input, resp.StatusCode, body)
|
||||
}
|
||||
if tc.status == http.StatusOK {
|
||||
var got struct {
|
||||
TLSChecks json.RawMessage `json:"tls_checks"`
|
||||
}
|
||||
if err := json.Unmarshal(body, &got); err != nil || string(got.TLSChecks) != tc.wantTLS {
|
||||
t.Fatalf("%s: want tls_checks=%s, got %s (%v)", tc.input, tc.wantTLS, got.TLSChecks, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestProberRegisterSetsHostnameAndIdleState proves POST
|
||||
|
||||
Reference in new issue
Block a user