Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Split up Write API feature tests
Browse files Browse the repository at this point in the history
Everything was in a single feature, which is very confusing.
  • Loading branch information
Paul M Furley committed May 8, 2014
1 parent 9930519 commit 332481b
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 121 deletions.
14 changes: 14 additions & 0 deletions features/write_api/access_control.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@use_write_api_client
Feature: access_control

Scenario: unauthorized when posting with an incorrect token
Given I have JSON data '[]'
and I have a data_set named "some_data_set" with settings
| key | value |
| data_group | "group" |
| data_type | "type" |
and I have the bearer token "invalid-bearer-token"
when I POST to the specific path "/data/group/type"
then I should get back a status of "401"
and I should get a "WWW-Authenticate" header of "bearer"
and I should get back the message "Unauthorized: Invalid bearer token "invalid-bearer-token""
63 changes: 63 additions & 0 deletions features/write_api/create_collection.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
@use_write_api_client
Feature: create_collection

Scenario: creating an uncapped collection
Given I have JSON data '{"capped_size": 0}'
and I have the bearer token "dev-create-endpoint-token"
when I POST to the specific path "/data-sets/new-uncapped"
then I should get back a status of "200"
and the collection called "new-uncapped" should exist
and the collection called "new-uncapped" should be uncapped

Scenario: creating a capped collection
Given I have JSON data '{"capped_size": 5040}'
and I have the bearer token "dev-create-endpoint-token"
when I POST to the specific path "/data-sets/new-capped"
then I should get back a status of "200"
and the collection called "new-capped" should exist
and the collection called "new-capped" should be capped at "5040"

Scenario: denying create collection with missing bearer token
Given I have JSON data '{"capped_size": 0}'
when I POST to the specific path "/data-sets/new-dataset"
then I should get back a status of "401"
and I should get a "WWW-Authenticate" header of "bearer"
and I should get back the message "Unauthorized: invalid or no token given."

Scenario: denying create collection with incorrect bearer token
Given I have JSON data '{"capped_size": 0}'
and I have the bearer token "invalid-bearer-token"
when I POST to the specific path "/data-sets/new-dataset"
then I should get back a status of "401"
and I should get a "WWW-Authenticate" header of "bearer"
and I should get back the message "Unauthorized: invalid or no token given."

Scenario: not creating a collection if it already exists
Given I have JSON data '{"capped_size": 4096}'
and I have the bearer token "dev-create-endpoint-token"
when I POST to the specific path "/data-sets/some-dataset"
and I POST to the specific path "/data-sets/some-dataset"
then I should get back a status of "400"

Scenario: rejecting a missing capped_size when creating a collection
Given I have JSON data '{}'
and I have the bearer token "dev-create-endpoint-token"
and I have a data_set named "new-dataset" with settings
| key | value |
when I POST to the specific path "/data-sets/new-dataset"
then I should get back a status of "400"
and the collection called "new-dataset" should not exist

Scenario: rejecting an invalid capped_size when creating a collection
Given I have JSON data '{"capped_size": "invalid"}'
and I have the bearer token "dev-create-endpoint-token"
when I POST to the specific path "/data-sets/new-dataset"
then I should get back a status of "400"
and the collection called "new-dataset" should not exist

Scenario: rejecting an invalid JSON body when creating a collection
Given I have JSON data '{broken}'
and I have the bearer token "dev-create-endpoint-token"
when I POST to the specific path "/data-sets/new-dataset"
then I should get back a status of "400"
and the collection called "new-dataset" should not exist
22 changes: 22 additions & 0 deletions features/write_api/delete_data_set.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@use_write_api_client
Feature: delete_data_set

@delete_things
Scenario: deleting a data-set
Given I have a data_set named "some-dataset" with settings
| key | value |
and I have JSON data '{"capped_size": 4096}'
and I have the bearer token "dev-create-endpoint-token"
when I POST to the specific path "/data-sets/some-dataset"
then the collection called "some-dataset" should exist
when I send a DELETE request to "/data-sets/some-dataset"
then I should get back a status of "200"
and I should get back the message "Deleted some-dataset"
and the collection called "some-dataset" should not exist

@delete_things
Scenario: cannot delete a data-set that does not exist
Given I have the bearer token "dev-create-endpoint-token"
when I send a DELETE request to "/data-sets/some-dataset"
then I should get back a status of "404"
and I should get back the message "No collection exists with name "some-dataset""
30 changes: 30 additions & 0 deletions features/write_api/empty_data_set.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@use_write_api_client
Feature: empty_data_set

@empty_data_set
Scenario: emptying a data-set by PUTing an empty JSON list
Given I have the data in "dinosaur.json"
and I have a data_set named "some_data_set" with settings
| key | value |
| data_group | "group" |
| data_type | "type" |
and I use the bearer token for the data_set
when I POST to the specific path "/data/group/type"
given I have JSON data '[]'
when I PUT to the specific path "/data/group/type"
then I should get back a status of "200"
and the collection called "some_data_set" should exist
and the collection called "some_data_set" should contain 0 records
and I should get back the message "some_data_set now contains 0 records"

