From 37f3b8173e60b6863b9e86806ccdb18c23949946 Mon Sep 17 00:00:00 2001 From: Erez Freiberger Date: Sun, 6 Aug 2017 11:00:44 +0300 Subject: [PATCH] use OPTIONS /api/providers --- app/controllers/api/providers_controller.rb | 7 +++++++ spec/requests/providers_spec.rb | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/app/controllers/api/providers_controller.rb b/app/controllers/api/providers_controller.rb index a1067a8268..933e345281 100644 --- a/app/controllers/api/providers_controller.rb +++ b/app/controllers/api/providers_controller.rb @@ -86,6 +86,13 @@ def import_vm_resource(type, id = nil, data = {}) end end + def options + providers_options = ManageIQ::Providers::BaseManager.leaf_subclasses.inject({}) do |po, ems| + po.merge(ems.ems_type => ems.options_description) + end + render_options(:providers, {"provider_settings" => providers_options}) + end + private def format_provider_custom_attributes(attribute) diff --git a/spec/requests/providers_spec.rb b/spec/requests/providers_spec.rb index 3782e5274f..cb402d433f 100644 --- a/spec/requests/providers_spec.rb +++ b/spec/requests/providers_spec.rb @@ -1134,4 +1134,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"]["provider_settings"].keys.count).to eq( + ManageIQ::Providers::BaseManager.leaf_subclasses.count + ) + expect(response.parsed_body["data"]["provider_settings"]["kubernetes"]["proxy_settings"]["settings"]["http_proxy"]["label"]).to eq(N_('HTTP Proxy')) + end + end end