package zitcli
import (
"strings"
"testing"
)
// The push's command line is fixed, passes the argument guard, and has
// no place for the password.
func TestAFossilPushCarriesNoPasswordInItsArguments(t *testing.T) {
args := fossilPushArgs("https://fossil.example.org/r", "pusher")
want := []string{"push", "https://fossil.example.org/r", "--user", "pusher", "--once"}
if strings.Join(args, "\x00") != strings.Join(want, "\x00") {
t.Fatalf("FAIL: argv is %q, want %q", args, want)
}
if err := checkArgs(args); err != nil {
t.Errorf("FAIL: the guard refuses the push: %v", err)
}
for _, a := range args {
if a == "--password" {
t.Error("FAIL: --password in argv")
}
}
// An operand that looks like an option is still refused.
if err := checkArgs(fossilPushArgs("https://fossil.example.org/r", "--evil")); err == nil {
t.Error("FAIL: a user named like an option passed the guard")
}
t.Log("ok")
}