From af0a5fac18e91824d90cb67dbffcb5670a973af2 Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Tue, 15 Feb 2022 14:18:27 +0100 Subject: [PATCH] Create space with description (#3168) * send description during create space * add changelog * update reva * add to API test * only use opaque if not nil * use forked xattr to fix windows build Signed-off-by: Michael Barz --- ...e-use-description-during-space-creation.md | 5 ++ go.mod | 5 +- go.sum | 8 +-- graph/pkg/service/v0/drives.go | 10 +--- .../features/apiSpaces/changeSpaces.feature | 4 +- .../features/bootstrap/SpacesContext.php | 52 +++++++++++++++---- 6 files changed, 60 insertions(+), 24 deletions(-) create mode 100644 changelog/unreleased/change-use-description-during-space-creation.md diff --git a/changelog/unreleased/change-use-description-during-space-creation.md b/changelog/unreleased/change-use-description-during-space-creation.md new file mode 100644 index 0000000000..8103f91a96 --- /dev/null +++ b/changelog/unreleased/change-use-description-during-space-creation.md @@ -0,0 +1,5 @@ +Enhancement: Provide Description when creating a space + +We added the possibility to send a short description when creating a space. + +https://github.com/owncloud/ocis/pull/3167 diff --git a/go.mod b/go.mod index 5d4bc97e30..209ff47837 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/blevesearch/bleve/v2 v2.3.0 github.com/coreos/go-oidc/v3 v3.1.0 github.com/cs3org/go-cs3apis v0.0.0-20220126114148-64c025ccdd19 - github.com/cs3org/reva v1.16.1-0.20220211121851-e55c1157726d + github.com/cs3org/reva v1.16.1-0.20220214105747-d217886c962b github.com/disintegration/imaging v1.6.2 github.com/glauth/glauth/v2 v2.0.0-20211021011345-ef3151c28733 github.com/go-chi/chi/v5 v5.0.7 @@ -263,3 +263,6 @@ require ( stash.kopano.io/kgol/kcc-go/v5 v5.0.1 // indirect stash.kopano.io/kgol/oidc-go v0.3.2 // indirect ) + +// we need to use a fork to make the windows build pass +replace github.com/pkg/xattr => github.com/micbar/xattr v0.4.6-0.20220215112335-88e74d648fb7 diff --git a/go.sum b/go.sum index 9552323584..971382e6e6 100644 --- a/go.sum +++ b/go.sum @@ -337,8 +337,8 @@ github.com/crewjam/saml v0.4.5/go.mod h1:qCJQpUtZte9R1ZjUBcW8qtCNlinbO363ooNl02S github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e/go.mod h1:XJEZ3/EQuI3BXTp/6DUzFr850vlxq11I6satRtz0YQ4= github.com/cs3org/go-cs3apis v0.0.0-20220126114148-64c025ccdd19 h1:1jqPH58jCxvbaJ9WLIJ7W2/m622bWS6ChptzljSG6IQ= github.com/cs3org/go-cs3apis v0.0.0-20220126114148-64c025ccdd19/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY= -github.com/cs3org/reva v1.16.1-0.20220211121851-e55c1157726d h1:yA7Xpq8PHvVYBrJV+rxvUyW+bX7LJ/QK98iLaCSfrH0= -github.com/cs3org/reva v1.16.1-0.20220211121851-e55c1157726d/go.mod h1:gdKuhou74V47snANuHNIhGNJfCKUSCHPPvuhSx7nu5M= +github.com/cs3org/reva v1.16.1-0.20220214105747-d217886c962b h1:E53EHbKiHIIJeZgDEx5tE3AflxgL1dHughNbBQU7Dfk= +github.com/cs3org/reva v1.16.1-0.20220214105747-d217886c962b/go.mod h1:gdKuhou74V47snANuHNIhGNJfCKUSCHPPvuhSx7nu5M= github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8 h1:Z9lwXumT5ACSmJ7WGnFl+OMLLjpz5uR2fyz7dC255FI= github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8/go.mod h1:4abs/jPXcmJzYoYGF91JF9Uq9s/KL5n1jvFDix8KcqY= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= @@ -999,6 +999,8 @@ github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103 h1:Z/i1e+gTZrmcGeZy github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103/go.mod h1:o9YPB5aGP8ob35Vy6+vyq3P3bWe7NQWzf+JLiXCiMaE= github.com/mennanov/fieldmask-utils v0.5.0 h1:8em4akN0NM3hmmrg8VbvOPfdS4SSBdbFd53m9VtfOg0= github.com/mennanov/fieldmask-utils v0.5.0/go.mod h1:lah2lHczE2ff+7SqnNKpB+YzaO7M3h5iNO4LgPTJheM= +github.com/micbar/xattr v0.4.6-0.20220215112335-88e74d648fb7 h1:M0R40eUlyqxMuZn3Knx4DJTwHE3TiPFzcWUA/BKtDMM= +github.com/micbar/xattr v0.4.6-0.20220215112335-88e74d648fb7/go.mod h1:sBD3RAqlr8Q+RC3FutZcikpT8nyDrIEEBw2J744gVWs= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.40/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= @@ -1170,8 +1172,6 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pkg/term v1.1.0/go.mod h1:E25nymQcrSllhX42Ok8MRm1+hyBdHY0dCeiKZ9jpNGw= -github.com/pkg/xattr v0.4.4 h1:FSoblPdYobYoKCItkqASqcrKCxRn9Bgurz0sCBwzO5g= -github.com/pkg/xattr v0.4.4/go.mod h1:sBD3RAqlr8Q+RC3FutZcikpT8nyDrIEEBw2J744gVWs= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= diff --git a/graph/pkg/service/v0/drives.go b/graph/pkg/service/v0/drives.go index df7108e3aa..58daa2c697 100644 --- a/graph/pkg/service/v0/drives.go +++ b/graph/pkg/service/v0/drives.go @@ -17,6 +17,7 @@ import ( storageprovider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" ctxpkg "github.com/cs3org/reva/pkg/ctx" + "github.com/cs3org/reva/pkg/utils" "github.com/go-chi/chi/v5" "github.com/go-chi/render" libregraph "github.com/owncloud/libre-graph-api-go" @@ -192,14 +193,7 @@ func (g Graph) CreateDrive(w http.ResponseWriter, r *http.Request) { } if drive.Description != nil { - csr.Opaque = &types.Opaque{ - Map: map[string]*types.OpaqueEntry{ - "description": { - Decoder: "plain", - Value: []byte(*drive.Description), - }, - }, - } + csr.Opaque = utils.AppendPlainToOpaque(csr.Opaque, "description", *drive.Description) } resp, err := client.CreateStorageSpace(r.Context(), &csr) diff --git a/tests/acceptance/features/apiSpaces/changeSpaces.feature b/tests/acceptance/features/apiSpaces/changeSpaces.feature index 1ce5fcae37..b132f0e14f 100644 --- a/tests/acceptance/features/apiSpaces/changeSpaces.feature +++ b/tests/acceptance/features/apiSpaces/changeSpaces.feature @@ -10,15 +10,17 @@ Feature: Change data of space Given user "Alice" has been created with default attributes and without skeleton files And the administrator has given "Alice" the role "Admin" using the settings api - Scenario: An admin user can change the name of a Space via the Graph API + Scenario: An admin user can change the name and description of a Space via the Graph API Given user "Alice" has created a space "Project Jupiter" of type "project" with quota "20" When user "Alice" changes the name of the "Project Jupiter" space to "Project Death Star" + And user "Alice" changes the description of the "Project Death Star" space to "The Death Star is a fictional mobile space station" Then the HTTP status code should be "200" When user "Alice" lists all available spaces via the GraphApi Then the json responded should contain a space "Project Death Star" with these key and value pairs: | key | value | | driveType | project | | name | Project Death Star | + | description | The Death Star is a fictional mobile space station | | quota@@@total | 20 | | root@@@webDavUrl | %base_url%/dav/spaces/%space_id% | diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index 67c6c55f2d..f8000f1ab7 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -217,11 +217,11 @@ class SpacesContext implements Context { $fullUrl = $this->baseUrl . "/api/v0/accounts/accounts-list"; $this->featureContext->setResponse( HttpRequestHelper::post( - $fullUrl, - "", - $this->featureContext->getAdminUsername(), - $this->featureContext->getAdminPassword(), - [], + $fullUrl, + "", + $this->featureContext->getAdminUsername(), + $this->featureContext->getAdminPassword(), + [], "{}" ) ); @@ -756,7 +756,7 @@ class SpacesContext implements Context { /** * @Then /^the json responded should contain a space "([^"]*)" (?:|(?:owned by|granted to) "([^"]*)" )with these key and value pairs:$/ - * + * * @param string $spaceName * @param string $userName * @param TableNode $table @@ -785,7 +785,7 @@ class SpacesContext implements Context { [$this, "getSpaceIdByNameFromResponse"], "parameter" => [$spaceName] ], - [ + [ "code" => "%user_id%", "function" => [$this, "getUserIdByUserName"], @@ -1195,6 +1195,38 @@ class SpacesContext implements Context { ); } + /** + * @When /^user "([^"]*)" changes the description of the "([^"]*)" space to "([^"]*)"$/ + * + * @param string $user + * @param string $spaceName + * @param string $newName + * + * @return void + * @throws GuzzleException + * @throws Exception + */ + public function updateSpaceDescription( + string $user, + string $spaceName, + string $newDescription + ): void { + $space = $this->getSpaceByName($user, $spaceName); + $spaceId = $space["id"]; + + $bodyData = ["description" => $newDescription]; + $body = json_encode($bodyData, JSON_THROW_ON_ERROR); + + $this->featureContext->setResponse( + $this->sendUpdateSpaceRequest( + $user, + $this->featureContext->getPasswordForUser($user), + $body, + $spaceId + ) + ); + } + /** * @When /^user "([^"]*)" changes the quota of the "([^"]*)" space to "([^"]*)"$/ * @@ -1351,9 +1383,9 @@ class SpacesContext implements Context { } $space = $this->getSpaceByName($user, $spaceName); $body = [ - "space_ref" => $space['id'], - "shareType" => 7, - "shareWith" => $userRecipient, + "space_ref" => $space['id'], + "shareType" => 7, + "shareWith" => $userRecipient, "permissions" => $role ];