/
upload-image.feature
46 lines (39 loc) · 1.53 KB
/
upload-image.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Feature: file upload end-point
Background:
* url demoBaseUrl
Scenario: upload image - multipart
Given path 'files'
And multipart file myFile = { read: 'karate-logo.jpg', filename: 'karate-logo.jpg', contentType: 'image/jpg' }
And multipart field message = 'image test'
When method post
Then status 200
And match response == { id: '#uuid', filename: 'karate-logo.jpg', message: 'image test', contentType: 'image/jpg' }
And def id = response.id
Given path 'files', id
When method get
Then status 200
And match response == read('karate-logo.jpg')
And match header Content-Disposition contains 'attachment'
And match header Content-Disposition contains 'karate-logo.jpg'
And match header Content-Type == 'image/jpg'
Scenario: upload image - binary request body
Given path 'files', 'binary'
And param name = 'karate-logo.jpg'
And request read('karate-logo.jpg')
When method post
Then status 200
And match response contains { id: '#uuid' }
And def id = response.id
Given path 'files', id
When method get
Then status 200
And match responseBytes == read('karate-logo.jpg')
And match header Content-Disposition contains 'karate-logo.jpg'
Scenario: upload stream - content-length should be sent correctly
Given path 'search', 'headers'
And param name = 'karate-logo.jpg'
And request read('karate-logo.jpg')
When method post
Then status 200
And def response = karate.lowerCase(response)
And match response['content-length'][0] == '13575'