github.com/jcmturner/gokrb5/v8@v8.4.4/types/KerberosFlags_test.go (about)

     1  package types
     2  
     3  import (
     4  	"github.com/jcmturner/gofork/encoding/asn1"
     5  	"github.com/jcmturner/gokrb5/v8/iana/flags"
     6  	"github.com/stretchr/testify/assert"
     7  	"testing"
     8  )
     9  
    10  func TestKerberosFlags_SetFlag(t *testing.T) {
    11  	t.Parallel()
    12  	b := []byte{byte(64), byte(0), byte(0), byte(16)}
    13  	var f asn1.BitString
    14  	SetFlag(&f, flags.Forwardable)
    15  	SetFlag(&f, flags.RenewableOK)
    16  	assert.Equal(t, b, f.Bytes, "Flag bytes not as expected")
    17  }
    18  
    19  func TestKerberosFlags_UnsetFlag(t *testing.T) {
    20  	t.Parallel()
    21  	b := []byte{byte(64), byte(0), byte(0), byte(0)}
    22  	var f asn1.BitString
    23  	SetFlag(&f, flags.Forwardable)
    24  	SetFlag(&f, flags.RenewableOK)
    25  	UnsetFlag(&f, flags.RenewableOK)
    26  	assert.Equal(t, b, f.Bytes, "Flag bytes not as expected")
    27  }
    28  
    29  func TestKerberosFlags_IsFlagSet(t *testing.T) {
    30  	t.Parallel()
    31  	var f asn1.BitString
    32  	SetFlag(&f, flags.Forwardable)
    33  	SetFlag(&f, flags.RenewableOK)
    34  	UnsetFlag(&f, flags.Proxiable)
    35  	assert.True(t, IsFlagSet(&f, flags.Forwardable))
    36  	assert.True(t, IsFlagSet(&f, flags.RenewableOK))
    37  	assert.False(t, IsFlagSet(&f, flags.Proxiable))
    38  }