diff options
author | Michael Steinert <[email protected]> | 2015-03-30 14:53:16 -0500 |
---|---|---|
committer | Michael Steinert <[email protected]> | 2015-03-30 14:53:16 -0500 |
commit | a0cde3fe01c403f3651e9ee3fec9d62e2a7d806b (patch) | |
tree | 1db3659102bdd0b4110f163b615f2a933d8ca6de /transaction_test.go | |
parent | b129ae324b126900d06d78a132b5784ddd9beeae (diff) |
Rework pam_getenvlist so it doesn't leak
Diffstat (limited to 'transaction_test.go')
-rw-r--r-- | transaction_test.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/transaction_test.go b/transaction_test.go index a1b7050..ce84376 100644 --- a/transaction_test.go +++ b/transaction_test.go @@ -2,10 +2,15 @@ package pam import ( "errors" + "os/user" "testing" ) func TestPAM_001(t *testing.T) { + u, _ := user.Current() + if u.Uid != "0" { + t.Skip("run this test as root") + } tx, err := StartFunc("", "test", func(s Style, msg string) (string, error) { return "secret", nil }) @@ -19,6 +24,10 @@ func TestPAM_001(t *testing.T) { } func TestPAM_002(t *testing.T) { + u, _ := user.Current() + if u.Uid != "0" { + t.Skip("run this test as root") + } tx, err := StartFunc("", "", func(s Style, msg string) (string, error) { switch s { case PromptEchoOn: @@ -53,6 +62,10 @@ func (c Credentials) RespondPAM(s Style, msg string) (string, error) { } func TestPAM_003(t *testing.T) { + u, _ := user.Current() + if u.Uid != "0" { + t.Skip("run this test as root") + } c := Credentials{ User: "test", Password: "secret", @@ -68,6 +81,10 @@ func TestPAM_003(t *testing.T) { } func TestPAM_004(t *testing.T) { + u, _ := user.Current() + if u.Uid != "0" { + t.Skip("run this test as root") + } c := Credentials{ Password: "secret", } @@ -80,3 +97,17 @@ func TestPAM_004(t *testing.T) { t.Fatalf("authenticate #error: %v", err) } } + +func TestGetEnvList(t *testing.T) { + tx, err := StartFunc("passwd", "test", func(s Style, msg string) (string, error) { + return "", nil + }) + if err != nil { + t.Fatalf("start #error: %v", err) + } + m, err := tx.GetEnvList() + if err != nil { + t.Fatalf("getenvlist #error: %v", err) + } + t.Log(m) +} |