From 8db120c39a9989e014ba2f464ff43b7558d081c7 Mon Sep 17 00:00:00 2001 From: Florian Schade Date: Thu, 29 Dec 2022 10:30:22 +0100 Subject: [PATCH 1/2] bump libre-graph-go --- go.mod | 2 +- go.sum | 6 ++---- services/graph/pkg/service/v0/drives.go | 8 ++++---- services/graph/pkg/service/v0/ordering.go | 4 ++-- services/graph/pkg/service/v0/password.go | 2 +- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index fe8e2fae4e..3de9e39ca7 100644 --- a/go.mod +++ b/go.mod @@ -54,7 +54,7 @@ require ( github.com/onsi/ginkgo/v2 v2.5.0 github.com/onsi/gomega v1.24.1 github.com/orcaman/concurrent-map v1.0.0 - github.com/owncloud/libre-graph-api-go v1.0.1-0.20221216081114-57ab57ed98b0 + github.com/owncloud/libre-graph-api-go v1.0.1-0.20221220084037-8c6f7ea26400 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.14.0 github.com/rs/zerolog v1.28.0 diff --git a/go.sum b/go.sum index 211fe21960..42b0f4e452 100644 --- a/go.sum +++ b/go.sum @@ -343,8 +343,6 @@ github.com/crewjam/saml v0.4.6 h1:XCUFPkQSJLvzyl4cW9OvpWUbRf0gE7VUpU8ZnilbeM4= github.com/crewjam/saml v0.4.6/go.mod h1:ZBOXnNPFzB3CgOkRm7Nd6IVdkG+l/wF+0ZXLqD96t1A= github.com/cs3org/go-cs3apis v0.0.0-20221012090518-ef2996678965 h1:y4n2j68LLnvac+zw/al8MfPgO5aQiIwLmHM/JzYN8AM= github.com/cs3org/go-cs3apis v0.0.0-20221012090518-ef2996678965/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY= -github.com/cs3org/reva/v2 v2.12.1-0.20221219152307-4d5800e63bf4 h1:FxPCpd3oE5snNw5filxKGd3M27ySbjqeiiMTBJI8tSw= -github.com/cs3org/reva/v2 v2.12.1-0.20221219152307-4d5800e63bf4/go.mod h1:GpocVB1w6yxeSr1VBsO9jztmt1SyNC4lCwudLwDzxHQ= github.com/cs3org/reva/v2 v2.12.1-0.20221223093348-3ae37de4759d h1:8CzNOyGaqIDv3rlYGYxv8TIYVHPBLkPmyTprlOh1Om4= github.com/cs3org/reva/v2 v2.12.1-0.20221223093348-3ae37de4759d/go.mod h1:GpocVB1w6yxeSr1VBsO9jztmt1SyNC4lCwudLwDzxHQ= github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8 h1:Z9lwXumT5ACSmJ7WGnFl+OMLLjpz5uR2fyz7dC255FI= @@ -1057,8 +1055,8 @@ github.com/oracle/oci-go-sdk v24.3.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35uk github.com/orcaman/concurrent-map v1.0.0 h1:I/2A2XPCb4IuQWcQhBhSwGfiuybl/J0ev9HDbW65HOY= github.com/orcaman/concurrent-map v1.0.0/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI= github.com/ovh/go-ovh v1.1.0/go.mod h1:AxitLZ5HBRPyUd+Zl60Ajaag+rNTdVXWIkzfrVuTXWA= -github.com/owncloud/libre-graph-api-go v1.0.1-0.20221216081114-57ab57ed98b0 h1:47N8o/5MmQ5781dF44fk1lQtyFmTAvu6/5hPG3rM1TQ= -github.com/owncloud/libre-graph-api-go v1.0.1-0.20221216081114-57ab57ed98b0/go.mod h1:579sFrPP7aP24LZXGPopLfvE+hAka/2DYHk0+Ij+w+U= +github.com/owncloud/libre-graph-api-go v1.0.1-0.20221220084037-8c6f7ea26400 h1:E8+qYjS2P21dE4gGVep0JAqPleL74wugwnXSHKAoDp4= +github.com/owncloud/libre-graph-api-go v1.0.1-0.20221220084037-8c6f7ea26400/go.mod h1:579sFrPP7aP24LZXGPopLfvE+hAka/2DYHk0+Ij+w+U= github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw= github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= diff --git a/services/graph/pkg/service/v0/drives.go b/services/graph/pkg/service/v0/drives.go index b03242c1fe..fc631a3d05 100644 --- a/services/graph/pkg/service/v0/drives.go +++ b/services/graph/pkg/service/v0/drives.go @@ -248,7 +248,7 @@ func (g Graph) CreateDrive(w http.ResponseWriter, r *http.Request) { errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "invalid body schema definition") return } - spaceName := strings.TrimSpace(*drive.Name) + spaceName := strings.TrimSpace(drive.Name) if err := validateSpaceName(spaceName); err != nil { logger.Debug().Str("name", spaceName).Err(err).Msg("could not create drive: name validation failed") errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid spacename: %s", err.Error())) @@ -392,8 +392,8 @@ func (g Graph) UpdateDrive(w http.ResponseWriter, r *http.Request) { } } - if drive.Name != nil { - spacename := strings.TrimSpace(*drive.Name) + if drive.Name != "" { + spacename := strings.TrimSpace(drive.Name) if err := validateSpaceName(spacename); err != nil { logger.Info().Err(err).Msg("could not update drive: spacename invalid") errorcode.GeneralException.Render(w, r, http.StatusBadRequest, err.Error()) @@ -599,7 +599,7 @@ func (g Graph) cs3StorageSpaceToDrive(ctx context.Context, baseURL *url.URL, spa drive := &libregraph.Drive{ Id: libregraph.PtrString(spaceID), - Name: &space.Name, + Name: space.Name, //"createdDateTime": "string (timestamp)", // TODO read from StorageSpace ... needs Opaque for now DriveType: &space.SpaceType, Root: &libregraph.DriveItem{ diff --git a/services/graph/pkg/service/v0/ordering.go b/services/graph/pkg/service/v0/ordering.go index f3464619fc..b636e4dacf 100644 --- a/services/graph/pkg/service/v0/ordering.go +++ b/services/graph/pkg/service/v0/ordering.go @@ -24,7 +24,7 @@ type spacesByLastModifiedDateTime struct { // Less reports whether the element with index i // must sort before the element with index j. func (s spacesByName) Less(i, j int) bool { - return strings.ToLower(*s.spacesSlice[i].Name) < strings.ToLower(*s.spacesSlice[j].Name) + return strings.ToLower(s.spacesSlice[i].Name) < strings.ToLower(s.spacesSlice[j].Name) } // Less reports whether the element with index i @@ -43,7 +43,7 @@ func (s spacesByLastModifiedDateTime) Less(i, j int) bool { return false } // fallback to name if no dateTime is set on both items - return strings.ToLower(*s.spacesSlice[i].Name) < strings.ToLower(*s.spacesSlice[j].Name) + return strings.ToLower(s.spacesSlice[i].Name) < strings.ToLower(s.spacesSlice[j].Name) } type userSlice []*libregraph.User diff --git a/services/graph/pkg/service/v0/password.go b/services/graph/pkg/service/v0/password.go index 854372a9a2..66c82ffccd 100644 --- a/services/graph/pkg/service/v0/password.go +++ b/services/graph/pkg/service/v0/password.go @@ -33,7 +33,7 @@ func (g Graph) ChangeOwnPassword(w http.ResponseWriter, r *http.Request) { errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, err.Error()) return } - cpw := libregraph.NewPasswordChange() + cpw := libregraph.NewPasswordChangeWithDefaults() err = json.NewDecoder(r.Body).Decode(cpw) if err != nil { errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, err.Error()) From 482e4a26c9f4b0110d0312478661ab552fe6b237 Mon Sep 17 00:00:00 2001 From: jkoberg Date: Thu, 29 Dec 2022 11:06:53 +0100 Subject: [PATCH 2/2] fix graph unit tests Signed-off-by: jkoberg --- services/graph/pkg/service/v0/drives_test.go | 2 +- services/graph/pkg/service/v0/graph_test.go | 10 +++++----- services/graph/pkg/service/v0/password_test.go | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/services/graph/pkg/service/v0/drives_test.go b/services/graph/pkg/service/v0/drives_test.go index 7cd084036e..28bcb7cf56 100644 --- a/services/graph/pkg/service/v0/drives_test.go +++ b/services/graph/pkg/service/v0/drives_test.go @@ -111,7 +111,7 @@ var sortTests = []sortTest{ } func drive(ID string, dType string, name string, lastModified *time.Time) *libregraph.Drive { - return &libregraph.Drive{Id: libregraph.PtrString(ID), DriveType: libregraph.PtrString(dType), Name: libregraph.PtrString(name), LastModifiedDateTime: lastModified} + return &libregraph.Drive{Id: libregraph.PtrString(ID), DriveType: libregraph.PtrString(dType), Name: name, LastModifiedDateTime: lastModified} } // TestSort tests the available orderby queries diff --git a/services/graph/pkg/service/v0/graph_test.go b/services/graph/pkg/service/v0/graph_test.go index a7bc51a07a..f5cf009092 100644 --- a/services/graph/pkg/service/v0/graph_test.go +++ b/services/graph/pkg/service/v0/graph_test.go @@ -292,7 +292,7 @@ var _ = Describe("Graph", func() { Expect(*value.DriveAlias).To(Equal("mountpoint/new-folder")) Expect(*value.DriveType).To(Equal("mountpoint")) Expect(*value.Id).To(Equal("prID$aID!differentID")) - Expect(*value.Name).To(Equal("New Folder")) + Expect(value.Name).To(Equal("New Folder")) Expect(*value.Root.WebDavUrl).To(Equal("https://localhost:9200/dav/spaces/prID$aID%21differentID")) Expect(*value.Root.ETag).To(Equal("101112131415")) Expect(*value.Root.Id).To(Equal("prID$aID!differentID")) @@ -680,7 +680,7 @@ var _ = Describe("Graph", func() { var response libregraph.Drive err := json.Unmarshal(body, &response) Expect(err).ToNot(HaveOccurred()) - Expect(*response.Name).To(Equal("Test Space")) + Expect(response.Name).To(Equal("Test Space")) Expect(*response.DriveType).To(Equal("project")) Expect(*response.DriveAlias).To(Equal("project/testspace")) Expect(*response.Description).To(Equal("This space is for testing")) @@ -967,7 +967,7 @@ var _ = Describe("Graph", func() { }) It("sets the description, alias and name", func() { - drive := libregraph.NewDrive() + drive := libregraph.NewDrive("thename") drive.SetDriveAlias("thealias") drive.SetDescription("thedescription") drive.SetName("thename") @@ -996,7 +996,7 @@ var _ = Describe("Graph", func() { }) It("restores", func() { - drive := libregraph.NewDrive() + drive := libregraph.NewDrive("thename") driveJson, err := json.Marshal(drive) Expect(err).ToNot(HaveOccurred()) @@ -1021,7 +1021,7 @@ var _ = Describe("Graph", func() { }) It("sets the quota", func() { - drive := libregraph.NewDrive() + drive := libregraph.NewDrive("thename") quota := libregraph.Quota{} quota.SetTotal(1000) drive.SetQuota(quota) diff --git a/services/graph/pkg/service/v0/password_test.go b/services/graph/pkg/service/v0/password_test.go index 84a33fd07f..51b272804a 100644 --- a/services/graph/pkg/service/v0/password_test.go +++ b/services/graph/pkg/service/v0/password_test.go @@ -108,7 +108,7 @@ var _ = Describe("Users changing their own password", func() { Token: "authtoken", }, nil) } - cpw := libregraph.NewPasswordChange() + cpw := libregraph.NewPasswordChangeWithDefaults() cpw.SetCurrentPassword(current) cpw.SetNewPassword(newpw) body, _ := json.Marshal(cpw)