github.com/jcmturner/gokrb5/v8@v8.4.4/pac/upn_dns_info_test.go (about) 1 package pac 2 3 import ( 4 "encoding/hex" 5 "testing" 6 7 "github.com/jcmturner/gokrb5/v8/test/testdata" 8 "github.com/stretchr/testify/assert" 9 ) 10 11 func TestUPN_DNSInfo_Unmarshal(t *testing.T) { 12 t.Parallel() 13 b, err := hex.DecodeString(testdata.MarshaledPAC_UPN_DNS_Info) 14 if err != nil { 15 t.Fatal("Could not decode test data hex string") 16 } 17 var k UPNDNSInfo 18 err = k.Unmarshal(b) 19 if err != nil { 20 t.Fatalf("Error unmarshaling test data: %v", err) 21 } 22 assert.Equal(t, uint16(42), k.UPNLength, "UPN Length not as expected") 23 assert.Equal(t, uint16(16), k.UPNOffset, "UPN Offset not as expected") 24 assert.Equal(t, uint16(22), k.DNSDomainNameLength, "DNS Domain Length not as expected") 25 assert.Equal(t, uint16(64), k.DNSDomainNameOffset, "DNS Domain Offset not as expected") 26 assert.Equal(t, "testuser1@test.gokrb5", k.UPN, "UPN not as expected") 27 assert.Equal(t, "TEST.GOKRB5", k.DNSDomain, "DNS Domain not as expected") 28 assert.Equal(t, uint32(0), k.Flags, "DNS Domain not as expected") 29 }