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