diff options
author | elijah <elijah@riseup.net> | 2013-03-17 13:34:30 -0700 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2013-03-17 13:34:30 -0700 |
commit | 24ca5c6bc02ff03168d72cf3fcd2b757ab4f741c (patch) | |
tree | 80281376243fd32c29d641d5aedfd6b848a65893 /lib/leap_cli/commands/test.rb | |
parent | 35229e4c4eecbe3a79e66dd8cf81d4103921cb7b (diff) |
updated `leap test init` to work with openvpn service levels.
Diffstat (limited to 'lib/leap_cli/commands/test.rb')
-rw-r--r-- | lib/leap_cli/commands/test.rb | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/leap_cli/commands/test.rb b/lib/leap_cli/commands/test.rb index 1da4f6d..3f0feb0 100644 --- a/lib/leap_cli/commands/test.rb +++ b/lib/leap_cli/commands/test.rb @@ -5,8 +5,7 @@ module LeapCli; module Commands test.desc 'Creates files needed to run tests.' test.command :init do |init| init.action do |global_options,options,args| - generate_test_client_cert - generate_test_client_openvpn_config + generate_test_client_openvpn_configs end end @@ -22,14 +21,25 @@ module LeapCli; module Commands private - def generate_test_client_openvpn_config + # + # generates a whole bunch of openvpn configs that can be used to connect to different openvpn gateways + # + def generate_test_client_openvpn_configs + assert_config! 'provider.ca.client_certificates.unlimited_prefix' + assert_config! 'provider.ca.client_certificates.limited_prefix' template = read_file! Path.find_file(:test_client_openvpn_template) - ['production', 'testing', 'local', 'development'].each do |env| - vpn_nodes = manager.nodes[:environment => env][:services => 'openvpn'] + vpn_nodes = manager.nodes[:environment => env][:services => 'openvpn']['openvpn.allow_limited' => true] + if vpn_nodes.any? + generate_test_client_cert(provider.ca.client_certificates.limited_prefix) do |key, cert| + write_file! [:test_openvpn_config, env+'_limited'], Util.erb_eval(template, binding) + end + end + vpn_nodes = manager.nodes[:environment => env][:services => 'openvpn']['openvpn.allow_unlimited' => true] if vpn_nodes.any? - config = Util.erb_eval(template, binding) - write_file! [:test_openvpn_config, env], config + generate_test_client_cert(provider.ca.client_certificates.unlimited_prefix) do |key, cert| + write_file! [:test_openvpn_config, env+'_unlimited'], Util.erb_eval(template, binding) + end end end end |