Skip to content

Commit

Permalink
Fix protocol selection when adding a new nuage provider
Browse files Browse the repository at this point in the history
  • Loading branch information
gasper-vrhovsek committed Dec 7, 2017
1 parent 377e47f commit ac9f881
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 @@ -17,7 +17,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
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 ac9f881

Please sign in to comment.