Sha256: b72e433b283e3f9669fef8213f78171e017188ec56cab768bf21e6f556d91b16

Contents?: true

Size: 1.7 KB

Versions: 20

Compression:

Stored size: 1.7 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
          @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

    end

  end

end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
hybrid_platforms_conductor-32.12.0 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-32.11.2 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-32.11.1 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-32.11.0 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-32.10.0 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-32.9.1 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-32.9.0 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-32.8.2 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-32.8.1 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-32.8.0 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-32.7.3 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-32.7.2 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-32.7.1 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-32.7.0 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-32.6.0 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-32.5.0 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-32.4.2 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-32.4.1 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-32.4.0 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb
hybrid_platforms_conductor-32.3.6 lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb