| 
									
										
										
										
											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 | 
					
						
							|  |  |  |     """ | 
					
						
							| 
									
										
										
										
											2015-10-06 13:50:26 +03:00
										 |  |  |     <%= @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' | 
					
						
							|  |  |  |     """ | 
					
						
							| 
									
										
										
										
											2015-10-06 13:50:26 +03:00
										 |  |  |     <%= @formatter.json('user/create', spaces: 4) %> | 
					
						
							| 
									
										
										
										
											2014-07-15 12:57:21 +04:00
										 |  |  |     """ | 
					
						
							|  |  |  |     Then response should be '415' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-06 13:50:26 +03:00
										 |  |  |   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
										 |  |  |     """ | 
					
						
							| 
									
										
										
										
											2015-10-06 13:50:26 +03:00
										 |  |  |     <%= @formatter.json('user/create', spaces: 4) %> | 
					
						
							| 
									
										
										
										
											2014-07-15 12:57:21 +04:00
										 |  |  |     """ | 
					
						
							| 
									
										
										
										
											2015-10-06 13:50:26 +03:00
										 |  |  |     Then response should be '406' | 
					
						
							| 
									
										
										
										
											2014-07-15 12:57:21 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-06 13:50:26 +03: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' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-06 13:50:26 +03:00
										 |  |  |   <% 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 | 
					
						
							|  |  |  |     """ | 
					
						
							| 
									
										
										
										
											2015-10-06 13:50:26 +03:00
										 |  |  |     <%= @formatter.json('user/create', {spaces: 4, value: {"username" => invalid_name}}) %> | 
					
						
							| 
									
										
										
										
											2014-07-15 12:57:21 +04:00
										 |  |  |     """ | 
					
						
							|  |  |  |     Then response should be '400' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-06 13:50:26 +03:00
										 |  |  |   <% 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 | 
					
						
							|  |  |  |     """ | 
					
						
							| 
									
										
										
										
											2015-10-06 13:50:26 +03:00
										 |  |  |     <%= @formatter.json('user/create', {spaces: 4, value: {"username" => long_name}}) %> | 
					
						
							| 
									
										
										
										
											2014-07-15 12:57:21 +04:00
										 |  |  |     """ | 
					
						
							|  |  |  |     Then response should be '400' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-06 13:50:26 +03:00
										 |  |  |   <% [{}, []].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 | 
					
						
							|  |  |  |     """ | 
					
						
							| 
									
										
										
										
											2015-10-06 13:50:26 +03:00
										 |  |  |     <%= k %> | 
					
						
							| 
									
										
										
										
											2014-07-15 12:57:21 +04:00
										 |  |  |     """ | 
					
						
							|  |  |  |     Then response should be '400' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   <% end %> | 
					
						
							| 
									
										
										
										
											2015-10-06 13:50:26 +03:00
										 |  |  |   <% 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 | 
					
						
							|  |  |  |     """ | 
					
						
							| 
									
										
										
										
											2015-10-06 13:50:26 +03:00
										 |  |  |     <%= @formatter.json('user/create', {spaces: 4, value: {field => k}}) %> | 
					
						
							| 
									
										
										
										
											2014-07-15 12:57:21 +04:00
										 |  |  |     """ | 
					
						
							|  |  |  |     Then response should be '400' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-06 13:50:26 +03:00
										 |  |  |   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 | 
					
						
							|  |  |  |     """ | 
					
						
							| 
									
										
										
										
											2015-10-06 13:50:26 +03:00
										 |  |  |     <%= @formatter.json('user/create', {spaces: 4, without_field: field}) %> | 
					
						
							| 
									
										
										
										
											2014-07-15 12:57:21 +04:00
										 |  |  |     """ | 
					
						
							|  |  |  |     Then response should be '400' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-06 13:50:26 +03:00
										 |  |  |   <% end %> | 
					
						
							|  |  |  |   <% end %> | 
					
						
							| 
									
										
										
										
											2014-07-15 12:57:21 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  |   Scenario: create user | 
					
						
							|  |  |  |     When I send POST '/v2.0/user' query with JSON body | 
					
						
							|  |  |  |     """ | 
					
						
							| 
									
										
										
										
											2015-10-06 13:50:26 +03:00
										 |  |  |     <%= @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' | 
					
						
							|  |  |  | 
 |