session_test.go 718 B

123456789101112131415161718192021222324252627282930
  1. package xs
  2. import (
  3. "testing"
  4. )
  5. func _newMockSession() (s *Session) {
  6. s = &Session{op: []byte("A"),
  7. who: []byte("johndoe"),
  8. connhost: []byte("host"),
  9. termtype: []byte("vt100"),
  10. cmd: []byte("/bin/false"),
  11. authCookie: []byte("authcookie"),
  12. status: 0}
  13. return s
  14. }
  15. func TestSessionAuthCookieShowTrue(t *testing.T) {
  16. sess := _newMockSession()
  17. if string(sess.AuthCookie(true)) != string(sess.authCookie) {
  18. t.Fatal("Failed to return unredacted authcookie on request")
  19. }
  20. }
  21. func TestSessionAuthCookieShowFalse(t *testing.T) {
  22. sess := _newMockSession()
  23. if string(sess.AuthCookie(false)) != string("**REDACTED**") {
  24. t.Fatal("Failed to return redacted authcookie on request")
  25. }
  26. }