@image @list
Feature: List images

  <% @formatter.get_fixture('providers/without_static').each do |provider| %>
  <% generate_get_path_scenarios_with_provider "Get list of images with provider #{provider}", "/v3/images?provider=#{provider}", provider do %>
    And the JSON response should be an array
    And response array should contains elements like:
    """
    <%= @formatter.json(provider + '/image') %>
    """
  <% end %>

  <% end %>

  <% generate_get_path_scenarios_with_provider "Get list of images with provider static", "/v3/images?provider=static", "static" do %>
    And the JSON response should be an array
    And response array should be empty
  <% end %>

  <% providers = @formatter.get_fixture('providers/all').map{|provider| "@#{provider}"} %>
  <%= providers.join(" ") %>
  Scenario: Get images list of unknown provider
    When I send GET '/v3/images?provider=foo' query
    Then response should be '422'

  <%= providers.join(" ") %>
  Scenario: Get images list without privileges
    When I send GET '/v3/images' query with user without privileges
    Then response should be '401'

  <%= providers.join(" ") %>
  Scenario: Get groups list of unknown provider without privileges
    When I send GET '/v3/images?provider=foo' query with user without privileges
    Then response should be '401'

  <%= providers.join(" ") %>
  Scenario: Get list of all images - invalid path
    When I send GET '/v3/images/foo' query
    Then response should be '404'

  <%= providers.join(" ") %>
  Scenario: Get list of images of unknown provider
    When I send GET '/v3/images/provider/foo' query
    Then response should be '404'

  <%= providers.join(" ") %>
  Scenario: Get unknown image
    When I send GET '/v3/image/foo' query
    Then response should be '404'

  <%= providers.join(" ") %>
  Scenario: Get unknown image without privileges
    When I send GET '/v3/image/foo' query with user without privileges
    Then response should be '401'

  <%= providers.join(" ") %>
  Scenario: Get image path
    When I send GET '/v3/image' query
    Then response should be '404'