@empty_data_set
Scenario: PUT is only implemented for an empty JSON list
Given I have a data_set named "some_data_set" with settings
| key | value |
| data_group | "group" |
| data_type | "type" |
and I use the bearer token for the data_set
given I have JSON data '[{"a": 1}]'
when I PUT to the specific path "/data/group/type"
then I should get back a status of "400"
and I should get back the message "Not implemented: you can only pass an empty JSON list"
121 changes: 0 additions & 121 deletions features/write_api/write_api.feature
Original file line number Diff line number Diff line change
Expand Up @@ -61,124 +61,3 @@ Feature: the performance platform write api
then I should get back a status of "200"
and the stored data should contain "3" "_week_start_at" on "2013-03-11"
and the stored data should contain "2" "_week_start_at" on "2013-03-18"

Scenario: unauthorized when posting with an incorrect token
Given I have JSON data '[]'
and I have a data_set named "some_data_set" with settings
| key | value |
| data_group | "group" |
| data_type | "type" |
and I have the bearer token "invalid-bearer-token"
when I POST to the specific path "/data/group/type"
then I should get back a status of "401"
and I should get a "WWW-Authenticate" header of "bearer"
and I should get back the message "Unauthorized: Invalid bearer token "invalid-bearer-token""

Scenario: denying create collection with missing bearer token
Given I have JSON data '{"capped_size": 0}'
when I POST to the specific path "/data-sets/new-dataset"
then I should get back a status of "401"
and I should get a "WWW-Authenticate" header of "bearer"
and I should get back the message "Unauthorized: invalid or no token given."

Scenario: denying create collection with incorrect bearer token
Given I have JSON data '{"capped_size": 0}'
and I have the bearer token "invalid-bearer-token"
when I POST to the specific path "/data-sets/new-dataset"
then I should get back a status of "401"
and I should get a "WWW-Authenticate" header of "bearer"
and I should get back the message "Unauthorized: invalid or no token given."

Scenario: creating an uncapped collection
Given I have JSON data '{"capped_size": 0}'
and I have the bearer token "dev-create-endpoint-token"
when I POST to the specific path "/data-sets/new-uncapped"
then I should get back a status of "200"
and the collection called "new-uncapped" should exist
and the collection called "new-uncapped" should be uncapped

Scenario: creating a capped collection
Given I have JSON data '{"capped_size": 5040}'
and I have the bearer token "dev-create-endpoint-token"
when I POST to the specific path "/data-sets/new-capped"
then I should get back a status of "200"
and the collection called "new-capped" should exist
and the collection called "new-capped" should be capped at "5040"

@delete_things
Scenario: deleting a data-set
Given I have a data_set named "some-dataset" with settings
| key | value |
and I have JSON data '{"capped_size": 4096}'
and I have the bearer token "dev-create-endpoint-token"
when I POST to the specific path "/data-sets/some-dataset"
then the collection called "some-dataset" should exist
when I send a DELETE request to "/data-sets/some-dataset"
then I should get back a status of "200"
and I should get back the message "Deleted some-dataset"
and the collection called "some-dataset" should not exist

@delete_things
Scenario: trying to delete a data-set that does not exist
Given I have the bearer token "dev-create-endpoint-token"
when I send a DELETE request to "/data-sets/some-dataset"
then I should get back a status of "404"
and I should get back the message "No collection exists with name "some-dataset""

Scenario: not creating a collection if it already exists
Given I have JSON data '{"capped_size": 4096}'
and I have the bearer token "dev-create-endpoint-token"
when I POST to the specific path "/data-sets/some-dataset"
and I POST to the specific path "/data-sets/some-dataset"
then I should get back a status of "400"

Scenario: rejecting a missing capped_size when creating a collection
Given I have JSON data '{}'
and I have the bearer token "dev-create-endpoint-token"
and I have a data_set named "new-dataset" with settings
| key | value |
when I POST to the specific path "/data-sets/new-dataset"
then I should get back a status of "400"
and the collection called "new-dataset" should not exist

Scenario: rejecting an invalid capped_size when creating a collection
Given I have JSON data '{"capped_size": "invalid"}'
and I have the bearer token "dev-create-endpoint-token"
when I POST to the specific path "/data-sets/new-dataset"
then I should get back a status of "400"
and the collection called "new-dataset" should not exist

Scenario: rejecting an JSON body when creating a collection
Given I have JSON data '{broken}'
and I have the bearer token "dev-create-endpoint-token"
when I POST to the specific path "/data-sets/new-dataset"
then I should get back a status of "400"
and the collection called "new-dataset" should not exist

@empty_data_set
Scenario: emptying a data-set by PUTing an empty JSON list
Given I have the data in "dinosaur.json"
and I have a data_set named "some_data_set" with settings
| key | value |
| data_group | "group" |
| data_type | "type" |
and I use the bearer token for the data_set
when I POST to the specific path "/data/group/type"
given I have JSON data '[]'
when I PUT to the specific path "/data/group/type"
then I should get back a status of "200"
and the collection called "some_data_set" should exist
and the collection called "some_data_set" should contain 0 records
and I should get back the message "some_data_set now contains 0 records"

@empty_data_set
Scenario: PUT is only implemented for an empty JSON list
Given I have a data_set named "some_data_set" with settings
| key | value |
| data_group | "group" |
| data_type | "type" |
and I use the bearer token for the data_set
given I have JSON data '[{"a": 1}]'
when I PUT to the specific path "/data/group/type"
then I should get back a status of "400"
and I should get back the message "Not implemented: you can only pass an empty JSON list"

0 comments on commit 332481b

Please sign in to comment.