simp-cli 1.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/LICENSE +27 -0
- data/README.md +48 -0
- data/Rakefile +142 -0
- data/bin/simp +5 -0
- data/lib/simp/cli.rb +88 -0
- data/lib/simp/cli/commands/bootstrap.rb +275 -0
- data/lib/simp/cli/commands/check.rb +163 -0
- data/lib/simp/cli/commands/cleancerts.rb +114 -0
- data/lib/simp/cli/commands/config.rb +235 -0
- data/lib/simp/cli/commands/doc.rb +14 -0
- data/lib/simp/cli/commands/passgen.rb +128 -0
- data/lib/simp/cli/commands/puppeteval.rb +82 -0
- data/lib/simp/cli/commands/runpuppet.rb +95 -0
- data/lib/simp/cli/config/item.rb +456 -0
- data/lib/simp/cli/config/item/add_ldap_to_hiera.rb +43 -0
- data/lib/simp/cli/config/item/answers_yaml_file_writer.rb +58 -0
- data/lib/simp/cli/config/item/certificates.rb +39 -0
- data/lib/simp/cli/config/item/client_nets.rb +65 -0
- data/lib/simp/cli/config/item/common_runlevel_default.rb +32 -0
- data/lib/simp/cli/config/item/dns_search.rb +48 -0
- data/lib/simp/cli/config/item/dns_servers.rb +57 -0
- data/lib/simp/cli/config/item/failover_log_servers.rb +27 -0
- data/lib/simp/cli/config/item/gateway.rb +32 -0
- data/lib/simp/cli/config/item/grub_password.rb +51 -0
- data/lib/simp/cli/config/item/hostname.rb +24 -0
- data/lib/simp/cli/config/item/hostname_conf.rb +48 -0
- data/lib/simp/cli/config/item/ipaddress.rb +46 -0
- data/lib/simp/cli/config/item/is_master_yum_server.rb +23 -0
- data/lib/simp/cli/config/item/ldap_base_dn.rb +38 -0
- data/lib/simp/cli/config/item/ldap_bind_dn.rb +34 -0
- data/lib/simp/cli/config/item/ldap_bind_hash.rb +28 -0
- data/lib/simp/cli/config/item/ldap_bind_pw.rb +24 -0
- data/lib/simp/cli/config/item/ldap_master.rb +33 -0
- data/lib/simp/cli/config/item/ldap_root_dn.rb +42 -0
- data/lib/simp/cli/config/item/ldap_root_hash.rb +35 -0
- data/lib/simp/cli/config/item/ldap_sync_dn.rb +24 -0
- data/lib/simp/cli/config/item/ldap_sync_hash.rb +28 -0
- data/lib/simp/cli/config/item/ldap_sync_pw.rb +26 -0
- data/lib/simp/cli/config/item/ldap_uri.rb +43 -0
- data/lib/simp/cli/config/item/log_servers.rb +27 -0
- data/lib/simp/cli/config/item/netmask.rb +39 -0
- data/lib/simp/cli/config/item/network_conf.rb +63 -0
- data/lib/simp/cli/config/item/network_dhcp.rb +27 -0
- data/lib/simp/cli/config/item/network_interface.rb +41 -0
- data/lib/simp/cli/config/item/network_setup_nic.rb +28 -0
- data/lib/simp/cli/config/item/ntp_servers.rb +69 -0
- data/lib/simp/cli/config/item/puppet_autosign.rb +66 -0
- data/lib/simp/cli/config/item/puppet_ca.rb +31 -0
- data/lib/simp/cli/config/item/puppet_ca_port.rb +28 -0
- data/lib/simp/cli/config/item/puppet_conf.rb +98 -0
- data/lib/simp/cli/config/item/puppet_fileserver.rb +104 -0
- data/lib/simp/cli/config/item/puppet_hosts_entry.rb +44 -0
- data/lib/simp/cli/config/item/puppet_server.rb +30 -0
- data/lib/simp/cli/config/item/puppet_server_ip.rb +25 -0
- data/lib/simp/cli/config/item/puppetdb_port.rb +25 -0
- data/lib/simp/cli/config/item/puppetdb_server.rb +26 -0
- data/lib/simp/cli/config/item/remove_ldap_from_hiera.rb +47 -0
- data/lib/simp/cli/config/item/rename_fqdn_yaml.rb +40 -0
- data/lib/simp/cli/config/item/rsync_base.rb +37 -0
- data/lib/simp/cli/config/item/rsync_server.rb +44 -0
- data/lib/simp/cli/config/item/rsync_timeout.rb +26 -0
- data/lib/simp/cli/config/item/set_grub_password.rb +19 -0
- data/lib/simp/cli/config/item/simp_yum_servers.rb +30 -0
- data/lib/simp/cli/config/item/use_auditd.rb +19 -0
- data/lib/simp/cli/config/item/use_fips.rb +46 -0
- data/lib/simp/cli/config/item/use_iptables.rb +22 -0
- data/lib/simp/cli/config/item/use_ldap.rb +19 -0
- data/lib/simp/cli/config/item/use_selinux.rb +32 -0
- data/lib/simp/cli/config/item/yum_repositories.rb +75 -0
- data/lib/simp/cli/config/item_list_factory.rb +236 -0
- data/lib/simp/cli/config/questionnaire.rb +86 -0
- data/lib/simp/cli/config/utils.rb +128 -0
- data/lib/simp/cli/lib/utils.rb +114 -0
- data/lib/simp/simp.rb +77 -0
- data/spec/lib/simp/cli/commands/config_spec.rb +42 -0
- data/spec/lib/simp/cli/config/item/add_ldap_to_hiera_spec.rb +58 -0
- data/spec/lib/simp/cli/config/item/answers_yaml_file_writer_spec.rb +86 -0
- data/spec/lib/simp/cli/config/item/certificates_spec.rb +50 -0
- data/spec/lib/simp/cli/config/item/client_nets_spec.rb +66 -0
- data/spec/lib/simp/cli/config/item/common_runlevel_default_spec.rb +27 -0
- data/spec/lib/simp/cli/config/item/dns_search_spec.rb +74 -0
- data/spec/lib/simp/cli/config/item/dns_servers_spec.rb +76 -0
- data/spec/lib/simp/cli/config/item/failover_log_servers_spec.rb +49 -0
- data/spec/lib/simp/cli/config/item/files/FakeCA/cacertkey +1 -0
- data/spec/lib/simp/cli/config/item/files/FakeCA/gencerts_nopass.sh +10 -0
- data/spec/lib/simp/cli/config/item/files/autosign.conf.new +11 -0
- data/spec/lib/simp/cli/config/item/files/autosign.conf.used +15 -0
- data/spec/lib/simp/cli/config/item/files/fileserver.conf +41 -0
- data/spec/lib/simp/cli/config/item/files/hosts +2 -0
- data/spec/lib/simp/cli/config/item/files/hosts.old_puppet_entry +3 -0
- data/spec/lib/simp/cli/config/item/files/puppet.conf +25 -0
- data/spec/lib/simp/cli/config/item/files/puppet.your.domain.yaml +21 -0
- data/spec/lib/simp/cli/config/item/files/resolv.conf__multiple +10 -0
- data/spec/lib/simp/cli/config/item/files/resolv.conf__single +4 -0
- data/spec/lib/simp/cli/config/item/files/rsyncd.conf +225 -0
- data/spec/lib/simp/cli/config/item/gateway_spec.rb +23 -0
- data/spec/lib/simp/cli/config/item/grub_password_spec.rb +24 -0
- data/spec/lib/simp/cli/config/item/hostname_conf_spec.rb +27 -0
- data/spec/lib/simp/cli/config/item/hostname_spec.rb +22 -0
- data/spec/lib/simp/cli/config/item/ipaddress_spec.rb +40 -0
- data/spec/lib/simp/cli/config/item/is_master_yum_server_spec.rb +29 -0
- data/spec/lib/simp/cli/config/item/ldap_base_dn_spec.rb +23 -0
- data/spec/lib/simp/cli/config/item/ldap_bind_dn_spec.rb +23 -0
- data/spec/lib/simp/cli/config/item/ldap_bind_hash_spec.rb +23 -0
- data/spec/lib/simp/cli/config/item/ldap_bind_pw_spec.rb +21 -0
- data/spec/lib/simp/cli/config/item/ldap_master_spec.rb +37 -0
- data/spec/lib/simp/cli/config/item/ldap_root_dn_spec.rb +23 -0
- data/spec/lib/simp/cli/config/item/ldap_root_hash_spec.rb +23 -0
- data/spec/lib/simp/cli/config/item/ldap_sync_dn_spec.rb +22 -0
- data/spec/lib/simp/cli/config/item/ldap_sync_hash_spec.rb +23 -0
- data/spec/lib/simp/cli/config/item/ldap_sync_pw_spec.rb +21 -0
- data/spec/lib/simp/cli/config/item/ldap_uri_spec.rb +32 -0
- data/spec/lib/simp/cli/config/item/log_servers_spec.rb +49 -0
- data/spec/lib/simp/cli/config/item/netmask_spec.rb +28 -0
- data/spec/lib/simp/cli/config/item/network_conf_spec.rb +63 -0
- data/spec/lib/simp/cli/config/item/network_dhcp_spec.rb +11 -0
- data/spec/lib/simp/cli/config/item/network_interface_spec.rb +26 -0
- data/spec/lib/simp/cli/config/item/network_setup_nic_spec.rb +29 -0
- data/spec/lib/simp/cli/config/item/ntp_servers_spec.rb +43 -0
- data/spec/lib/simp/cli/config/item/puppet_autosign_spec.rb +55 -0
- data/spec/lib/simp/cli/config/item/puppet_ca_port_spec.rb +23 -0
- data/spec/lib/simp/cli/config/item/puppet_ca_spec.rb +22 -0
- data/spec/lib/simp/cli/config/item/puppet_conf_spec.rb +110 -0
- data/spec/lib/simp/cli/config/item/puppet_fileserver_spec.rb +53 -0
- data/spec/lib/simp/cli/config/item/puppet_hosts_entry_spec.rb +85 -0
- data/spec/lib/simp/cli/config/item/puppet_server_ip_spec.rb +24 -0
- data/spec/lib/simp/cli/config/item/puppet_server_spec.rb +22 -0
- data/spec/lib/simp/cli/config/item/puppetdb_port_spec.rb +25 -0
- data/spec/lib/simp/cli/config/item/puppetdb_server_spec.rb +25 -0
- data/spec/lib/simp/cli/config/item/remove_ldap_from_hiera_spec.rb +58 -0
- data/spec/lib/simp/cli/config/item/rename_fqdn_yaml_spec.rb +63 -0
- data/spec/lib/simp/cli/config/item/rsync_base_spec.rb +28 -0
- data/spec/lib/simp/cli/config/item/rsync_server_spec.rb +41 -0
- data/spec/lib/simp/cli/config/item/rsync_timeout_spec.rb +21 -0
- data/spec/lib/simp/cli/config/item/set_grub_password_spec.rb +29 -0
- data/spec/lib/simp/cli/config/item/simp_yum_servers_spec.rb +41 -0
- data/spec/lib/simp/cli/config/item/spec_helper.rb +22 -0
- data/spec/lib/simp/cli/config/item/use_auditd_spec.rb +29 -0
- data/spec/lib/simp/cli/config/item/use_fips_spec.rb +29 -0
- data/spec/lib/simp/cli/config/item/use_iptables_spec.rb +29 -0
- data/spec/lib/simp/cli/config/item/use_ldap_spec.rb +29 -0
- data/spec/lib/simp/cli/config/item/use_selinux_spec.rb +24 -0
- data/spec/lib/simp/cli/config/item/yum_repositories_spec.rb +94 -0
- data/spec/lib/simp/cli/config/item_spec.rb +106 -0
- data/spec/lib/simp/cli/config/spec_helper.rb +1 -0
- data/spec/lib/simp/cli/config/utils_spec.rb +131 -0
- data/spec/lib/simp/cli/spec_helper.rb +1 -0
- data/spec/spec_helper.rb +91 -0
- metadata +391 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'simp/cli/config/item/hostname'
|
2
|
+
require 'rspec/its'
|
3
|
+
require_relative( 'spec_helper' )
|
4
|
+
|
5
|
+
describe Simp::Cli::Config::Item::Hostname do
|
6
|
+
before :each do
|
7
|
+
@ci = Simp::Cli::Config::Item::Hostname.new
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#validate' do
|
11
|
+
it 'validates fqdns' do
|
12
|
+
expect( @ci.validate 'puppet.change.me' ).to eq true
|
13
|
+
end
|
14
|
+
|
15
|
+
it "doesn't validate bad fqdns" do
|
16
|
+
expect( @ci.validate 'puppet' ).to eq false
|
17
|
+
expect( @ci.validate 'puppet-' ).to eq false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it_behaves_like 'a child of Simp::Cli::Config::Item'
|
22
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'simp/cli/config/item/ipaddress'
|
2
|
+
require 'simp/cli/config/item/network_interface'
|
3
|
+
require 'rspec/its'
|
4
|
+
require_relative( 'spec_helper' )
|
5
|
+
|
6
|
+
describe Simp::Cli::Config::Item::IPAddress do
|
7
|
+
before :each do
|
8
|
+
@ci = Simp::Cli::Config::Item::IPAddress.new
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#os_value" do
|
12
|
+
it "returns the ip address of the SIMP NIC" do
|
13
|
+
env_var = "SIMP_NIC"
|
14
|
+
if nic_value = ENV.fetch( env_var, false)
|
15
|
+
nic = Simp::Cli::Config::Item::NetworkInterface.new
|
16
|
+
nic.value = nic_value
|
17
|
+
@ci.config_items = { nic.key => nic }
|
18
|
+
expect( @ci.os_value ).to be_a_kind_of(String)
|
19
|
+
else
|
20
|
+
skip %Q{to enable this test, set env var "$#{env_var}" to a configured interface}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
describe "#validate" do
|
27
|
+
it "validates IPv4 IPs" do
|
28
|
+
expect( @ci.validate '192.168.1.1' ).to eq true
|
29
|
+
end
|
30
|
+
|
31
|
+
it "doesn't validate bad IPs" do
|
32
|
+
expect( @ci.validate 'x.x.x.x' ).to eq false
|
33
|
+
expect( @ci.validate '999.999.999.999' ).to eq false
|
34
|
+
expect( @ci.validate '192.168.1.1/24' ).to eq false
|
35
|
+
expect( @ci.validate nil ).to eq false
|
36
|
+
expect( @ci.validate false ).to eq false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
it_behaves_like "a child of Simp::Cli::Config::Item"
|
40
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'simp/cli/config/item/is_master_yum_server'
|
2
|
+
require 'rspec/its'
|
3
|
+
require_relative( 'spec_helper' )
|
4
|
+
|
5
|
+
describe Simp::Cli::Config::Item::IsMasterYumServer do
|
6
|
+
before :each do
|
7
|
+
@ci = Simp::Cli::Config::Item::IsMasterYumServer.new
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#validate" do
|
11
|
+
it "validates yes/no" do
|
12
|
+
expect( @ci.validate 'yes' ).to eq true
|
13
|
+
expect( @ci.validate 'y' ).to eq true
|
14
|
+
expect( @ci.validate 'Y' ).to eq true
|
15
|
+
expect( @ci.validate 'no' ).to eq true
|
16
|
+
expect( @ci.validate 'n' ).to eq true
|
17
|
+
expect( @ci.validate 'NO' ).to eq true
|
18
|
+
expect( @ci.validate true ).to eq true
|
19
|
+
expect( @ci.validate false ).to eq true
|
20
|
+
end
|
21
|
+
|
22
|
+
it "doesn't validate other things" do
|
23
|
+
expect( @ci.validate 'ydd' ).to eq false
|
24
|
+
expect( @ci.validate 'gsdg' ).to eq false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it_behaves_like "a child of Simp::Cli::Config::Item"
|
29
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'simp/cli/config/item/ldap_base_dn'
|
2
|
+
require 'rspec/its'
|
3
|
+
require_relative( 'spec_helper' )
|
4
|
+
|
5
|
+
describe Simp::Cli::Config::Item::LdapBaseDn do
|
6
|
+
before :each do
|
7
|
+
@ci = Simp::Cli::Config::Item::LdapBaseDn.new
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#validate" do
|
11
|
+
it "validates ldap_base_dns" do
|
12
|
+
expect( @ci.validate 'dc=tasty,dc=bacon' ).to eq true
|
13
|
+
end
|
14
|
+
|
15
|
+
it "doesn't validate bad ldap_base_dns" do
|
16
|
+
expect( @ci.validate 'cn=hostAuth,ou=Hosts,dc=tasty,dc=bacon' ).to eq false
|
17
|
+
expect( @ci.validate nil ).to eq false
|
18
|
+
expect( @ci.validate false ).to eq false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it_behaves_like "a child of Simp::Cli::Config::Item"
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'simp/cli/config/item/ldap_bind_dn'
|
2
|
+
require 'rspec/its'
|
3
|
+
require_relative( 'spec_helper' )
|
4
|
+
|
5
|
+
describe Simp::Cli::Config::Item::LdapBindDn do
|
6
|
+
before :each do
|
7
|
+
@ci = Simp::Cli::Config::Item::LdapBindDn.new
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#validate" do
|
11
|
+
it "validates ldap_bind_dns" do
|
12
|
+
expect( @ci.validate 'cn=hostAuth,ou=Hosts,dc=tasty,dc=bacon' ).to eq true
|
13
|
+
end
|
14
|
+
|
15
|
+
it "doesn't validate bad ldap_bind_dns" do
|
16
|
+
expect( @ci.validate 'dc=tasty,dc=bacon' ).to eq false
|
17
|
+
expect( @ci.validate nil ).to eq false
|
18
|
+
expect( @ci.validate false ).to eq false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it_behaves_like "a child of Simp::Cli::Config::Item"
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'simp/cli/config/item/ldap_bind_hash'
|
2
|
+
require 'rspec/its'
|
3
|
+
require_relative( 'spec_helper' )
|
4
|
+
|
5
|
+
describe Simp::Cli::Config::Item::LdapBindHash do
|
6
|
+
before :each do
|
7
|
+
@ci = Simp::Cli::Config::Item::LdapBindHash.new
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#encrypt" do
|
11
|
+
it "encrypts a known password and salt to the correct SHA-1 password" do
|
12
|
+
expect( @ci.encrypt( 'foo', "\xef\xb2\x2e\xac" ) ).to eq '{SSHA}zxOLQEdncCJTMObl5s+y1N/Ydh3vsi6s'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#validate" do
|
17
|
+
it "validates OpenLDAP-format SHA-1 algorithm (FIPS 160-1) password hash" do
|
18
|
+
expect( @ci.validate '{SSHA}Y6x92VpatHf9G6yMiktUYTrA/3SxUFm' ).to eq true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it_behaves_like "a child of Simp::Cli::Config::Item"
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'simp/cli/config/item/ldap_bind_pw'
|
2
|
+
require_relative( 'spec_helper' )
|
3
|
+
|
4
|
+
describe Simp::Cli::Config::Item::LdapBindPw do
|
5
|
+
before :each do
|
6
|
+
@ci = Simp::Cli::Config::Item::LdapBindPw.new
|
7
|
+
@ci.silent = true
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#validate" do
|
11
|
+
it "validates common_runlevel_defaults" do
|
12
|
+
expect( @ci.validate 'a!S@d3F$g5H^j&k' ).to eq true
|
13
|
+
end
|
14
|
+
|
15
|
+
it "doesn't validate empty passwords" do
|
16
|
+
expect( @ci.validate '' ).to eq false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it_behaves_like "a child of Simp::Cli::Config::Item"
|
21
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'simp/cli/config/item/ldap_master'
|
2
|
+
require 'rspec/its'
|
3
|
+
require_relative( 'spec_helper' )
|
4
|
+
|
5
|
+
describe Simp::Cli::Config::Item::LdapMaster do
|
6
|
+
before :each do
|
7
|
+
@ci = Simp::Cli::Config::Item::LdapMaster.new
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#validate" do
|
11
|
+
it "validates good ldap uri" do
|
12
|
+
expect( @ci.validate 'ldap://master' ).to eq true
|
13
|
+
expect( @ci.validate 'ldap://master-server' ).to eq true
|
14
|
+
expect( @ci.validate 'ldap://master.ldap.org' ).to eq true
|
15
|
+
expect( @ci.validate 'ldap://master.ldap.org' ).to eq true
|
16
|
+
expect( @ci.validate 'ldap://192.168.1.1' ).to eq true
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
it "doesn't validate bad ldap uri" do
|
21
|
+
expect( @ci.validate nil ).to eq false
|
22
|
+
expect( @ci.validate '' ).to eq false
|
23
|
+
expect( @ci.validate ' ' ).to eq false
|
24
|
+
expect( @ci.validate false ).to eq false
|
25
|
+
expect( @ci.validate [nil] ).to eq false
|
26
|
+
expect( @ci.validate 'master' ).to eq false
|
27
|
+
expect( @ci.validate 'ldap://master-' ).to eq false
|
28
|
+
expect( @ci.validate 'ldap://-master' ).to eq false
|
29
|
+
expect( @ci.validate 'ldap://master.loggitylog.org.' ).to eq false
|
30
|
+
expect( @ci.validate 'ldap://.master.loggitylog.org' ).to eq false
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it_behaves_like "a child of Simp::Cli::Config::Item"
|
36
|
+
end
|
37
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'simp/cli/config/item/ldap_root_dn'
|
2
|
+
require 'rspec/its'
|
3
|
+
require_relative( 'spec_helper' )
|
4
|
+
|
5
|
+
describe Simp::Cli::Config::Item::LdapRootDn do
|
6
|
+
before :each do
|
7
|
+
@ci = Simp::Cli::Config::Item::LdapRootDn.new
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#validate" do
|
11
|
+
it "validates ldap_root_dns" do
|
12
|
+
expect( @ci.validate 'cn=hostAuth,ou=Hosts,dc=tasty,dc=bacon' ).to eq true
|
13
|
+
end
|
14
|
+
|
15
|
+
it "doesn't validate bad ldap_root_dns" do
|
16
|
+
expect( @ci.validate 'dc=tasty,dc=bacon' ).to eq false
|
17
|
+
expect( @ci.validate nil ).to eq false
|
18
|
+
expect( @ci.validate false ).to eq false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it_behaves_like "a child of Simp::Cli::Config::Item"
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'simp/cli/config/item/ldap_root_hash'
|
2
|
+
require 'rspec/its'
|
3
|
+
require_relative( 'spec_helper' )
|
4
|
+
|
5
|
+
describe Simp::Cli::Config::Item::LdapRootHash do
|
6
|
+
before :each do
|
7
|
+
@ci = Simp::Cli::Config::Item::LdapRootHash.new
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#encrypt" do
|
11
|
+
it "encrypts a known password and salt to the correct SHA-1 password" do
|
12
|
+
expect( @ci.encrypt( 'foo', "\xef\xb2\x2e\xac" ) ).to eq '{SSHA}zxOLQEdncCJTMObl5s+y1N/Ydh3vsi6s'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#validate" do
|
17
|
+
it "validates OpenLDAP-format SHA-1 algorithm (FIPS 160-1) password hash" do
|
18
|
+
expect( @ci.validate '{SSHA}Y6x92VpatHf9G6yMiktUYTrA/3SxUFm' ).to eq true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it_behaves_like "a child of Simp::Cli::Config::Item"
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'simp/cli/config/item/ldap_sync_dn'
|
2
|
+
require 'rspec/its'
|
3
|
+
require_relative( 'spec_helper' )
|
4
|
+
|
5
|
+
describe Simp::Cli::Config::Item::LdapSyncDn do
|
6
|
+
before :each do
|
7
|
+
@ci = Simp::Cli::Config::Item::LdapSyncDn.new
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#validate" do
|
11
|
+
it "validates ldap_sync_dns" do
|
12
|
+
expect( @ci.validate 'cn=LDAPSync,ou=Hosts,dc=tasty,dc=bacon' ).to eq true
|
13
|
+
end
|
14
|
+
|
15
|
+
it "doesn't validate bad ldap_sync_dns" do
|
16
|
+
expect( @ci.validate nil ).to eq false
|
17
|
+
expect( @ci.validate false ).to eq false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it_behaves_like "a child of Simp::Cli::Config::Item"
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'simp/cli/config/item/ldap_sync_hash'
|
2
|
+
require 'rspec/its'
|
3
|
+
require_relative( 'spec_helper' )
|
4
|
+
|
5
|
+
describe Simp::Cli::Config::Item::LdapSyncHash do
|
6
|
+
before :each do
|
7
|
+
@ci = Simp::Cli::Config::Item::LdapSyncHash.new
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#encrypt" do
|
11
|
+
it "encrypts a known password and salt to the correct SHA-1 password hash" do
|
12
|
+
expect( @ci.encrypt( 'foo', "\xef\xb2\x2e\xac" ) ).to eq '{SSHA}zxOLQEdncCJTMObl5s+y1N/Ydh3vsi6s'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#validate" do
|
17
|
+
it "validates OpenLDAP-format SHA-1 algorithm (FIPS 160-1) password hash" do
|
18
|
+
expect( @ci.validate '{SSHA}Y6x92VpatHf9G6yMiktUYTrA/3SxUFm' ).to eq true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it_behaves_like "a child of Simp::Cli::Config::Item"
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'simp/cli/config/item/ldap_sync_pw'
|
2
|
+
require_relative( 'spec_helper' )
|
3
|
+
|
4
|
+
describe Simp::Cli::Config::Item::LdapSyncPw do
|
5
|
+
before :each do
|
6
|
+
@ci = Simp::Cli::Config::Item::LdapSyncPw.new
|
7
|
+
@ci.silent = true
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#validate" do
|
11
|
+
it "validates common_runlevel_defaults" do
|
12
|
+
expect( @ci.validate 'a!S@d3F$g5H^j&k' ).to eq true
|
13
|
+
end
|
14
|
+
|
15
|
+
it "doesn't validate empty passwords" do
|
16
|
+
expect( @ci.validate '' ).to eq false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it_behaves_like "a child of Simp::Cli::Config::Item"
|
21
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'simp/cli/config/item/ldap_uri'
|
2
|
+
require 'rspec/its'
|
3
|
+
require_relative( 'spec_helper' )
|
4
|
+
|
5
|
+
describe Simp::Cli::Config::Item::LdapUri do
|
6
|
+
before :each do
|
7
|
+
@ci = Simp::Cli::Config::Item::LdapUri.new
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#validate" do
|
11
|
+
it "validates array with good hosts" do
|
12
|
+
expect( @ci.validate ['ldap://log'] ).to eq true
|
13
|
+
expect( @ci.validate ['ldap://log-server'] ).to eq true
|
14
|
+
expect( @ci.validate ['ldap://log.loggitylog.org'] ).to eq true
|
15
|
+
expect( @ci.validate ['ldap://192.168.1.1'] ).to eq true
|
16
|
+
expect( @ci.validate ['ldap://192.168.1.1', 'ldap://log.loggitylog.org'] ).to eq true
|
17
|
+
end
|
18
|
+
|
19
|
+
it "doesn't validate array with bad hosts" do
|
20
|
+
expect( @ci.validate 0 ).to eq false
|
21
|
+
expect( @ci.validate false ).to eq false
|
22
|
+
expect( @ci.validate [nil] ).to eq false
|
23
|
+
expect( @ci.validate ['log-'] ).to eq false
|
24
|
+
expect( @ci.validate ['-log'] ).to eq false
|
25
|
+
expect( @ci.validate ['log.loggitylog.org.'] ).to eq false
|
26
|
+
expect( @ci.validate ['.log.loggitylog.org'] ).to eq false
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it_behaves_like "a child of Simp::Cli::Config::Item"
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'simp/cli/config/item/log_servers'
|
2
|
+
require 'rspec/its'
|
3
|
+
require_relative( 'spec_helper' )
|
4
|
+
|
5
|
+
describe Simp::Cli::Config::Item::LogServers do
|
6
|
+
before :each do
|
7
|
+
@ci = Simp::Cli::Config::Item::LogServers.new
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#recommended_value" do
|
11
|
+
it "recommends nil when gateway is unavailable" do
|
12
|
+
expect( @ci.recommended_value ).to be_nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#validate" do
|
17
|
+
it "validates array with good hosts" do
|
18
|
+
expect( @ci.validate ['log'] ).to eq true
|
19
|
+
expect( @ci.validate ['log-server'] ).to eq true
|
20
|
+
expect( @ci.validate ['log.loggitylog.org'] ).to eq true
|
21
|
+
expect( @ci.validate ['192.168.1.1'] ).to eq true
|
22
|
+
expect( @ci.validate ['192.168.1.1', 'log.loggitylog.org'] ).to eq true
|
23
|
+
|
24
|
+
# log_servers is optional and can be empty
|
25
|
+
expect( @ci.validate nil ).to eq true
|
26
|
+
expect( @ci.validate '' ).to eq true
|
27
|
+
expect( @ci.validate ' ' ).to eq true
|
28
|
+
end
|
29
|
+
|
30
|
+
it "doesn't validate array with bad hosts" do
|
31
|
+
expect( @ci.validate 0 ).to eq false
|
32
|
+
expect( @ci.validate false ).to eq false
|
33
|
+
expect( @ci.validate [nil] ).to eq false
|
34
|
+
expect( @ci.validate ['log-'] ).to eq false
|
35
|
+
expect( @ci.validate ['-log'] ).to eq false
|
36
|
+
expect( @ci.validate ['log.loggitylog.org.'] ).to eq false
|
37
|
+
expect( @ci.validate ['.log.loggitylog.org'] ).to eq false
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
it "accepts an empty list" do
|
42
|
+
expect( @ci.validate [] ).to eq true
|
43
|
+
expect( @ci.validate "" ).to eq true
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it_behaves_like "a child of Simp::Cli::Config::Item"
|
48
|
+
end
|
49
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'simp/cli/config/item/netmask'
|
2
|
+
require 'rspec/its'
|
3
|
+
require_relative( 'spec_helper' )
|
4
|
+
|
5
|
+
describe Simp::Cli::Config::Item::Netmask do
|
6
|
+
before :each do
|
7
|
+
@ci = Simp::Cli::Config::Item::Netmask.new
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#validate" do
|
11
|
+
it "validates netmasks" do
|
12
|
+
expect( @ci.validate '255.255.255.0' ).to eq true
|
13
|
+
expect( @ci.validate '255.254.0.0' ).to eq true
|
14
|
+
expect( @ci.validate '192.0.0.0' ).to eq true
|
15
|
+
end
|
16
|
+
|
17
|
+
it "doesn't validate bad netmasks" do
|
18
|
+
expect( @ci.validate '999.999.999.999' ).to eq false
|
19
|
+
expect( @ci.validate '255.999.0.0' ).to eq false
|
20
|
+
expect( @ci.validate '255.0.255.0' ).to eq false
|
21
|
+
expect( @ci.validate '0.255.0.0' ).to eq false
|
22
|
+
expect( @ci.validate nil ).to eq false
|
23
|
+
expect( @ci.validate false ).to eq false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it_behaves_like "a child of Simp::Cli::Config::Item"
|
28
|
+
end
|