summaryrefslogtreecommitdiff
path: root/lib/leap_cli/commands/test.rb
blob: e895a5ec021391aceac0299a0b9a065709bb3c9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
module LeapCli; module Commands

  desc 'Run tests'
  command :test do |c|
    c.desc 'Creates files needed to run tests'
    c.command :init do |c|
      c.action do |global_options,options,args|
        generate_test_client_cert
        generate_test_client_openvpn_config
      end
    end

    c.desc 'Run tests'
    c.command :run do |c|
      c.action do |global_options,options,args|
        log 'not yet implemented'
      end
    end

    c.default_command :run
  end

  private

  def generate_test_client_openvpn_config
    template = read_file! Path.find_file(:test_client_openvpn_template)

    ['production', 'testing', 'local'].each do |tag|
      vpn_nodes = manager.nodes[:tags => tag][:services => 'openvpn']
      if vpn_nodes.any?
        config = Util.erb_eval(template, binding)
        write_file! ('test_openvpn_'+tag).to_sym, config
      end
    end
  end

end; end