From d3b87fa3a1dd5c742984bdff42eb63a09f9f54c7 Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Thu, 10 Feb 2022 16:18:52 +0100 Subject: [PATCH] fix API tests --- graph/pkg/service/v0/driveitems.go | 30 ++++++++++--------- graph/pkg/service/v0/drives.go | 5 ++-- .../features/apiSpaces/listSpaces.feature | 4 --- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/graph/pkg/service/v0/driveitems.go b/graph/pkg/service/v0/driveitems.go index 14ee759b39..48da547b28 100644 --- a/graph/pkg/service/v0/driveitems.go +++ b/graph/pkg/service/v0/driveitems.go @@ -166,14 +166,15 @@ func (g Graph) GetSpecialSpaceItems(ctx context.Context, baseURL *url.URL, space readmeItem, err := g.getDriveItem(ctx, &storageprovider.ResourceId{StorageId: space.Root.StorageId, OpaqueId: readmeID}) if err != nil { g.logger.Error().Err(err).Str("ID", readmeID).Msg("Could not get readme Item") - } - readmePath, err := g.getPathForDriveItem(ctx, &storageprovider.ResourceId{StorageId: space.Root.StorageId, OpaqueId: readmeID}) - if err != nil { - g.logger.Error().Err(err).Str("ID", readmeID).Msg("Could not get readme path") } else { - readmeItem.SpecialFolder = &libregraph.SpecialFolder{Name: libregraph.PtrString(ReadmeSpecialFolderName)} - readmeItem.WebDavUrl = libregraph.PtrString(baseURL.String() + filepath.Join(space.Root.OpaqueId, *readmePath)) - spaceItems = append(spaceItems, *readmeItem) + readmePath, err := g.getPathForDriveItem(ctx, &storageprovider.ResourceId{StorageId: space.Root.StorageId, OpaqueId: readmeID}) + if err != nil { + g.logger.Error().Err(err).Str("ID", readmeID).Msg("Could not get readme path") + } else { + readmeItem.SpecialFolder = &libregraph.SpecialFolder{Name: libregraph.PtrString(ReadmeSpecialFolderName)} + readmeItem.WebDavUrl = libregraph.PtrString(baseURL.String() + filepath.Join(space.Root.OpaqueId, *readmePath)) + spaceItems = append(spaceItems, *readmeItem) + } } } } @@ -183,14 +184,15 @@ func (g Graph) GetSpecialSpaceItems(ctx context.Context, baseURL *url.URL, space imageItem, err := g.getDriveItem(ctx, &storageprovider.ResourceId{StorageId: space.Root.StorageId, OpaqueId: imageID}) if err != nil { g.logger.Error().Err(err).Str("ID", imageID).Msg("Could not get image Item") - } - imagePath, err := g.getPathForDriveItem(ctx, &storageprovider.ResourceId{StorageId: space.Root.StorageId, OpaqueId: imageID}) - if err != nil { - g.logger.Error().Err(err).Str("ID", imageID).Msg("Could not get image path") } else { - imageItem.SpecialFolder = &libregraph.SpecialFolder{Name: libregraph.PtrString(SpaceImageSpecialFolderName)} - imageItem.WebDavUrl = libregraph.PtrString(baseURL.String() + filepath.Join(space.Root.OpaqueId, *imagePath)) - spaceItems = append(spaceItems, *imageItem) + imagePath, err := g.getPathForDriveItem(ctx, &storageprovider.ResourceId{StorageId: space.Root.StorageId, OpaqueId: imageID}) + if err != nil { + g.logger.Error().Err(err).Str("ID", imageID).Msg("Could not get image path") + } else { + imageItem.SpecialFolder = &libregraph.SpecialFolder{Name: libregraph.PtrString(SpaceImageSpecialFolderName)} + imageItem.WebDavUrl = libregraph.PtrString(baseURL.String() + filepath.Join(space.Root.OpaqueId, *imagePath)) + spaceItems = append(spaceItems, *imageItem) + } } } } diff --git a/graph/pkg/service/v0/drives.go b/graph/pkg/service/v0/drives.go index 5db552f095..82e2afaaae 100644 --- a/graph/pkg/service/v0/drives.go +++ b/graph/pkg/service/v0/drives.go @@ -289,11 +289,10 @@ func (g Graph) UpdateDrive(w http.ResponseWriter, r *http.Request) { // Use the Opaque prop of the space opaque := make(map[string]*types.OpaqueEntry) - spaceDescription := *drive.Description - if spaceDescription != "" { + if drive.Description != nil { opaque["description"] = &types.OpaqueEntry{ Decoder: "plain", - Value: []byte(spaceDescription), + Value: []byte(*drive.Description), } } diff --git a/tests/acceptance/features/apiSpaces/listSpaces.feature b/tests/acceptance/features/apiSpaces/listSpaces.feature index ac3afc65e9..213d2a7d3d 100644 --- a/tests/acceptance/features/apiSpaces/listSpaces.feature +++ b/tests/acceptance/features/apiSpaces/listSpaces.feature @@ -64,10 +64,6 @@ Feature: List and create spaces | name | Project Mars | | quota@@@total | 1000000000 | | root@@@webDavUrl | %base_url%/dav/spaces/%space_id% | - When user "Alice" lists all available spaces via the GraphApi - And user "Alice" lists the content of the space with the name "Project Mars" using the WebDav Api - Then the propfind result of the space should contain these entries: - | .space/ | Scenario: An admin user can create a Space via the Graph API with certain quota Given the administrator has given "Alice" the role "Admin" using the settings api