Collect auth requirements for bidirectional source peers and fix follow-up review findings

This commit is contained in:
Viktor Liu
2026-08-29 09:57:07 +02:00
parent 1c10c19d45
commit ec320278e3
5 changed files with 60 additions and 29 deletions
@@ -961,12 +961,23 @@ func TestGetPeerNetworkMapComponents_SSHRequirements(t *testing.T) {
mutateRule: func(r *nmdata.PolicyRule) { r.Ports = []string{"443"} },
sshEnabled: true,
},
// A bidirectional rule grants access both ways, so the peer is
// authorized from the sources side too and needs the same inputs.
{
name: "netbird-ssh only counts on the destination side",
name: "netbird-ssh on the source side of a bidirectional rule",
mutateRule: func(r *nmdata.PolicyRule) {
r.Protocol = string(nbtypes.PolicyRuleProtocolNetbirdSSH)
},
targetInSrc: true,
wantAllowed: true,
},
{
name: "netbird-ssh on the source side of a one-way rule",
mutateRule: func(r *nmdata.PolicyRule) {
r.Protocol = string(nbtypes.PolicyRuleProtocolNetbirdSSH)
r.Bidirectional = false
},
targetInSrc: true,
},
// VNC resolves authorized users exactly the way SSH does, so it needs
@@ -995,11 +1006,20 @@ func TestGetPeerNetworkMapComponents_SSHRequirements(t *testing.T) {
},
},
{
name: "netbird-vnc only counts on the destination side",
name: "netbird-vnc on the source side of a bidirectional rule",
mutateRule: func(r *nmdata.PolicyRule) {
r.Protocol = string(nbtypes.PolicyRuleProtocolNetbirdVNC)
},
targetInSrc: true,
wantAllowed: true,
},
{
name: "netbird-vnc on the source side of a one-way rule",
mutateRule: func(r *nmdata.PolicyRule) {
r.Protocol = string(nbtypes.PolicyRuleProtocolNetbirdVNC)
r.Bidirectional = false
},
targetInSrc: true,
},
}