Class: HybridPlatformsConductor::HpcPlugins::Test::DeployRemovesRootAccess
- Inherits:
-
TestByService
- Object
- Plugin
- Test
- TestByService
- HybridPlatformsConductor::HpcPlugins::Test::DeployRemovesRootAccess
- Defined in:
- lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
Overview
Test that deploy removes root access
Constant Summary
Constants included from LoggerHelpers
LoggerHelpers::LEVELS_MODIFIERS, LoggerHelpers::LEVELS_TO_STDERR
Instance Attribute Summary
Attributes inherited from Test
#errors, #expected_failure, #name, #node, #platform
Instance Method Summary collapse
-
#test_for_node ⇒ Object
Check my_test_plugin.rb.sample documentation for signature details.
Methods inherited from TestByService
Methods inherited from Test
#assert_equal, #assert_match, #error, #executed, #executed?, #initialize, only_on_nodes, only_on_platforms, #to_s
Methods inherited from Plugin
extend_config_dsl_with, #initialize, valid?
Methods included from LoggerHelpers
#err, #init_loggers, #log_component=, #log_debug?, #log_level=, #out, #section, #set_loggers_format, #stderr_device, #stderr_device=, #stderr_displayed?, #stdout_device, #stdout_device=, #stdout_displayed?, #stdouts_to_s, #with_progress_bar
Constructor Details
This class inherits a constructor from HybridPlatformsConductor::Test
Instance Method Details
#test_for_node ⇒ Object
Check my_test_plugin.rb.sample documentation for signature details.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb', line 14 def test_for_node unless @nodes_handler.get_root_access_allowed_of(@node) @deployer.with_test_provisioned_instance(@config.tests_provisioner_id, @node, environment: 'deploy_removes_root_access', reuse_instance: log_debug?) do |deployer, instance| # Check that we can connect with root ssh_ok = false begin Net::SSH.start(instance.ip, 'root', password: 'root_pwd', auth_methods: ['password'], verify_host_key: :never) do |ssh| ssh_ok = ssh.exec!('echo Works').strip == 'Works' end rescue end assert_equal ssh_ok, true, 'Root does not have access from the empty image' if ssh_ok deployer.nbr_retries_on_error = 3 deployer.deploy_on @node # As sshd is certainly being restarted, start and stop the container to reload it. deployer.restart @node # Check that we can't connect with root ssh_ok = false begin Net::SSH.start(instance.ip, 'root', password: 'root_pwd', auth_methods: ['password'], verify_host_key: :never) do |ssh| ssh_ok = ssh.exec!('echo Works').strip == 'Works' end rescue end assert_equal ssh_ok, false, 'Root can still connect on the image after deployment' end end end end |