Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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<Long> listOfLongs(String longs) {
return Arrays.stream(longs.split(", ?"))
.map(Long::parseLong)
.collect(Collectors.toList());
}

@When("the user with token {string} wants to download the fileSystemItems with Ids {listOfLongs}")
public void theUserWithTokenWantsToDownloadTheFileSystemItemsWithIds(String token,List<Long> Ids) {
}
}
104 changes: 104 additions & 0 deletions src/test/resources/Download.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
Feature: Download Files
As a user
I want to be able to download files and whole directories or multiple files from the same directory

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 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 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"
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 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."