From 33a542aced2afda6b75a6ff7c95a3491a30ac0cb Mon Sep 17 00:00:00 2001 From: qvalentin Date: Sat, 15 May 2021 12:32:22 +0200 Subject: [PATCH 1/2] FF-397 added basic download steps --- .../cucumber/FIleSystemDownloadSteps.java | 23 ++++++++++ src/test/resources/Download.feature | 43 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 src/test/java/de/filefighter/rest/cucumber/FIleSystemDownloadSteps.java create mode 100644 src/test/resources/Download.feature diff --git a/src/test/java/de/filefighter/rest/cucumber/FIleSystemDownloadSteps.java b/src/test/java/de/filefighter/rest/cucumber/FIleSystemDownloadSteps.java new file mode 100644 index 00000000..7ed7ed28 --- /dev/null +++ b/src/test/java/de/filefighter/rest/cucumber/FIleSystemDownloadSteps.java @@ -0,0 +1,23 @@ +package de.filefighter.rest.cucumber; + +import io.cucumber.java.ParameterType; +import io.cucumber.java.en.When; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + + +public class FIleSystemDownloadSteps { + + @ParameterType("\\[([0-9, ]*)\\]") + public List listOfLongs(String integers) { + return Arrays.stream(integers.split(", ?")) + .map(Long::parseLong) + .collect(Collectors.toList()); + } + + @When("the user with token {string} wants to download the files with Ids {listOfLongs}") + public void theUserWithTokenWantsToDownloadTheFilesWithIds(String token,List Ids) { + } +} diff --git a/src/test/resources/Download.feature b/src/test/resources/Download.feature new file mode 100644 index 00000000..d9f243f2 --- /dev/null +++ b/src/test/resources/Download.feature @@ -0,0 +1,43 @@ +Feature: Download Files + As a user + I want to be able to download files and whole directories + + Background: + Given database is empty + And runtime user exists + And user with userId 1234 exists and has username "Richard", password "badPassword" + And user with userId 420 exists and has username "Nasir", password "AlsoBadPassword" + And accessToken with value "Richard" exists for user 1234 + And accessToken with value "Nasir" exists for user 420 + And user with userId 1234 has HomeFolder with Id 1234 + And user with userId 420 has HomeFolder with Id 420 + And fileSystemItem with the fileSystemId 420 is a folder and contains the fileSystemId 42 + And fileSystemItem with the fileSystemId 42 exists, has owner with userId 420 has the path "/gebäude" and name "gebäude" + And fileSystemItem with the fileSystemId 42 is a folder and contains the fileSystemId 72 + And fileSystemItem with the fileSystemId 72 exists, has owner with userId 420 and name "Bergfried.avi" and mimeType "video/avi" + + Scenario: Successful interaction, download of file in personal folder + When the user with token "Nasir" wants to download the files with Ids [72] + Then response status code is 200 + And the response contains a entity with the path "Bergfried.avi" that has key "name" with value "Bergfried.avi" + And the response contains a entity with the path "Bergfried.avi" that has key "fsItemId" with value "72" + And the response contains a entity with the path "Bergfried.avi" that has key "mimeType" with value "video/avi" + + Scenario: Successful interaction, download of folder in personal folder + When the user with token "Nasir" wants to download the files with Ids [42] + Then response status code is 200 + And the response contains a entity with the path "Bergfried.avi" that has key "name" with value "Bergfried.avi" + And the response contains a entity with the path "Bergfried.avi" that has key "fsItemId" with value "72" + And the response contains a entity with the path "Bergfried.avi" that has key "mimeType" with value "video/avi" + # this will be the name of the zip archive (could also return gebäude.zip) + And the response has a header "X-FF-NAME" set with the value "gebäude" + + Scenario: Successful interaction, download of two files + Given fileSystemItem with the fileSystemId 73 exists, has owner with userId 420 and name "Torhaus.avi" + # does this step update the content? + And fileSystemItem with the fileSystemId 42 is a folder and contains the fileSystemId 73 + When the user with token "Nasir" wants to download the files with Ids [72,73] + Then response status code is 200 + And the response contains a entity with the path "Bergfried.avi" that has key "name" with value "Bergfried.avi" + And the response contains a entity with the path "Torhaus.avi" that has key "name" with value "Torhaus.avi" + And the response has a header "X-FF-NAME" set with the value "gebäude" From b69e8f335862a158d09e0e19ccc45e49669d7d69 Mon Sep 17 00:00:00 2001 From: qvalentin Date: Sun, 16 May 2021 16:33:39 +0200 Subject: [PATCH 2/2] FF-397 add more Screnarios for bad cases --- ...teps.java => FileSystemDownloadSteps.java} | 10 +-- src/test/resources/Download.feature | 69 +++++++++++++++++-- 2 files changed, 70 insertions(+), 9 deletions(-) rename src/test/java/de/filefighter/rest/cucumber/{FIleSystemDownloadSteps.java => FileSystemDownloadSteps.java} (58%) diff --git a/src/test/java/de/filefighter/rest/cucumber/FIleSystemDownloadSteps.java b/src/test/java/de/filefighter/rest/cucumber/FileSystemDownloadSteps.java similarity index 58% rename from src/test/java/de/filefighter/rest/cucumber/FIleSystemDownloadSteps.java rename to src/test/java/de/filefighter/rest/cucumber/FileSystemDownloadSteps.java index 7ed7ed28..851d07dd 100644 --- a/src/test/java/de/filefighter/rest/cucumber/FIleSystemDownloadSteps.java +++ b/src/test/java/de/filefighter/rest/cucumber/FileSystemDownloadSteps.java @@ -8,16 +8,16 @@ import java.util.stream.Collectors; -public class FIleSystemDownloadSteps { +public class FileSystemDownloadSteps { @ParameterType("\\[([0-9, ]*)\\]") - public List listOfLongs(String integers) { - return Arrays.stream(integers.split(", ?")) + public List listOfLongs(String longs) { + return Arrays.stream(longs.split(", ?")) .map(Long::parseLong) .collect(Collectors.toList()); } - @When("the user with token {string} wants to download the files with Ids {listOfLongs}") - public void theUserWithTokenWantsToDownloadTheFilesWithIds(String token,List Ids) { + @When("the user with token {string} wants to download the fileSystemItems with Ids {listOfLongs}") + public void theUserWithTokenWantsToDownloadTheFileSystemItemsWithIds(String token,List Ids) { } } diff --git a/src/test/resources/Download.feature b/src/test/resources/Download.feature index d9f243f2..245d3aea 100644 --- a/src/test/resources/Download.feature +++ b/src/test/resources/Download.feature @@ -1,6 +1,6 @@ Feature: Download Files As a user - I want to be able to download files and whole directories + I want to be able to download files and whole directories or multiple files from the same directory Background: Given database is empty @@ -17,14 +17,14 @@ Feature: Download Files And fileSystemItem with the fileSystemId 72 exists, has owner with userId 420 and name "Bergfried.avi" and mimeType "video/avi" Scenario: Successful interaction, download of file in personal folder - When the user with token "Nasir" wants to download the files with Ids [72] + When the user with token "Nasir" wants to download the fileSystemItems with Ids [72] Then response status code is 200 And the response contains a entity with the path "Bergfried.avi" that has key "name" with value "Bergfried.avi" And the response contains a entity with the path "Bergfried.avi" that has key "fsItemId" with value "72" And the response contains a entity with the path "Bergfried.avi" that has key "mimeType" with value "video/avi" Scenario: Successful interaction, download of folder in personal folder - When the user with token "Nasir" wants to download the files with Ids [42] + When the user with token "Nasir" wants to download the fileSystemItems with Ids [42] Then response status code is 200 And the response contains a entity with the path "Bergfried.avi" that has key "name" with value "Bergfried.avi" And the response contains a entity with the path "Bergfried.avi" that has key "fsItemId" with value "72" @@ -36,8 +36,69 @@ Feature: Download Files Given fileSystemItem with the fileSystemId 73 exists, has owner with userId 420 and name "Torhaus.avi" # does this step update the content? And fileSystemItem with the fileSystemId 42 is a folder and contains the fileSystemId 73 - When the user with token "Nasir" wants to download the files with Ids [72,73] + When the user with token "Nasir" wants to download the fileSystemItems with Ids [72,73] Then response status code is 200 And the response contains a entity with the path "Bergfried.avi" that has key "name" with value "Bergfried.avi" And the response contains a entity with the path "Torhaus.avi" that has key "name" with value "Torhaus.avi" And the response has a header "X-FF-NAME" set with the value "gebäude" + + Scenario: Successful interaction, download of file and folder + Given fileSystemItem with the fileSystemId 43 exists, has owner with userId 420 has the path "/gebäude/wirtschaft" and name "wirtschaft" + And fileSystemItem with the fileSystemId 42 is a folder and contains the fileSystemId 43 + And fileSystemItem with the fileSystemId 43 is a folder and contains the fileSystemId 73 + And fileSystemItem with the fileSystemId 73 exists, has owner with userId 420 and name "Eisenmine.avi" + When the user with token "Nasir" wants to download the fileSystemItems with Ids [43,72] + Then response status code is 200 + And the response contains a entity with the path "Bergfried.avi" that has key "name" with value "Bergfried.avi" + And the response contains a entity with the path "wirtschaft/Eisenmine.avi" that has key "name" with value "Eisenmine.avi" + And the response has a header "X-FF-NAME" set with the value "gebäude" + + Scenario: Successful interaction, download of folder with nested content + Given fileSystemItem with the fileSystemId 43 exists, has owner with userId 420 has the path "/gebäude/wirtschaft" and name "wirtschaft" + And fileSystemItem with the fileSystemId 42 is a folder and contains the fileSystemId 43 + And fileSystemItem with the fileSystemId 43 is a folder and contains the fileSystemId 73 + And fileSystemItem with the fileSystemId 73 exists, has owner with userId 420 and name "Eisenmine.avi" + When the user with token "Nasir" wants to download the fileSystemItems with Ids [42] + Then response status code is 200 + And the response contains a entity with the path "Bergfried.avi" that has key "name" with value "Bergfried.avi" + And the response contains a entity with the path "wirtschaft/Eisenmine.avi" that has key "name" with value "Eisenmine.avi" + And the response has a header "X-FF-NAME" set with the value "gebäude" + + Scenario: Successful interaction, download of shared file (user) + Given user with the userId 1234 is allowed to VIEW the fileSystemItem with the fileSystemId 72 + When the user with token "Richard" wants to download the fileSystemItems with Ids [72] + Then response status code is 200 + And the response contains a entity with the path "Bergfried.avi" that has key "name" with value "Bergfried.avi" + And the response contains a entity with the path "Bergfried.avi" that has key "fsItemId" with value "72" + + Scenario: Successful interaction, download of shared file (group) + Given group with the groupId 1 is allowed to VIEW the fileSystemItem with the fileSystemId 72 + And user with userId 1234 is in group with groupId 1 + When the user with token "Richard" wants to download the fileSystemItems with Ids [72] + Then response status code is 200 + And the response contains a entity with the path "Bergfried.avi" that has key "name" with value "Bergfried.avi" + And the response contains a entity with the path "Bergfried.avi" that has key "fsItemId" with value "72" + + Scenario: File does not exist + When the user with token "Nasir" wants to download the fileSystemItems with Ids [666] + Then response status code is 400 + And response contains key "message" and value "File does not exist, or you are not allowed to see the file." + + Scenario: Folder is empty + Given fileSystemItem with the fileSystemId 43 exists, has owner with userId 420 has the path "/gebäude/wirtschaft" and name "wirtschaft" + And fileSystemItem with the fileSystemId 42 is a folder and contains the fileSystemId 43 + When the user with token "Nasir" wants to download the fileSystemItems with Ids [43] + Then response status code is 400 + And response contains key "message" and value "You can't download a empty directory." + + Scenario: No unique parent folder + When the user with token "Nasir" wants to download the fileSystemItems with Ids [42,72] + Then response status code is 400 + And response contains key "message" and value "Could not find a unique parent directory for the selected files." + + Scenario: insufficient authorization + When the user with token "Richard" wants to download the fileSystemItems with Ids [42] + And response contains key "message" and value "File does not exist, or you are not allowed to see the file." + + +