|
|
@@ -5,6 +5,7 @@ import (
|
|
|
"testing"
|
|
|
|
|
|
"github.com/jcmturner/gofork/encoding/asn1"
|
|
|
+ "github.com/jcmturner/gokrb5/v8/gssapi"
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
)
|
|
|
|
|
|
@@ -88,3 +89,58 @@ func TestMarshal_negTokenResp(t *testing.T) {
|
|
|
}
|
|
|
assert.Equal(t, b, mb, "Marshalled bytes not as expected for NegTokenResp")
|
|
|
}
|
|
|
+
|
|
|
+func TestUnmarshal_negTokenInitWithReqFlags(t *testing.T) {
|
|
|
+ //t.Parallel()
|
|
|
+ //b, err := hex.DecodeString(testNegTokenInit)
|
|
|
+ //if err != nil {
|
|
|
+ // t.Fatalf("Error converting hex string test data to bytes: %v", err)
|
|
|
+ //}
|
|
|
+ //isInit, nt, err := UnmarshalNegToken(b)
|
|
|
+ //if err != nil {
|
|
|
+ // t.Fatalf("Error unmarshalling negotiation token: %v", err)
|
|
|
+ //}
|
|
|
+ //assert.IsType(t, NegTokenInit{}, nt, "Not the expected type NegTokenInit")
|
|
|
+ //assert.True(t, isInit, "Boolean indicating type is negTokenInit is not true")
|
|
|
+ //nInit := nt.(NegTokenInit)
|
|
|
+ //
|
|
|
+ //// Now add some ReqFlags
|
|
|
+ //nInit.ReqFlags = gssapi.NewContextFlags()
|
|
|
+ //nInit.ReqFlags.Bytes = []byte{0xF6}
|
|
|
+ //mb, err := nInit.Marshal()
|
|
|
+ //if err != nil {
|
|
|
+ // t.Fatalf("could not marshal with ReqFlags: %v", err)
|
|
|
+ //}
|
|
|
+ //t.Logf("MB: %s\n", hex.EncodeToString(mb))
|
|
|
+ //
|
|
|
+ //isInit, nt, err = UnmarshalNegToken(mb)
|
|
|
+ //if err != nil {
|
|
|
+ // t.Fatalf("Error unmarshalling negotiation token: %v", err)
|
|
|
+ //}
|
|
|
+ //assert.IsType(t, NegTokenInit{}, nt, "Not the expected type NegTokenInit")
|
|
|
+ //assert.True(t, isInit, "Boolean indicating type is negTokenInit is not true")
|
|
|
+ //nInit2 := nt.(NegTokenInit)
|
|
|
+ //t.Logf("nt2: %+v\n", nInit2)
|
|
|
+ //assert.Equal(t, nInit.MechTokenBytes, nInit2.MechTokenBytes)
|
|
|
+
|
|
|
+ m := NegTokenInit{
|
|
|
+ MechTypes: []asn1.ObjectIdentifier{
|
|
|
+ asn1.ObjectIdentifier{1, 2, 840, 113554, 1, 2, 2},
|
|
|
+ },
|
|
|
+ // the presence of ReqFlags field messes up the asn1 parser. comment
|
|
|
+ ReqFlags: gssapi.ContextFlags{BitLength: 7, Bytes: []byte{0xF6}},
|
|
|
+ MechTokenBytes: []byte{'\x01', '\x02', '\x03'},
|
|
|
+ }
|
|
|
+
|
|
|
+ mb, err := m.Marshal()
|
|
|
+ if err != nil {
|
|
|
+ t.Fatal(err)
|
|
|
+ }
|
|
|
+
|
|
|
+ var m2 NegTokenInit
|
|
|
+ err = m2.Unmarshal(mb)
|
|
|
+ if err != nil {
|
|
|
+ t.Fatal(err)
|
|
|
+ }
|
|
|
+ t.Logf("%+v/n", m2)
|
|
|
+}
|