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