fluke/devops-service/tests/templates/api_v2/20_update/00_user.feature.erb

167 lines
5.7 KiB
Plaintext
Raw Normal View History

2014-07-16 13:32:59 +04:00
@user
Feature: change user privileges and password
<% user_hash = @formatter.get_fixture('user/create') %>
<% username = user_hash["username"] %>
<% update_user_hash = @formatter.get_fixture('user/update') %>
<% update_user_hash.keys.each do |k| %>
2014-07-16 13:32:59 +04:00
Scenario: change user <%= k %> with user without privileges
When I send PUT '/v2.0/user/<%= username %>/<%= k %>' query with JSON body with user without privileges
2014-07-16 13:32:59 +04:00
"""
{
"<%= k %>": "<%= update_user_hash[k] %>"
2014-07-16 13:32:59 +04:00
}
"""
Then response should be '401'
Scenario: change root <%= k %>
When I send PUT '/v2.0/user/root/<%= k %>' query with JSON body
"""
{
"<%= k %>": "<%= update_user_hash[k] %>"
2014-07-16 13:32:59 +04:00
}
"""
Then response should be '401'
Scenario: change user <%= k %> without header 'Content-Type'
When I send PUT '/v2.0/user/<%= username %>/<%= k %>' query with JSON body without header 'Content-Type'
2014-07-16 13:32:59 +04:00
"""
{
"<%= k %>": "<%= update_user_hash[k] %>"
2014-07-16 13:32:59 +04:00
}
"""
Then response should be '415'
Scenario: change user <%= k %>, invalid body: empty
When I send PUT '/v2.0/user/<%= username %>/<%= k %>' query with JSON body
2014-07-16 13:32:59 +04:00
"""
"""
Then response should be '400'
<% ["", "[]"].each do |body| %>
2014-07-16 13:32:59 +04:00
Scenario: change user <%= k %>, invalid body: body is a '<%= body %>'
When I send PUT '/v2.0/user/<%= username %>/<%= k %>' query with JSON body
2014-07-16 13:32:59 +04:00
"""
<%= body %>
"""
Then response should be '400'
<% end %>
<% elements = ["{}", "[]", "null" ] %>
<% elements.each do |value| %>
Scenario: change user <%= k %>, invalid body: <%= k %> is a '<%= value %>'
When I send PUT '/v2.0/user/<%= username %>/<%= k %>' query with JSON body
2014-07-16 13:32:59 +04:00
"""
{
"<%= k %>": <%= value %>
}
"""
Then response should be '400'
<% end %>
Scenario: change user <%= k %>
When I send PUT '/v2.0/user/<%= username %>/<%= k %>' query with JSON body
2014-07-16 13:32:59 +04:00
"""
{
"<%= k %>": "<%= update_user_hash[k] %>"
2014-07-16 13:32:59 +04:00
}
"""
Then response should be '200'
And the Content-Type header should include 'application/json'
<% end %>
Scenario: change user privileges with user without privileges
When I send PUT '/v2.0/user/<%= username %>' query with JSON body with user without privileges
2014-07-16 13:32:59 +04:00
"""
<%= @formatter.json('user/privileges', {spaces: 4}) %>
2014-07-16 13:32:59 +04:00
"""
Then response should be '401'
Scenario: change root privileges
When I send PUT '/v2.0/user/root' query with JSON body
"""
<%= @formatter.json('user/privileges', {spaces: 4}) %>
2014-07-16 13:32:59 +04:00
"""
Then response should be '401'
Scenario: change user privileges without header 'Content-Type'
When I send PUT '/v2.0/user/<%= username %>' query with JSON body without header 'Content-Type'
2014-07-16 13:32:59 +04:00
"""
<%= @formatter.json('user/privileges', {spaces: 4}) %>
2014-07-16 13:32:59 +04:00
"""
Then response should be '415'
Scenario: change user privileges with header 'Accept' value is not application/json
When I send PUT '/v2.0/user/<%= username %>' query with JSON body with header 'Accept' value 'application/xml'
2014-07-16 13:32:59 +04:00
"""
<%= @formatter.json('user/privileges', {spaces: 4}) %>
2014-07-16 13:32:59 +04:00
"""
Then response should be '406'
2014-07-16 13:32:59 +04:00
<% elements = ["{}", "[]" ] %>
<% elements.each do |value| %>
Scenario: change user privileges, invalid body: cmd is a '<%= value %>'
When I send PUT '/v2.0/user/<%= username %>' query with JSON body
2014-07-16 13:32:59 +04:00
"""
<%= @formatter.json('user/privileges_update', {spaces: 4, value: {"cmd" => value, "privileges" => "r"}}) %>
2014-07-16 13:32:59 +04:00
"""
Then response should be '400'
Scenario: change user privileges, invalid body: privileges is a '<%= value %>'
When I send PUT '/v2.0/user/<%= username %>' query with JSON body
2014-07-16 13:32:59 +04:00
"""
<%= @formatter.json('user/privileges_update', {spaces: 4, value: {"cmd" => "foo", "privileges" => value}}) %>
2014-07-16 13:32:59 +04:00
"""
Then response should be '400'
<% end %>
Scenario: change user privileges: foo - r
When I send PUT '/v2.0/user/<%= username %>' query with JSON body
2014-07-16 13:32:59 +04:00
"""
<%= @formatter.json('user/privileges_update', {spaces: 4, value: {"cmd" => "foo", "privileges" => "r"}}) %>
2014-07-16 13:32:59 +04:00
"""
Then response should be '400'
<% %w{foo, rr, rwwww, rwxxx, rwf}.each do |priv| %>
Scenario: change user privileges: all - <%= priv %>
When I send PUT '/v2.0/user/<%= @config["user"]["name"] %>' query with JSON body
"""
<%= @formatter.json('user/privileges_update', {spaces: 4, value: {"cmd" => "all", "privileges" => priv}}) %>
2014-07-16 13:32:59 +04:00
"""
Then response should be '400'
<% end %>
<% privs = @formatter.get_fixture('user/privileges_values') %>
<% (@formatter.get_fixture('user/privileges').keys.map(&:to_s) << "all").each do |cmd| %>
2014-07-16 13:32:59 +04:00
<% privs.each do |priv| %>
Scenario: change user privileges: <%= cmd %> - <%= priv %>
When I send PUT '/v2.0/user/<%= username %>' query with JSON body
2014-07-16 13:32:59 +04:00
"""
<%= @formatter.json('user/privileges_update', {spaces: 4, value: {"cmd" => cmd, "privileges" => priv}}) %>
2014-07-16 13:32:59 +04:00
"""
Then response should be '200'
<% end %>
Scenario: change user privileges: <%= cmd %> - without privileges
When I send PUT '/v2.0/user/<%= username %>' query with JSON body
2014-07-16 13:32:59 +04:00
"""
<%= @formatter.json('user/privileges_update', {spaces: 4, value: {"cmd" => cmd}, without_field: "privileges"}) %>
2014-07-16 13:32:59 +04:00
"""
Then response should be '200'
Scenario: change user privileges: <%= cmd %> - ' '
When I send PUT '/v2.0/user/<%= username %>' query with JSON body
2014-07-16 13:32:59 +04:00
"""
<%= @formatter.json('user/privileges_update', {spaces: 4, value: {"cmd" => cmd, "privileges" => " "}}) %>
2014-07-16 13:32:59 +04:00
"""
Then response should be '400'
<% end %>
Scenario: change user privileges: set default privileges
When I send PUT '/v2.0/user/<%= username %>' query with JSON body
2014-07-16 13:32:59 +04:00
"""
{
}
"""
Then response should be '200'