Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests-only] Minor fixes: eosfs, grappa #1481

Merged
merged 2 commits into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/cbox/group/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ func (m *manager) parseAndCacheGroup(ctx context.Context, groupData map[string]i
}

func (m *manager) GetGroup(ctx context.Context, gid *grouppb.GroupId) (*grouppb.Group, error) {

g, err := m.fetchCachedGroupDetails(gid)
if err != nil {
groupData, err := m.getGroupByParam(ctx, "groupIdentifier", gid.OpaqueId)
Expand All @@ -335,6 +334,7 @@ func (m *manager) GetGroup(ctx context.Context, gid *grouppb.GroupId) (*grouppb.
}

func (m *manager) GetGroupByClaim(ctx context.Context, claim, value string) (*grouppb.Group, error) {
value = url.QueryEscape(value)
opaqueID, err := m.fetchCachedParam(claim, value)
if err == nil {
return m.GetGroup(ctx, &grouppb.GroupId{OpaqueId: opaqueID})
Expand Down Expand Up @@ -420,7 +420,7 @@ func (m *manager) FindGroups(ctx context.Context, query string) ([]*grouppb.Grou

for _, f := range filters {
url := fmt.Sprintf("%s/Group/?filter=%s:contains:%s&field=groupIdentifier&field=displayName&field=gid",
m.conf.APIBaseURL, f, query)
m.conf.APIBaseURL, f, url.QueryEscape(query))
err := m.findGroupsByFilter(ctx, url, groups)
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions pkg/cbox/user/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ func (m *manager) parseAndCacheUser(ctx context.Context, userData map[string]int
}

func (m *manager) GetUser(ctx context.Context, uid *userpb.UserId) (*userpb.User, error) {

u, err := m.fetchCachedUserDetails(uid)
if err != nil {
userData, err := m.getUserByParam(ctx, "upn", uid.OpaqueId)
Expand All @@ -347,6 +346,7 @@ func (m *manager) GetUser(ctx context.Context, uid *userpb.UserId) (*userpb.User
}

func (m *manager) GetUserByClaim(ctx context.Context, claim, value string) (*userpb.User, error) {
value = url.QueryEscape(value)
opaqueID, err := m.fetchCachedParam(claim, value)
if err == nil {
return m.GetUser(ctx, &userpb.UserId{OpaqueId: opaqueID})
Expand Down Expand Up @@ -439,7 +439,7 @@ func (m *manager) FindUsers(ctx context.Context, query string) ([]*userpb.User,

for _, f := range filters {
url := fmt.Sprintf("%s/Identity/?filter=%s:contains:%s&field=id&field=upn&field=primaryAccountEmail&field=displayName&field=uid&field=gid&field=type",
m.conf.APIBaseURL, f, query)
m.conf.APIBaseURL, f, url.QueryEscape(query))
err := m.findUsersByFilter(ctx, url, users)
if err != nil {
return nil, err
Expand Down
4 changes: 3 additions & 1 deletion pkg/group/manager/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ func (m *manager) FindGroups(ctx context.Context, query string) ([]*grouppb.Grou
}

func groupContains(g *grouppb.Group, query string) bool {
return strings.Contains(g.GroupName, query) || strings.Contains(g.DisplayName, query) || strings.Contains(g.Mail, query) || strings.Contains(g.Id.OpaqueId, query)
query = strings.ToLower(query)
return strings.Contains(strings.ToLower(g.GroupName), query) || strings.Contains(strings.ToLower(g.DisplayName), query) ||
strings.Contains(strings.ToLower(g.Mail), query) || strings.Contains(strings.ToLower(g.Id.OpaqueId), query)
}

func (m *manager) GetMembers(ctx context.Context, gid *grouppb.GroupId) ([]*userpb.UserId, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/utils/eosfs/eosfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ func (fs *eosfs) GetQuota(ctx context.Context) (int, int, error) {
return 0, 0, err
}

qi, err := fs.c.GetQuota(ctx, u.Username, rootUID, rootGID, fs.conf.Namespace)
qi, err := fs.c.GetQuota(ctx, u.Username, rootUID, rootGID, fs.conf.QuotaNode)
if err != nil {
err := errors.Wrap(err, "eosfs: error getting quota")
return 0, 0, err
Expand Down
4 changes: 3 additions & 1 deletion pkg/user/manager/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ func extractClaim(u *userpb.User, claim string) (string, error) {

// TODO(jfd) search Opaque? compare sub?
func userContains(u *userpb.User, query string) bool {
return strings.Contains(u.Username, query) || strings.Contains(u.DisplayName, query) || strings.Contains(u.Mail, query) || strings.Contains(u.Id.OpaqueId, query)
query = strings.ToLower(query)
return strings.Contains(strings.ToLower(u.Username), query) || strings.Contains(strings.ToLower(u.DisplayName), query) ||
strings.Contains(strings.ToLower(u.Mail), query) || strings.Contains(strings.ToLower(u.Id.OpaqueId), query)
}

func (m *manager) FindUsers(ctx context.Context, query string) ([]*userpb.User, error) {
Expand Down
1 change: 1 addition & 0 deletions tests/oc-integration-tests/drone/gateway.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ storageregistrysvc = "localhost:19000"
# user metadata
preferencessvc = "localhost:18000"
userprovidersvc = "localhost:18000"
groupprovidersvc = "localhost:18000"
# an approvider lives on "localhost:18000" as well, see users.toml
# sharing
usershareprovidersvc = "localhost:17000"
Expand Down
21 changes: 21 additions & 0 deletions tests/oc-integration-tests/drone/ldap-users.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,24 @@ uid="uid"
displayName="displayName"
dn="dn"
cn="cn"

[grpc.services.groupprovider]
driver = "ldap"

[grpc.services.groupprovider.drivers.ldap]
hostname="ldap"
port=636
base_dn="dc=owncloud,dc=com"
groupfilter="(&(objectclass=posixGroup)(|(gid={{.OpaqueId}})(cn={{.OpaqueId}})))"
findfilter="(&(objectclass=posixGroup)(|(cn={{query}}*)(displayname={{query}}*)(mail={{query}}*)))"
attributefilter="(&(objectclass=posixGroup)({{attr}}={{value}}))"
memberfilter="(&(objectclass=posixAccount)(cn={{.OpaqueId}}))"
bind_username="cn=admin,dc=owncloud,dc=com"
bind_password="admin"
idp="http://localhost:18000"

[grpc.services.groupprovider.drivers.ldap.schema]
gid="gid"
displayName="displayName"
dn="dn"
cn="cn"
1 change: 1 addition & 0 deletions tests/oc-integration-tests/local/gateway.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ storageregistrysvc = "localhost:19000"
# user metadata
preferencessvc = "localhost:18000"
userprovidersvc = "localhost:18000"
groupprovidersvc = "localhost:18000"
# an approvider lives on "localhost:18000" as well, see users.toml
# sharing
usershareprovidersvc = "localhost:17000"
Expand Down
21 changes: 21 additions & 0 deletions tests/oc-integration-tests/local/ldap-users.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,24 @@ uid="uid"
displayName="displayName"
dn="dn"
cn="cn"

[grpc.services.groupprovider]
driver = "ldap"

[grpc.services.groupprovider.drivers.ldap]
hostname="localhost"
port=636
base_dn="dc=owncloud,dc=com"
groupfilter="(&(objectclass=posixGroup)(|(gid={{.OpaqueId}})(cn={{.OpaqueId}})))"
findfilter="(&(objectclass=posixGroup)(|(cn={{query}}*)(displayname={{query}}*)(mail={{query}}*)))"
attributefilter="(&(objectclass=posixGroup)({{attr}}={{value}}))"
memberfilter="(&(objectclass=posixAccount)(cn={{.OpaqueId}}))"
bind_username="cn=admin,dc=owncloud,dc=com"
bind_password="admin"
idp="http://localhost:18000"

[grpc.services.groupprovider.drivers.ldap.schema]
gid="gid"
displayName="displayName"
dn="dn"
cn="cn"