Sha256: 3c6c49f96d848ed65f2e63729ec322a7b8d9a75e51a1017ef154f5da2135515b

Contents?: true

Size: 1.87 KB

Versions: 31

Compression:

Stored size: 1.87 KB

Contents

describe HybridPlatformsConductor::NodesHandler do

  context 'when checking config DSL' do

    it 'adds helpers for master cmdbs' do
      with_test_platform(
        {
          nodes: {
            'node1' => {},
            'node2' => {},
            'node3' => {}
          }
        },
        additional_config: <<~'EO_CONFIG'
          master_cmdbs(
            test_cmdb: :property_1,
            test_cmdb_2: :property_2
          )
          for_nodes('node2') do
            master_cmdbs(test_cmdb: :property_3)
          end
        EO_CONFIG
      ) do
        register_test_cmdb(%i[test_cmdb test_cmdb_2])
        expect(test_config.cmdb_masters).to eq [
          {
            nodes_selectors_stack: [],
            cmdb_masters: {
              test_cmdb: [:property_1],
              test_cmdb_2: [:property_2]
            }
          },
          {
            nodes_selectors_stack: ['node2'],
            cmdb_masters: {
              test_cmdb: [:property_3]
            }
          }
        ]
      end
    end

    it 'adds helpers for configurable sudo' do
      with_test_platform(
        {
          nodes: {
            'node1' => {},
            'node2' => {},
            'node3' => {}
          }
        },
        additional_config: <<~'EO_CONFIG'
          sudo_for { |user| "alt_sudo1 -p #{user}" }
          for_nodes('node2') do
            sudo_for { |user| "alt_sudo2 -q #{user}" }
          end
        EO_CONFIG
      ) do
        expect(test_config.sudo_procs.size).to eq 2
        expect(test_config.sudo_procs[0][:nodes_selectors_stack]).to eq []
        expect(test_config.sudo_procs[0][:sudo_proc].call('test_user')).to eq 'alt_sudo1 -p test_user'
        expect(test_config.sudo_procs[1][:nodes_selectors_stack]).to eq ['node2']
        expect(test_config.sudo_procs[1][:sudo_proc].call('test_user')).to eq 'alt_sudo2 -q test_user'
      end
    end

  end

end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
hybrid_platforms_conductor-33.9.5 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-33.9.4 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-33.9.2 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-33.9.1 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-33.9.0 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-33.8.4 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-33.8.3 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-33.8.2 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-33.8.1 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-33.8.0 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-33.7.4 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-33.7.3 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-33.7.2 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-33.7.1 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-33.7.0 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-33.6.0 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-33.5.1 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-33.5.0 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-33.4.0 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-33.3.0 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb