forked from test-kitchen/test-kitchen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request test-kitchen#801 from codranger:compression
- Loading branch information
Showing
2 changed files
with
26 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,16 +52,26 @@ class Ssh < Kitchen::Transport::Base | |
default_config :ssh_key, nil | ||
expand_path_for :ssh_key | ||
|
||
default_config :compression, "zlib" | ||
required_config :compression do |attr, value, transport| | ||
if !%W[zlib none].include?(value) | ||
raise UserError, "#{transport} :#{attr} value may only " \ | ||
"be set to `none' or `zlib'." | ||
end | ||
end | ||
default_config :compression, true | ||
required_config :compression | ||
|
||
default_config :compression_level do |transport| | ||
transport[:compression] == "none" ? 0 : 6 | ||
transport[:compression] == false ? 0 : 6 | ||
end | ||
|
||
def finalize_config!(instance) | ||
super | ||
|
||
# zlib was never a valid value and breaks in net-ssh >= 2.10 | ||
# TODO: remove these backwards compatiable casts in 2.0 | ||
case config[:compression] | ||
when "zlib" | ||
config[:compression] = "[email protected]" | ||
when "none" | ||
config[:compression] = false | ||
end | ||
|
||
self | ||
end | ||
|
||
# (see Base#connection) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,21 +145,20 @@ def types # rubocop:disable Lint/NestedMethodDefinition | |
transport[:username].must_equal "root" | ||
end | ||
|
||
it "sets :compression to zlib by default" do | ||
transport[:compression].must_equal "zlib" | ||
it "sets :compression to true by default" do | ||
transport[:compression].must_equal true | ||
end | ||
|
||
it "sets :compression to none if set to none" do | ||
it "sets :compression to false if set to none" do | ||
config[:compression] = "none" | ||
|
||
transport[:compression].must_equal "none" | ||
transport[:compression].must_equal false | ||
end | ||
|
||
it "raises a UserError if :compression is set to a bogus value" do | ||
config[:compression] = "boom" | ||
it "sets :compression to [email protected] if set to zlib" do | ||
config[:compression] = "zlib" | ||
|
||
err = proc { transport }.must_raise Kitchen::UserError | ||
err.message.must_match(%r{value may only be set to `none' or `zlib'}) | ||
transport[:compression].must_equal "[email protected]" | ||
end | ||
|
||
it "sets :compression_level to 6 by default" do | ||
|
@@ -309,7 +308,7 @@ def self.common_connection_specs | |
config[:compression] = "none" | ||
|
||
klass.expects(:new).with do |hash| | ||
hash[:compression] == "none" | ||
hash[:compression] == false | ||
end | ||
|
||
make_connection | ||
|