Browse Source

Added session_test.go

Signed-off-by: Russ Magee <rmagee@gmail.com>
Russ Magee 1 year ago
parent
commit
8de76520e4
1 changed files with 30 additions and 0 deletions
  1. 30 0
      session_test.go

+ 30 - 0
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")
+	}
+}