aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/leap_cli/leapfile.rb8
-rw-r--r--test/leap_platform/platform.rb77
-rw-r--r--test/leap_platform/provider_base/common.json3
-rw-r--r--test/test_helper.rb11
-rw-r--r--test/unit/command_line_test.rb4
5 files changed, 91 insertions, 12 deletions
diff --git a/lib/leap_cli/leapfile.rb b/lib/leap_cli/leapfile.rb
index e37cd4e..f517620 100644
--- a/lib/leap_cli/leapfile.rb
+++ b/lib/leap_cli/leapfile.rb
@@ -23,8 +23,8 @@ module LeapCli
@vagrant_network = '10.5.5.0/24'
end
- def load
- directory = File.expand_path(find_in_directory_tree('Leapfile'))
+ def load(search_directory=nil)
+ directory = File.expand_path(find_in_directory_tree('Leapfile', search_directory))
if directory == '/'
return nil
else
@@ -66,8 +66,8 @@ module LeapCli
end
end
- def find_in_directory_tree(filename)
- search_dir = Dir.pwd
+ def find_in_directory_tree(filename, directory_tree=nil)
+ search_dir = directory_tree || Dir.pwd
while search_dir != "/"
Dir.foreach(search_dir) do |f|
return search_dir if f == filename
diff --git a/test/leap_platform/platform.rb b/test/leap_platform/platform.rb
new file mode 100644
index 0000000..19563ae
--- /dev/null
+++ b/test/leap_platform/platform.rb
@@ -0,0 +1,77 @@
+#
+# These are variables defined by this leap_platform and used by leap_cli.
+#
+
+Leap::Platform.define do
+ self.version = "1.1.0"
+ self.compatible_cli = "1.1".."1.99"
+
+ #
+ # the facter facts that should be gathered
+ #
+ self.facts = ["ec2_local_ipv4"]
+
+ #
+ # the named paths for this platform
+ #
+ self.paths = {
+ # directories
+ :hiera_dir => 'hiera',
+ :files_dir => 'files',
+ :nodes_dir => 'nodes',
+ :services_dir => 'services',
+ :tags_dir => 'tags',
+ :node_files_dir => 'files/nodes/#{arg}',
+
+ # input config files
+ :common_config => 'common.json',
+ :provider_config => 'provider.json',
+ :secrets_config => 'secrets.json',
+ :node_config => 'nodes/#{arg}.json',
+ :service_config => 'services/#{arg}.json',
+ :tag_config => 'tags/#{arg}.json',
+
+ # input templates
+ :provider_json_template => 'files/service-definitions/provider.json.erb',
+ :eip_service_json_template => 'files/service-definitions/#{arg}/eip-service.json.erb',
+ :soledad_service_json_template => 'files/service-definitions/#{arg}/soledad-service.json.erb',
+ :smtp_service_json_template => 'files/service-definitions/#{arg}/smtp-service.json.erb',
+
+ # output files
+ :facts => 'facts.json',
+ :user_ssh => 'users/#{arg}/#{arg}_ssh.pub',
+ :user_pgp => 'users/#{arg}/#{arg}_pgp.pub',
+ :known_hosts => 'files/ssh/known_hosts',
+ :authorized_keys => 'files/ssh/authorized_keys',
+ :ca_key => 'files/ca/ca.key',
+ :ca_cert => 'files/ca/ca.crt',
+ :client_ca_key => 'files/ca/client_ca.key',
+ :client_ca_cert => 'files/ca/client_ca.crt',
+ :dh_params => 'files/ca/dh.pem',
+ :commercial_key => 'files/cert/#{arg}.key',
+ :commercial_csr => 'files/cert/#{arg}.csr',
+ :commercial_cert => 'files/cert/#{arg}.crt',
+ :commercial_ca_cert => 'files/cert/commercial_ca.crt',
+ :vagrantfile => 'test/Vagrantfile',
+
+ # node output files
+ :hiera => 'hiera/#{arg}.yaml',
+ :node_ssh_pub_key => 'files/nodes/#{arg}/#{arg}_ssh.pub',
+ :node_x509_key => 'files/nodes/#{arg}/#{arg}.key',
+ :node_x509_cert => 'files/nodes/#{arg}/#{arg}.crt',
+
+ # testing files
+ :test_client_key => 'test/cert/client.key',
+ :test_client_cert => 'test/cert/client.crt',
+ :test_openvpn_config => 'test/openvpn/#{arg}.ovpn',
+ :test_client_openvpn_template => 'test/openvpn/client.ovpn.erb'
+ }
+
+ #
+ # the files that need to get renamed when a node is renamed
+ #
+ self.node_files = [
+ :node_config, :hiera, :node_x509_cert, :node_x509_key, :node_ssh_pub_key
+ ]
+end
+
diff --git a/test/leap_platform/provider_base/common.json b/test/leap_platform/provider_base/common.json
index 653b9a0..d7b3f87 100644
--- a/test/leap_platform/provider_base/common.json
+++ b/test/leap_platform/provider_base/common.json
@@ -26,5 +26,6 @@
"ca_cert": "= try_file :ca_cert"
},
"service_type": "internal_service",
- "name": "common"
+ "name": "common",
+ "enabled": true
}
diff --git a/test/test_helper.rb b/test/test_helper.rb
index a031caa..c813ead 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -9,8 +9,9 @@ class MiniTest::Unit::TestCase
# Add global extensions to the test case class here
def setup
- LeapCli::Path.set_platform_path(test_platform_path)
- LeapCli::Path.set_provider_path(test_provider_path)
+ LeapCli.leapfile.load(test_provider_path)
+ LeapCli::Path.set_platform_path(LeapCli.leapfile.platform_directory_path)
+ LeapCli::Path.set_provider_path(LeapCli.leapfile.provider_directory_path)
end
def manager
@@ -33,9 +34,9 @@ class MiniTest::Unit::TestCase
`#{ruby_path} #{base_path}/bin/leap #{args.join ' '}`
end
- def test_platform_path
- "#{base_path}/test/leap_platform"
- end
+ #def test_platform_path
+ # "#{base_path}/test/leap_platform"
+ #end
def test_provider_path
"#{base_path}/test/provider"
diff --git a/test/unit/command_line_test.rb b/test/unit/command_line_test.rb
index 97a4042..3493600 100644
--- a/test/unit/command_line_test.rb
+++ b/test/unit/command_line_test.rb
@@ -3,10 +3,10 @@ require File.expand_path('../test_helper', __FILE__)
class CommandLineTest < MiniTest::Unit::TestCase
def test_help
- with_multiple_rubies do
+ #with_multiple_rubies do
output = leap_bin('help')
assert_equal 0, $?, "help should exit 0 -- #{output}"
- end
+ #end
end
end