Skip to content

Commit 83b8f31

Browse files
authored
gofumpt (#427)
1 parent 6a543b2 commit 83b8f31

17 files changed

+85
-60
lines changed

add.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ func NewAddRequest(dn string, controls []Control) *AddRequest {
6161
DN: dn,
6262
Controls: controls,
6363
}
64-
6564
}
6665

6766
// Add performs the given AddRequest

bind.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ func parseParams(str string) (map[string]string, error) {
261261
var state int
262262
for i := 0; i <= len(str); i++ {
263263
switch state {
264-
case 0: //reading key
264+
case 0: // reading key
265265
if i == len(str) {
266266
return nil, fmt.Errorf("syntax error on %d", i)
267267
}
@@ -270,7 +270,7 @@ func parseParams(str string) (map[string]string, error) {
270270
continue
271271
}
272272
state = 1
273-
case 1: //reading value
273+
case 1: // reading value
274274
if i == len(str) {
275275
m[key] = value
276276
break
@@ -289,7 +289,7 @@ func parseParams(str string) (map[string]string, error) {
289289
default:
290290
value += string(str[i])
291291
}
292-
case 2: //inside quotes
292+
case 2: // inside quotes
293293
if i == len(str) {
294294
return nil, fmt.Errorf("syntax error on %d", i)
295295
}
@@ -651,7 +651,6 @@ func (l *Conn) GSSAPIBindRequest(client GSSAPIClient, req *GSSAPIBindRequest) er
651651
}
652652

653653
func (l *Conn) saslBindTokenExchange(reqControls []Control, reqToken []byte) ([]byte, error) {
654-
655654
// Construct LDAP Bind request with GSSAPI SASL mechanism.
656655
envelope := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "LDAP Request")
657656
envelope.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, l.nextMessageID(), "MessageID"))

compare.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ func (l *Conn) Compare(dn, attribute, value string) (bool, error) {
3434
msgCtx, err := l.doRequest(&CompareRequest{
3535
DN: dn,
3636
Attribute: attribute,
37-
Value: value})
37+
Value: value,
38+
})
3839
if err != nil {
3940
return false, err
4041
}

