ruby_gpg 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.markdown +7 -0
- data/Rakefile +3 -1
- data/VERSION +1 -1
- data/features/encryption.feature +8 -1
- data/features/step_definitions/ruby_gpg_steps.rb +15 -1
- data/lib/ruby_gpg.rb +4 -7
- data/ruby_gpg.gemspec +73 -0
- data/spec/ruby_gpg_spec.rb +4 -12
- metadata +4 -3
- data/.document +0 -5
data/CHANGELOG.markdown
ADDED
data/Rakefile
CHANGED
@@ -50,7 +50,9 @@ task :default => :spec
|
|
50
50
|
|
51
51
|
begin
|
52
52
|
require 'yard'
|
53
|
-
YARD::Rake::YardocTask.new
|
53
|
+
YARD::Rake::YardocTask.new do |y|
|
54
|
+
y.files << '-' << 'CHANGELOG.*' << 'TODO.*'
|
55
|
+
end
|
54
56
|
rescue LoadError
|
55
57
|
task :yardoc do
|
56
58
|
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/features/encryption.feature
CHANGED
@@ -3,10 +3,17 @@ Feature: Encryption
|
|
3
3
|
As a user
|
4
4
|
I want to encrypt the file
|
5
5
|
|
6
|
-
|
6
|
+
Background:
|
7
7
|
Given a key pair for Slow Joe Crow with passphrase test
|
8
8
|
And a file named "secrets" containing "some content"
|
9
9
|
And the file "secrets.gpg" does not exist
|
10
|
+
|
11
|
+
Scenario: Encrypt
|
10
12
|
When I encrypt the file "secrets" for "Slow Joe Crow"
|
11
13
|
Then the file "secrets.gpg" should exist
|
12
14
|
And the file "secrets.gpg" should not contain "some content"
|
15
|
+
|
16
|
+
Scenario: Unknown recipient
|
17
|
+
When I try to encrypt the file "secrets" for "Sue"
|
18
|
+
Then the command should raise an error matching "key not found"
|
19
|
+
And the file "secrets.gpg" should not exist
|
@@ -10,7 +10,7 @@ Given /^a file named "([^\"]*)" containing "([^\"]*)"$/ do |filename, content|
|
|
10
10
|
end
|
11
11
|
|
12
12
|
Given /^the file "([^\"]*)" does not exist$/ do |filename|
|
13
|
-
if File.exist?(filename)
|
13
|
+
if File.exist?("#{TMP_PATH}/#{filename}")
|
14
14
|
File.delete("#{TMP_PATH}/#{filename}")
|
15
15
|
end
|
16
16
|
end
|
@@ -19,14 +19,28 @@ When /^I encrypt the file "([^\"]*)" for "([^\"]*)"$/ do |filename, recipient|
|
|
19
19
|
RubyGpg.encrypt("#{TMP_PATH}/#{filename}", recipient)
|
20
20
|
end
|
21
21
|
|
22
|
+
When /^I try to encrypt the file "([^\"]*)" for "([^\"]*)"$/ do |filename, recipient|
|
23
|
+
@command = lambda {
|
24
|
+
RubyGpg.encrypt("#{TMP_PATH}/#{filename}", recipient)
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
22
28
|
When /^I decrypt the file "([^\"]*)" with passphrase "([^\"]*)"$/ do |filename, passphrase|
|
23
29
|
RubyGpg.decrypt("#{TMP_PATH}/#{filename}", passphrase)
|
24
30
|
end
|
25
31
|
|
32
|
+
Then /^the command should raise an error matching "([^\"]*)"$/ do |error|
|
33
|
+
@command.should raise_error(/#{Regexp.escape(error)}/)
|
34
|
+
end
|
35
|
+
|
26
36
|
Then /^the file "([^\"]*)" should exist$/ do |filename|
|
27
37
|
File.exist?("#{TMP_PATH}/#{filename}").should be_true
|
28
38
|
end
|
29
39
|
|
40
|
+
Then /^the file "([^\"]*)" should not exist$/ do |filename|
|
41
|
+
File.exist?("#{TMP_PATH}/#{filename}").should_not be_true
|
42
|
+
end
|
43
|
+
|
30
44
|
Then /^the file "([^\"]*)" should not contain "([^\"]*)"$/ do |filename, content|
|
31
45
|
File.read("#{TMP_PATH}/#{filename}").should_not include(content)
|
32
46
|
end
|
data/lib/ruby_gpg.rb
CHANGED
@@ -9,7 +9,7 @@ module RubyGpg
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def gpg_command
|
12
|
-
"#{config.executable} --homedir #{config.homedir}" +
|
12
|
+
"#{config.executable} --homedir #{config.homedir} --quiet" +
|
13
13
|
" --no-secmem-warning --no-permission-warning --no-tty --yes"
|
14
14
|
end
|
15
15
|
|
@@ -30,12 +30,9 @@ module RubyGpg
|
|
30
30
|
private
|
31
31
|
def run_command(command)
|
32
32
|
Open3.popen3(command) do |stdin, stdout, stderr|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
errors = stderr.read
|
37
|
-
msg << " with: #{errors}" if errors && !errors.empty?
|
38
|
-
raise msg
|
33
|
+
error = stderr.read
|
34
|
+
if error && !error.empty?
|
35
|
+
raise "GPG command (#{command}) failed with: #{error}"
|
39
36
|
end
|
40
37
|
end
|
41
38
|
end
|
data/ruby_gpg.gemspec
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{ruby_gpg}
|
8
|
+
s.version = "0.1.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Justin Blake"]
|
12
|
+
s.date = %q{2010-03-16}
|
13
|
+
s.description = %q{Ruby wrapper for the gpg binary}
|
14
|
+
s.email = %q{justin@megablaix.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.markdown"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".autotest",
|
21
|
+
".gitignore",
|
22
|
+
"CHANGELOG.markdown",
|
23
|
+
"LICENSE",
|
24
|
+
"README.markdown",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"cucumber.yml",
|
28
|
+
"features/decryption.feature",
|
29
|
+
"features/encryption.feature",
|
30
|
+
"features/step_definitions/ruby_gpg_steps.rb",
|
31
|
+
"features/support/env.rb",
|
32
|
+
"lib/ruby_gpg.rb",
|
33
|
+
"ruby_gpg.gemspec",
|
34
|
+
"spec/ruby_gpg_spec.rb",
|
35
|
+
"spec/spec.opts",
|
36
|
+
"spec/spec_helper.rb",
|
37
|
+
"test_keys/pubring.gpg",
|
38
|
+
"test_keys/secring.gpg",
|
39
|
+
"test_keys/trustdb.gpg"
|
40
|
+
]
|
41
|
+
s.homepage = %q{http://github.com/blaix/ruby_gpg}
|
42
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
43
|
+
s.require_paths = ["lib"]
|
44
|
+
s.rubygems_version = %q{1.3.6}
|
45
|
+
s.summary = %q{Ruby wrapper for the gpg binary}
|
46
|
+
s.test_files = [
|
47
|
+
"spec/ruby_gpg_spec.rb",
|
48
|
+
"spec/spec_helper.rb"
|
49
|
+
]
|
50
|
+
|
51
|
+
if s.respond_to? :specification_version then
|
52
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
53
|
+
s.specification_version = 3
|
54
|
+
|
55
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
56
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
57
|
+
s.add_development_dependency(%q<yard>, [">= 0"])
|
58
|
+
s.add_development_dependency(%q<cucumber>, [">= 0"])
|
59
|
+
s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
62
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
63
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
64
|
+
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
65
|
+
end
|
66
|
+
else
|
67
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
68
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
69
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
70
|
+
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
data/spec/ruby_gpg_spec.rb
CHANGED
@@ -11,8 +11,7 @@ describe "RubyGpg" do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
$?.stubs(:exitstatus).returns(1)
|
14
|
+
def stub_error(error_message)
|
16
15
|
@stderr.write(error_message)
|
17
16
|
@stderr.rewind
|
18
17
|
end
|
@@ -22,7 +21,6 @@ describe "RubyGpg" do
|
|
22
21
|
@stdout = StringIO.new
|
23
22
|
@stderr = StringIO.new
|
24
23
|
Open3.stubs(:popen3).yields(@stdin, @stdout, @stderr)
|
25
|
-
$?.stubs(:exitstatus).returns(0)
|
26
24
|
end
|
27
25
|
|
28
26
|
it "allows the use of a custom path to the gpg executable" do
|
@@ -40,6 +38,7 @@ describe "RubyGpg" do
|
|
40
38
|
command.should include("--no-secmem-warning")
|
41
39
|
command.should include("--no-permission-warning")
|
42
40
|
command.should include("--no-tty")
|
41
|
+
command.should include("--quiet")
|
43
42
|
command.should include("--yes")
|
44
43
|
end
|
45
44
|
|
@@ -74,7 +73,7 @@ describe "RubyGpg" do
|
|
74
73
|
end
|
75
74
|
|
76
75
|
it "raises any errors from gpg" do
|
77
|
-
|
76
|
+
stub_error("error message")
|
78
77
|
lambda { run_encrypt }.should raise_error(/GPG command \(.*gpg.*--encrypt.*filename\) failed with: error message/)
|
79
78
|
end
|
80
79
|
|
@@ -114,19 +113,12 @@ describe "RubyGpg" do
|
|
114
113
|
end
|
115
114
|
|
116
115
|
it "raises any errors from gpg" do
|
117
|
-
|
116
|
+
stub_error("error message")
|
118
117
|
lambda { run_decrypt }.should raise_error(/GPG command \(.*gpg.*--decrypt.*filename\.gpg\) failed with: error message/)
|
119
118
|
end
|
120
119
|
|
121
120
|
it "does not raise if there is no output from gpg" do
|
122
121
|
lambda { run_decrypt }.should_not raise_error
|
123
122
|
end
|
124
|
-
|
125
|
-
it "does not raise when gpg spits 'successful' output to stderr" do
|
126
|
-
$?.stubs(:exitstatus).returns(0)
|
127
|
-
@stderr.write("success message")
|
128
|
-
@stderr.rewind
|
129
|
-
lambda { run_decrypt }.should_not raise_error
|
130
|
-
end
|
131
123
|
end
|
132
124
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Justin Blake
|
@@ -80,8 +80,8 @@ extra_rdoc_files:
|
|
80
80
|
- README.markdown
|
81
81
|
files:
|
82
82
|
- .autotest
|
83
|
-
- .document
|
84
83
|
- .gitignore
|
84
|
+
- CHANGELOG.markdown
|
85
85
|
- LICENSE
|
86
86
|
- README.markdown
|
87
87
|
- Rakefile
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- features/step_definitions/ruby_gpg_steps.rb
|
93
93
|
- features/support/env.rb
|
94
94
|
- lib/ruby_gpg.rb
|
95
|
+
- ruby_gpg.gemspec
|
95
96
|
- spec/ruby_gpg_spec.rb
|
96
97
|
- spec/spec.opts
|
97
98
|
- spec/spec_helper.rb
|