Skip to content

Commit

Permalink
Rename the function name to the term 'request controls' and 'response…
Browse files Browse the repository at this point in the history
… controls'
  • Loading branch information
t2y committed Sep 6, 2023
1 parent f807f31 commit 8e276e7
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions control.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ func DecodeControl(packet *ber.Packet) (Control, error) {
return NewControlSubtreeDelete(), nil
case ControlTypeDirSync:
value.Description += " (DirSync)"
return NewControlDirSyncForDecode(value)
return NewResponseControlDirSync(value)
case ControlTypeSyncState:
value.Description += " (Sync State)"
valueChildren, err := ber.DecodePacketErr(value.Data.Bytes())
Expand Down Expand Up @@ -624,8 +624,8 @@ type ControlDirSync struct {
Cookie []byte
}

// NewControlDirSyncForEncode returns a dir sync control
func NewControlDirSyncForEncode(
// NewRequestControlDirSync returns a dir sync control
func NewRequestControlDirSync(
flags int64, maxAttrCount int64, cookie []byte,
) *ControlDirSync {
return &ControlDirSync{
Expand All @@ -636,8 +636,8 @@ func NewControlDirSyncForEncode(
}
}

// NewControlDirSyncForDecode returns a dir sync control
func NewControlDirSyncForDecode(value *ber.Packet) (*ControlDirSync, error) {
// NewResponseControlDirSync returns a dir sync control
func NewResponseControlDirSync(value *ber.Packet) (*ControlDirSync, error) {
if value.Value != nil {
valueChildren, err := ber.DecodePacketErr(value.Data.Bytes())
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ func TestControlString(t *testing.T) {
}

func TestControlDirSync(t *testing.T) {
runControlTest(t, NewControlDirSyncForEncode(DirSyncObjectSecurity, 1000, nil))
runControlTest(t, NewControlDirSyncForEncode(DirSyncObjectSecurity, 1000, []byte("I'm a cookie!")))
runControlTest(t, NewRequestControlDirSync(DirSyncObjectSecurity, 1000, nil))
runControlTest(t, NewRequestControlDirSync(DirSyncObjectSecurity, 1000, []byte("I'm a cookie!")))
}

func runControlTest(t *testing.T, originalControl Control) {
Expand Down Expand Up @@ -122,7 +122,7 @@ func TestDescribeControlString(t *testing.T) {
}

func TestDescribeControlDirSync(t *testing.T) {
runAddControlDescriptions(t, NewControlDirSyncForEncode(DirSyncObjectSecurity, 1000, nil), "Control Type (DirSync)", "Criticality", "Control Value")
runAddControlDescriptions(t, NewRequestControlDirSync(DirSyncObjectSecurity, 1000, nil), "Control Type (DirSync)", "Criticality", "Control Value")
}

func runAddControlDescriptions(t *testing.T, originalControl Control, childDescriptions ...string) {
Expand Down
4 changes: 2 additions & 2 deletions search.go
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ func (l *Conn) DirSync(
) (*SearchResult, error) {
control := FindControl(searchRequest.Controls, ControlTypeDirSync)
if control == nil {
c := NewControlDirSyncForEncode(flags, maxAttrCount, cookie)
c := NewRequestControlDirSync(flags, maxAttrCount, cookie)
searchRequest.Controls = append(searchRequest.Controls, c)
} else {
c := control.(*ControlDirSync)
Expand Down Expand Up @@ -680,7 +680,7 @@ func (l *Conn) DirSyncAsync(
ctx context.Context, searchRequest *SearchRequest, bufferSize int,
flags, maxAttrCount int64, cookie []byte,
) Response {
control := NewControlDirSyncForEncode(flags, maxAttrCount, cookie)
control := NewRequestControlDirSync(flags, maxAttrCount, cookie)
searchRequest.Controls = append(searchRequest.Controls, control)
r := newSearchResponse(l, bufferSize)
r.start(ctx, searchRequest)
Expand Down
10 changes: 5 additions & 5 deletions v3/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ func DecodeControl(packet *ber.Packet) (Control, error) {
return NewControlServerSideSortingResult(value)
case ControlTypeDirSync:
value.Description += " (DirSync)"
return NewControlDirSyncForDecode(value)
return NewResponseControlDirSync(value)
case ControlTypeSyncState:
value.Description += " (Sync State)"
valueChildren, err := ber.DecodePacketErr(value.Data.Bytes())
Expand Down Expand Up @@ -635,8 +635,8 @@ type ControlDirSync struct {
Cookie []byte
}

// NewControlDirSyncForEncode returns a dir sync control
func NewControlDirSyncForEncode(
// NewRequestControlDirSync returns a dir sync control
func NewRequestControlDirSync(
flags int64, maxAttrCount int64, cookie []byte,
) *ControlDirSync {
return &ControlDirSync{
Expand All @@ -647,8 +647,8 @@ func NewControlDirSyncForEncode(
}
}

// NewControlDirSyncForDecode returns a dir sync control
func NewControlDirSyncForDecode(value *ber.Packet) (*ControlDirSync, error) {
// NewResponseControlDirSync returns a dir sync control
func NewResponseControlDirSync(value *ber.Packet) (*ControlDirSync, error) {
if value.Value != nil {
valueChildren, err := ber.DecodePacketErr(value.Data.Bytes())
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions v3/control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ func TestControlString(t *testing.T) {
}

func TestControlDirSync(t *testing.T) {
runControlTest(t, NewControlDirSyncForEncode(DirSyncObjectSecurity, 1000, nil))
runControlTest(t, NewControlDirSyncForEncode(DirSyncObjectSecurity, 1000, []byte("I'm a cookie!")))
runControlTest(t, NewRequestControlDirSync(DirSyncObjectSecurity, 1000, nil))
runControlTest(t, NewRequestControlDirSync(DirSyncObjectSecurity, 1000, []byte("I'm a cookie!")))
}

func runControlTest(t *testing.T, originalControl Control) {
Expand Down Expand Up @@ -122,7 +122,7 @@ func TestDescribeControlString(t *testing.T) {
}

func TestDescribeControlDirSync(t *testing.T) {
runAddControlDescriptions(t, NewControlDirSyncForEncode(DirSyncObjectSecurity, 1000, nil), "Control Type (DirSync)", "Criticality", "Control Value")
runAddControlDescriptions(t, NewRequestControlDirSync(DirSyncObjectSecurity, 1000, nil), "Control Type (DirSync)", "Criticality", "Control Value")
}

func runAddControlDescriptions(t *testing.T, originalControl Control, childDescriptions ...string) {
Expand Down
4 changes: 2 additions & 2 deletions v3/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ func (l *Conn) DirSync(
) (*SearchResult, error) {
control := FindControl(searchRequest.Controls, ControlTypeDirSync)
if control == nil {
c := NewControlDirSyncForEncode(flags, maxAttrCount, cookie)
c := NewRequestControlDirSync(flags, maxAttrCount, cookie)
searchRequest.Controls = append(searchRequest.Controls, c)
} else {
c := control.(*ControlDirSync)
Expand Down Expand Up @@ -682,7 +682,7 @@ func (l *Conn) DirSyncAsync(
ctx context.Context, searchRequest *SearchRequest, bufferSize int,
flags, maxAttrCount int64, cookie []byte,
) Response {
control := NewControlDirSyncForEncode(flags, maxAttrCount, cookie)
control := NewRequestControlDirSync(flags, maxAttrCount, cookie)
searchRequest.Controls = append(searchRequest.Controls, control)
r := newSearchResponse(l, bufferSize)
r.start(ctx, searchRequest)
Expand Down

0 comments on commit 8e276e7

Please sign in to comment.