File: test_pageant.rb

package info (click to toggle)
ruby-net-ssh 1%3A7.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,804 kB
  • sloc: ruby: 16,999; makefile: 5
file content (43 lines) | stat: -rw-r--r-- 1,034 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
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
require_relative '../common'
require 'net/ssh/authentication/agent'

module Authentication
  unless RUBY_PLATFORM == "java"

    class TestPageapnt < NetSSHTest
      def with_pagent
        pageant_path = 'C:\ProgramData\chocolatey\lib\putty.portable\tools\pageant.exe'
        raise "No pageant found at:#{pageant_path}" unless File.executable?(pageant_path)

        pageant_pid = Process.spawn(pageant_path)
        sleep 4
        yield
      ensure
        Process.kill(9, pageant_pid)
      end

      def test_agent_should_be_able_to_negotiate_with_pagent
        with_pagent do
          agent.negotiate!
        end
      end

      def test_agent_should_raise_without_pagent
        assert_raises Net::SSH::Authentication::AgentNotAvailable do
          agent.negotiate!
        end
      end

      private

      def agent(auto = :connect)
        @agent ||= begin
          agent = Net::SSH::Authentication::Agent.new
          agent.connect! if auto == :connect
          agent
        end
      end
    end

  end
end