Skip to content

Commit

Permalink
spec for update_proxy_settings
Browse files Browse the repository at this point in the history
  • Loading branch information
ailisp committed Sep 23, 2017
1 parent 0594836 commit 7672e03
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions spec/lib/embedded_ansible_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
expect(nginx_service).to receive(:enable).and_return(nginx_service)
expect(supervisord_service).to receive(:enable).and_return(supervisord_service)
expect(rabbitmq_service).to receive(:enable).and_return(rabbitmq_service)
expect(described_class).to receive(:update_proxy_settings)
end

it "waits for Ansible to respond" do
Expand Down Expand Up @@ -481,5 +482,35 @@
expect(auth.password).to eq(password)
end
end

describe ".update_proxy_settings (private)" do
let(:file_content) do
<<-EOF
# Arbitrary line 1
# Arbitrary line 2
AWX_TASK_ENV['HTTP_PROXY'] = 'somehost'
AWX_TASK_ENV['HTTPS_PROXY'] = 'somehost'
AWX_TASK_ENV['NO_PROXY'] = 'somehost'
EOF
end
let(:proxy_uri) { "http://user:password@localhost:3333" }
let(:settings_file) { Tempfile.new("settings.py") }
before do
settings_file.write(file_content)
settings_file.close
stub_const("EmbeddedAnsible::SETTINGS_FILE", settings_file.path)
expect(VMDB::Util).to receive(:http_proxy_uri).and_return(proxy_uri)
end

it "add current proxy info" do
described_class.send(:update_proxy_settings)
new_contents = File.read(settings_file.path)
expect(new_contents).to include("AWX_TASK_ENV['HTTP_PROXY'] = '#{proxy_uri}'\n")
expect(new_contents).to include("AWX_TASK_ENV['HTTPS_PROXY'] = '#{proxy_uri}'\n")
expect(new_contents).to include("AWX_TASK_ENV['NO_PROXY'] = '127.0.0.1'\n")
expect(new_contents).not_to include("'somehost'")
end
end
end
end

0 comments on commit 7672e03

Please sign in to comment.