Sha256: 3e6c1352e4333cc0fb4690a9d71799ed86172c22adb3deaca2946f58bf74c236
Contents?: true
Size: 1.72 KB
Versions: 16
Compression:
Stored size: 1.72 KB
Contents
# frozen_string_literal: true require 'test_plugin_helper' # Tests for the behavior of Ansible Role, currently only validations class AnsibleProviderTest < ActiveSupport::TestCase describe '.proxy_command_options' do let(:template_invocation) { FactoryBot.create(:template_invocation) } let(:dummyhost) { FactoryBot.create(:host) } it 'adds an ansible inventory' do assert command_options['ansible_inventory'] end context 'when it is not using the ansible_run_host feature' do it 'sets enables :remote_execution_command to true' do assert command_options[:remote_execution_command] end end context 'when it is using the ansible_run_host feature' do let(:rex_feature) do RemoteExecutionFeature.where(:label => 'ansible_run_host').first end it 'has remote_execution_command false' do template_invocation.template.remote_execution_features << rex_feature assert_not command_options[:remote_execution_command] end end context 'when using secrets' do let(:host) { FactoryBot.build(:host) } it 'generates secrets properly' do params = { 'remote_execution_ssh_password' => 'password', 'remote_execution_sudo_password' => 'letmein' } host.expects(:params).twice.returns(params) secrets = ForemanAnsible::AnsibleProvider.secrets(host) host_secrets = secrets['per-host'][host.name] assert_equal host_secrets['ansible_ssh_pass'], 'password' assert_equal host_secrets['ansible_sudo_pass'], 'letmein' end end def command_options ForemanAnsible::AnsibleProvider. proxy_command_options(template_invocation, dummyhost) end end end
Version data entries
16 entries across 16 versions & 1 rubygems