Skip to content

Commit

Permalink
Remove unused argument of the Encrypted#decrypt method
Browse files Browse the repository at this point in the history
  • Loading branch information
jefmathiot committed Feb 10, 2015
1 parent 65eb4a1 commit 8c1a3c8
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/electric_sheep/agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Agent
protected
def option(name)
option = @metadata.send(name)
return option.decrypt(@job.private_key) if option.respond_to?(:decrypt)
return option.decrypt if option.respond_to?(:decrypt)
option
end

Expand Down
2 changes: 1 addition & 1 deletion lib/electric_sheep/metadata/encrypted.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def initialize(options, cipher_text)
@cipher_text = cipher_text
end

def decrypt(keyfile)
def decrypt
Crypto.gpg.string.decrypt(@options.with, @cipher_text)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/electric_sheep/notifiers/email.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def assets_url
def handle_options(options)
if options
options.reduce({}) do |h, (k, v)|
v=v.decrypt(@job.private_key) if v.respond_to?(:decrypt)
v=v.decrypt if v.respond_to?(:decrypt)
h[k.to_sym]=v
h
end
Expand Down
2 changes: 1 addition & 1 deletion lib/electric_sheep/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ElectricSheep
VERSION = "0.2.1"
VERSION = "0.3.0.rc1"
end
4 changes: 1 addition & 3 deletions spec/electric_sheep/command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
command.shell.must_equal shell
end


it 'stats the input and performs' do
command.expects(:stat!).with(resource)
command.expects(:perform!).returns(output=mock)
Expand All @@ -39,8 +38,7 @@
# TODO Move to an agent spec
it 'decrypts options' do
metadata.expects(:some_option).returns(encrypted = mock)
job.expects(:private_key).returns('/path/to/private/key')
encrypted.expects(:decrypt).with('/path/to/private/key').returns('VALUE')
encrypted.expects(:decrypt).returns('VALUE')
command.send(:option, :some_option).must_equal 'VALUE'
end

Expand Down
2 changes: 1 addition & 1 deletion spec/electric_sheep/metadata/encrypted_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'/path/to/private/key'.tap do |key|
encryptor.expects(:decrypt).with(key, 'CIPHER').returns('PLAIN')
decrypt_options = mock(with: key)
subject.new(decrypt_options, 'CIPHER').decrypt(key).must_equal 'PLAIN'
subject.new(decrypt_options, 'CIPHER').decrypt.must_equal 'PLAIN'
end
end
end
3 changes: 1 addition & 2 deletions spec/electric_sheep/notifiers/email_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
report=mock.tap{|m| m.stubs(:stack).returns([])}
p.stubs(:report).returns(report)
p.stubs(:last_product).returns(resource)
p.stubs(:private).returns('private/key')
end
}

let(:encrypted){
mock.tap{
|m| m.expects(:decrypt).with(job.private_key).returns('value')
|m| m.expects(:decrypt).returns('value')
}
}

Expand Down

0 comments on commit 8c1a3c8

Please sign in to comment.