cheffish 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +201 -201
- data/README.md +120 -120
- data/Rakefile +23 -23
- data/lib/chef/provider/chef_acl.rb +439 -439
- data/lib/chef/provider/chef_client.rb +53 -53
- data/lib/chef/provider/chef_container.rb +55 -55
- data/lib/chef/provider/chef_data_bag.rb +55 -55
- data/lib/chef/provider/chef_data_bag_item.rb +278 -278
- data/lib/chef/provider/chef_environment.rb +83 -83
- data/lib/chef/provider/chef_group.rb +83 -83
- data/lib/chef/provider/chef_mirror.rb +169 -169
- data/lib/chef/provider/chef_node.rb +87 -87
- data/lib/chef/provider/chef_organization.rb +155 -155
- data/lib/chef/provider/chef_resolved_cookbooks.rb +46 -46
- data/lib/chef/provider/chef_role.rb +84 -84
- data/lib/chef/provider/chef_user.rb +59 -59
- data/lib/chef/provider/private_key.rb +225 -225
- data/lib/chef/provider/public_key.rb +88 -88
- data/lib/chef/resource/chef_acl.rb +69 -69
- data/lib/chef/resource/chef_client.rb +48 -48
- data/lib/chef/resource/chef_container.rb +22 -22
- data/lib/chef/resource/chef_data_bag.rb +22 -22
- data/lib/chef/resource/chef_data_bag_item.rb +121 -121
- data/lib/chef/resource/chef_environment.rb +77 -77
- data/lib/chef/resource/chef_group.rb +53 -53
- data/lib/chef/resource/chef_mirror.rb +52 -52
- data/lib/chef/resource/chef_node.rb +22 -22
- data/lib/chef/resource/chef_organization.rb +69 -69
- data/lib/chef/resource/chef_resolved_cookbooks.rb +35 -35
- data/lib/chef/resource/chef_role.rb +110 -110
- data/lib/chef/resource/chef_user.rb +56 -56
- data/lib/chef/resource/private_key.rb +48 -48
- data/lib/chef/resource/public_key.rb +25 -25
- data/lib/cheffish/actor_provider_base.rb +131 -131
- data/lib/cheffish/basic_chef_client.rb +184 -184
- data/lib/cheffish/chef_provider_base.rb +246 -246
- data/lib/cheffish/chef_run.rb +162 -162
- data/lib/cheffish/chef_run_data.rb +19 -19
- data/lib/cheffish/chef_run_listener.rb +30 -30
- data/lib/cheffish/key_formatter.rb +113 -113
- data/lib/cheffish/merged_config.rb +94 -94
- data/lib/cheffish/recipe_dsl.rb +157 -157
- data/lib/cheffish/rspec/chef_run_support.rb +83 -83
- data/lib/cheffish/rspec/matchers/be_idempotent.rb +16 -16
- data/lib/cheffish/rspec/matchers/emit_no_warnings_or_errors.rb +15 -15
- data/lib/cheffish/rspec/matchers/have_updated.rb +37 -37
- data/lib/cheffish/rspec/matchers/partially_match.rb +63 -63
- data/lib/cheffish/rspec/matchers.rb +4 -4
- data/lib/cheffish/rspec/recipe_run_wrapper.rb +78 -59
- data/lib/cheffish/rspec/repository_support.rb +108 -108
- data/lib/cheffish/rspec.rb +8 -8
- data/lib/cheffish/server_api.rb +52 -52
- data/lib/cheffish/version.rb +3 -3
- data/lib/cheffish/with_pattern.rb +21 -21
- data/lib/cheffish.rb +235 -235
- data/spec/functional/fingerprint_spec.rb +64 -64
- data/spec/functional/merged_config_spec.rb +19 -19
- data/spec/functional/server_api_spec.rb +13 -13
- data/spec/integration/chef_acl_spec.rb +879 -879
- data/spec/integration/chef_client_spec.rb +105 -105
- data/spec/integration/chef_container_spec.rb +33 -33
- data/spec/integration/chef_group_spec.rb +309 -309
- data/spec/integration/chef_mirror_spec.rb +491 -491
- data/spec/integration/chef_node_spec.rb +786 -786
- data/spec/integration/chef_organization_spec.rb +226 -226
- data/spec/integration/chef_role_spec.rb +78 -78
- data/spec/integration/chef_user_spec.rb +85 -85
- data/spec/integration/private_key_spec.rb +399 -399
- data/spec/integration/recipe_dsl_spec.rb +28 -28
- data/spec/integration/rspec/converge_spec.rb +183 -183
- data/spec/support/key_support.rb +29 -29
- data/spec/support/spec_support.rb +15 -15
- data/spec/unit/get_private_key_spec.rb +131 -131
- data/spec/unit/recipe_run_wrapper_spec.rb +37 -37
- metadata +3 -2
@@ -1,28 +1,28 @@
|
|
1
|
-
require 'support/spec_support'
|
2
|
-
require 'cheffish/rspec/chef_run_support'
|
3
|
-
require 'chef/resource/chef_node'
|
4
|
-
require 'chef/provider/chef_node'
|
5
|
-
require 'tmpdir'
|
6
|
-
|
7
|
-
describe 'Cheffish Recipe DSL' do
|
8
|
-
extend Cheffish::RSpec::ChefRunSupport
|
9
|
-
|
10
|
-
context 'when we include with_chef_local_server' do
|
11
|
-
before :each do
|
12
|
-
@tmp_repo = tmp_repo = Dir.mktmpdir('chef_repo')
|
13
|
-
end
|
14
|
-
|
15
|
-
after :each do
|
16
|
-
FileUtils.remove_entry_secure @tmp_repo
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'chef_nodes get put into said server' do
|
20
|
-
tmp_repo = @tmp_repo
|
21
|
-
expect_recipe {
|
22
|
-
with_chef_local_server :chef_repo_path => tmp_repo
|
23
|
-
chef_node 'blah'
|
24
|
-
}.to have_updated 'chef_node[blah]', :create
|
25
|
-
expect(File).to exist("#{@tmp_repo}/nodes/blah.json")
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
1
|
+
require 'support/spec_support'
|
2
|
+
require 'cheffish/rspec/chef_run_support'
|
3
|
+
require 'chef/resource/chef_node'
|
4
|
+
require 'chef/provider/chef_node'
|
5
|
+
require 'tmpdir'
|
6
|
+
|
7
|
+
describe 'Cheffish Recipe DSL' do
|
8
|
+
extend Cheffish::RSpec::ChefRunSupport
|
9
|
+
|
10
|
+
context 'when we include with_chef_local_server' do
|
11
|
+
before :each do
|
12
|
+
@tmp_repo = tmp_repo = Dir.mktmpdir('chef_repo')
|
13
|
+
end
|
14
|
+
|
15
|
+
after :each do
|
16
|
+
FileUtils.remove_entry_secure @tmp_repo
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'chef_nodes get put into said server' do
|
20
|
+
tmp_repo = @tmp_repo
|
21
|
+
expect_recipe {
|
22
|
+
with_chef_local_server :chef_repo_path => tmp_repo
|
23
|
+
chef_node 'blah'
|
24
|
+
}.to have_updated 'chef_node[blah]', :create
|
25
|
+
expect(File).to exist("#{@tmp_repo}/nodes/blah.json")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,183 +1,183 @@
|
|
1
|
-
require 'support/spec_support'
|
2
|
-
require 'cheffish/rspec/chef_run_support'
|
3
|
-
|
4
|
-
describe 'Cheffish::RSpec::ChefRunSupport' do
|
5
|
-
extend Cheffish::RSpec::ChefRunSupport
|
6
|
-
|
7
|
-
let(:temp_file) { Tempfile.new('test') }
|
8
|
-
|
9
|
-
context "#recipe" do
|
10
|
-
it "recipe { file ... } updates the file" do
|
11
|
-
result = recipe {
|
12
|
-
file temp_file.path do
|
13
|
-
content 'test'
|
14
|
-
end
|
15
|
-
}
|
16
|
-
expect(result.updated?).to be_falsey
|
17
|
-
expect(IO.read(temp_file.path)).to eq ''
|
18
|
-
end
|
19
|
-
|
20
|
-
it "recipe 'file ...' does not update the file" do
|
21
|
-
result = recipe <<-EOM
|
22
|
-
file temp_file.path do
|
23
|
-
content 'test'
|
24
|
-
end
|
25
|
-
EOM
|
26
|
-
expect(result.updated?).to be_falsey
|
27
|
-
expect(IO.read(temp_file.path)).to eq ''
|
28
|
-
end
|
29
|
-
|
30
|
-
it "recipe 'file ...' with file and line number does not update the file" do
|
31
|
-
result = recipe(<<-EOM, __FILE__, __LINE__+1)
|
32
|
-
file temp_file.path do
|
33
|
-
content 'test'
|
34
|
-
end
|
35
|
-
EOM
|
36
|
-
expect(result.updated?).to be_falsey
|
37
|
-
expect(IO.read(temp_file.path)).to eq ''
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context "#converge" do
|
42
|
-
it "converge { file ... } updates the file" do
|
43
|
-
result = converge {
|
44
|
-
file temp_file.path do
|
45
|
-
content 'test'
|
46
|
-
end
|
47
|
-
}
|
48
|
-
expect(result.updated?).to be_truthy
|
49
|
-
expect(IO.read(temp_file.path)).to eq 'test'
|
50
|
-
end
|
51
|
-
|
52
|
-
it "converge 'file ...' updates the file" do
|
53
|
-
result = converge <<-EOM
|
54
|
-
file temp_file.path do
|
55
|
-
content 'test'
|
56
|
-
end
|
57
|
-
EOM
|
58
|
-
expect(result.updated?).to be_truthy
|
59
|
-
expect(IO.read(temp_file.path)).to eq 'test'
|
60
|
-
end
|
61
|
-
|
62
|
-
it "converge 'file ...' with file and line number updates the file" do
|
63
|
-
result = converge(<<-EOM, __FILE__, __LINE__+1)
|
64
|
-
file temp_file.path do
|
65
|
-
content 'test'
|
66
|
-
end
|
67
|
-
EOM
|
68
|
-
expect(result.updated?).to be_truthy
|
69
|
-
expect(IO.read(temp_file.path)).to eq 'test'
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
context "#expect_recipe" do
|
74
|
-
it "expect_recipe { file ... }.to be_updated updates the file, and be_idempotent does not fail" do
|
75
|
-
expect_recipe {
|
76
|
-
file temp_file.path do
|
77
|
-
content 'test'
|
78
|
-
end
|
79
|
-
}.to be_updated.and be_idempotent
|
80
|
-
|
81
|
-
expect(IO.read(temp_file.path)).to eq 'test'
|
82
|
-
end
|
83
|
-
|
84
|
-
it "expect_recipe 'file ...'.to be_updated updates the file, and be_idempotent does not fail" do
|
85
|
-
expect_recipe(<<-EOM).to be_updated.and be_idempotent
|
86
|
-
file temp_file.path do
|
87
|
-
content 'test'
|
88
|
-
end
|
89
|
-
EOM
|
90
|
-
|
91
|
-
expect(IO.read(temp_file.path)).to eq 'test'
|
92
|
-
end
|
93
|
-
|
94
|
-
it "expect_recipe('file ...', file, line).to be_updated updates the file, and be_idempotent does not fail" do
|
95
|
-
expect_recipe(<<-EOM, __FILE__, __LINE__+1).to be_updated.and be_idempotent
|
96
|
-
file temp_file.path do
|
97
|
-
content 'test'
|
98
|
-
end
|
99
|
-
EOM
|
100
|
-
|
101
|
-
expect(IO.read(temp_file.path)).to eq 'test'
|
102
|
-
end
|
103
|
-
|
104
|
-
it "expect_recipe { file ... }.to be_up_to_date fails" do
|
105
|
-
expect {
|
106
|
-
expect_recipe {
|
107
|
-
file temp_file.path do
|
108
|
-
content 'test'
|
109
|
-
end
|
110
|
-
}.to be_up_to_date
|
111
|
-
}.to raise_error RSpec::Expectations::ExpectationNotMetError
|
112
|
-
end
|
113
|
-
|
114
|
-
it "expect_recipe { }.to be_updated fails" do
|
115
|
-
expect {
|
116
|
-
expect_recipe { }.to be_updated
|
117
|
-
}.to raise_error RSpec::Expectations::ExpectationNotMetError
|
118
|
-
end
|
119
|
-
|
120
|
-
it "expect_recipe { }.to be_up_to_date succeeds" do
|
121
|
-
expect_recipe { }.to be_up_to_date
|
122
|
-
end
|
123
|
-
|
124
|
-
it "expect_recipe { }.to be_idempotent succeeds" do
|
125
|
-
expect_recipe { }.to be_idempotent
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
context "#expect_converge" do
|
130
|
-
it "expect_converge { file ... }.not_to raise_error updates the file" do
|
131
|
-
expect_converge {
|
132
|
-
file temp_file.path do
|
133
|
-
content 'test'
|
134
|
-
end
|
135
|
-
}.not_to raise_error
|
136
|
-
expect(IO.read(temp_file.path)).to eq 'test'
|
137
|
-
end
|
138
|
-
|
139
|
-
it "expect_converge('file ...').not_to raise_error updates the file" do
|
140
|
-
expect_converge(<<-EOM).not_to raise_error
|
141
|
-
file temp_file.path do
|
142
|
-
content 'test'
|
143
|
-
end
|
144
|
-
EOM
|
145
|
-
expect(IO.read(temp_file.path)).to eq 'test'
|
146
|
-
end
|
147
|
-
|
148
|
-
it "expect_converge('file ...', file, line).not_to raise_error updates the file" do
|
149
|
-
expect_converge(<<-EOM, __FILE__, __LINE__+1).not_to raise_error
|
150
|
-
file temp_file.path do
|
151
|
-
content 'test'
|
152
|
-
end
|
153
|
-
EOM
|
154
|
-
expect(IO.read(temp_file.path)).to eq 'test'
|
155
|
-
end
|
156
|
-
|
157
|
-
it "expect_converge { raise 'oh no' }.to raise_error passes" do
|
158
|
-
expect_converge {
|
159
|
-
raise 'oh no'
|
160
|
-
}.to raise_error('oh no')
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
context "when there is a let variable" do
|
165
|
-
let(:let_variable) { "test" }
|
166
|
-
|
167
|
-
it "converge { let_variable } accesses it" do
|
168
|
-
# Capture the variable outside
|
169
|
-
x = nil
|
170
|
-
converge { x = let_variable }
|
171
|
-
expect(x).to eq 'test'
|
172
|
-
end
|
173
|
-
|
174
|
-
it "converge with a file resource referencing let_variable accesses let_variable" do
|
175
|
-
converge {
|
176
|
-
file temp_file.path do
|
177
|
-
content let_variable
|
178
|
-
end
|
179
|
-
}
|
180
|
-
expect(IO.read(temp_file.path)).to eq 'test'
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
1
|
+
require 'support/spec_support'
|
2
|
+
require 'cheffish/rspec/chef_run_support'
|
3
|
+
|
4
|
+
describe 'Cheffish::RSpec::ChefRunSupport' do
|
5
|
+
extend Cheffish::RSpec::ChefRunSupport
|
6
|
+
|
7
|
+
let(:temp_file) { Tempfile.new('test') }
|
8
|
+
|
9
|
+
context "#recipe" do
|
10
|
+
it "recipe { file ... } updates the file" do
|
11
|
+
result = recipe {
|
12
|
+
file temp_file.path do
|
13
|
+
content 'test'
|
14
|
+
end
|
15
|
+
}
|
16
|
+
expect(result.updated?).to be_falsey
|
17
|
+
expect(IO.read(temp_file.path)).to eq ''
|
18
|
+
end
|
19
|
+
|
20
|
+
it "recipe 'file ...' does not update the file" do
|
21
|
+
result = recipe <<-EOM
|
22
|
+
file temp_file.path do
|
23
|
+
content 'test'
|
24
|
+
end
|
25
|
+
EOM
|
26
|
+
expect(result.updated?).to be_falsey
|
27
|
+
expect(IO.read(temp_file.path)).to eq ''
|
28
|
+
end
|
29
|
+
|
30
|
+
it "recipe 'file ...' with file and line number does not update the file" do
|
31
|
+
result = recipe(<<-EOM, __FILE__, __LINE__+1)
|
32
|
+
file temp_file.path do
|
33
|
+
content 'test'
|
34
|
+
end
|
35
|
+
EOM
|
36
|
+
expect(result.updated?).to be_falsey
|
37
|
+
expect(IO.read(temp_file.path)).to eq ''
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "#converge" do
|
42
|
+
it "converge { file ... } updates the file" do
|
43
|
+
result = converge {
|
44
|
+
file temp_file.path do
|
45
|
+
content 'test'
|
46
|
+
end
|
47
|
+
}
|
48
|
+
expect(result.updated?).to be_truthy
|
49
|
+
expect(IO.read(temp_file.path)).to eq 'test'
|
50
|
+
end
|
51
|
+
|
52
|
+
it "converge 'file ...' updates the file" do
|
53
|
+
result = converge <<-EOM
|
54
|
+
file temp_file.path do
|
55
|
+
content 'test'
|
56
|
+
end
|
57
|
+
EOM
|
58
|
+
expect(result.updated?).to be_truthy
|
59
|
+
expect(IO.read(temp_file.path)).to eq 'test'
|
60
|
+
end
|
61
|
+
|
62
|
+
it "converge 'file ...' with file and line number updates the file" do
|
63
|
+
result = converge(<<-EOM, __FILE__, __LINE__+1)
|
64
|
+
file temp_file.path do
|
65
|
+
content 'test'
|
66
|
+
end
|
67
|
+
EOM
|
68
|
+
expect(result.updated?).to be_truthy
|
69
|
+
expect(IO.read(temp_file.path)).to eq 'test'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context "#expect_recipe" do
|
74
|
+
it "expect_recipe { file ... }.to be_updated updates the file, and be_idempotent does not fail" do
|
75
|
+
expect_recipe {
|
76
|
+
file temp_file.path do
|
77
|
+
content 'test'
|
78
|
+
end
|
79
|
+
}.to be_updated.and be_idempotent
|
80
|
+
|
81
|
+
expect(IO.read(temp_file.path)).to eq 'test'
|
82
|
+
end
|
83
|
+
|
84
|
+
it "expect_recipe 'file ...'.to be_updated updates the file, and be_idempotent does not fail" do
|
85
|
+
expect_recipe(<<-EOM).to be_updated.and be_idempotent
|
86
|
+
file temp_file.path do
|
87
|
+
content 'test'
|
88
|
+
end
|
89
|
+
EOM
|
90
|
+
|
91
|
+
expect(IO.read(temp_file.path)).to eq 'test'
|
92
|
+
end
|
93
|
+
|
94
|
+
it "expect_recipe('file ...', file, line).to be_updated updates the file, and be_idempotent does not fail" do
|
95
|
+
expect_recipe(<<-EOM, __FILE__, __LINE__+1).to be_updated.and be_idempotent
|
96
|
+
file temp_file.path do
|
97
|
+
content 'test'
|
98
|
+
end
|
99
|
+
EOM
|
100
|
+
|
101
|
+
expect(IO.read(temp_file.path)).to eq 'test'
|
102
|
+
end
|
103
|
+
|
104
|
+
it "expect_recipe { file ... }.to be_up_to_date fails" do
|
105
|
+
expect {
|
106
|
+
expect_recipe {
|
107
|
+
file temp_file.path do
|
108
|
+
content 'test'
|
109
|
+
end
|
110
|
+
}.to be_up_to_date
|
111
|
+
}.to raise_error RSpec::Expectations::ExpectationNotMetError
|
112
|
+
end
|
113
|
+
|
114
|
+
it "expect_recipe { }.to be_updated fails" do
|
115
|
+
expect {
|
116
|
+
expect_recipe { }.to be_updated
|
117
|
+
}.to raise_error RSpec::Expectations::ExpectationNotMetError
|
118
|
+
end
|
119
|
+
|
120
|
+
it "expect_recipe { }.to be_up_to_date succeeds" do
|
121
|
+
expect_recipe { }.to be_up_to_date
|
122
|
+
end
|
123
|
+
|
124
|
+
it "expect_recipe { }.to be_idempotent succeeds" do
|
125
|
+
expect_recipe { }.to be_idempotent
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
context "#expect_converge" do
|
130
|
+
it "expect_converge { file ... }.not_to raise_error updates the file" do
|
131
|
+
expect_converge {
|
132
|
+
file temp_file.path do
|
133
|
+
content 'test'
|
134
|
+
end
|
135
|
+
}.not_to raise_error
|
136
|
+
expect(IO.read(temp_file.path)).to eq 'test'
|
137
|
+
end
|
138
|
+
|
139
|
+
it "expect_converge('file ...').not_to raise_error updates the file" do
|
140
|
+
expect_converge(<<-EOM).not_to raise_error
|
141
|
+
file temp_file.path do
|
142
|
+
content 'test'
|
143
|
+
end
|
144
|
+
EOM
|
145
|
+
expect(IO.read(temp_file.path)).to eq 'test'
|
146
|
+
end
|
147
|
+
|
148
|
+
it "expect_converge('file ...', file, line).not_to raise_error updates the file" do
|
149
|
+
expect_converge(<<-EOM, __FILE__, __LINE__+1).not_to raise_error
|
150
|
+
file temp_file.path do
|
151
|
+
content 'test'
|
152
|
+
end
|
153
|
+
EOM
|
154
|
+
expect(IO.read(temp_file.path)).to eq 'test'
|
155
|
+
end
|
156
|
+
|
157
|
+
it "expect_converge { raise 'oh no' }.to raise_error passes" do
|
158
|
+
expect_converge {
|
159
|
+
raise 'oh no'
|
160
|
+
}.to raise_error('oh no')
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
context "when there is a let variable" do
|
165
|
+
let(:let_variable) { "test" }
|
166
|
+
|
167
|
+
it "converge { let_variable } accesses it" do
|
168
|
+
# Capture the variable outside
|
169
|
+
x = nil
|
170
|
+
converge { x = let_variable }
|
171
|
+
expect(x).to eq 'test'
|
172
|
+
end
|
173
|
+
|
174
|
+
it "converge with a file resource referencing let_variable accesses let_variable" do
|
175
|
+
converge {
|
176
|
+
file temp_file.path do
|
177
|
+
content let_variable
|
178
|
+
end
|
179
|
+
}
|
180
|
+
expect(IO.read(temp_file.path)).to eq 'test'
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
data/spec/support/key_support.rb
CHANGED
@@ -1,29 +1,29 @@
|
|
1
|
-
RSpec::Matchers.define :be_public_key_for do |private_key, pass_phrase|
|
2
|
-
match do |public_key|
|
3
|
-
if public_key.is_a?(String)
|
4
|
-
public_key, public_key_format = Cheffish::KeyFormatter.decode(IO.read(File.expand_path(public_key)), pass_phrase, public_key)
|
5
|
-
end
|
6
|
-
if private_key.is_a?(String)
|
7
|
-
private_key, private_key_format = Cheffish::KeyFormatter.decode(IO.read(File.expand_path(private_key)), pass_phrase, private_key)
|
8
|
-
end
|
9
|
-
|
10
|
-
encrypted = public_key.public_encrypt('hi there')
|
11
|
-
expect(private_key.private_decrypt(encrypted)).to eq('hi there')
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
RSpec::Matchers.define :match_private_key do |expected, pass_phrase|
|
16
|
-
match do |actual|
|
17
|
-
if expected.is_a?(String)
|
18
|
-
expected, format = Cheffish::KeyFormatter.decode(IO.read(File.expand_path(expected)), pass_phrase, expected)
|
19
|
-
end
|
20
|
-
if actual.is_a?(String)
|
21
|
-
actual, format = Cheffish::KeyFormatter.decode(IO.read(File.expand_path(actual)), pass_phrase, actual)
|
22
|
-
end
|
23
|
-
|
24
|
-
encrypted = actual.public_encrypt('hi there')
|
25
|
-
expect(expected.private_decrypt(encrypted)).to eq('hi there')
|
26
|
-
encrypted = expected.public_encrypt('hi there')
|
27
|
-
expect(actual.private_decrypt(encrypted)).to eq('hi there')
|
28
|
-
end
|
29
|
-
end
|
1
|
+
RSpec::Matchers.define :be_public_key_for do |private_key, pass_phrase|
|
2
|
+
match do |public_key|
|
3
|
+
if public_key.is_a?(String)
|
4
|
+
public_key, public_key_format = Cheffish::KeyFormatter.decode(IO.read(File.expand_path(public_key)), pass_phrase, public_key)
|
5
|
+
end
|
6
|
+
if private_key.is_a?(String)
|
7
|
+
private_key, private_key_format = Cheffish::KeyFormatter.decode(IO.read(File.expand_path(private_key)), pass_phrase, private_key)
|
8
|
+
end
|
9
|
+
|
10
|
+
encrypted = public_key.public_encrypt('hi there')
|
11
|
+
expect(private_key.private_decrypt(encrypted)).to eq('hi there')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
RSpec::Matchers.define :match_private_key do |expected, pass_phrase|
|
16
|
+
match do |actual|
|
17
|
+
if expected.is_a?(String)
|
18
|
+
expected, format = Cheffish::KeyFormatter.decode(IO.read(File.expand_path(expected)), pass_phrase, expected)
|
19
|
+
end
|
20
|
+
if actual.is_a?(String)
|
21
|
+
actual, format = Cheffish::KeyFormatter.decode(IO.read(File.expand_path(actual)), pass_phrase, actual)
|
22
|
+
end
|
23
|
+
|
24
|
+
encrypted = actual.public_encrypt('hi there')
|
25
|
+
expect(expected.private_decrypt(encrypted)).to eq('hi there')
|
26
|
+
encrypted = expected.public_encrypt('hi there')
|
27
|
+
expect(actual.private_decrypt(encrypted)).to eq('hi there')
|
28
|
+
end
|
29
|
+
end
|
@@ -1,15 +1,15 @@
|
|
1
|
-
require 'cheffish/rspec'
|
2
|
-
|
3
|
-
require 'cheffish'
|
4
|
-
require 'chef/provider/chef_acl'
|
5
|
-
|
6
|
-
RSpec.configure do |config|
|
7
|
-
config.filter_run :focus => true
|
8
|
-
config.run_all_when_everything_filtered = true
|
9
|
-
|
10
|
-
config.before :each do
|
11
|
-
Chef::Config.reset
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
require 'chef/providers'
|
1
|
+
require 'cheffish/rspec'
|
2
|
+
|
3
|
+
require 'cheffish'
|
4
|
+
require 'chef/provider/chef_acl'
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
config.filter_run :focus => true
|
8
|
+
config.run_all_when_everything_filtered = true
|
9
|
+
|
10
|
+
config.before :each do
|
11
|
+
Chef::Config.reset
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
require 'chef/providers'
|