Skip to content

Commit

Permalink
Merge pull request #45 from gasper-vrhovsek/feature/fix_protocol_sele…
Browse files Browse the repository at this point in the history
…ction

Fix protocol selection when adding a new nuage provider
  • Loading branch information
juliancheal authored Dec 13, 2017
2 parents a0c7015 + ac9f881 commit 3887e05
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/manageiq/providers/nuage/manager_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def raw_connect(username, password, endpoint_opts)
end

def auth_url(protocol, server, port, version)
scheme = protocol == "ssl-with-validation" ? "https" : "http"
scheme = %w(ssl ssl-with-validation).include?(protocol) ? "https" : "http"
URI::Generic.build(:scheme => scheme, :host => server, :port => port, :path => "/nuage/api/#{version}").to_s
end

Expand Down
10 changes: 10 additions & 0 deletions spec/models/manageiq/providers/nuage/network_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
@ems.connect
end

it 'connects over secure channel without validation' do
@ems.security_protocol = 'ssl'
expect(ManageIQ::Providers::Nuage::NetworkManager::VsdClient).to receive(:new).with("https://host:8000/nuage/api/v5_0", "testuser", "secret")
@ems.connect
end

it 'connects over secure channel' do
@ems.security_protocol = 'ssl-with-validation'
expect(ManageIQ::Providers::Nuage::NetworkManager::VsdClient).to receive(:new).with("https://host:8000/nuage/api/v5_0", "testuser", "secret")
Expand Down Expand Up @@ -144,6 +150,10 @@
expect(described_class.auth_url(nil, 'hostname', 8443, 'v5')).to eq('http://hostname:8443/nuage/api/v5')
end

it 'builds insecure ssl URL' do
expect(described_class.auth_url('ssl', 'hostname', 8443, 'v5')).to eq('https://hostname:8443/nuage/api/v5')
end

it 'builds secure URL' do
expect(described_class.auth_url('ssl-with-validation', 'hostname', 8443, 'v5')).to eq('https://hostname:8443/nuage/api/v5')
end
Expand Down

0 comments on commit 3887e05

Please sign in to comment.