mirror of
https://github.com/netbirdio/netbird.git
synced 2025-08-18 02:50:43 +02:00
Add single Unix/Windows path check in process tests
This commit is contained in:
@@ -27,14 +27,14 @@ func (p *ProcessCheck) Check(peer nbpeer.Peer) (bool, error) {
|
||||
switch peer.Meta.GoOS {
|
||||
case "darwin", "linux":
|
||||
for _, process := range p.Processes {
|
||||
if !slices.Contains(peerActiveProcesses, process.Path) {
|
||||
if process.Path == "" || !slices.Contains(peerActiveProcesses, process.Path) {
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
return true, nil
|
||||
case "windows":
|
||||
for _, process := range p.Processes {
|
||||
if !slices.Contains(peerActiveProcesses, process.WindowsPath) {
|
||||
if process.WindowsPath == "" || !slices.Contains(peerActiveProcesses, process.WindowsPath) {
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
|
@@ -35,6 +35,26 @@ func TestProcessCheck_Check(t *testing.T) {
|
||||
wantErr: false,
|
||||
isValid: true,
|
||||
},
|
||||
{
|
||||
name: "darwin with windows process paths",
|
||||
input: peer.Peer{
|
||||
Meta: peer.PeerSystemMeta{
|
||||
GoOS: "darwin",
|
||||
Processes: []peer.Process{
|
||||
{Path: "process1"},
|
||||
{Path: "process2"},
|
||||
},
|
||||
},
|
||||
},
|
||||
check: ProcessCheck{
|
||||
Processes: []Process{
|
||||
{WindowsPath: "process1"},
|
||||
{WindowsPath: "process2"},
|
||||
},
|
||||
},
|
||||
wantErr: false,
|
||||
isValid: false,
|
||||
},
|
||||
{
|
||||
name: "linux with matching processes",
|
||||
input: peer.Peer{
|
||||
@@ -55,6 +75,26 @@ func TestProcessCheck_Check(t *testing.T) {
|
||||
wantErr: false,
|
||||
isValid: true,
|
||||
},
|
||||
{
|
||||
name: "linux with windows process paths",
|
||||
input: peer.Peer{
|
||||
Meta: peer.PeerSystemMeta{
|
||||
GoOS: "linux",
|
||||
Processes: []peer.Process{
|
||||
{Path: "process1"},
|
||||
{Path: "process2"},
|
||||
},
|
||||
},
|
||||
},
|
||||
check: ProcessCheck{
|
||||
Processes: []Process{
|
||||
{WindowsPath: "process1"},
|
||||
{WindowsPath: "process2"},
|
||||
},
|
||||
},
|
||||
wantErr: false,
|
||||
isValid: false,
|
||||
},
|
||||
{
|
||||
name: "linux with non-matching processes",
|
||||
input: peer.Peer{
|
||||
@@ -95,6 +135,26 @@ func TestProcessCheck_Check(t *testing.T) {
|
||||
wantErr: false,
|
||||
isValid: true,
|
||||
},
|
||||
{
|
||||
name: "windows with darwin process paths",
|
||||
input: peer.Peer{
|
||||
Meta: peer.PeerSystemMeta{
|
||||
GoOS: "windows",
|
||||
Processes: []peer.Process{
|
||||
{Path: "process1"},
|
||||
{Path: "process2"},
|
||||
},
|
||||
},
|
||||
},
|
||||
check: ProcessCheck{
|
||||
Processes: []Process{
|
||||
{Path: "process1"},
|
||||
{Path: "process2"},
|
||||
},
|
||||
},
|
||||
wantErr: false,
|
||||
isValid: false,
|
||||
},
|
||||
{
|
||||
name: "windows with non-matching processes",
|
||||
input: peer.Peer{
|
||||
|
Reference in New Issue
Block a user