fix webdav URL of drive roots in graph API

This commit is contained in:
David Christofas
2022-06-02 14:24:56 +02:00
parent 6cde9c5405
commit 4470c045ed
3 changed files with 13 additions and 3 deletions
+6
View File
@@ -0,0 +1,6 @@
Bugfix: Fix the webdav URL of drive roots
Fixed the webdav URL of drive roots in the graph API.
https://github.com/owncloud/ocis/issues/3706
https://github.com/owncloud/ocis/pull/3916
+4 -2
View File
@@ -7,6 +7,7 @@ import (
"math" "math"
"net/http" "net/http"
"net/url" "net/url"
"path"
"sort" "sort"
"strconv" "strconv"
"strings" "strings"
@@ -581,8 +582,9 @@ func (g Graph) cs3StorageSpaceToDrive(ctx context.Context, baseURL *url.URL, spa
// TODO read from StorageSpace ... needs Opaque for now // TODO read from StorageSpace ... needs Opaque for now
// TODO how do we build the url? // TODO how do we build the url?
// for now: read from request // for now: read from request
webDavURL := baseURL.String() + spaceID webDavURL := *baseURL
drive.Root.WebDavUrl = &webDavURL webDavURL.Path = path.Join(webDavURL.Path, spaceID)
drive.Root.WebDavUrl = libregraph.PtrString(webDavURL.String())
} }
// TODO The public space has no owner ... should we even show it? // TODO The public space has no owner ... should we even show it?
@@ -7,6 +7,7 @@ import (
"io" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"net/url"
"time" "time"
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1" gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
@@ -245,11 +246,12 @@ var _ = Describe("Graph", func() {
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(len(response["value"])).To(Equal(1)) Expect(len(response["value"])).To(Equal(1))
value := response["value"][0] value := response["value"][0]
webdavURL, _ := url.PathUnescape(*value.Root.WebDavUrl)
Expect(*value.DriveAlias).To(Equal("mountpoint/new-folder")) Expect(*value.DriveAlias).To(Equal("mountpoint/new-folder"))
Expect(*value.DriveType).To(Equal("mountpoint")) Expect(*value.DriveType).To(Equal("mountpoint"))
Expect(*value.Id).To(Equal("prID$aID!differentID")) 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!differentID")) Expect(webdavURL).To(Equal("https://localhost:9200/dav/spaces/prID$aID!differentID"))
Expect(*value.Root.ETag).To(Equal("101112131415")) Expect(*value.Root.ETag).To(Equal("101112131415"))
Expect(*value.Root.Id).To(Equal("prID$aID!differentID")) Expect(*value.Root.Id).To(Equal("prID$aID!differentID"))
Expect(*value.Root.RemoteItem.ETag).To(Equal("123456789")) Expect(*value.Root.RemoteItem.ETag).To(Equal("123456789"))