Skip to content

Commit dfbb923

Browse files
committed
chore: cleanup outdated tests
1 parent 1604cf7 commit dfbb923

4 files changed

Lines changed: 22 additions & 69 deletions

File tree

pkg/vpn/vpn_test.go

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package vpn
22

33
import (
44
"os"
5-
"strings"
65
"testing"
76

87
"github.com/malwarebytes/mbvpn-linux/pkg/config"
@@ -349,51 +348,6 @@ func TestGenerateKeys_ErrorPaths(t *testing.T) {
349348
}
350349
}
351350

352-
// Test parsing logic for connected servers output (similar to wg show output)
353-
func TestParseWgShowOutput(t *testing.T) {
354-
testOutput := `interface: wg0
355-
public key: test-public-key-1
356-
private key: (hidden)
357-
listening port: 51820
358-
359-
peer: peer-public-key-1
360-
endpoint: 203.0.113.1:51820
361-
allowed ips: 0.0.0.0/0, ::/0
362-
363-
interface: wg1
364-
public key: test-public-key-2
365-
private key: (hidden)
366-
listening port: 51821
367-
368-
peer: peer-public-key-2
369-
endpoint: 203.0.113.2:51820
370-
allowed ips: 0.0.0.0/0, ::/0`
371-
372-
// Extract interface names from output
373-
lines := strings.Split(testOutput, "\n")
374-
interfaceCount := strings.Count(testOutput, "interface:")
375-
interfaces := make([]string, interfaceCount)
376-
i := 0
377-
for _, line := range lines {
378-
if strings.HasPrefix(line, "interface") {
379-
interfaceName := strings.TrimPrefix(line, "interface: ")
380-
interfaces[i] = interfaceName
381-
i++
382-
}
383-
}
384-
385-
expectedInterfaces := []string{"wg0", "wg1"}
386-
if len(interfaces) != len(expectedInterfaces) {
387-
t.Errorf("Expected %d interfaces, got %d", len(expectedInterfaces), len(interfaces))
388-
}
389-
390-
for i, expected := range expectedInterfaces {
391-
if i < len(interfaces) && interfaces[i] != expected {
392-
t.Errorf("Expected interface %s, got %s", expected, interfaces[i])
393-
}
394-
}
395-
}
396-
397351
// Benchmark tests
398352
func BenchmarkGetCountryFlag(b *testing.B) {
399353
for i := 0; i < b.N; i++ {

test/e2e/connect_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func TestConnectCommandWithValidCountryCode(t *testing.T) {
9191
}
9292

9393
// Expected errors include server data missing, network issues, or sudo requirements
94-
validErrors := []string{"servers.json", "no servers found", "sudo", "wg-quick", "permission"}
94+
validErrors := []string{"servers.json", "no servers found", "sudo", "permission"}
9595
hasValidError := false
9696
for _, validErr := range validErrors {
9797
if strings.Contains(strings.ToLower(output), validErr) {
@@ -125,7 +125,7 @@ func TestConnectCommandWithCountryName(t *testing.T) {
125125
}
126126

127127
// Expected errors include server data missing, network issues, or sudo requirements
128-
validErrors := []string{"servers.json", "no servers found", "sudo", "wg-quick", "permission"}
128+
validErrors := []string{"servers.json", "no servers found", "sudo", "permission"}
129129
hasValidError := false
130130
for _, validErr := range validErrors {
131131
if strings.Contains(strings.ToLower(output), validErr) {
@@ -159,7 +159,7 @@ func TestConnectCommandWithCityCode(t *testing.T) {
159159
}
160160

161161
// Expected errors include server data missing, network issues, or sudo requirements
162-
validErrors := []string{"servers.json", "no servers found", "sudo", "wg-quick", "permission"}
162+
validErrors := []string{"servers.json", "no servers found", "sudo", "permission"}
163163
hasValidError := false
164164
for _, validErr := range validErrors {
165165
if strings.Contains(strings.ToLower(output), validErr) {

test/e2e/disconnect_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ func TestDisconnectCommandBasic(t *testing.T) {
2323
t.Errorf("Disconnect command crashed unexpectedly: %s", output)
2424
}
2525

26-
// Expected errors include sudo requirements, wg command issues, or no active connections
27-
validErrors := []string{"sudo", "wg-quick", "permission", "no active", "not found"}
26+
// Expected errors include sudo requirements or no active connections
27+
validErrors := []string{"sudo", "permission", "no active", "not found"}
2828
hasValidError := false
2929
for _, validErr := range validErrors {
3030
if strings.Contains(strings.ToLower(output), validErr) {
@@ -59,8 +59,8 @@ func TestDisconnectCommandWithServer(t *testing.T) {
5959
t.Errorf("Disconnect command crashed unexpectedly: %s", output)
6060
}
6161

62-
// Expected errors include sudo requirements, wg command issues, or server not found
63-
validErrors := []string{"sudo", "wg-quick", "permission", "not found", "no active"}
62+
// Expected errors include sudo requirements or server not found
63+
validErrors := []string{"sudo", "permission", "not found", "no active"}
6464
hasValidError := false
6565
for _, validErr := range validErrors {
6666
if strings.Contains(strings.ToLower(output), validErr) {
@@ -179,8 +179,8 @@ func TestDisconnectCommandWithInvalidServer(t *testing.T) {
179179
t.Errorf("Disconnect command crashed unexpectedly with invalid server: %s", output)
180180
}
181181

182-
// Expected errors include server not found, sudo requirements, or wg command issues
183-
validErrors := []string{"not found", "sudo", "wg-quick", "permission", "no active"}
182+
// Expected errors include server not found or sudo requirements
183+
validErrors := []string{"not found", "sudo", "permission", "no active"}
184184
hasValidError := false
185185
for _, validErr := range validErrors {
186186
if strings.Contains(strings.ToLower(output), validErr) {
@@ -210,8 +210,8 @@ func TestDisconnectCommandNoActiveConnection(t *testing.T) {
210210
t.Errorf("Disconnect command crashed unexpectedly: %s", output)
211211
}
212212

213-
// Expected errors include no active connections, sudo requirements, or wg command issues
214-
validErrors := []string{"no active", "not found", "sudo", "wg-quick", "permission"}
213+
// Expected errors include no active connections or sudo requirements
214+
validErrors := []string{"no active", "not found", "sudo", "permission"}
215215
hasValidError := false
216216
for _, validErr := range validErrors {
217217
if strings.Contains(strings.ToLower(output), validErr) {
@@ -241,8 +241,8 @@ func TestDisconnectCommandWithExtraArguments(t *testing.T) {
241241
t.Errorf("Disconnect command crashed unexpectedly with extra args: %s", output)
242242
}
243243

244-
// Expected errors include server not found, sudo requirements, or wg command issues
245-
validErrors := []string{"not found", "sudo", "wg-quick", "permission", "no active"}
244+
// Expected errors include server not found or sudo requirements
245+
validErrors := []string{"not found", "sudo", "permission", "no active"}
246246
hasValidError := false
247247
for _, validErr := range validErrors {
248248
if strings.Contains(strings.ToLower(output), validErr) {

test/e2e/status_test.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ func TestStatusCommandNotConnected(t *testing.T) {
4444

4545
// Status command may fail due to sudo requirements for wg commands
4646
if err != nil {
47-
// If it fails, it should be due to sudo/wg requirements, not session issues
48-
if !strings.Contains(output, "sudo") && !strings.Contains(output, "wg show") {
47+
// If it fails, it should be due to sudo requirements, not session issues
48+
if !strings.Contains(output, "sudo") {
4949
t.Errorf("Status command failed for unexpected reason: %v, output: %s", err, output)
5050
}
5151
return
@@ -70,8 +70,8 @@ func TestStatusCommandWithDebugFlag(t *testing.T) {
7070

7171
// Status command may fail due to sudo requirements
7272
if err != nil {
73-
// If it fails, it should be due to sudo/wg requirements
74-
if !strings.Contains(output, "sudo") && !strings.Contains(output, "wg show") {
73+
// If it fails, it should be due to sudo requirements
74+
if !strings.Contains(output, "sudo") {
7575
t.Errorf("Status command with debug flag failed for unexpected reason: %v", err)
7676
}
7777
}
@@ -152,11 +152,10 @@ func TestStatusCommandInvalidArguments(t *testing.T) {
152152
// Command should handle extra arguments gracefully
153153
// Most CLI tools ignore extra arguments for status commands
154154
if err != nil {
155-
// If it fails, it should be due to sudo/wg requirements or session issues
156-
if !strings.Contains(output, "not logged in") &&
155+
// If it fails, it should be due to sudo requirements or session issues
156+
if !strings.Contains(output, "not logged in") &&
157157
!strings.Contains(output, "No active session") &&
158-
!strings.Contains(output, "sudo") &&
159-
!strings.Contains(output, "wg show") {
158+
!strings.Contains(output, "sudo") {
160159
t.Errorf("Status command failed for unexpected reason with invalid args: %v, output: %s", err, output)
161160
}
162161
}
@@ -175,8 +174,8 @@ func TestStatusCommandOutputStructure(t *testing.T) {
175174

176175
// Status command may fail due to sudo requirements
177176
if err != nil {
178-
// If it fails, it should be due to sudo/wg requirements
179-
if !strings.Contains(output, "sudo") && !strings.Contains(output, "wg show") {
177+
// If it fails, it should be due to sudo requirements
178+
if !strings.Contains(output, "sudo") {
180179
t.Errorf("Status command failed for unexpected reason: %v", err)
181180
}
182181
}

0 commit comments

Comments
 (0)