MCPcopy Index your code
hub / github.com/filebrowser/filebrowser / TestRunCommandReceivesCredentialsViaEnv

Function TestRunCommandReceivesCredentialsViaEnv

auth/hook_test.go:61–88  ·  view source on GitHub ↗

TestRunCommandReceivesCredentialsViaEnv verifies the supported contract: the hook receives credentials through the USERNAME and PASSWORD environment variables.

(t *testing.T)

Source from the content-addressed store, hash-verified

59// hook receives credentials through the USERNAME and PASSWORD environment
60// variables.
61func TestRunCommandReceivesCredentialsViaEnv(t *testing.T) {
62 if runtime.GOOS == "windows" {
63 t.Skip("uses POSIX shell")
64 }
65
66 script := writeHookScript(t, `if [ "$USERNAME" = alice ] && [ "$PASSWORD" = secret ]; then
67 echo hook.action=auth
68else
69 echo hook.action=block
70fi
71`)
72
73 a := &HookAuth{
74 Command: script,
75 Cred: hookCred{
76 Username: "alice",
77 Password: "secret",
78 },
79 }
80
81 action, err := a.RunCommand()
82 if err != nil {
83 t.Fatalf("RunCommand returned error: %v", err)
84 }
85 if action != "auth" {
86 t.Fatalf("expected action %q, got %q", "auth", action)
87 }
88}

Callers

nothing calls this directly

Calls 2

RunCommandMethod · 0.95
writeHookScriptFunction · 0.85

Tested by

no test coverage detected