Skip to content
quarry Artifact [10e46ecf85]
Login

Artifact [10e46ecf85]

Artifact 10e46ecf8533eed8688564c20fce118c46833a397b8f29a77b74503add113e90:


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")
}