Skip to content

Commit

Permalink
use OPTIONS /api/providers
Browse files Browse the repository at this point in the history
  • Loading branch information
Erez Freiberger committed Aug 9, 2017
1 parent 254d7d8 commit accf865
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/controllers/api/providers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ def import_vm_resource(type, id = nil, data = {})
end
end

def options
all_options = ExtManagementSystem.descendants.inject({}) do |ao, ems|
ao[ems.ems_type] = ems.respond_to?(:provider_settings) ? ems.provider_settings : {}
ao
end
all_options.delete(nil)
render_options(:providers, all_options)
end

private

def format_provider_custom_attributes(attribute)
Expand Down
10 changes: 10 additions & 0 deletions spec/requests/providers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1116,4 +1116,14 @@ def gen_import_request
end
end
end

context "OPTIONS /api/providers" do
it "returns options for all providers when no query" do
run_options(providers_url)
expect(response.parsed_body["data"].keys.count).to eq(
ExtManagementSystem.descendants.select { |ems| !ems.ems_type.blank? }.count
)
expect(response.parsed_body["data"]["kubernetes"]["proxy_settings"]["settings"]["http_proxy"]["label"]).to eq(N_('HTTP Proxy'))
end
end
end

0 comments on commit accf865

Please sign in to comment.