return only single permission on link creation

This commit is contained in:
Artur Neumann
2023-12-05 11:15:49 +05:45
parent 62afc6e9b6
commit fcd13cf9b8
2 changed files with 14 additions and 16 deletions

View File

@@ -52,7 +52,7 @@ func (g Graph) CreateLink(w http.ResponseWriter, r *http.Request) {
}
render.Status(r, http.StatusOK)
render.JSON(w, r, []libregraph.Permission{*perm})
render.JSON(w, r, *perm)
}
func (g Graph) createLink(ctx context.Context, driveItemID *providerv1beta1.ResourceId, createLink libregraph.DriveItemCreateLink) (*link.PublicShare, error) {

View File

@@ -165,15 +165,14 @@ var _ = Describe("createLinkTests", func() {
Expect(rr.Code).To(Equal(http.StatusOK))
var createLinkResponseBody []*libregraph.Permission
var createLinkResponseBody *libregraph.Permission
err := json.Unmarshal(rr.Body.Bytes(), &createLinkResponseBody)
Expect(err).ToNot(HaveOccurred())
Expect(len(createLinkResponseBody)).To(Equal(1))
Expect(createLinkResponseBody[0].GetId()).To(Equal("123"))
Expect(createLinkResponseBody[0].GetExpirationDateTime().Unix()).To(Equal(driveItemCreateLink.ExpirationDateTime.Unix()))
Expect(createLinkResponseBody[0].GetHasPassword()).To(Equal(false))
Expect(createLinkResponseBody[0].GetLink().LibreGraphDisplayName).To(Equal(libregraph.PtrString(ViewerLinkString)))
link := createLinkResponseBody[0].GetLink()
Expect(createLinkResponseBody.GetId()).To(Equal("123"))
Expect(createLinkResponseBody.GetExpirationDateTime().Unix()).To(Equal(driveItemCreateLink.ExpirationDateTime.Unix()))
Expect(createLinkResponseBody.GetHasPassword()).To(Equal(false))
Expect(createLinkResponseBody.GetLink().LibreGraphDisplayName).To(Equal(libregraph.PtrString(ViewerLinkString)))
link := createLinkResponseBody.GetLink()
respLinkType := link.GetType()
expected, err := libregraph.NewSharingLinkTypeFromValue("view")
Expect(err).ToNot(HaveOccurred())
@@ -357,15 +356,14 @@ var _ = Describe("createLinkTests", func() {
Expect(rr.Code).To(Equal(http.StatusOK))
var createLinkResponseBody []*libregraph.Permission
var createLinkResponseBody *libregraph.Permission
err = json.Unmarshal(rr.Body.Bytes(), &createLinkResponseBody)
Expect(err).ToNot(HaveOccurred())
Expect(len(createLinkResponseBody)).To(Equal(1))
Expect(createLinkResponseBody[0].GetId()).To(Equal("123"))
Expect(createLinkResponseBody[0].GetExpirationDateTime().Unix()).To(Equal(driveItemCreateLink.ExpirationDateTime.Unix()))
Expect(createLinkResponseBody[0].GetHasPassword()).To(Equal(false))
Expect(createLinkResponseBody[0].GetLink().LibreGraphDisplayName).To(Equal(libregraph.PtrString(ViewerLinkString)))
respLink := createLinkResponseBody[0].GetLink()
Expect(createLinkResponseBody.GetId()).To(Equal("123"))
Expect(createLinkResponseBody.GetExpirationDateTime().Unix()).To(Equal(driveItemCreateLink.ExpirationDateTime.Unix()))
Expect(createLinkResponseBody.GetHasPassword()).To(Equal(false))
Expect(createLinkResponseBody.GetLink().LibreGraphDisplayName).To(Equal(libregraph.PtrString(ViewerLinkString)))
respLink := createLinkResponseBody.GetLink()
// some conversion gymnastics
respLinkType := respLink.GetType()
Expect(err).ToNot(HaveOccurred())
@@ -374,7 +372,7 @@ var _ = Describe("createLinkTests", func() {
mockLink.Type = lt
expectedType := mockLink.GetType()
Expect(&respLinkType).To(Equal(&expectedType))
libreGraphActions := createLinkResponseBody[0].LibreGraphPermissionsActions
libreGraphActions := createLinkResponseBody.LibreGraphPermissionsActions
Expect(libreGraphActions[0]).To(Equal("libre.graph/driveItem/children/create"))
Expect(libreGraphActions[1]).To(Equal("libre.graph/driveItem/upload/create"))
Expect(libreGraphActions[2]).To(Equal("libre.graph/driveItem/path/update"))