summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/e2e/arg_integrity_test.go5
-rw-r--r--tests/e2e/fuzz_args_test.go7
-rw-r--r--tests/e2e/test_helpers.go42
3 files changed, 18 insertions, 36 deletions
diff --git a/tests/e2e/arg_integrity_test.go b/tests/e2e/arg_integrity_test.go
index 7121c2b..497a51d 100644
--- a/tests/e2e/arg_integrity_test.go
+++ b/tests/e2e/arg_integrity_test.go
@@ -20,7 +20,10 @@ func TestArgumentIntegrity(t *testing.T) {
for _, payload := range payloads {
t.Run(fmt.Sprintf("Payload_%s", payload), func(t *testing.T) {
- binaryPath := GetBinaryPath()
+ binaryPath, err := GetBinaryPath()
+ if err != nil {
+ t.Skip("Skipping E2E test: wg-wrap binary not found (WG_WRAP_BIN not set)")
+ }
cmd := exec.Command(binaryPath, "test-args", payload)
out, err := cmd.CombinedOutput()
if err != nil {
diff --git a/tests/e2e/fuzz_args_test.go b/tests/e2e/fuzz_args_test.go
index 0d4a45b..0d71e0e 100644
--- a/tests/e2e/fuzz_args_test.go
+++ b/tests/e2e/fuzz_args_test.go
@@ -8,8 +8,6 @@ import (
)
func FuzzArgumentIntegrity(f *testing.F) {
- binaryPath := GetBinaryPath()
-
f.Add("; rm -rf /")
f.Add("$(whoami)")
f.Add(" spaced ")
@@ -17,6 +15,11 @@ func FuzzArgumentIntegrity(f *testing.F) {
f.Add("\x00null\x00")
f.Fuzz(func(t *testing.T, payload string) {
+ binaryPath, err := GetBinaryPath()
+ if err != nil {
+ t.Skip("Skipping E2E fuzz test: wg-wrap binary not found (WG_WRAP_BIN not set)")
+ }
+
out, err := exec.Command(binaryPath, "test-args", payload).CombinedOutput()
if strings.Contains(payload, "\x00") {
diff --git a/tests/e2e/test_helpers.go b/tests/e2e/test_helpers.go
index 34aae3f..0ae83aa 100644
--- a/tests/e2e/test_helpers.go
+++ b/tests/e2e/test_helpers.go
@@ -1,45 +1,21 @@
package e2e
import (
+ "fmt"
"os"
- "os/exec"
- "path/filepath"
- "runtime"
)
// GetBinaryPath resolves the path to the wg-wrap binary.
-// It checks the current directory, then the project root, then the system PATH.
-func GetBinaryPath() string {
- binaryName := "wg-wrap"
- if runtime.GOOS == "windows" {
- binaryName += ".exe"
+// It prioritizes the WG_WRAP_BIN environment variable.
+func GetBinaryPath() (string, error) {
+ path := os.Getenv("WG_WRAP_BIN")
+ if path == "" {
+ return "", fmt.Errorf("WG_WRAP_BIN environment variable not set")
}
- // 1. Check current working directory
- if _, err := os.Stat(binaryName); err == nil {
- abs, _ := filepath.Abs(binaryName)
- return abs
+ if _, err := os.Stat(path); err != nil {
+ return "", fmt.Errorf("binary not found at path %s: %w", path, err)
}
- // 2. Check common project root relative paths
- // Since go test can be run from root or package dir, we try both.
- candidates := []string{
- filepath.Join("..", "..", binaryName), // from tests/e2e
- filepath.Join("..", binaryName), // from tests/
- binaryName, // from root
- }
- for _, c := range candidates {
- if _, err := os.Stat(c); err == nil {
- abs, _ := filepath.Abs(c)
- return abs
- }
- }
-
- // 3. Check system PATH
- path, err := exec.LookPath(binaryName)
- if err == nil {
- return path
- }
-
- return binaryName
+ return path, nil
}