Files
mesh-catalog/modules/gitea/cmd/forge-account-provider/main_test.go
T
jschoubben 35ff67bda0
mesh/delivery-group group feat/774-l3-reland rejected: composed together: the checker's verdict at the members' heads (b48c90fea31f): integration: mesh-self-ch…
mesh/delivery closed: a newer head of the same pull request
mesh/check failed: integration: mesh-self-check/cmd/mesh-self-check.TestTheSelfCheckWholeRunsOnTheBus: the run answered {Run:doctor-1793351737-1 At:20…
Design 47's last milestones: the keeper, self-check, healers, hand-acts, provisioner, vault, artifact sweep, disk readings, credential forms (issues 774, 1952, 1953, 1954, 1955)
One commit with exactly the tree of the reviewed head 35b4509c0a, on main 12c2574c9d, so two compiled programs added and removed on the branch leave no trace in history (issue 1577).
2026-10-30 02:21:51 +01:00

47 lines
1.7 KiB
Go

package main
import (
"encoding/json"
"os"
"slices"
"strings"
"testing"
)
func TestConfigFromEnvNamesWhatIsMissing(t *testing.T) {
env := map[string]string{"MESH_NODE": "novox", "MESH_FORGE_HOST_FILE": "/h", "MESH_GITEA_ORIGINS_FILE": "/o",
"MESH_GITEA_URL": "http://127.0.0.1:3000/", "MESH_GITEA_ADMIN_USER": "mesh-admin",
"MESH_GITEA_ADMIN_PASSWORD_FILE": "/p", "MESH_GITEA_SSH_PORT": "222"}
cfg, err := configFromEnv(func(k string) string { return env[k] })
if err != nil || cfg.Port != 222 || cfg.Forge.URL != "http://127.0.0.1:3000" {
t.Fatalf("%+v %v", cfg, err)
}
delete(env, "MESH_FORGE_HOST_FILE")
env["MESH_GITEA_SSH_PORT"] = "x"
_, err = configFromEnv(func(k string) string { return env[k] })
if err == nil || !strings.Contains(err.Error(), "MESH_FORGE_HOST_FILE") || !strings.Contains(err.Error(), "MESH_GITEA_SSH_PORT") {
t.Fatalf("%v", err)
}
}
// Issue 955: the runtime grants a module only the states its manifest `reads`, and the provider watches the machines'
// keys and, through the SDK's provider, the seat mesh-provisioner's plans and provisions (where it learns its consumers, ADR 0570). Run as the
// bus test does, with every bucket made, a missing grant passes unseen; the manifest is read here instead.
func TestTheManifestReadsEveryStateTheProviderWatches(t *testing.T) {
raw, err := os.ReadFile("../../module.json")
if err != nil {
t.Fatal(err)
}
var m struct {
Reads []string `json:"reads"`
}
if err := json.Unmarshal(raw, &m); err != nil {
t.Fatal(err)
}
for _, state := range []string{"mesh-provisioner.plans", "mesh-provisioner.provisions", "ssh-client.keys"} {
if !slices.Contains(m.Reads, state) {
t.Errorf("gitea's reads %v lack %q, so the runtime refuses its watch", m.Reads, state)
}
}
}