fix: use "displayName" as LDAP attribute
This commit is contained in:
8 files changed
+31
-31
No files matched your search
@@ -63,7 +63,7 @@ func DefaultConfig() *config.Config {
|
||||
UserSchema: config.LDAPUserSchema{
|
||||
ID: "ownCloudUUID",
|
||||
Mail: "mail",
|
||||
DisplayName: "displayname",
|
||||
DisplayName: "displayName",
|
||||
Username: "uid",
|
||||
Enabled: "ownCloudUserEnabled",
|
||||
},
|
||||
|
||||
@@ -98,7 +98,7 @@ func (i *CS3) GetUsers(ctx context.Context, oreq *godata.GoDataRequest) ([]*libr
|
||||
|
||||
res, err := gatewayClient.FindUsers(ctx, &cs3user.FindUsersRequest{
|
||||
// FIXME presence match is currently not implemented, an empty search currently leads to
|
||||
// Unwilling To Perform": Search Error: error parsing filter: (&(objectclass=posixAccount)(|(cn=*)(displayname=*)(mail=*))), error: Present filter match for cn not implemented
|
||||
// Unwilling To Perform": Search Error: error parsing filter: (&(objectclass=posixAccount)(|(cn=*)(displayName=*)(mail=*))), error: Present filter match for cn not implemented
|
||||
Filter: search,
|
||||
})
|
||||
switch {
|
||||
@@ -149,7 +149,7 @@ func (i *CS3) GetGroups(ctx context.Context, oreq *godata.GoDataRequest) ([]*lib
|
||||
|
||||
res, err := gatewayClient.FindGroups(ctx, &cs3group.FindGroupsRequest{
|
||||
// FIXME presence match is currently not implemented, an empty search currently leads to
|
||||
// Unwilling To Perform": Search Error: error parsing filter: (&(objectclass=posixAccount)(|(cn=*)(displayname=*)(mail=*))), error: Present filter match for cn not implemented
|
||||
// Unwilling To Perform": Search Error: error parsing filter: (&(objectclass=posixAccount)(|(cn=*)(displayName=*)(mail=*))), error: Present filter match for cn not implemented
|
||||
Filter: search,
|
||||
})
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ var eduConfig = config.LDAP{
|
||||
UserObjectClass: "inetOrgPerson",
|
||||
UserSearchScope: "sub",
|
||||
UserFilter: "",
|
||||
UserDisplayNameAttribute: "displayname",
|
||||
UserDisplayNameAttribute: "displayName",
|
||||
UserIDAttribute: "entryUUID",
|
||||
UserEmailAttribute: "mail",
|
||||
UserNameAttribute: "uid",
|
||||
|
||||
@@ -14,7 +14,7 @@ var instanceMapperConfig = config.LDAP{
|
||||
UserBaseDN: "ou=people,dc=test",
|
||||
UserObjectClass: "inetOrgPerson",
|
||||
UserSearchScope: "sub",
|
||||
UserDisplayNameAttribute: "displayname",
|
||||
UserDisplayNameAttribute: "displayName",
|
||||
UserIDAttribute: "entryUUID",
|
||||
UserEmailAttribute: "mail",
|
||||
UserNameAttribute: "uid",
|
||||
|
||||
@@ -31,7 +31,7 @@ var lconfig = config.LDAP{
|
||||
UserObjectClass: "inetOrgPerson",
|
||||
UserSearchScope: "sub",
|
||||
UserFilter: "",
|
||||
UserDisplayNameAttribute: "displayname",
|
||||
UserDisplayNameAttribute: "displayName",
|
||||
UserIDAttribute: "entryUUID",
|
||||
UserEmailAttribute: "mail",
|
||||
UserNameAttribute: "uid",
|
||||
@@ -55,7 +55,7 @@ var lconfig = config.LDAP{
|
||||
var userEntry = ldap.NewEntry("uid=user",
|
||||
map[string][]string{
|
||||
"uid": {"user"},
|
||||
"displayname": {"DisplayName"},
|
||||
"displayName": {"DisplayName"},
|
||||
"mail": {"user@example"},
|
||||
"entryuuid": {"abcd-defg"},
|
||||
"sn": {"surname"},
|
||||
@@ -67,14 +67,14 @@ var userEntry = ldap.NewEntry("uid=user",
|
||||
var invalidUserEntry = ldap.NewEntry("uid=user",
|
||||
map[string][]string{
|
||||
"uid": {"invalid"},
|
||||
"displayname": {"DisplayName"},
|
||||
"displayName": {"DisplayName"},
|
||||
"mail": {"user@example"},
|
||||
})
|
||||
|
||||
var logger = log.NewLogger(log.Level("debug"))
|
||||
|
||||
var ldapUserAttributes = []string{
|
||||
"displayname",
|
||||
"displayName",
|
||||
"entryUUID",
|
||||
"mail",
|
||||
"uid",
|
||||
@@ -340,7 +340,7 @@ func TestGetUsersSearch(t *testing.T) {
|
||||
// only match if the filter contains the search term unquoted
|
||||
lm.On("Search", mock.MatchedBy(
|
||||
func(req *ldap.SearchRequest) bool {
|
||||
return req.Filter == "(&(objectClass=inetOrgPerson)(|(uid=*term*)(mail=*term*)(displayname=*term*)))"
|
||||
return req.Filter == "(&(objectClass=inetOrgPerson)(|(uid=*term*)(mail=*term*)(displayName=*term*)))"
|
||||
})).
|
||||
Return(&ldap.SearchResult{}, nil)
|
||||
b, _ := getMockedBackend(lm, lconfig, &logger)
|
||||
@@ -913,7 +913,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: "displayname",
|
||||
Name: "displayName",
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
@@ -1032,7 +1032,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: "displayname",
|
||||
Name: "displayName",
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
@@ -1150,7 +1150,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
Name: "displayname",
|
||||
Name: "displayName",
|
||||
Values: []string{"testUser"},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -18,13 +18,13 @@ import (
|
||||
func TestAttrsFromAddRequest(t *testing.T) {
|
||||
ar := ldap.NewAddRequest("uid=alice,ou=people,dc=test", nil)
|
||||
ar.Attribute("uid", []string{"alice"})
|
||||
ar.Attribute("displayname", []string{"Alice Example"})
|
||||
ar.Attribute("displayName", []string{"Alice Example"})
|
||||
ar.Attribute("mail", []string{"alice@example.org", "a@example.org"})
|
||||
|
||||
attrs := attrsFromAddRequest(ar)
|
||||
|
||||
assert.Equal(t, []string{"alice"}, attrs["uid"])
|
||||
assert.Equal(t, []string{"Alice Example"}, attrs["displayname"])
|
||||
assert.Equal(t, []string{"Alice Example"}, attrs["displayName"])
|
||||
assert.Equal(t, []string{"alice@example.org", "a@example.org"}, attrs["mail"])
|
||||
|
||||
// round-trips through ldap.NewEntry with case-insensitive lookup
|
||||
@@ -51,17 +51,17 @@ func TestAttrsFromAddRequestDoesNotAliasRequest(t *testing.T) {
|
||||
func TestApplyModifyToEntry(t *testing.T) {
|
||||
base := ldap.NewEntry("uid=alice,ou=people,dc=test", map[string][]string{
|
||||
"uid": {"alice"},
|
||||
"displayname": {"Alice Example"},
|
||||
"displayName": {"Alice Example"},
|
||||
"mail": {"alice@example.org"},
|
||||
"member": {"cn=a", "cn=b"},
|
||||
})
|
||||
|
||||
t.Run("Replace overwrites existing attribute", func(t *testing.T) {
|
||||
mr := &ldap.ModifyRequest{DN: base.DN}
|
||||
mr.Replace("displayname", []string{"Alice New"})
|
||||
mr.Replace("displayName", []string{"Alice New"})
|
||||
|
||||
got := applyModifyToEntry(base, mr)
|
||||
assert.Equal(t, "Alice New", got.GetEqualFoldAttributeValue("displayname"))
|
||||
assert.Equal(t, "Alice New", got.GetEqualFoldAttributeValue("displayName"))
|
||||
})
|
||||
|
||||
t.Run("Replace adds a not-yet-present attribute", func(t *testing.T) {
|
||||
@@ -113,13 +113,13 @@ func TestApplyModifyToEntry(t *testing.T) {
|
||||
t.Run("nil ModifyRequest returns base unchanged", func(t *testing.T) {
|
||||
got := applyModifyToEntry(base, nil)
|
||||
assert.Equal(t, base.DN, got.DN)
|
||||
assert.Equal(t, "Alice Example", got.GetEqualFoldAttributeValue("displayname"))
|
||||
assert.Equal(t, "Alice Example", got.GetEqualFoldAttributeValue("displayName"))
|
||||
assert.Equal(t, []string{"cn=a", "cn=b"}, got.GetEqualFoldAttributeValues("member"))
|
||||
})
|
||||
|
||||
t.Run("nil base returns nil", func(t *testing.T) {
|
||||
mr := &ldap.ModifyRequest{DN: "uid=alice,ou=people,dc=test"}
|
||||
mr.Replace("displayname", []string{"Alice New"})
|
||||
mr.Replace("displayName", []string{"Alice New"})
|
||||
|
||||
got := applyModifyToEntry(nil, mr)
|
||||
assert.Nil(t, got)
|
||||
@@ -130,11 +130,11 @@ func TestApplyModifyToEntry(t *testing.T) {
|
||||
mr.Replace("DisplayName", []string{"Alice Caps"})
|
||||
|
||||
got := applyModifyToEntry(base, mr)
|
||||
assert.Equal(t, "Alice Caps", got.GetEqualFoldAttributeValue("displayname"))
|
||||
assert.Equal(t, "Alice Caps", got.GetEqualFoldAttributeValue("displayName"))
|
||||
// exactly one attribute entry whose name folds to displayname
|
||||
count := 0
|
||||
for _, a := range got.Attributes {
|
||||
if strings.EqualFold(a.Name, "displayname") {
|
||||
if strings.EqualFold(a.Name, "displayName") {
|
||||
count++
|
||||
}
|
||||
}
|
||||
@@ -143,22 +143,22 @@ func TestApplyModifyToEntry(t *testing.T) {
|
||||
|
||||
t.Run("base is never mutated", func(t *testing.T) {
|
||||
mr := &ldap.ModifyRequest{DN: base.DN}
|
||||
mr.Replace("displayname", []string{"Mutated"})
|
||||
mr.Replace("displayName", []string{"Mutated"})
|
||||
mr.Add("member", []string{"cn=z"})
|
||||
mr.Delete("mail", []string{})
|
||||
|
||||
_ = applyModifyToEntry(base, mr)
|
||||
assert.Equal(t, "Alice Example", base.GetEqualFoldAttributeValue("displayname"))
|
||||
assert.Equal(t, "Alice Example", base.GetEqualFoldAttributeValue("displayName"))
|
||||
assert.Equal(t, []string{"cn=a", "cn=b"}, base.GetEqualFoldAttributeValues("member"))
|
||||
assert.Equal(t, "alice@example.org", base.GetEqualFoldAttributeValue("mail"))
|
||||
})
|
||||
|
||||
t.Run("Replace populates ByteValues for raw accessors", func(t *testing.T) {
|
||||
mr := &ldap.ModifyRequest{DN: base.DN}
|
||||
mr.Replace("displayname", []string{"Raw Value"})
|
||||
mr.Replace("displayName", []string{"Raw Value"})
|
||||
|
||||
got := applyModifyToEntry(base, mr)
|
||||
assert.Equal(t, []byte("Raw Value"), got.GetEqualFoldRawAttributeValue("displayname"))
|
||||
assert.Equal(t, []byte("Raw Value"), got.GetEqualFoldRawAttributeValue("displayName"))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -351,7 +351,7 @@ func TestSynthesizedEntryPopulatesInstancesWithoutSearch(t *testing.T) {
|
||||
// member-of-instance value so the Instances loop runs.
|
||||
entry := ldap.NewEntry("uid=user,ou=people,dc=test", map[string][]string{
|
||||
"uid": {"user"},
|
||||
"displayname": {"DisplayName"},
|
||||
"displayName": {"DisplayName"},
|
||||
"mail": {"user@example"},
|
||||
"entryUUID": {"abcd-defg"},
|
||||
"ocMemberOfInstance": {"instanceA"},
|
||||
@@ -523,7 +523,7 @@ func TestUpdateUserFoldsNoReadBack(t *testing.T) {
|
||||
|
||||
preRead := ldap.NewEntry("uid=user,ou=people,dc=test", map[string][]string{
|
||||
"uid": {"user"},
|
||||
"displayname": {"Old Name"},
|
||||
"displayName": {"Old Name"},
|
||||
"mail": {"old@example.org"},
|
||||
"entryUUID": {"abcd-defg"},
|
||||
"userTypeAttribute": {"Member"},
|
||||
@@ -563,7 +563,7 @@ func TestUpdateEducationUserFoldsNoReadBack(t *testing.T) {
|
||||
|
||||
preRead := ldap.NewEntry("uid=testuser,ou=people,dc=test", map[string][]string{
|
||||
"uid": {"testuser"},
|
||||
"displayname": {"Test User"},
|
||||
"displayName": {"Test User"},
|
||||
"mail": {"old@example.org"},
|
||||
"entryUUID": {"abcd-defg"},
|
||||
"userClass": {"student"},
|
||||
|
||||
@@ -61,7 +61,7 @@ func DefaultConfig() *config.Config {
|
||||
UserSchema: config.LDAPUserSchema{
|
||||
ID: "ownCloudUUID",
|
||||
Mail: "mail",
|
||||
DisplayName: "displayname",
|
||||
DisplayName: "displayName",
|
||||
Username: "uid",
|
||||
},
|
||||
GroupSchema: config.LDAPGroupSchema{
|
||||
|
||||
@@ -64,7 +64,7 @@ func DefaultConfig() *config.Config {
|
||||
UserSchema: config.LDAPUserSchema{
|
||||
ID: "ownCloudUUID",
|
||||
Mail: "mail",
|
||||
DisplayName: "displayname",
|
||||
DisplayName: "displayName",
|
||||
Username: "uid",
|
||||
Enabled: "ownCloudUserEnabled",
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user