mesh/delivery-group group feat/sdk1 rejected: composed together: the checker's verdict at the members' heads (428d048dd50a): unit: git.novox.be/novox/mesh-sdk/…
mesh/delivery closed: a newer head of the same pull request
mesh/check failed: unit: git.novox.be/novox/mesh-sdk/go/process.TestStatePutWritesAKeyWhole: a Put through a short blackout: 0, mesh-mail's state send…
Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
62 lines
2.6 KiB
Go
62 lines
2.6 KiB
Go
package catalogue
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
// novox/hq ADR 0100: on an adopted node the found firewall stays in force. The mesh declares
|
|
// openings where it would have loaded a filter, and guards its own ports in a table that only
|
|
// refuses.
|
|
|
|
// hub is the private network's generator on the hub: it opens the hub's port from anywhere.
|
|
type hub struct{}
|
|
|
|
// anAdoptedAnchor is the control-node's set: the store, the bus, the registry, the private network,
|
|
// a served module and the filter module.
|
|
func anAdoptedAnchor() Resolution {
|
|
return Resolution{Node: "anchor", Modules: []Manifest{
|
|
{Module: "network", Computed: "overlay"},
|
|
{Module: "postgres", Guards: []int{5432},
|
|
Listens: []Listening{{Port: 5432, From: FromMesh}},
|
|
Resources: []map[string]any{{"id": "server", "type": "container", "name": "mesh-store",
|
|
"ports": []any{"5432:5432"}}}},
|
|
{Module: "lavinmq", Guards: []int{15672},
|
|
Listens: []Listening{{Port: 5671, From: FromMesh}, {Port: 5672, From: FromMesh}},
|
|
Resources: []map[string]any{{"id": "server", "type": "container", "name": "mesh-broker",
|
|
"ports": []any{"5671:5671", "5672:5672", "127.0.0.1:15672:15672"}}}},
|
|
{Module: "distribution",
|
|
Listens: []Listening{{Port: 5000, From: FromMesh}},
|
|
Resources: []map[string]any{{"id": "store", "type": "container", "name": "registry",
|
|
"ports": []any{"5000"}}}},
|
|
{Module: "hello-web",
|
|
Listens: []Listening{{Port: 8080, From: FromEverywhere}},
|
|
Resources: []map[string]any{{"id": "server", "type": "container", "name": "hello-web",
|
|
"ports": []any{"8080"}}}},
|
|
{Module: "helper", Listens: []Listening{{Port: 9000, From: FromMachine}}},
|
|
{Module: "nftables", Filtering: &Filtering{Into: "/etc/nftables.conf"},
|
|
Resources: []map[string]any{{"id": "load", "type": "service", "unit": "mesh-filter.service",
|
|
"state": "running", "restart-on": []any{"filtering"}}}},
|
|
}}
|
|
}
|
|
|
|
func byID(resources []map[string]any) map[string]map[string]any {
|
|
out := map[string]map[string]any{}
|
|
for _, r := range resources {
|
|
out[r["id"].(string)] = r
|
|
}
|
|
return out
|
|
}
|
|
|
|
// A mapping bound to loopback is not published to anything off the machine — in either address
|
|
// family — and an address's own colons never shift the ports.
|
|
func TestPublishedLeavesOutLoopbackInBothFamilies(t *testing.T) {
|
|
got := Published([]map[string]any{{"type": "container", "ports": []any{
|
|
"127.0.0.1:15672:15672", "[::1]:8080:80", "localhost:9090:90",
|
|
"[::]:8443:443", "0.0.0.0:5000:5000", "5353:53/udp"}}})
|
|
want := map[string]map[int]int{"tcp": {8443: 443, 5000: 5000}, "udp": {5353: 53}}
|
|
if !reflect.DeepEqual(got, want) {
|
|
t.Fatalf("published is %v, want %v", got, want)
|
|
}
|
|
}
|