Skip to content

Commit 4edbe98

Browse files
authored
fix: fixes ldap config to allow PATCH (#340)
1 parent 3230017 commit 4edbe98

File tree

2 files changed

+37
-36
lines changed

2 files changed

+37
-36
lines changed

mongodbatlas/ldap_configurations.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ type LDAPConfiguration struct {
5656

5757
// LDAP specifies an LDAP configuration for a Atlas project.
5858
type LDAP struct {
59-
AuthenticationEnabled bool `json:"authenticationEnabled,omitempty"` // Specifies whether user authentication with LDAP is enabled.
60-
AuthorizationEnabled bool `json:"authorizationEnabled,omitempty"` // The current status of the LDAP over TLS/SSL configuration.
61-
Hostname string `json:"hostname,omitempty"` // The hostname or IP address of the LDAP server
62-
Port int `json:"port,omitempty"` // The port to which the LDAP server listens for client connections.
63-
BindUsername string `json:"bindUsername,omitempty"` // The user DN that Atlas uses to connect to the LDAP server.
59+
AuthenticationEnabled *bool `json:"authenticationEnabled,omitempty"` // Specifies whether user authentication with LDAP is enabled.
60+
AuthorizationEnabled *bool `json:"authorizationEnabled,omitempty"` // The current status of the LDAP over TLS/SSL configuration.
61+
Hostname *string `json:"hostname,omitempty"` // The hostname or IP address of the LDAP server
62+
Port *int `json:"port,omitempty"` // The port to which the LDAP server listens for client connections.
63+
BindUsername *string `json:"bindUsername,omitempty"` // The user DN that Atlas uses to connect to the LDAP server.
6464
UserToDNMapping []*UserToDNMapping `json:"userToDNMapping,omitempty"` // Maps an LDAP username for authentication to an LDAP Distinguished Name (DN).
65-
BindPassword string `json:"bindPassword,omitempty"` // The password used to authenticate the bindUsername.
66-
CaCertificate string `json:"caCertificate,omitempty"` // CA certificate used to verify the identify of the LDAP server.
67-
AuthzQueryTemplate string `json:"authzQueryTemplate,omitempty"` // An LDAP query template that Atlas executes to obtain the LDAP groups to which the authenticated user belongs.
65+
BindPassword *string `json:"bindPassword,omitempty"` // The password used to authenticate the bindUsername.
66+
CaCertificate *string `json:"caCertificate,omitempty"` // CA certificate used to verify the identity of the LDAP server.
67+
AuthzQueryTemplate *string `json:"authzQueryTemplate,omitempty"` // An LDAP query template that Atlas executes to obtain the LDAP groups to which the authenticated user belongs.
6868
}
6969

7070
// UserToDNMapping maps an LDAP username for authentication to an LDAP Distinguished Name (DN). Each document contains a match regular expression and either a substitution or ldapQuery template used to transform the LDAP username extracted from the regular expression.

mongodbatlas/ldap_configurations_test.go

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"testing"
2121

2222
"github.com/go-test/deep"
23+
"github.com/openlyinc/pointy"
2324
)
2425

2526
func TestLDAPConfigurations_Verify(t *testing.T) {
@@ -43,10 +44,10 @@ func TestLDAPConfigurations_Verify(t *testing.T) {
4344
})
4445

4546
request := &LDAP{
46-
Hostname: "atlas-ldaps-01.ldap.myteam.com",
47-
Port: 636,
48-
BindUsername: "CN=Administrator,CN=Users,DC=atlas-ldaps-01,DC=myteam,DC=com",
49-
BindPassword: "admin",
47+
Hostname: pointy.String("atlas-ldaps-01.ldap.myteam.com"),
48+
Port: pointy.Int(636),
49+
BindUsername: pointy.String("CN=Administrator,CN=Users,DC=atlas-ldaps-01,DC=myteam,DC=com"),
50+
BindPassword: pointy.String("admin"),
5051
}
5152
ldap, _, err := client.LDAPConfigurations.Verify(ctx, groupID, request)
5253
if err != nil {
@@ -154,12 +155,12 @@ func TestLDAPConfigurations_Save(t *testing.T) {
154155

155156
request := &LDAPConfiguration{
156157
LDAP: &LDAP{
157-
AuthenticationEnabled: true,
158-
AuthorizationEnabled: true,
159-
Hostname: "atlas-ldaps-01.ldap.myteam.com",
160-
Port: 636,
161-
BindUsername: "CN=Administrator,CN=Users,DC=atlas-ldaps-01,DC=myteam,DC=com",
162-
BindPassword: "admin",
158+
AuthenticationEnabled: pointy.Bool(true),
159+
AuthorizationEnabled: pointy.Bool(true),
160+
Hostname: pointy.String("atlas-ldaps-01.ldap.myteam.com"),
161+
Port: pointy.Int(636),
162+
BindUsername: pointy.String("CN=Administrator,CN=Users,DC=atlas-ldaps-01,DC=myteam,DC=com"),
163+
BindPassword: pointy.String("admin"),
163164
},
164165
}
165166
ldap, _, err := client.LDAPConfigurations.Save(ctx, groupID, request)
@@ -169,18 +170,18 @@ func TestLDAPConfigurations_Save(t *testing.T) {
169170

170171
expected := &LDAPConfiguration{
171172
LDAP: &LDAP{
172-
AuthenticationEnabled: true,
173-
AuthorizationEnabled: true,
174-
Hostname: "atlas-ldaps-01.ldap.myteam.com",
175-
Port: 636,
176-
BindUsername: "CN=Administrator,CN=Users,DC=atlas-ldaps-01,DC=myteam,DC=com",
173+
AuthenticationEnabled: pointy.Bool(true),
174+
AuthorizationEnabled: pointy.Bool(true),
175+
Hostname: pointy.String("atlas-ldaps-01.ldap.myteam.com"),
176+
Port: pointy.Int(636),
177+
BindUsername: pointy.String("CN=Administrator,CN=Users,DC=atlas-ldaps-01,DC=myteam,DC=com"),
177178
UserToDNMapping: []*UserToDNMapping{
178179
{
179180
Match: "(.*)",
180181
Substitution: "CN={0},CN=Users,DC=atlas-ldaps-01,DC=myteam,DC=com",
181182
},
182183
},
183-
AuthzQueryTemplate: "{USER}?memberOf?base",
184+
AuthzQueryTemplate: pointy.String("{USER}?memberOf?base"),
184185
},
185186
}
186187

@@ -220,18 +221,18 @@ func TestLDAPConfigurations_Get(t *testing.T) {
220221

221222
expected := &LDAPConfiguration{
222223
LDAP: &LDAP{
223-
AuthenticationEnabled: true,
224-
AuthorizationEnabled: true,
225-
Hostname: "atlas-ldaps-01.ldap.myteam.com",
226-
Port: 636,
227-
BindUsername: "CN=Administrator,CN=Users,DC=atlas-ldaps-01,DC=myteam,DC=com",
224+
AuthenticationEnabled: pointy.Bool(true),
225+
AuthorizationEnabled: pointy.Bool(true),
226+
Hostname: pointy.String("atlas-ldaps-01.ldap.myteam.com"),
227+
Port: pointy.Int(636),
228+
BindUsername: pointy.String("CN=Administrator,CN=Users,DC=atlas-ldaps-01,DC=myteam,DC=com"),
228229
UserToDNMapping: []*UserToDNMapping{
229230
{
230231
Match: "(.*)",
231232
Substitution: "CN={0},CN=Users,DC=atlas-ldaps-01,DC=myteam,DC=com",
232233
},
233234
},
234-
AuthzQueryTemplate: "{USER}?memberOf?base",
235+
AuthzQueryTemplate: pointy.String("{USER}?memberOf?base"),
235236
},
236237
}
237238

@@ -267,12 +268,12 @@ func TestLDAPConfigurations_Delete(t *testing.T) {
267268

268269
expected := &LDAPConfiguration{
269270
LDAP: &LDAP{
270-
AuthenticationEnabled: true,
271-
AuthorizationEnabled: true,
272-
Hostname: "atlas-ldaps-01.ldap.myteam.com",
273-
Port: 636,
274-
BindUsername: "CN=Administrator,CN=Users,DC=atlas-ldaps-01,DC=myteam,DC=com",
275-
AuthzQueryTemplate: "{USER}?memberOf?base",
271+
AuthenticationEnabled: pointy.Bool(true),
272+
AuthorizationEnabled: pointy.Bool(true),
273+
Hostname: pointy.String("atlas-ldaps-01.ldap.myteam.com"),
274+
Port: pointy.Int(636),
275+
BindUsername: pointy.String("CN=Administrator,CN=Users,DC=atlas-ldaps-01,DC=myteam,DC=com"),
276+
AuthzQueryTemplate: pointy.String("{USER}?memberOf?base"),
276277
},
277278
}
278279

0 commit comments

Comments
 (0)