github.com/jcmturner/gokrb5/v8@v8.4.4/kadmin/changepasswddata_test.go (about)

     1  package kadmin
     2  
     3  import (
     4  	"encoding/hex"
     5  	"testing"
     6  
     7  	"github.com/jcmturner/gokrb5/v8/iana/nametype"
     8  	"github.com/jcmturner/gokrb5/v8/test/testdata"
     9  	"github.com/jcmturner/gokrb5/v8/types"
    10  	"github.com/stretchr/testify/assert"
    11  )
    12  
    13  func TestChangePasswdData_Marshal(t *testing.T) {
    14  	t.Parallel()
    15  	chgpasswd := ChangePasswdData{
    16  		NewPasswd: []byte("newpassword"),
    17  		TargName:  types.NewPrincipalName(nametype.KRB_NT_PRINCIPAL, "testuser1"),
    18  		TargRealm: "TEST.GOKRB5",
    19  	}
    20  	chpwdb, err := chgpasswd.Marshal()
    21  	if err != nil {
    22  		t.Fatalf("error marshaling change passwd data: %v\n", err)
    23  	}
    24  	b, err := hex.DecodeString(testdata.MarshaledChangePasswdData)
    25  	if err != nil {
    26  		t.Fatalf("Test vector read error: %v", err)
    27  	}
    28  	assert.Equal(t, b, chpwdb, "marshaled bytes of change passwd data not as expected")
    29  }