120 lines
5.9 KiB
Gherkin
120 lines
5.9 KiB
Gherkin
Feature: Video upload
|
|
Getting a video into the catalogue is a two-step exchange. The client asks
|
|
the CMS for an upload slot, PUTs the file straight to storage with the
|
|
short-lived URL it is handed, and then registers the video — which queues
|
|
the transcoding job and writes the catalogue record. The file itself never
|
|
passes through the API.
|
|
|
|
Background:
|
|
Given the CMS API is available
|
|
|
|
Scenario: Discovering the categories a video can be filed under
|
|
When I ask the CMS for the list of categories
|
|
Then the request succeeds with status 200
|
|
And the category list is not empty
|
|
And every category has an id and a name
|
|
|
|
Scenario: Asking for an upload slot for an MP4
|
|
When I request an upload slot for "interview-cut.mp4" of type "video/mp4"
|
|
Then the request succeeds with status 200
|
|
And I am given an upload URL
|
|
And the storage key is under "videos/" and ends with ".mp4"
|
|
|
|
Scenario: Asking for an upload slot for a QuickTime movie
|
|
When I request an upload slot for "interview-cut.mov" of type "video/quicktime"
|
|
Then the request succeeds with status 200
|
|
And I am given an upload URL
|
|
And the storage key is under "videos/" and ends with ".mov"
|
|
|
|
Scenario Outline: Refusing to hand out a slot for anything that is not an MP4 or MOV
|
|
When I request an upload slot for "<file>" of type "<type>"
|
|
Then the request is rejected with status 422
|
|
And the problem title is "Unsupported file type. Please upload an MP4 or MOV video."
|
|
|
|
Examples:
|
|
| file | type |
|
|
| clip.avi | video/avi |
|
|
| reel.mkv | video/x-matroska |
|
|
| poster.png | image/png |
|
|
| notes.txt | text/plain |
|
|
| blob.bin | application/octet-stream |
|
|
| clip.mp4 | |
|
|
|
|
Scenario: Refusing a request body that is not JSON
|
|
When I send malformed JSON to the upload slot endpoint
|
|
Then the request is rejected with status 400
|
|
And the problem title is "Invalid request."
|
|
|
|
Scenario: Registering a video that has been uploaded
|
|
Given I have requested an upload slot for "interview-cut.mp4" of type "video/mp4"
|
|
And I have uploaded the file to the upload URL
|
|
When I register the uploaded video titled "Inside the Newsroom" under categories "documentary, news"
|
|
Then the request succeeds with status 201
|
|
And the video is registered with status "processing"
|
|
And the video has an id
|
|
And the video is stored under the key from the upload slot
|
|
And the video has a transcoding job id
|
|
And the video is filed under categories "documentary, news"
|
|
And the video keeps the metadata I sent
|
|
|
|
Scenario: Registering a video under a single category
|
|
Given I have requested an upload slot for "short.mov" of type "video/quicktime"
|
|
And I have uploaded the file to the upload URL
|
|
When I register the uploaded video titled "A Short Film" under categories "documentary"
|
|
Then the request succeeds with status 201
|
|
And the video is filed under categories "documentary"
|
|
|
|
Scenario: Refusing to register a video whose file was never uploaded
|
|
Given I have requested an upload slot for "ghost.mp4" of type "video/mp4"
|
|
When I register the uploaded video titled "The One That Got Away" under categories "other"
|
|
Then the request is rejected with status 422
|
|
And the problem title is "Failed to find video in storage"
|
|
|
|
Scenario: Refusing to register a video without a title
|
|
Given I have requested an upload slot for "untitled.mp4" of type "video/mp4"
|
|
And I have uploaded the file to the upload URL
|
|
When I register the uploaded video titled " " under categories "other"
|
|
Then the request is rejected with status 422
|
|
And the problem title is "Title is required."
|
|
|
|
Scenario: Refusing to register a video with no category
|
|
Given I have requested an upload slot for "uncategorised.mp4" of type "video/mp4"
|
|
And I have uploaded the file to the upload URL
|
|
When I register the uploaded video titled "Uncategorised" under categories ""
|
|
Then the request is rejected with status 422
|
|
And the problem title is "At least one category is required."
|
|
|
|
Scenario Outline: Refusing to register a storage key this API never issued
|
|
When I register a video titled "Smuggled In" with the key "<key>" under categories "other"
|
|
Then the request is rejected with status 422
|
|
And the problem title is "A video file is required."
|
|
|
|
Examples:
|
|
| key |
|
|
| |
|
|
| not-mine.mp4 |
|
|
| uploads/not-mine.mp4 |
|
|
| ../videos/escape.mp4 |
|
|
| videos-of-someone-else/clip.mp4 |
|
|
|
|
# An id no category has is the client's mistake, and is answered separately
|
|
# from the category lookup failing, which is the server's and stays a 500.
|
|
Scenario: Registering a video under a category id that does not exist
|
|
Given I have requested an upload slot for "mystery.mp4" of type "video/mp4"
|
|
And I have uploaded the file to the upload URL
|
|
When I register the uploaded video titled "Mystery Genre" under category id 32767
|
|
Then the request is rejected with status 404
|
|
And the problem title is "Catagory Does Not Exist"
|
|
|
|
# Registration is not idempotent: videos.storage_key is UNIQUE, so a retry
|
|
# with a key that was already registered fails the insert — after a second
|
|
# MediaConvert job has already been queued for the same file.
|
|
@known-gap
|
|
Scenario: Registering the same upload twice
|
|
Given I have requested an upload slot for "twice.mp4" of type "video/mp4"
|
|
And I have uploaded the file to the upload URL
|
|
And I have registered the uploaded video titled "Filed Once" under categories "other"
|
|
When I register the uploaded video titled "Filed Twice" under categories "other"
|
|
Then the request is rejected with status 500
|
|
And the problem title is "Something Went Wrong Saving The Video Record"
|