dn_test.go

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,55 +11,72 @@ func TestSuccessfulDNParsing(t *testing.T) {
1111
"cn=Jim\\2C \\22Hasse Hö\\22 Hansson!,dc=dummy,dc=com": {[]*RelativeDN{
1212
{[]*AttributeTypeAndValue{{"cn", "Jim, \"Hasse Hö\" Hansson!"}}},
1313
{[]*AttributeTypeAndValue{{"dc", "dummy"}}},
14-
{[]*AttributeTypeAndValue{{"dc", "com"}}}}},
14+
{[]*AttributeTypeAndValue{{"dc", "com"}}},
15+
}},
1516
"UID=jsmith,DC=example,DC=net": {[]*RelativeDN{
1617
{[]*AttributeTypeAndValue{{"UID", "jsmith"}}},
1718
{[]*AttributeTypeAndValue{{"DC", "example"}}},
18-
{[]*AttributeTypeAndValue{{"DC", "net"}}}}},
19+
{[]*AttributeTypeAndValue{{"DC", "net"}}},
20+
}},
1921
"OU=Sales+CN=J. Smith,DC=example,DC=net": {[]*RelativeDN{
2022
{[]*AttributeTypeAndValue{
2123
{"OU", "Sales"},
22-
{"CN", "J. Smith"}}},
24+
{"CN", "J. Smith"},
25+
}},
2326
{[]*AttributeTypeAndValue{{"DC", "example"}}},
24-
{[]*AttributeTypeAndValue{{"DC", "net"}}}}},
27+
{[]*AttributeTypeAndValue{{"DC", "net"}}},
28+
}},
2529
"1.3.6.1.4.1.1466.0=#04024869": {[]*RelativeDN{
26-
{[]*AttributeTypeAndValue{{"1.3.6.1.4.1.1466.0", "Hi"}}}}},
30+
{[]*AttributeTypeAndValue{{"1.3.6.1.4.1.1466.0", "Hi"}}},
31+
}},
2732
"1.3.6.1.4.1.1466.0=#04024869,DC=net": {[]*RelativeDN{
2833
{[]*AttributeTypeAndValue{{"1.3.6.1.4.1.1466.0", "Hi"}}},
29-
{[]*AttributeTypeAndValue{{"DC", "net"}}}}},
34+
{[]*AttributeTypeAndValue{{"DC", "net"}}},
35+
}},
3036
"CN=Lu\\C4\\8Di\\C4\\87": {[]*RelativeDN{
31-
{[]*AttributeTypeAndValue{{"CN", "Lučić"}}}}},
37+
{[]*AttributeTypeAndValue{{"CN", "Lučić"}}},
38+
}},
3239
" CN = Lu\\C4\\8Di\\C4\\87 ": {[]*RelativeDN{
33-
{[]*AttributeTypeAndValue{{"CN", "Lučić"}}}}},
40+
{[]*AttributeTypeAndValue{{"CN", "Lučić"}}},
41+
}},
3442
` A = 1 , B = 2 `: {[]*RelativeDN{
3543
{[]*AttributeTypeAndValue{{"A", "1"}}},
36-
{[]*AttributeTypeAndValue{{"B", "2"}}}}},
44+
{[]*AttributeTypeAndValue{{"B", "2"}}},
45+
}},
3746
` A = 1 + B = 2 `: {[]*RelativeDN{
3847
{[]*AttributeTypeAndValue{
3948
{"A", "1"},
40-
{"B", "2"}}}}},
49+
{"B", "2"},
50+
}},
51+
}},
4152
` \ \ A\ \ = \ \ 1\ \ , \ \ B\ \ = \ \ 2\ \ `: {[]*RelativeDN{
4253
{[]*AttributeTypeAndValue{{" A ", " 1 "}}},
43-
{[]*AttributeTypeAndValue{{" B ", " 2 "}}}}},
54+
{[]*AttributeTypeAndValue{{" B ", " 2 "}}},
55+
}},
4456
` \ \ A\ \ = \ \ 1\ \ + \ \ B\ \ = \ \ 2\ \ `: {[]*RelativeDN{
4557
{[]*AttributeTypeAndValue{
4658
{" A ", " 1 "},
47-
{" B ", " 2 "}}}}},
59+
{" B ", " 2 "},
60+
}},
61+
}},
4862

4963
`cn=john.doe;dc=example,dc=net`: {[]*RelativeDN{
5064
{[]*AttributeTypeAndValue{{"cn", "john.doe"}}},
5165
{[]*AttributeTypeAndValue{{"dc", "example"}}},
52-
{[]*AttributeTypeAndValue{{"dc", "net"}}}}},
66+
{[]*AttributeTypeAndValue{{"dc", "net"}}},
67+
}},
5368

5469
// Escaped `;` should not be treated as RDN
5570
`cn=john.doe\;weird name,dc=example,dc=net`: {[]*RelativeDN{
5671
{[]*AttributeTypeAndValue{{"cn", "john.doe;weird name"}}},
5772
{[]*AttributeTypeAndValue{{"dc", "example"}}},
58-
{[]*AttributeTypeAndValue{{"dc", "net"}}}}},
73+
{[]*AttributeTypeAndValue{{"dc", "net"}}},
74+
}},
5975
`cn=ZXhhbXBsZVRleHQ=,dc=dummy,dc=com`: {[]*RelativeDN{
6076
{[]*AttributeTypeAndValue{{"cn", "ZXhhbXBsZVRleHQ="}}},
6177
{[]*AttributeTypeAndValue{{"dc", "dummy"}}},
62-
{[]*AttributeTypeAndValue{{"dc", "com"}}}}},
78+
{[]*AttributeTypeAndValue{{"dc", "com"}}},
79+
}},
6380
}
6481

