Sha256: cbd730891c1d7badb50e7ef388c453f582477cf93e0f7b73b5509c4ad4ceff8c
Contents?: true
Size: 1.8 KB
Versions: 3
Compression:
Stored size: 1.8 KB
Contents
require 'spec_helper' describe Aptible::CLI::Helpers::Tunnel do include_context 'mock ssh' it 'forwards traffic to the remote port given by the server (1234)' do helper = described_class.new({}, ['ssh_mock.rb']) helper.start(0) helper.stop mock_argv = read_mock_argv expect(mock_argv.size).to eq(8) expect(mock_argv.shift).to eq('-L') expect(mock_argv.shift).to match(/\d+:localhost:1234$/) expect(mock_argv.shift).to eq('-o') expect(mock_argv.shift).to eq('SendEnv=TUNNEL_PORT') expect(mock_argv.shift).to eq('-o') expect(mock_argv.shift).to eq('SendEnv=TUNNEL_SIGNAL_OPEN') expect(mock_argv.shift).to eq('-o') expect(mock_argv.shift).to eq('ExitOnForwardFailure=yes') end it 'accepts a desired local port' do helper = described_class.new({}, ['ssh_mock.rb']) helper.start(5678) helper.stop mock_argv = read_mock_argv expect(mock_argv.size).to eq(8) expect(mock_argv.shift).to eq('-L') expect(mock_argv.shift).to eq('5678:localhost:1234') end it 'captures and displays port discovery errors' do helper = described_class.new({ 'FAIL_PORT' => '1' }, ['ssh_mock.rb']) expect { helper.start } .to raise_error(/Failed to request.*Something went wrong/m) end it 'captures and displays tunnel errors' do helper = described_class.new({ 'FAIL_TUNNEL' => '1' }, ['ssh_mock.rb']) expect { helper.start(0) } .to raise_error(/Tunnel did not come up.*Something went wrong/m) end it 'should fail if #port is called before #start' do socat = described_class.new({}, []) expect { socat.port }.to raise_error(/You must call #start/) end it 'should fail if #stop is called before #start' do socat = described_class.new({}, []) expect { socat.stop }.to raise_error(/You must call #start/) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
aptible-cli-0.7.4 | spec/aptible/cli/helpers/tunnel_spec.rb |
aptible-cli-0.7.3 | spec/aptible/cli/helpers/tunnel_spec.rb |
aptible-cli-0.7.2 | spec/aptible/cli/helpers/tunnel_spec.rb |