ruby-pgp 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/pgp/gpg/engine.rb +8 -7
- data/lib/pgp/gpg/temp_path_helper.rb +2 -0
- data/lib/pgp/version.rb +1 -1
- data/spec/helpers/temp_helper.rb +0 -19
- data/spec/lib/pgp/gpg/engine_spec.rb +4 -7
- data/spec/lib/quirks_spec.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a2f20309e0bba2ee5b6f21a6147dfd3b718abf796e5e43df145a6cebdd4946a3
|
|
4
|
+
data.tar.gz: c0cdba253d3b1b8c7c31b69630f7396855bf0073280826c18ad6646a84d35bd8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ce0777ec36e513bb1960811b7d70597d4a493a9056c58b7e9d6f89c52e719545b553f6d3dc643697180146d48c318344096369ff17d580fa7f8062674d62dadf
|
|
7
|
+
data.tar.gz: 8d1bf0b32fe44113730c528bade31d882c83449231c5617c16b01cfc1f52c74bdd111f95a51289f63299ff778fb43bbe2f126966ef8a942baedf440d0da1435f
|
data/lib/pgp/gpg/engine.rb
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
require 'tempfile'
|
|
2
|
-
require 'tmpdir'
|
|
3
|
-
|
|
4
1
|
module GPG
|
|
5
2
|
class Engine
|
|
6
3
|
include PGP::LogCapable
|
|
@@ -13,13 +10,17 @@ module GPG
|
|
|
13
10
|
|
|
14
11
|
def import_key(key_contents)
|
|
15
12
|
log("Import Key")
|
|
13
|
+
|
|
16
14
|
validate_gpg_version
|
|
17
|
-
Tempfile.open do |f|
|
|
18
|
-
f.write(key_contents)
|
|
19
|
-
f.rewind
|
|
20
15
|
|
|
21
|
-
|
|
16
|
+
result = []
|
|
17
|
+
|
|
18
|
+
GPG::TempPathHelper.create do |path1|
|
|
19
|
+
File.write(path1, key_contents)
|
|
20
|
+
result = runner.import_key_from_file(path1)
|
|
22
21
|
end
|
|
22
|
+
|
|
23
|
+
result
|
|
23
24
|
end
|
|
24
25
|
|
|
25
26
|
def verify_signature(signature_data)
|
data/lib/pgp/version.rb
CHANGED
data/spec/helpers/temp_helper.rb
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
module TempHelper
|
|
2
|
-
def setup_temp_file(contents='')
|
|
3
|
-
stub = create_temp_file_stub(contents)
|
|
4
|
-
allow(Tempfile).to receive(:open).and_yield(stub)
|
|
5
|
-
stub
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def create_temp_file_stub(contents='')
|
|
9
|
-
stub = double
|
|
10
|
-
allow(stub).to receive(:path).and_return(random_string)
|
|
11
|
-
allow(stub).to receive(:write).with(contents)
|
|
12
|
-
allow(stub).to receive(:read).and_return(contents)
|
|
13
|
-
allow(stub).to receive(:rewind)
|
|
14
|
-
stub
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def random_string(length=20)
|
|
18
|
-
(0...length).map { (65 + rand(26)).chr }.join
|
|
19
|
-
end
|
|
20
|
-
|
|
21
2
|
def setup_temp_paths(paths)
|
|
22
3
|
allow(GPG::TempPathHelper).to receive(:create) do |&block|
|
|
23
4
|
p = paths.pop
|
|
@@ -75,16 +75,13 @@ describe GPG::Engine do
|
|
|
75
75
|
describe :import_key do
|
|
76
76
|
it 'creates a temporary file and imports the key' do
|
|
77
77
|
setup_valid_gpg_version
|
|
78
|
-
|
|
79
|
-
allow(
|
|
80
|
-
|
|
81
|
-
'email2@gmail.com'
|
|
82
|
-
])
|
|
78
|
+
setup_temp_paths(['path1'])
|
|
79
|
+
allow(File).to receive(:write).with('path1', 'key contents aaaaa')
|
|
80
|
+
allow(runner).to receive(:import_key_from_file).with('path1').and_return(['email1@gmail.com', 'email2@gmail.com'])
|
|
83
81
|
|
|
84
82
|
expect(engine.import_key('key contents aaaaa')).to eq(['email1@gmail.com', 'email2@gmail.com'])
|
|
85
83
|
|
|
86
|
-
expect(
|
|
87
|
-
expect(temp_file_stub).to have_received(:rewind)
|
|
84
|
+
expect(File).to have_received(:write)
|
|
88
85
|
expect(runner).to have_received(:import_key_from_file)
|
|
89
86
|
end
|
|
90
87
|
|
data/spec/lib/quirks_spec.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby-pgp
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Camilo Sanchez
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-02-
|
|
11
|
+
date: 2020-02-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|