summaryrefslogtreecommitdiff
path: root/features/api/sandboxes/sandboxes_api.feature
blob: 56675ab47e4405df4970e7e2e8c8508764cb8d7f (plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
@api @sandboxes @sandbox @create_sandbox
Feature: Create a sandbox via the REST API 
  In order to have files available to be included in a cookbook
  As a Developer
  I want to upload files into a sandbox and commit the sandbox

  @positive  
  Scenario: Create a one-file sandbox
    Given I am an administrator
     When I create a sandbox named 'sandbox1'
     Then the inflated responses key 'uri' should match '^http://.+/sandboxes/[^\/]+$'

  @negative  
  Scenario: Create a one-file sandbox, but commit without uploading any files
    Given I am an administrator
     When I create a sandbox named 'sandbox1'
     Then the inflated responses key 'uri' should match '^http://.+/sandboxes/[^\/]+$'
     When I commit the sandbox
     Then I should get a '400 "Bad Request"' exception

  @positive
  Scenario: Create a one-file sandbox, upload a file with an expected checksum, then commit
    Given I am an administrator
    When I create a sandbox named 'sandbox1'
    Then the inflated responses key 'uri' should match '^http://.+/sandboxes/[^\/]+$'
    Then I upload a file named 'sandbox1_file1' to the sandbox
    Then the response code should be '200'
    When I commit the sandbox
    Then I should not get an exception

  @negative
  Scenario: Create a one-file sandbox, upload a file with an unexpected checksum, then commit
    Given I am an administrator
    When I create a sandbox named 'sandbox1'
    Then the inflated responses key 'uri' should match '^http://.+/sandboxes/[^\/]+$'
    Then I upload a file named 'sandbox2_file1' to the sandbox
    Then I should get a '404 Resource Not Found' exception
    When I commit the sandbox
    Then I should get a '400 "Bad Request"' exception

  @negative
  Scenario: Create a one-file sandbox, upload a file with an expected checksum and one with an unexpected checksum, then commit
    Given I am an administrator
    When I create a sandbox named 'sandbox1'
    Then the inflated responses key 'uri' should match '^http://.+/sandboxes/[^\/]+$'
    Then I upload a file named 'sandbox1_file1' to the sandbox
    Then the response code should be '200'
    Then I upload a file named 'sandbox2_file1' to the sandbox
    Then I should get a '404 Resource Not Found' exception
    When I commit the sandbox
    # commit works as we did upload the only correct file.
    Then I should not get an exception
 
  @negative @die
  Scenario: Create a one-file sandbox, upload a file to an expected checksum URL whose contents do not match that checksum, then commit
    Given I am an administrator
    When I create a sandbox named 'sandbox1'
    Then the inflated responses key 'uri' should match '^http://.+/sandboxes/[^\/]+$'
    Then I upload a file named 'sandbox2_file1' using the checksum of 'sandbox1_file1' to the sandbox
    Then the response code should be '400'
    When I commit the sandbox
    Then I should get a '400 "Bad Request"' exception

# multiple file sandbox positive and 1/2 negative
  @positive
  Scenario: Create a two-file sandbox, upload two expected checksums, and commit
    Given I am an administrator
    When I create a sandbox named 'sandbox2'
    Then the inflated responses key 'uri' should match '^http://.+/sandboxes/[^\/]+$'
    Then I upload a file named 'sandbox2_file1' to the sandbox
    Then the response code should be '200'
    Then I upload a file named 'sandbox2_file2' to the sandbox
    Then the response code should be '200'
    When I commit the sandbox
    Then I should not get an exception
    
  @negative
  Scenario: Create a two-file sandbox, upload one of the expected checksums, then commit
    Given I am an administrator
    When I create a sandbox named 'sandbox2'
    Then the inflated responses key 'uri' should match '^http://.+/sandboxes/[^\/]+$'
    Then I upload a file named 'sandbox2_file1' to the sandbox
    Then the response code should be '200'
    When I commit the sandbox
    Then I should get a '400 "Bad Request"' exception

  @positive
  Scenario: Create a two-file sandbox, and check the needs_upload field is set for both checksums
    Given I am an administrator
    When I create a sandbox named 'sandbox2'
    Then the inflated responses key 'uri' should match '^http://.+/sandboxes/[^\/]+$'
    Then the sandbox file 'sandbox2_file1' should need upload
    Then the sandbox file 'sandbox2_file2' should need upload

  @positive
  Scenario: Create a two-file sandbox, upload the files, then commit. Create the same sandbox again, and neither file should need_upload.
    Given I am an administrator
    When I create a sandbox named 'sandbox2'
    Then the inflated responses key 'uri' should match '^http://.+/sandboxes/[^\/]+$'
    Then the sandbox file 'sandbox2_file1' should need upload
    Then the sandbox file 'sandbox2_file2' should need upload
    Then I upload a file named 'sandbox2_file1' to the sandbox
    Then the response code should be '200'
    Then I upload a file named 'sandbox2_file2' to the sandbox
    Then the response code should be '200'
    When I commit the sandbox
    Then I should not get an exception
    # create again.
    When I create a sandbox named 'sandbox2'
    Then the inflated responses key 'uri' should match '^http://.+/sandboxes/[^\/]+$'
    Then the sandbox file 'sandbox2_file1' should not need upload
    Then the sandbox file 'sandbox2_file2' should not need upload