message_test.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. package kadmin
  2. import (
  3. "encoding/hex"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. "gopkg.in/jcmturner/gokrb5.v6/iana"
  7. "gopkg.in/jcmturner/gokrb5.v6/iana/msgtype"
  8. "gopkg.in/jcmturner/gokrb5.v6/testdata"
  9. )
  10. func TestUnmarshalReply(t *testing.T) {
  11. t.Parallel()
  12. var a Reply
  13. v := "Kpasswd_Rep"
  14. b, err := hex.DecodeString(testdata.TestVectors[v])
  15. if err != nil {
  16. t.Fatalf("Test vector read error of %s: %v\n", v, err)
  17. }
  18. err = a.Unmarshal(b)
  19. if err != nil {
  20. t.Fatalf("Unmarshal error of %s: %v\n", v, err)
  21. }
  22. assert.Equal(t, 236, a.MessageLength, "message length not as expected")
  23. assert.Equal(t, 1, a.Version, "message version not as expected")
  24. assert.Equal(t, 140, a.APREPLength, "AP_REP length not as expected")
  25. assert.Equal(t, iana.PVNO, a.APREP.PVNO, "AP_REP within reply not as expected")
  26. assert.Equal(t, msgtype.KRB_AP_REP, a.APREP.MsgType, "AP_REP message type within reply not as expected")
  27. assert.Equal(t, int32(18), a.APREP.EncPart.EType, "AP_REQ etype not as expected")
  28. assert.Equal(t, iana.PVNO, a.KRBPriv.PVNO, "KRBPriv within reply not as expected")
  29. assert.Equal(t, msgtype.KRB_PRIV, a.KRBPriv.MsgType, "KRBPriv type within reply not as expected")
  30. assert.Equal(t, int32(18), a.KRBPriv.EncPart.EType, "KRBPriv etype not as expected")
  31. }
  32. // Request marshal is tested via integration test in the client package due to the dynamic keys and encryption.