capistrano 2.5.3 → 2.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +15 -0
- data/Rakefile +1 -1
- data/capistrano.gemspec +5 -5
- data/lib/capistrano/cli/help.txt +13 -0
- data/lib/capistrano/cli/options.rb +1 -1
- data/lib/capistrano/configuration/actions/invocation.rb +105 -5
- data/lib/capistrano/configuration/namespaces.rb +2 -2
- data/lib/capistrano/configuration/variables.rb +2 -2
- data/lib/capistrano/recipes/deploy/scm/git.rb +1 -1
- data/lib/capistrano/recipes/deploy/strategy/remote_cache.rb +1 -1
- data/lib/capistrano/ssh.rb +25 -5
- data/lib/capistrano/version.rb +1 -1
- data/test/configuration/actions/invocation_test.rb +14 -0
- data/test/configuration/connections_test.rb +6 -5
- data/test/configuration/namespace_dsl_test.rb +6 -0
- data/test/configuration/variables_test.rb +4 -0
- data/test/ssh_test.rb +6 -4
- metadata +3 -3
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
== 2.5.4 / 4 Feb 2009
|
2
|
+
|
3
|
+
* When using rsync with the remote_cache strategy include -t switch to preserve file times [Kevin McCarthy]
|
4
|
+
|
5
|
+
* Bump Net::SSH dependency to version 2.0.10 [Jamis Buck]
|
6
|
+
|
7
|
+
* Use 'user' from .ssh/config appropriately [Jamis Buck]
|
8
|
+
|
9
|
+
* Allow respond_to?() method to accept optional second parameter (include_priv) [Matthias Marschall]
|
10
|
+
|
11
|
+
* Make sure sudo prompts are retried correctly even if "try again" and the prompt appear in the same text chunk from the server [Jamis Buck]
|
12
|
+
|
13
|
+
* Add supported environment variables to -H output [François Beausoleil]
|
14
|
+
|
15
|
+
|
1
16
|
== 2.5.3 / December 6, 2008
|
2
17
|
|
3
18
|
* Make previous_release return nil if there is no previous release [Mathias Meyer]
|
data/Rakefile
CHANGED
@@ -26,7 +26,7 @@ Echoe.new('capistrano', version) do |p|
|
|
26
26
|
p.need_zip = true
|
27
27
|
p.rdoc_pattern = /^(lib|README.rdoc|CHANGELOG.rdoc)/
|
28
28
|
|
29
|
-
p.dependencies = ["net-ssh >=2.0.
|
29
|
+
p.dependencies = ["net-ssh >=2.0.10",
|
30
30
|
"net-sftp >=2.0.0",
|
31
31
|
"net-scp >=1.0.0",
|
32
32
|
"net-ssh-gateway >=1.0.0",
|
data/capistrano.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{capistrano}
|
3
|
-
s.version = "2.5.
|
3
|
+
s.version = "2.5.4"
|
4
4
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
6
6
|
s.authors = ["Jamis Buck"]
|
7
|
-
s.date = %q{
|
7
|
+
s.date = %q{2009-02-04}
|
8
8
|
s.description = %q{Capistrano is a utility and framework for executing commands in parallel on multiple remote machines, via SSH.}
|
9
9
|
s.email = %q{jamis@jamisbuck.org}
|
10
10
|
s.executables = ["cap", "capify"]
|
@@ -24,14 +24,14 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.specification_version = 2
|
25
25
|
|
26
26
|
if current_version >= 3 then
|
27
|
-
s.add_runtime_dependency(%q<net-ssh>, [">= 2.0.
|
27
|
+
s.add_runtime_dependency(%q<net-ssh>, [">= 2.0.10"])
|
28
28
|
s.add_runtime_dependency(%q<net-sftp>, [">= 2.0.0"])
|
29
29
|
s.add_runtime_dependency(%q<net-scp>, [">= 1.0.0"])
|
30
30
|
s.add_runtime_dependency(%q<net-ssh-gateway>, [">= 1.0.0"])
|
31
31
|
s.add_runtime_dependency(%q<highline>, [">= 0"])
|
32
32
|
s.add_development_dependency(%q<echoe>, [">= 0"])
|
33
33
|
else
|
34
|
-
s.add_dependency(%q<net-ssh>, [">= 2.0.
|
34
|
+
s.add_dependency(%q<net-ssh>, [">= 2.0.10"])
|
35
35
|
s.add_dependency(%q<net-sftp>, [">= 2.0.0"])
|
36
36
|
s.add_dependency(%q<net-scp>, [">= 1.0.0"])
|
37
37
|
s.add_dependency(%q<net-ssh-gateway>, [">= 1.0.0"])
|
@@ -39,7 +39,7 @@ Gem::Specification.new do |s|
|
|
39
39
|
s.add_dependency(%q<echoe>, [">= 0"])
|
40
40
|
end
|
41
41
|
else
|
42
|
-
s.add_dependency(%q<net-ssh>, [">= 2.0.
|
42
|
+
s.add_dependency(%q<net-ssh>, [">= 2.0.10"])
|
43
43
|
s.add_dependency(%q<net-sftp>, [">= 2.0.0"])
|
44
44
|
s.add_dependency(%q<net-scp>, [">= 1.0.0"])
|
45
45
|
s.add_dependency(%q<net-ssh-gateway>, [">= 1.0.0"])
|
data/lib/capistrano/cli/help.txt
CHANGED
@@ -60,3 +60,16 @@ The following options are understood:
|
|
60
60
|
|
61
61
|
<%= color '-x, --skip-user-config', :bold %>
|
62
62
|
By default, cap will look for and (if it exists) load the user-specific configuration file located in $HOME/.caprc. If you don't want cap to load that file, give this option.
|
63
|
+
|
64
|
+
-----------------------------
|
65
|
+
<%= color('Environment Variables', :bold) %>
|
66
|
+
-----------------------------
|
67
|
+
|
68
|
+
<%= color 'HOSTS', :bold %>
|
69
|
+
Execute the tasks against this comma-separated list of hosts. Effectively, this makes the host(s) part of every roles.
|
70
|
+
|
71
|
+
<%= color 'HOSTFILTER', :bold %>
|
72
|
+
Execute tasks against this comma-separated list of host, but only if the host has the proper role for the task.
|
73
|
+
|
74
|
+
<%= color 'ROLES', :bold %>
|
75
|
+
Execute tasks against this comma-separated list of roles. Hosts which do not have the right roles will be skipped.
|
@@ -43,7 +43,7 @@ module Capistrano
|
|
43
43
|
"A recipe file to load. May be given more than once."
|
44
44
|
) { |value| options[:recipes] << value }
|
45
45
|
|
46
|
-
opts.on("-H", "--long-help", "Explain these options.") do
|
46
|
+
opts.on("-H", "--long-help", "Explain these options and environment variables.") do
|
47
47
|
long_help
|
48
48
|
exit
|
49
49
|
end
|
@@ -26,10 +26,57 @@ module Capistrano
|
|
26
26
|
set :default_run_options, {}
|
27
27
|
end
|
28
28
|
|
29
|
+
# Executes different commands in parallel. This is useful for commands
|
30
|
+
# that need to be different on different hosts, but which could be
|
31
|
+
# otherwise run in parallel.
|
32
|
+
#
|
33
|
+
# The +options+ parameter is currently unused.
|
34
|
+
#
|
35
|
+
# Example:
|
36
|
+
#
|
37
|
+
# task :restart_everything do
|
38
|
+
# parallel do |session|
|
39
|
+
# session.when "in?(:app)", "/path/to/restart/mongrel"
|
40
|
+
# session.when "in?(:web)", "/path/to/restart/apache"
|
41
|
+
# session.when "in?(:db)", "/path/to/restart/mysql"
|
42
|
+
# end
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
# Each command may have its own callback block, for capturing and
|
46
|
+
# responding to output, with semantics identical to #run:
|
47
|
+
#
|
48
|
+
# session.when "in?(:app)", "/path/to/restart/mongrel" do |ch, stream, data|
|
49
|
+
# # ch is the SSH channel for this command, used to send data
|
50
|
+
# # back to the command (e.g. ch.send_data("password\n"))
|
51
|
+
# # stream is either :out or :err, for which stream the data arrived on
|
52
|
+
# # data is a string containing data sent from the remote command
|
53
|
+
# end
|
54
|
+
#
|
55
|
+
# Also, you can specify a fallback command, to use when none of the
|
56
|
+
# conditions match a server:
|
57
|
+
#
|
58
|
+
# session.else "/execute/something/else"
|
59
|
+
#
|
60
|
+
# The string specified as the first argument to +when+ may be any valid
|
61
|
+
# Ruby code. It has access to the following variables and methods:
|
62
|
+
#
|
63
|
+
# * +in?(role)+ returns true if the server participates in the given role
|
64
|
+
# * +server+ is the ServerDefinition object for the server. This can be
|
65
|
+
# used to get the host-name, etc.
|
66
|
+
# * +configuration+ is the current Capistrano::Configuration object, which
|
67
|
+
# you can use to get the value of variables, etc.
|
68
|
+
#
|
69
|
+
# For example:
|
70
|
+
#
|
71
|
+
# session.when "server.host =~ /app/", "/some/command"
|
72
|
+
# session.when "server.host == configuration[:some_var]", "/another/command"
|
73
|
+
# session.when "in?(:web) || in?(:app)", "/more/commands"
|
74
|
+
#
|
75
|
+
# See #run for a description of the valid +options+.
|
29
76
|
def parallel(options={})
|
30
77
|
raise ArgumentError, "parallel() requires a block" unless block_given?
|
31
78
|
tree = Command::Tree.new(self) { |t| yield t }
|
32
|
-
run_tree(tree)
|
79
|
+
run_tree(tree, options)
|
33
80
|
end
|
34
81
|
|
35
82
|
# Invokes the given command. If a +via+ key is given, it will be used
|
@@ -48,13 +95,58 @@ module Capistrano
|
|
48
95
|
# channel (which may be used to send data back to the remote process),
|
49
96
|
# the stream identifier (<tt>:err</tt> for stderr, and <tt>:out</tt> for
|
50
97
|
# stdout), and the data that was received.
|
98
|
+
#
|
99
|
+
# The +options+ hash may include any of the following keys:
|
100
|
+
#
|
101
|
+
# * :hosts - this is either a string (for a single target host) or an array
|
102
|
+
# of strings, indicating which hosts the command should run on. By default,
|
103
|
+
# the hosts are determined from the task definition.
|
104
|
+
# * :roles - this is either a string or symbol (for a single target role) or
|
105
|
+
# an array of strings or symbols, indicating which roles the command should
|
106
|
+
# run on. If :hosts is specified, :roles will be ignored.
|
107
|
+
# * :only - specifies a condition limiting which hosts will be selected to
|
108
|
+
# run the command. This should refer to values set in the role definition.
|
109
|
+
# For example, if a role is defined with :primary => true, then you could
|
110
|
+
# select only hosts with :primary true by setting :only => { :primary => true }.
|
111
|
+
# * :except - specifies a condition limiting which hosts will be selected to
|
112
|
+
# run the command. This is the inverse of :only (hosts that do _not_ match
|
113
|
+
# the condition will be selected).
|
114
|
+
# * :once - if true, only the first matching server will be selected. The default
|
115
|
+
# is false (all matching servers will be selected).
|
116
|
+
# * :max_hosts - specifies the maximum number of hosts that should be selected
|
117
|
+
# at a time. If this value is less than the number of hosts that are selected
|
118
|
+
# to run, then the hosts will be run in groups of max_hosts. The default is nil,
|
119
|
+
# which indicates that there is no maximum host limit.
|
120
|
+
# * :shell - says which shell should be used to invoke commands. This
|
121
|
+
# defaults to "sh". Setting this to false causes Capistrano to invoke
|
122
|
+
# the commands directly, without wrapping them in a shell invocation.
|
123
|
+
# * :data - if not nil (the default), this should be a string that will
|
124
|
+
# be passed to the command's stdin stream.
|
125
|
+
# * :pty - if true, a pseudo-tty will be allocated for each command. The
|
126
|
+
# default is false. Note that there are benefits and drawbacks both ways.
|
127
|
+
# Empirically, it appears that if a pty is allocated, the SSH server daemon
|
128
|
+
# will _not_ read user shell start-up scripts (e.g. bashrc, etc.). However,
|
129
|
+
# if a pty is _not_ allocated, some commands will refuse to run in
|
130
|
+
# interactive mode and will not prompt for (e.g.) passwords.
|
131
|
+
# * :env - a hash of environment variable mappings that should be made
|
132
|
+
# available to the command. The keys should be environment variable names,
|
133
|
+
# and the values should be their corresponding values. The default is
|
134
|
+
# empty, but may be modified by changing the +default_environment+
|
135
|
+
# Capistrano variable.
|
136
|
+
#
|
137
|
+
# Note that if you set these keys in the +default_run_options+ Capistrano
|
138
|
+
# variable, they will apply for all invocations of #run, #invoke_command,
|
139
|
+
# and #parallel.
|
51
140
|
def run(cmd, options={}, &block)
|
52
141
|
block ||= self.class.default_io_proc
|
53
142
|
tree = Command::Tree.new(self) { |t| t.else(cmd, &block) }
|
54
143
|
run_tree(tree, options)
|
55
144
|
end
|
56
145
|
|
57
|
-
|
146
|
+
# Executes a Capistrano::Command::Tree object. This is not for direct
|
147
|
+
# use, but should instead be called indirectly, via #run or #parallel,
|
148
|
+
# or #invoke_command.
|
149
|
+
def run_tree(tree, options={}) #:nodoc:
|
58
150
|
if tree.branches.empty? && tree.fallback
|
59
151
|
logger.debug "executing #{tree.fallback}"
|
60
152
|
elsif tree.branches.any?
|
@@ -98,6 +190,12 @@ module Capistrano
|
|
98
190
|
# executable on the remote machine:
|
99
191
|
#
|
100
192
|
# set :sudo, "/opt/local/bin/sudo"
|
193
|
+
#
|
194
|
+
# If you know what you're doing, you can also set <tt>:sudo_prompt</tt>,
|
195
|
+
# which tells capistrano which prompt sudo should use when asking for
|
196
|
+
# a password. (This is so that capistrano knows what prompt to look for
|
197
|
+
# in the output.) If you set :sudo_prompt to an empty string, Capistrano
|
198
|
+
# will not send a preferred prompt.
|
101
199
|
def sudo(*parameters, &block)
|
102
200
|
options = parameters.last.is_a?(Hash) ? parameters.pop.dup : {}
|
103
201
|
command = parameters.first
|
@@ -125,14 +223,16 @@ module Capistrano
|
|
125
223
|
prompt_host = nil
|
126
224
|
|
127
225
|
Proc.new do |ch, stream, out|
|
128
|
-
if out =~
|
129
|
-
ch.send_data "#{self[:password]}\n"
|
130
|
-
elsif out =~ /^Sorry, try again/
|
226
|
+
if out =~ /^Sorry, try again/
|
131
227
|
if prompt_host.nil? || prompt_host == ch[:server]
|
132
228
|
prompt_host = ch[:server]
|
133
229
|
logger.important out, "#{stream} :: #{ch[:server]}"
|
134
230
|
reset! :password
|
135
231
|
end
|
232
|
+
end
|
233
|
+
|
234
|
+
if out =~ /^#{Regexp.escape(sudo_prompt)}/
|
235
|
+
ch.send_data "#{self[:password]}\n"
|
136
236
|
elsif fallback
|
137
237
|
fallback.call(ch, stream, out)
|
138
238
|
end
|
@@ -177,8 +177,8 @@ module Capistrano
|
|
177
177
|
raise NotImplementedError, "roles cannot be defined in a namespace"
|
178
178
|
end
|
179
179
|
|
180
|
-
def respond_to?(sym)
|
181
|
-
super || parent.respond_to?(sym)
|
180
|
+
def respond_to?(sym, include_priv=false)
|
181
|
+
super || parent.respond_to?(sym, include_priv)
|
182
182
|
end
|
183
183
|
|
184
184
|
def method_missing(sym, *args, &block)
|
@@ -111,8 +111,8 @@ module Capistrano
|
|
111
111
|
end
|
112
112
|
private :protect
|
113
113
|
|
114
|
-
def respond_to_with_variables?(sym) #:nodoc:
|
115
|
-
@variables.has_key?(sym) || respond_to_without_variables?(sym)
|
114
|
+
def respond_to_with_variables?(sym, include_priv=false) #:nodoc:
|
115
|
+
@variables.has_key?(sym) || respond_to_without_variables?(sym, include_priv)
|
116
116
|
end
|
117
117
|
|
118
118
|
def method_missing_with_variables(sym, *args, &block) #:nodoc:
|
@@ -208,7 +208,7 @@ module Capistrano
|
|
208
208
|
# Getting the actual commit id, in case we were passed a tag
|
209
209
|
# or partial sha or something - it will return the sha if you pass a sha, too
|
210
210
|
def query_revision(revision)
|
211
|
-
raise ArgumentError, "Deploying remote branches
|
211
|
+
raise ArgumentError, "Deploying remote branches is no longer supported. Specify the remote branch as a local branch for the git repository you're deploying from (ie: '#{revision.gsub('origin/', '')}' rather than '#{revision}')." if revision =~ /^origin\//
|
212
212
|
return revision if revision =~ /^[0-9a-f]{40}$/
|
213
213
|
command = scm('ls-remote', repository, revision)
|
214
214
|
result = yield(command)
|
@@ -42,7 +42,7 @@ module Capistrano
|
|
42
42
|
run "cp -RPp #{repository_cache} #{configuration[:release_path]} && #{mark}"
|
43
43
|
else
|
44
44
|
exclusions = copy_exclude.map { |e| "--exclude=\"#{e}\"" }.join(' ')
|
45
|
-
run "rsync -
|
45
|
+
run "rsync -lrpt #{exclusions} #{repository_cache}/* #{configuration[:release_path]} && #{mark}"
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
data/lib/capistrano/ssh.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
begin
|
2
2
|
require 'rubygems'
|
3
|
-
gem 'net-ssh', ">=
|
3
|
+
gem 'net-ssh', ">= 2.0.10"
|
4
4
|
rescue LoadError, NameError
|
5
5
|
end
|
6
6
|
|
@@ -55,12 +55,32 @@ module Capistrano
|
|
55
55
|
methods = [ %w(publickey hostbased), %w(password keyboard-interactive) ]
|
56
56
|
password_value = nil
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
# construct the hash of ssh options that should be passed more-or-less
|
59
|
+
# directly to Net::SSH. This will be the general ssh options, merged with
|
60
|
+
# the server-specific ssh-options.
|
61
|
+
ssh_options = (options[:ssh_options] || {}).merge(server.options[:ssh_options] || {})
|
62
|
+
|
63
|
+
# load any SSH configuration files that were specified in the SSH options. This
|
64
|
+
# will load from ~/.ssh/config and /etc/ssh_config by default (see Net::SSH
|
65
|
+
# for details). Merge the explicitly given ssh_options over the top of the info
|
66
|
+
# from the config file.
|
67
|
+
ssh_options = Net::SSH.configuration_for(server.host, ssh_options.fetch(:config, true)).merge(ssh_options)
|
68
|
+
|
69
|
+
# Once we've loaded the config, we don't need Net::SSH to do it again.
|
70
|
+
ssh_options[:config] = false
|
71
|
+
|
72
|
+
user = server.user || options[:user] || ssh_options[:username] ||
|
73
|
+
ssh_options[:user] || ServerDefinition.default_user
|
74
|
+
port = server.port || options[:port] || ssh_options[:port]
|
75
|
+
|
76
|
+
# the .ssh/config file might have changed the host-name on us
|
77
|
+
host = ssh_options.fetch(:host_name, server.host)
|
61
78
|
|
62
79
|
ssh_options[:port] = port if port
|
80
|
+
|
81
|
+
# delete these, since we've determined which username to use by this point
|
63
82
|
ssh_options.delete(:username)
|
83
|
+
ssh_options.delete(:user)
|
64
84
|
|
65
85
|
begin
|
66
86
|
connection_options = ssh_options.merge(
|
@@ -68,7 +88,7 @@ module Capistrano
|
|
68
88
|
:auth_methods => ssh_options[:auth_methods] || methods.shift
|
69
89
|
)
|
70
90
|
|
71
|
-
yield
|
91
|
+
yield host, user, connection_options
|
72
92
|
rescue Net::SSH::AuthenticationFailed
|
73
93
|
raise if methods.empty? || ssh_options[:auth_methods]
|
74
94
|
password_value = options[:password]
|
data/lib/capistrano/version.rb
CHANGED
@@ -166,6 +166,20 @@ class ConfigurationActionsInvocationTest < Test::Unit::TestCase
|
|
166
166
|
callback[ch, nil, "Sorry, try again."]
|
167
167
|
end
|
168
168
|
|
169
|
+
def test_sudo_behavior_callback_should_reset_password_and_prompt_again_if_output_includes_both_cues
|
170
|
+
ch = mock("channel")
|
171
|
+
ch.stubs(:[]).with(:host).returns("capistrano")
|
172
|
+
ch.stubs(:[]).with(:server).returns(server("capistrano"))
|
173
|
+
ch.expects(:send_data, "password!\n").times(2)
|
174
|
+
|
175
|
+
@config.set(:password, "password!")
|
176
|
+
@config.expects(:reset!).with(:password)
|
177
|
+
|
178
|
+
callback = @config.sudo_behavior_callback(nil)
|
179
|
+
callback[ch, :out, "sudo password: "]
|
180
|
+
callback[ch, :out, "Sorry, try again.\nsudo password: "]
|
181
|
+
end
|
182
|
+
|
169
183
|
def test_sudo_behavior_callback_should_defer_to_fallback_for_other_output
|
170
184
|
callback = @config.sudo_behavior_callback(inspectable_proc)
|
171
185
|
|
@@ -30,6 +30,7 @@ class ConfigurationConnectionsTest < Test::Unit::TestCase
|
|
30
30
|
def setup
|
31
31
|
@config = MockConfig.new
|
32
32
|
@config.stubs(:logger).returns(stub_everything)
|
33
|
+
Net::SSH.stubs(:configuration_for).returns({})
|
33
34
|
@ssh_options = {
|
34
35
|
:user => "user",
|
35
36
|
:port => 8080,
|
@@ -60,29 +61,29 @@ class ConfigurationConnectionsTest < Test::Unit::TestCase
|
|
60
61
|
|
61
62
|
def test_should_connect_through_gateway_if_gateway_variable_is_set
|
62
63
|
@config.values[:gateway] = "j@gateway"
|
63
|
-
Net::SSH::Gateway.expects(:new).with("gateway", "j", :password => nil, :auth_methods => %w(publickey hostbased)).returns(stub_everything)
|
64
|
+
Net::SSH::Gateway.expects(:new).with("gateway", "j", :password => nil, :auth_methods => %w(publickey hostbased), :config => false).returns(stub_everything)
|
64
65
|
assert_instance_of Capistrano::Configuration::Connections::GatewayConnectionFactory, @config.connection_factory
|
65
66
|
end
|
66
67
|
|
67
68
|
def test_connection_factory_as_gateway_should_honor_config_options
|
68
69
|
@config.values[:gateway] = "gateway"
|
69
70
|
@config.values.update(@ssh_options)
|
70
|
-
Net::SSH::Gateway.expects(:new).with("gateway", "user", :debug => :verbose, :port => 8080, :password => nil, :auth_methods => %w(publickey hostbased)).returns(stub_everything)
|
71
|
+
Net::SSH::Gateway.expects(:new).with("gateway", "user", :debug => :verbose, :port => 8080, :password => nil, :auth_methods => %w(publickey hostbased), :config => false).returns(stub_everything)
|
71
72
|
assert_instance_of Capistrano::Configuration::Connections::GatewayConnectionFactory, @config.connection_factory
|
72
73
|
end
|
73
74
|
|
74
75
|
def test_connection_factory_as_gateway_should_chain_gateways_if_gateway_variable_is_an_array
|
75
76
|
@config.values[:gateway] = ["j@gateway1", "k@gateway2"]
|
76
77
|
gateway1 = mock
|
77
|
-
Net::SSH::Gateway.expects(:new).with("gateway1", "j", :password => nil, :auth_methods => %w(publickey hostbased)).returns(gateway1)
|
78
|
+
Net::SSH::Gateway.expects(:new).with("gateway1", "j", :password => nil, :auth_methods => %w(publickey hostbased), :config => false).returns(gateway1)
|
78
79
|
gateway1.expects(:open).returns(65535)
|
79
|
-
Net::SSH::Gateway.expects(:new).with("127.0.0.1", "k", :port => 65535, :password => nil, :auth_methods => %w(publickey hostbased)).returns(stub_everything)
|
80
|
+
Net::SSH::Gateway.expects(:new).with("127.0.0.1", "k", :port => 65535, :password => nil, :auth_methods => %w(publickey hostbased), :config => false).returns(stub_everything)
|
80
81
|
assert_instance_of Capistrano::Configuration::Connections::GatewayConnectionFactory, @config.connection_factory
|
81
82
|
end
|
82
83
|
|
83
84
|
def test_connection_factory_as_gateway_should_share_gateway_between_connections
|
84
85
|
@config.values[:gateway] = "j@gateway"
|
85
|
-
Net::SSH::Gateway.expects(:new).once.with("gateway", "j", :password => nil, :auth_methods => %w(publickey hostbased)).returns(stub_everything)
|
86
|
+
Net::SSH::Gateway.expects(:new).once.with("gateway", "j", :password => nil, :auth_methods => %w(publickey hostbased), :config => false).returns(stub_everything)
|
86
87
|
Capistrano::SSH.stubs(:connect).returns(stub_everything)
|
87
88
|
assert_instance_of Capistrano::Configuration::Connections::GatewayConnectionFactory, @config.connection_factory
|
88
89
|
@config.establish_connections_to(server("capistrano"))
|
@@ -238,6 +238,12 @@ class ConfigurationNamespacesDSLTest < Test::Unit::TestCase
|
|
238
238
|
ns = @config.namespaces[:outer]
|
239
239
|
assert ns.respond_to?(:original_initialize_called)
|
240
240
|
end
|
241
|
+
|
242
|
+
def test_namespace_should_accept_respond_to_with_include_priv_parameter
|
243
|
+
@config.namespace(:outer) {}
|
244
|
+
ns = @config.namespaces[:outer]
|
245
|
+
assert ns.respond_to?(:original_initialize_called, true)
|
246
|
+
end
|
241
247
|
|
242
248
|
def test_namespace_should_delegate_unknown_messages_to_its_parent
|
243
249
|
@config.namespace(:outer) {}
|
@@ -53,6 +53,10 @@ class ConfigurationVariablesTest < Test::Unit::TestCase
|
|
53
53
|
@config[:sample] = :value
|
54
54
|
assert @config.respond_to?(:sample)
|
55
55
|
end
|
56
|
+
|
57
|
+
def test_respond_to_with_include_priv_paramter
|
58
|
+
assert !@config.respond_to?(:sample, true)
|
59
|
+
end
|
56
60
|
|
57
61
|
def test_set_should_require_value
|
58
62
|
assert_raises(ArgumentError) do
|
data/test/ssh_test.rb
CHANGED
@@ -5,8 +5,10 @@ class SSHTest < Test::Unit::TestCase
|
|
5
5
|
def setup
|
6
6
|
Capistrano::ServerDefinition.stubs(:default_user).returns("default-user")
|
7
7
|
@options = { :password => nil,
|
8
|
-
:auth_methods => %w(publickey hostbased)
|
8
|
+
:auth_methods => %w(publickey hostbased),
|
9
|
+
:config => false }
|
9
10
|
@server = server("capistrano")
|
11
|
+
Net::SSH.stubs(:configuration_for).returns({})
|
10
12
|
end
|
11
13
|
|
12
14
|
def test_connect_with_bare_server_without_options_or_config_with_public_key_succeeding_should_only_loop_once
|
@@ -69,8 +71,8 @@ class SSHTest < Test::Unit::TestCase
|
|
69
71
|
end
|
70
72
|
|
71
73
|
def test_connect_with_ssh_options_should_use_ssh_options
|
72
|
-
ssh_options = { :username => "JamisMan", :port => 8125 }
|
73
|
-
Net::SSH.expects(:start).with(@server.host, "JamisMan", @options.merge(:port => 8125)).returns(success = Object.new)
|
74
|
+
ssh_options = { :username => "JamisMan", :port => 8125, :config => false }
|
75
|
+
Net::SSH.expects(:start).with(@server.host, "JamisMan", @options.merge(:port => 8125, :config => false)).returns(success = Object.new)
|
74
76
|
assert_equal success, Capistrano::SSH.connect(@server, {:ssh_options => ssh_options})
|
75
77
|
end
|
76
78
|
|
@@ -83,7 +85,7 @@ class SSHTest < Test::Unit::TestCase
|
|
83
85
|
def test_connect_with_ssh_options_should_see_server_options_override_ssh_options
|
84
86
|
ssh_options = { :username => "JamisMan", :port => 8125, :forward_agent => true }
|
85
87
|
server = server("jamis@capistrano:1235")
|
86
|
-
Net::SSH.expects(:start).with(server.host, "jamis", @options.merge(:port => 1235, :forward_agent => true)).returns(success = Object.new)
|
88
|
+
Net::SSH.expects(:start).with(server.host, "jamis", @options.merge(:port => 1235, :forward_agent => true, :config => false)).returns(success = Object.new)
|
87
89
|
assert_equal success, Capistrano::SSH.connect(server, {:ssh_options => ssh_options})
|
88
90
|
end
|
89
91
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamis Buck
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-02-04 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 2.0.
|
23
|
+
version: 2.0.10
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: net-sftp
|