I'm new to Tavern and I'm implementing tests for an AWS API Gateway application.
Case Description and Normal Approach
In my case, I use pre-signed URLs to directly upload files to S3 bucket. A pre-signed URL is formed by the following attributes:
url = 'https://<bucket>.s3.amazonaws.com/'
fields:
key=<filename>.zip
x-amz-algorithm=***
x-amz-credential=***
x-amz-date=***
x-amz-security-token=***
policy=***
x-amz-signature=***
In a normal cURL request, this would be used as follows:
curl -v \
-F key=<filename>.zip \
-F x-amz-algorithm=*** \
-F x-amz-credential=*** \
-F x-amz-date=*** \
-F x-amz-security-token=*** \
-F policy=*** \
-F x-amz-signature=*** \
-F file=@<filename>.zip \
'https://<bucket>.s3.amazonaws.com/'
Implemented Test
As you can see, it's necessary to use the -F
flag of cURL
which forms a multipart/form-data
POST request.
In Tavern
approach, and as I read, -F
is equivalent to files
, so this would be as follows:
stages:
- name: UPLOAD A FILE TO S3
request:
method: POST
url: "https:/<bucket>.s3.amazonaws.com/"
files:
key: target.zip
x-amz-algorithm: ***
x-amz-credential: ***
x-amz-date: ***
x-amz-security-token: ***
policy: ***
x-amz-signature: ***
file: '@target.zip'
response:
status_code: 200
Error
But it's failing with the error :
Error: <value of x-amz-algorithm> file not found
So it's considering the fields as files and so it fails.
Is it possible to have this case implemented in Tavern
and so my implementation is wrong somewhere, or this is not possible in Tavern
yet?
Kind regards,
Rshad