@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) %> """ 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) %> """ 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' """ <%= @formatter.json('user/create', spaces: 4) %> """ Then response should be '406' Scenario: create user, invalid body: empty 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 %>' When I send POST '/v2.0/user' query with JSON body """ <%= @formatter.json('user/create', {spaces: 4, value: {"username" => invalid_name}}) %> """ Then response should be '400' <% long_name = "a"*250 %> Scenario: create user with long name '<% long_name %>' When I send POST '/v2.0/user' query with JSON body """ <%= @formatter.json('user/create', {spaces: 4, value: {"username" => long_name}}) %> """ Then response should be '400' <% [{}, []].each do |k| %> Scenario: create user, invalid body: body is a '<%= k %>' When I send POST '/v2.0/user' query with JSON body """ <%= k %> """ 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 %>' When I send POST '/v2.0/user' query with JSON body """ <%= @formatter.json('user/create', {spaces: 4, value: {field => k}}) %> """ Then response should be '400' Scenario: create user, invalid body: without <%= field %> When I send POST '/v2.0/user' query with JSON body """ <%= @formatter.json('user/create', {spaces: 4, without_field: field}) %> """ Then response should be '400' <% end %> <% end %> Scenario: create user When I send POST '/v2.0/user' query with JSON body """ <%= @formatter.json('user/create', spaces: 4) %> """ Then response should be '201' And the Content-Type header should include 'application/json'