Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
glpatcern committed Oct 24, 2023
1 parent a198b1e commit 1c75b03
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 51 deletions.
18 changes: 12 additions & 6 deletions pkg/ocm/share/repository/nextcloud/nextcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ type EfssShare struct {
Name string `json:"name" validate:"required"`
Token string `json:"token"`
ResourceID struct {
OpaqueID string `json:"opaque_id"`
OpaqueID string `json:"opaque_id" validate:"required"`
} `json:"resource_id" validate:"required"`
ResourceType string `json:"resource_type"`
ResourceType string `json:"resource_type" validate:"omitempty"`
RemoteShareID string `json:"remote_share_id" validate:"required"`
Protocols struct {
WebDAV struct {
Expand Down Expand Up @@ -181,7 +181,7 @@ func (sm *Manager) efssShareToOcm(resp *EfssShare) *ocm.Share {
// Parse the JSON struct returned by the PHP SM app into an OCM share object

// first generate the map of access methods, assuming WebDAV is always present
var am = make([]*ocm.AccessMethod, 1, 3)
var am = make([]*ocm.AccessMethod, 0, 3)
am = append(am, share.NewWebDavAccessMethod(conversions.RoleFromOCSPermissions(
conversions.Permissions(resp.Protocols.WebDAV.Permissions)).CS3ResourcePermissions()))
if resp.Protocols.WebApp.ViewMode != "" {
Expand All @@ -203,7 +203,10 @@ func (sm *Manager) efssShareToOcm(resp *EfssShare) *ocm.Share {
Grantee: &provider.Grantee{
Type: provider.GranteeType_GRANTEE_TYPE_USER,
Id: &provider.Grantee_UserId{
UserId: resp.Grantee.ID,
UserId: &userpb.UserId{
OpaqueId: resp.Grantee.ID.OpaqueId,
Idp: resp.Grantee.ID.Idp,
},
},
},
Owner: &userpb.UserId{
Expand Down Expand Up @@ -322,7 +325,7 @@ func efssReceivedShareToOcm(resp *ReceivedEfssShare) *ocm.ReceivedShare {
// Parse the JSON struct returned by the PHP SM app into an OCM received share object

// first generate the map of protocols, assuming WebDAV is always present
var proto = make([]*ocm.Protocol, 1, 3)
var proto = make([]*ocm.Protocol, 0, 3)
proto = append(proto, share.NewWebDAVProtocol(resp.Share.Protocols.WebDAV.URI, resp.Share.Token, &ocm.SharePermissions{
Permissions: conversions.RoleFromOCSPermissions(conversions.Permissions(resp.Share.Protocols.WebDAV.Permissions)).CS3ResourcePermissions(),
}))
Expand All @@ -344,7 +347,10 @@ func efssReceivedShareToOcm(resp *ReceivedEfssShare) *ocm.ReceivedShare {
RemoteShareId: resp.Share.RemoteShareID, // sic, see https://github.com/cs3org/reva/pull/3852#discussion_r1189681465
Grantee: &provider.Grantee{
Id: &provider.Grantee_UserId{
UserId: resp.Share.Grantee.ID,
UserId: &userpb.UserId{
OpaqueId: resp.Share.Grantee.ID.OpaqueId,
Idp: resp.Share.Grantee.ID.Idp,
},
},
},
Owner: resp.Share.Owner.Id,
Expand Down
Loading

0 comments on commit 1c75b03

Please sign in to comment.