From 8de76520e44857c335e62906a466cdbc5560f144 Mon Sep 17 00:00:00 2001 From: Russ Magee Date: Wed, 19 Feb 2020 13:27:56 -0800 Subject: [PATCH] Added session_test.go Signed-off-by: Russ Magee --- session_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 session_test.go diff --git a/session_test.go b/session_test.go new file mode 100644 index 0000000..0670ea8 --- /dev/null +++ b/session_test.go @@ -0,0 +1,30 @@ +package xs + +import ( + "testing" +) + +func _newMockSession() (s *Session) { + s = &Session{op: []byte("A"), + who: []byte("johndoe"), + connhost: []byte("host"), + termtype: []byte("vt100"), + cmd: []byte("/bin/false"), + authCookie: []byte("authcookie"), + status: 0} + return s +} + +func TestSessionAuthCookieShowTrue(t *testing.T) { + sess := _newMockSession() + if string(sess.AuthCookie(true)) != string(sess.authCookie) { + t.Fatal("Failed to return unredacted authcookie on request") + } +} + +func TestSessionAuthCookieShowFalse(t *testing.T) { + sess := _newMockSession() + if string(sess.AuthCookie(false)) != string("**REDACTED**") { + t.Fatal("Failed to return redacted authcookie on request") + } +}