client_info_test.go 720 B

123456789101112131415161718192021222324
  1. package pac
  2. import (
  3. "encoding/hex"
  4. "github.com/stretchr/testify/assert"
  5. "gopkg.in/jcmturner/gokrb5.v2/testdata"
  6. "testing"
  7. "time"
  8. )
  9. func TestPAC_ClientInfo_Unmarshal(t *testing.T) {
  10. b, err := hex.DecodeString(testdata.TestVectors["PAC_Client_Info"])
  11. if err != nil {
  12. t.Fatal("Could not decode test data hex string")
  13. }
  14. var k ClientInfo
  15. err = k.Unmarshal(b)
  16. if err != nil {
  17. t.Fatalf("Error unmarshaling test data: %v", err)
  18. }
  19. assert.Equal(t, time.Date(2017, 5, 6, 15, 53, 11, 000000000, time.UTC), k.ClientID.Time(), "Client ID time not as expected.")
  20. assert.Equal(t, uint16(18), k.NameLength, "Client name length not as expected")
  21. assert.Equal(t, "testuser1", k.Name, "Client name not as expected")
  22. }