Sha256: eb5002fa0d1ce8b64fe7ac1dcb998beeebcd0b01e2834b144ab1005829b91f37

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

require 'acceptance/acceptance_helper'

describe "Executing the ssh-allow CLI" do
  context "GIVEN: a path-limited 'ls' config file" do
    before(:each) do
      @file = 'test.rules'
      @dir_path = File.expand_path(current_dir + '/../')
      @allow = %(
      allow!("ls") do
        opts "-ld"
        args "#{@dir_path}/.*"
      end
      ).gsub(/^ {6}/, '')
      write_file(@file, @allow)
      @cmd = "ssh-allow guard --rules=#{File.expand_path(current_dir)}/#{@file} --echo"
    end

    context "WHEN: we run 'ssh-allow guard --echo' with an allowed path" do
      before(:each) do
        @ssh = ssh_command %(ls -ld #{@dir_path}/*)
        run_simple(@cmd)
      end

      context "THEN: the output of the run" do
        it "should contain the remote command" do
          all_output.should include(@ssh)
        end

        it "should contain a listing for the 'tmp/aruba' directory" do
          all_output.should match(/tmp\/aruba$/)
        end
      end
    end

    context "WHEN: we run 'ssh-allow guard --echo' with an disallowed path" do
      before(:each) do
        @ssh = ssh_command %(ls -ld /foo/bar/*)
        run_simple(@cmd)
      end

      it "standard error indicates a bad command" do
        all_stderr.should match(/Remote Command Not Allowed: #{@ssh}/)
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ssh-allow-0.6.0 spec/acceptance/cli_spec.rb