types/node, mapper, policy/v2: assemble self CapMap inside TailNode
types.NodeView.TailNode takes a selfPolicyCaps tailcfg.NodeCapMap parameter and merges it into the baseline. The mapper's WithSelfNode hands it the policy result via state.NodeCapMap; peer-path callers pass nil because peer-side CapMap is set downstream via policyv2.PeerCapMap. The nodeAttrs compat test now diffs the full TailNode self-view output against captured SaaS netmaps. Before this change the test compared compileNodeAttrs alone -- the policy-only output -- and needed a strip list to compensate for the missing baseline. With TailNode on the diff path, baseline emission is exercised end-to-end by every capture; a regression in TailNode breaks the suite. unmodelledTailnetStateCaps drops cap/ssh and cap/file-sharing now that both sides emit them identically. The file header is rewritten to read as 'caps SaaS emits where headscale has no equivalent yet' rather than the more confusing 'shape divergence' framing.
This commit is contained in:
parent
b3f795f0b4
commit
5ebc53c29e
5 changed files with 77 additions and 64 deletions
|
|
@ -239,6 +239,20 @@ func testNodeAttrsSuccess(
|
|||
got, err := pol.compileNodeAttrs(users, nodes.ViewSlice())
|
||||
require.NoErrorf(t, err, "%s: compileNodeAttrs", tf.TestID)
|
||||
|
||||
// Mirror the prod self-build: route function is irrelevant for CapMap;
|
||||
// Taildrop.Enabled=true matches the SaaS-captured tailnets.
|
||||
cfg := &types.Config{Taildrop: types.TaildropConfig{Enabled: true}}
|
||||
emptyRoutes := func(types.NodeID) []netip.Prefix { return nil }
|
||||
|
||||
selfCapMap := func(t *testing.T, node *types.Node) tailcfg.NodeCapMap {
|
||||
t.Helper()
|
||||
|
||||
tn, err := node.View().TailNode(0, emptyRoutes, cfg, got[node.ID])
|
||||
require.NoErrorf(t, err, "%s/%s: TailNode", tf.TestID, node.GivenName)
|
||||
|
||||
return tn.CapMap
|
||||
}
|
||||
|
||||
for nodeName, capture := range tf.Captures {
|
||||
if capture.Netmap == nil || !capture.Netmap.SelfNode.Valid() {
|
||||
continue
|
||||
|
|
@ -249,7 +263,7 @@ func testNodeAttrsSuccess(
|
|||
require.NotNilf(t, node,
|
||||
"node %q from capture not found in test setup", nodeName)
|
||||
|
||||
gotSelf := stripUnmodelledTailnetStateCaps(got[node.ID])
|
||||
gotSelf := stripUnmodelledTailnetStateCaps(selfCapMap(t, node))
|
||||
wantSelf := stripUnmodelledTailnetStateCaps(
|
||||
capMapFromView(capture.Netmap.SelfNode.CapMap()),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue