Enable SSH and TLS handshake on prober for TCP22 and TCP443 ports
This commit is contained in:
1 parent
af3453f19f
commit
550ce3fec4
11 files changed
+308
-20
No files matched your search
@@ -94,3 +94,36 @@ func TestPollOnceSkipsAssignmentsWhenHeartbeatFails(t *testing.T) {
|
||||
t.Fatalf("expected only [heartbeat] (assignments skipped on heartbeat failure), got %v", calls)
|
||||
}
|
||||
}
|
||||
|
||||
// TestExtraChecksForPort confirms only ports 443 (TLS) and 22 (SSH) get an
|
||||
// extra protocol check beyond the baseline TCPConnect every port gets.
|
||||
func TestExtraChecksForPort(t *testing.T) {
|
||||
// Use a host nothing is listening on so the extra check's own network
|
||||
// call fails fast — only its CheckType is asserted here, the
|
||||
// port->check mapping, not real connectivity.
|
||||
closedHost := "127.0.0.1"
|
||||
|
||||
cases := []struct {
|
||||
port int
|
||||
wantLen int
|
||||
wantCheckType string
|
||||
}{
|
||||
{port: 443, wantLen: 1, wantCheckType: "tls-443"},
|
||||
{port: 22, wantLen: 1, wantCheckType: "ssh"},
|
||||
{port: 80, wantLen: 0},
|
||||
{port: 8080, wantLen: 0},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
extra := extraChecksForPort(closedHost, tc.port, 100*time.Millisecond)
|
||||
if len(extra) != tc.wantLen {
|
||||
t.Fatalf("port %d: expected %d extra checks, got %d", tc.port, tc.wantLen, len(extra))
|
||||
}
|
||||
if tc.wantLen == 0 {
|
||||
continue
|
||||
}
|
||||
res := extra[0](context.Background())
|
||||
if res.CheckType != tc.wantCheckType {
|
||||
t.Fatalf("port %d: expected check type %q, got %q", tc.port, tc.wantCheckType, res.CheckType)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user