6582
for test, answer := range testcases {

examples_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,9 @@ func ExampleControlPaging_manualPaging() {
346346

347347
// This example demonstrates how to use EXTERNAL SASL with TLS client certificates.
348348
func ExampleConn_ExternalBind() {
349-
var ldapCert = "/path/to/cert.pem"
350-
var ldapKey = "/path/to/key.pem"
351-
var ldapCAchain = "/path/to/ca_chain.pem"
349+
ldapCert := "/path/to/cert.pem"
350+
ldapKey := "/path/to/key.pem"
351+
ldapCAchain := "/path/to/ca_chain.pem"
352352

353353
// Load client cert and key
354354
cert, err := tls.LoadX509KeyPair(ldapCert, ldapKey)

examples_windows_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
// This example demonstrates passwordless bind using the current process' user
1313
// credentials on Windows (SASL GSSAPI mechanism bind with SSPI client).
1414
func ExampleConn_SSPIClient_GSSAPIBind() {
15-
1615
// Windows only: Create a GSSAPIClient using Windows built-in SSPI lib
1716
// (secur32.dll).
1817
// This will use the credentials of the current process' user.

gssapi/sspi.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ func (c *SSPIClient) InitSecContext(target string, token []byte) ([]byte, bool,
9999
// NegotiateSaslAuth performs the last step of the SASL handshake.
100100
// See RFC 4752 section 3.1.
101101
func (c *SSPIClient) NegotiateSaslAuth(token []byte, authzid string) ([]byte, error) {
102-
103102
// Using SSPI rather than of GSSAPI, relevant documentation of differences here:
104103
// https://learn.microsoft.com/en-us/windows/win32/secauthn/sspi-kerberos-interoperability-with-gssapi
105104

search_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package ldap
22

33
import (
4-
"github.com/stretchr/testify/assert"
54
"reflect"
65
"testing"
6+
7+
"github.com/stretchr/testify/assert"
78
)
89

910
// TestNewEntry tests that repeated calls to NewEntry return the same value with the same input
@@ -51,7 +52,6 @@ func TestGetAttributeValue(t *testing.T) {
5152
}
5253

5354
func TestEntry_Unmarshal(t *testing.T) {
54-
5555
t.Run("passing a struct should fail", func(t *testing.T) {
5656
entry := &Entry{}
5757

@@ -131,7 +131,6 @@ func TestEntry_Unmarshal(t *testing.T) {
131131

132132
assert.Nil(t, err)
133133
assert.Equal(t, expect, result)
134-
135134
})
136135

137136
t.Run("group struct be decoded", func(t *testing.T) {
@@ -169,5 +168,4 @@ func TestEntry_Unmarshal(t *testing.T) {
169168
assert.Nil(t, err)
170169
assert.Equal(t, expect, result)
171170
})
172-
173171
}

v3/add.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ func NewAddRequest(dn string, controls []Control) *AddRequest {
6161
DN: dn,
6262
Controls: controls,
6363
}
64-
6564
}
6665

6766
// Add performs the given AddRequest

v3/bind.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ func parseParams(str string) (map[string]string, error) {
261261
var state int
262262
for i := 0; i <= len(str); i++ {
263263
switch state {
264-
case 0: //reading key
264+
case 0: // reading key
265265
if i == len(str) {
266266
return nil, fmt.Errorf("syntax error on %d", i)
267267
}
@@ -270,7 +270,7 @@ func parseParams(str string) (map[string]string, error) {
270270
continue
271271
}
272272
state = 1
273-
case 1: //reading value
273+
case 1: // reading value
274274
if i == len(str) {
275275
m[key] = value
276276
break
@@ -289,7 +289,7 @@ func parseParams(str string) (map[string]string, error) {
289289
default:
290290
value += string(str[i])
291291
}
292-
case 2: //inside quotes
292+
case 2: // inside quotes
293293
if i == len(str) {
294294
return nil, fmt.Errorf("syntax error on %d", i)
295295
}
@@ -651,7 +651,6 @@ func (l *Conn) GSSAPIBindRequest(client GSSAPIClient, req *GSSAPIBindRequest) er
651651
}
652652

653653
func (l *Conn) saslBindTokenExchange(reqControls []Control, reqToken []byte) ([]byte, error) {
654-
655654
// Construct LDAP Bind request with GSSAPI SASL mechanism.
656655
envelope := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "LDAP Request")
657656
envelope.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, l.nextMessageID(), "MessageID"))

0 commit comments

Comments
 (0)