fluke/devops-service/tests/templates/api_v2/10_create/00_user.feature.erb

85 lines
2.6 KiB
Plaintext
Raw Normal View History

2014-07-15 12:57:21 +04:00
@user
Feature: create user
Scenario: create user with user without privileges
When I send POST '/v2.0/user' query with JSON body with user without privileges
"""
<%= @formatter.json('user/create', spaces: 4) %>
2014-07-15 12:57:21 +04:00
"""
Then response should be '401'
Scenario: create user without header 'Content-Type'
When I send POST '/v2.0/user' query with JSON body without header 'Content-Type'
"""
<%= @formatter.json('user/create', spaces: 4) %>
2014-07-15 12:57:21 +04:00
"""
Then response should be '415'
Scenario: create user with header 'Accept' value is not 'application/json'
When I send POST '/v2.0/user' query with body with header 'Accept' value 'application/xml'
2014-07-15 12:57:21 +04:00
"""
<%= @formatter.json('user/create', spaces: 4) %>
2014-07-15 12:57:21 +04:00
"""
Then response should be '406'
2014-07-15 12:57:21 +04:00
Scenario: create user, invalid body: empty
2014-07-15 12:57:21 +04:00
When I send POST '/v2.0/user' query with JSON body
"""
"""
Then response should be '400'
<% invalid_name = "foo]&" %>
Scenario: create user with invalid name '<% invalid_name %>'
2014-07-15 12:57:21 +04:00
When I send POST '/v2.0/user' query with JSON body
"""
<%= @formatter.json('user/create', {spaces: 4, value: {"username" => invalid_name}}) %>
2014-07-15 12:57:21 +04:00
"""
Then response should be '400'
<% long_name = "a"*250 %>
Scenario: create user with long name '<% long_name %>'
2014-07-15 12:57:21 +04:00
When I send POST '/v2.0/user' query with JSON body
"""
<%= @formatter.json('user/create', {spaces: 4, value: {"username" => long_name}}) %>
2014-07-15 12:57:21 +04:00
"""
Then response should be '400'
<% [{}, []].each do |k| %>
Scenario: create user, invalid body: body is a '<%= k %>'
2014-07-15 12:57:21 +04:00
When I send POST '/v2.0/user' query with JSON body
"""
<%= k %>
2014-07-15 12:57:21 +04:00
"""
Then response should be '400'
<% end %>
<% elements = [{}, [], nil ] %>
<% fields = @formatter.get_fixture('user/create').keys.map{|k| k.to_s} %>
<% fields.each do |field| %>
<% elements.each do |k| %>
Scenario: create user, invalid body: <%= field %> is a '<%= k %>'
2014-07-15 12:57:21 +04:00
When I send POST '/v2.0/user' query with JSON body
"""
<%= @formatter.json('user/create', {spaces: 4, value: {field => k}}) %>
2014-07-15 12:57:21 +04:00
"""
Then response should be '400'
Scenario: create user, invalid body: without <%= field %>
2014-07-15 12:57:21 +04:00
When I send POST '/v2.0/user' query with JSON body
"""
<%= @formatter.json('user/create', {spaces: 4, without_field: field}) %>
2014-07-15 12:57:21 +04:00
"""
Then response should be '400'
<% end %>
<% end %>
2014-07-15 12:57:21 +04:00
Scenario: create user
When I send POST '/v2.0/user' query with JSON body
"""
<%= @formatter.json('user/create', spaces: 4) %>
2014-07-15 12:57:21 +04:00
"""
Then response should be '201'
And the Content-Type header should include 'application/json'