Sha256: 96615daeec325f5031ff794915428f08809b299821023f7babb68eb6d3715408

Contents?: true

Size: 1.81 KB

Versions: 15

Compression:

Stored size: 1.81 KB

Contents

require 'net/ssh'
require 'hybrid_platforms_conductor/test_by_service'

module HybridPlatformsConductor

  module HpcPlugins

    module Test

      # Test that deploy removes root access
      class DeployRemovesRootAccess < TestByService

        # Check my_test_plugin.rb.sample documentation for signature details.
        def test_for_node
          return if @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
              nil
            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
                nil
              end
              assert_equal ssh_ok, false, 'Root can still connect on the image after deployment'
            end
          end
        end

      end

    end

  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
hybrid_platforms_conductor-33.5.1 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-33.5.0 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-33.4.0 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-33.3.0 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-33.2.4 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-33.2.3 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-33.2.2 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-33.2.1 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-33.2.0 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-33.1.1 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-33.1.0 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-33.0.4 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-33.0.3 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-33.0.2 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-33.0.1 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb