knife-ec-backup 2.3.0 → 2.4.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e94dbbeb73cf96ad811e14f7f28c23122179345a8e892c56ca1a1b562f727e2
4
- data.tar.gz: 2bf04cbef9be2ec11aaccc083ee4b01d8647e7b3b3da6a9aec3f95ada34e1f59
3
+ metadata.gz: 312e0c84f3b2b40b6a2824917e31da481007f65f1b82282a18ec441e398220bd
4
+ data.tar.gz: e2f1962db8526925402afcf73c145f04ffda47263fa8bade5064c2d50f494c3e
5
5
  SHA512:
6
- metadata.gz: 101b9da212a5407d68829335e264b919760aca883cd9d9aec04a7165a4fb38b0daf86d04126324c681ee59965b80b3b34f8241f0d11eb351af771cf3612e087f
7
- data.tar.gz: 5b44c656dc7ed08f8965c0a6492ecdcf76fec04fa81631bd16d4c92dc4061accdbbe3c89b5805514832c88ef4b9c6df1dc5875389d5ca24af3273a349f994615
6
+ metadata.gz: 16f96728387157fad3ef2fe38c18c9597c8c2fc2b6cb295262a7c161fc52d2fddaa40b38e38ad3e4c39af22fbec8dbf4c3bce74b8b0c97da7b22994e3cc2e7c9
7
+ data.tar.gz: e8bb31bc8fde89b682b2ab3dd8c89c7bc9b885af3f9e21d30e1e3e3875f8beea9ccb228fb3e6c8909300cf79c6bfe24e799b83af85b83b3d0ec348f59959466b
data/README.md CHANGED
@@ -1,8 +1,16 @@
1
- # knife EC backup
2
- [![Build Status Master](https://travis-ci.org/chef/knife-ec-backup.svg?branch=master)](https://travis-ci.org/chef/knife-ec-backup)
1
+ # Knife EC Backup
2
+ [![Build status](https://badge.buildkite.com/4bc85427aab66accafbd7abb2932b9dd7f9208162c5be33488.svg?branch=master)](https://buildkite.com/chef-oss/chef-knife-ec-backup-master-verify)
3
3
  [![Gem Version](https://badge.fury.io/rb/knife-ec-backup.svg)](https://badge.fury.io/rb/knife-ec-backup)
4
4
 
5
- # Description
5
+ **Umbrella Project**: [Knife](https://github.com/chef/chef-oss-practices/blob/master/projects/knife.md)
6
+
7
+ **Project State**: [Active](https://github.com/chef/chef-oss-practices/blob/master/repo-management/repo-states.md#active)
8
+
9
+ **Issues [Response Time Maximum](https://github.com/chef/chef-oss-practices/blob/master/repo-management/repo-states.md)**: 14 days
10
+
11
+ **Pull Request [Response Time Maximum](https://github.com/chef/chef-oss-practices/blob/master/repo-management/repo-states.md)**: 14 days
12
+
13
+ ## Description
6
14
 
7
15
  knife-ec-backup can backup and restore the data in an Enterprise Chef
8
16
  Server installation, preserving the data in an intermediate, editable
@@ -13,26 +21,21 @@ Server API deficiencies. The long-run goal is to improve `knife
13
21
  download`, `knife upload` and the Chef Server API and deprecate this
14
22
  tool.
15
23
 
16
- # Requirements
24
+ ## Requirements
17
25
 
18
26
  This knife plugin requires Chef Client 11.8+.
19
27
 
20
- ## Chef 10
21
-
22
- Users who are still using Chef 10 can use the most recent 1.x version
23
- of this gem. Version 1.x additionally depends on knife-essentials.
28
+ ### Server Support
24
29
 
25
- ## Server Support
26
-
27
- This plugin currently supports Enterprise Chef 11 and Chef Server 12.
30
+ This plugin currently supports Enterprise Chef 11 and Chef Server 12+.
28
31
  Support for the beta key rotation features is provided via the
29
32
  `--with-keys-sql` flag, but users of this feature should note that
30
33
  this may change once the Chef Server supports an API-based export of
31
34
  the key data.
32
35
 
33
- # Installation
36
+ ## Installation
34
37
 
35
- ## Chef Server Install (Recommended)
38
+ ### Chef Server Install (Recommended)
36
39
 
37
40
  This gem is installed with chef-server-core 12.0.0 and newer.
38
41
 
@@ -45,7 +48,7 @@ downloading the .zip file. Once unpacked, run:
45
48
  /opt/opscode/embedded/bin/gem install knife-ec-backup*gem --no-ri --no-rdoc -V
46
49
  ```
47
50
 
48
- ### Note on installing with existing development tools:
51
+ #### Note on installing with existing development tools:
49
52
 
50
53
  The latest versions of knife-ec-backup require gems with native
51
54
  extensions, thus you must install a standard build toolchain. To
@@ -76,17 +79,17 @@ Clone the git repository and run the following from inside:
76
79
  gem build knife-ec-backup.gemspec
77
80
  gem install knife-ec-backup*gem
78
81
 
79
- # Configuration
82
+ ## Configuration
80
83
 
81
- ## Permissions
84
+ ### Permissions
82
85
 
83
86
  Note that most users in an EC installation lack the permissions to pull all of the data from all organizations and other users.
84
87
  This plugin **REQUIRES THE PIVOTAL KEY AND WEBUI KEY** from the Chef Server.
85
88
  It is recommended that you run this from a frontend Enterprise Chef Server, you can use --user and --key to pass the pivotal information along.
86
89
 
87
- # Subcommands
90
+ ## Subcommands
88
91
 
89
- ## Common Options
92
+ ### Common Options
90
93
 
91
94
  The following options are supported across all subcommands:
92
95
 
@@ -96,6 +99,10 @@ The following options are supported across all subcommands:
96
99
  * `--sql-port`:
97
100
  The postgresql listening port on the Chef Server. (default: 5432)
98
101
 
102
+ * `--sql-db`:
103
+ The postgresql Chef Server database name. (default: opscode_chef)
104
+ Specify 'automate-cs-oc-erchef' when using Automate Chef Server API
105
+
99
106
  * `--sql-user`:
100
107
  The username of postgresql user with access to the opscode_chef
101
108
  database. (default: autoconfigured from
@@ -110,7 +117,7 @@ The following options are supported across all subcommands:
110
117
  * `--dry-run`:
111
118
  Report what actions would be taken without performing any. (default: false)
112
119
 
113
- ## knife ec backup DEST_DIR (options)
120
+ ### knife ec backup DEST_DIR (options)
114
121
 
115
122
  *Path*: If you have chef-client installed as well, you may need to invoke this as `/opt/opscode/embedded/bin/knife ec backup backup`
116
123
 
@@ -202,7 +209,7 @@ This compares very closely with the "knife download /" from an OSC server:
202
209
  users
203
210
  <name>.json>
204
211
 
205
- ## knife ec restore DEST_DIR (options)
212
+ ### knife ec restore DEST_DIR (options)
206
213
 
207
214
  Restores all data from the specified DEST_DIR to an Enterprise Chef /
208
215
  Private Chef server. DEST_DIR should be a backup directory created by
@@ -230,6 +237,10 @@ Private Chef server. DEST_DIR should be a backup directory created by
230
237
  Skip Chef Server version check. This will
231
238
  also skip any auto-configured options (default: false)
232
239
 
240
+ * `--[no-]skip-user-ids`:
241
+ Reuses user ids from the restore destination when updating existing
242
+ users to avoid database conflicts (default: true)
243
+
233
244
  * `--with-user-sql`:
234
245
  Whether to backup/restore user data directly from the database. This
235
246
  requires access to the listening postgresql port on the Chef
@@ -252,10 +263,10 @@ Private Chef server. DEST_DIR should be a backup directory created by
252
263
  Chef objects.
253
264
 
254
265
  * `--only-org ORG`:
255
- Only donwload/restore objects in the named organization. Global
266
+ Only download/restore objects in the named organization. Global
256
267
  objects such as users will still be downloaded/restored.
257
268
 
258
- ## knife ec key export [FILENAME]
269
+ ### knife ec key export [FILENAME]
259
270
 
260
271
  Create a json representation of the users table from the Chef Server
261
272
  database. If no argument is given, the name of the backup is
@@ -264,7 +275,7 @@ database. If no argument is given, the name of the backup is
264
275
  Please note, most users should use `knife ec backup` with the
265
276
  `--with-user-sql` option rather than this command.
266
277
 
267
- ## knife ec key import [FILENAME]
278
+ ### knife ec key import [FILENAME]
268
279
 
269
280
  Import a json representation of the users table from FILENAME to the
270
281
  the Chef Server database. If no argument is given, the filename is
@@ -273,7 +284,7 @@ assumed to be `key_dump.json`.
273
284
  Please note, most user should use `knife ec restore` with the
274
285
  `--with-user-sql` option rather than this command.
275
286
 
276
- # Known Bugs
287
+ ## Known Bugs
277
288
 
278
289
  - knife-ec-backup cannot be installed in the embedded gemset of Chef
279
290
  Server 12. This will be resolved in a future Chef Server release.
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'bundler'
2
- require 'rubygems'
2
+ require 'rubygems' unless defined?(Gem)
3
3
  require 'rubygems/package_task'
4
4
  require 'rdoc/task'
5
5
  require 'rspec/core/rake_task'
@@ -1,5 +1,5 @@
1
1
  require 'chef/knife'
2
- require 'chef/knife/ec_base'
2
+ require_relative 'ec_base'
3
3
 
4
4
  class Chef
5
5
  class Knife
@@ -14,8 +14,8 @@ class Chef
14
14
  require 'chef/chef_fs/file_system'
15
15
  require 'chef/chef_fs/file_pattern'
16
16
  require 'chef/chef_fs/parallelizer'
17
- require 'chef/server'
18
- require 'fileutils'
17
+ require_relative '../server'
18
+ require 'fileutils' unless defined?(FileUtils)
19
19
  end
20
20
 
21
21
  def run
@@ -96,10 +96,10 @@ class Chef
96
96
  knife_ec_error_handler.add(ex)
97
97
  next
98
98
  end
99
- # Enterprise Chef 11 and below uses a pool of precreated
99
+ # Enterprise Chef 11 and below uses a pool of pre-created
100
100
  # organizations to account for slow organization creation
101
101
  # using CouchDB. Thus, on server versions < 12 we want to
102
- # skip any of these precreated organizations by checking if
102
+ # skip any of these pre-created organizations by checking if
103
103
  # they have been assigned or not. The Chef 12 API does not
104
104
  # return an assigned_at field.
105
105
  if org['assigned_at'] || server.version >= Gem::Version.new("12")
@@ -127,12 +127,13 @@ class Chef
127
127
  end
128
128
 
129
129
  def export_from_sql
130
- require 'chef/knife/ec_key_export'
130
+ require_relative 'ec_key_export'
131
131
  Chef::Knife::EcKeyExport.deps
132
132
  k = Chef::Knife::EcKeyExport.new
133
133
  k.name_args = ["#{dest_dir}/key_dump.json", "#{dest_dir}/key_table_dump.json"]
134
134
  k.config[:sql_host] = config[:sql_host]
135
135
  k.config[:sql_port] = config[:sql_port]
136
+ k.config[:sql_db] = config[:sql_db]
136
137
  k.config[:sql_user] = config[:sql_user]
137
138
  k.config[:sql_password] = config[:sql_password]
138
139
  k.config[:skip_users_table] = !config[:with_user_sql]
@@ -19,8 +19,8 @@
19
19
  require 'chef/knife'
20
20
  require 'chef/server_api'
21
21
  require 'veil'
22
- require 'chef/knife/ec_error_handler'
23
- require 'ffi_yajl'
22
+ require_relative 'ec_error_handler'
23
+ require 'ffi_yajl' unless defined?(FFI_Yajl)
24
24
 
25
25
  class Chef
26
26
  class Knife
@@ -31,6 +31,10 @@ class Chef
31
31
  def self.included(includer)
32
32
  includer.class_eval do
33
33
 
34
+ option :error_log_dir,
35
+ :long => '--error-log-dir PATH',
36
+ :description => 'Path to a directory where any errors will be logged'
37
+
34
38
  option :concurrency,
35
39
  :long => '--concurrency THREADS',
36
40
  :description => 'Maximum number of simultaneous requests to send (default: 10)'
@@ -70,6 +74,11 @@ class Chef
70
74
  :description => 'Postgresql database port (default: 5432)',
71
75
  :default => 5432
72
76
 
77
+ option :sql_db,
78
+ :long => '--sql-db DBNAME',
79
+ :description => 'Postgresql Chef Server database name (default: opscode_chef)',
80
+ :default => "opscode_chef"
81
+
73
82
  option :sql_user,
74
83
  :long => "--sql-user USERNAME",
75
84
  :description => 'User used to connect to the postgresql database.'
@@ -155,7 +164,8 @@ class Chef
155
164
  end
156
165
 
157
166
  def knife_ec_error_handler
158
- @knife_ec_error_handler ||= Chef::Knife::EcErrorHandler.new(dest_dir, self.class)
167
+ error_dir = config[:error_log_dir] || dest_dir
168
+ @knife_ec_error_handler ||= Chef::Knife::EcErrorHandler.new(error_dir, self.class)
159
169
  end
160
170
 
161
171
  def user_acl_rest
@@ -27,7 +27,7 @@ class Chef
27
27
 
28
28
  deps do
29
29
  require 'sequel'
30
- require 'json'
30
+ require 'json' unless defined?(JSON)
31
31
  end
32
32
 
33
33
  option :sql_host,
@@ -40,6 +40,11 @@ class Chef
40
40
  :description => 'Postgresql database port (default: 5432)',
41
41
  :default => 5432
42
42
 
43
+ option :sql_db,
44
+ :long => '--sql-db DBNAME',
45
+ :description => 'Postgresql Chef Server database name (default: opscode_chef)',
46
+ :default => "opscode_chef"
47
+
43
48
  option :sql_user,
44
49
  :long => "--sql-user USERNAME",
45
50
  :description => 'User used to connect to the postgresql database.'
@@ -68,7 +73,7 @@ class Chef
68
73
  def db
69
74
  @db ||= begin
70
75
  require 'sequel'
71
- server_string = "#{config[:sql_user]}:#{config[:sql_password]}@#{config[:sql_host]}:#{config[:sql_port]}/opscode_chef"
76
+ server_string = "#{config[:sql_user]}:#{config[:sql_password]}@#{config[:sql_host]}:#{config[:sql_port]}/#{config[:sql_db]}"
72
77
  ::Sequel.connect("postgres://#{server_string}", :convert_infinite_timestamps => :string)
73
78
  end
74
79
  end
@@ -17,7 +17,7 @@
17
17
  #
18
18
 
19
19
  require 'chef/knife'
20
- require 'chef/knife/ec_key_base'
20
+ require_relative 'ec_key_base'
21
21
 
22
22
  class Chef
23
23
  class Knife
@@ -17,8 +17,8 @@
17
17
  #
18
18
 
19
19
  require 'chef/knife'
20
- require 'chef/knife/ec_key_base'
21
- require 'chef/org_id_cache'
20
+ require_relative 'ec_key_base'
21
+ require_relative '../org_id_cache'
22
22
 
23
23
  class Chef
24
24
  class Knife
@@ -38,7 +38,7 @@ class Chef
38
38
  :long => "--[no-]skip-user-ids",
39
39
  :default => true,
40
40
  :boolean => true,
41
- :description => "Upload user ids."
41
+ :description => "Reuses user ids from the restore destination when updating existing users to avoid database conflicts."
42
42
 
43
43
  option :users_only,
44
44
  :long => "--users-only",
@@ -184,7 +184,7 @@ class Chef
184
184
  d.delete('id') if config[:skip_ids]
185
185
  # If the hash_type in the export,
186
186
  # we are dealing with a record where the password is still in the
187
- # serialized_obejct. Explictly setting these to nil ensures that the
187
+ # serialized_object. Explicitly setting these to nil ensures that the
188
188
  # password set in the restore is wiped out.
189
189
  unless d.has_key?('hash_type')
190
190
  d['hash_type'] = nil
@@ -1,5 +1,5 @@
1
1
  require 'chef/knife'
2
- require 'chef/knife/ec_base'
2
+ require_relative 'ec_base'
3
3
 
4
4
  class Chef
5
5
  class Knife
@@ -19,6 +19,12 @@ class Chef
19
19
  :long => "--skip-users",
20
20
  :description => "Skip restoring users"
21
21
 
22
+ option :skip_ids,
23
+ :long => "--[no-]skip-user-ids",
24
+ :default => true,
25
+ :boolean => true,
26
+ :description => "Reuses user ids from the restore destination when updating existing users to avoid database conflicts."
27
+
22
28
  deps do
23
29
  require 'chef/json_compat'
24
30
  require 'chef/chef_fs/config'
@@ -27,10 +33,10 @@ class Chef
27
33
  # Work around bug in chef_fs
28
34
  require 'chef/chef_fs/command_line'
29
35
  require 'chef/chef_fs/data_handler/acl_data_handler'
30
- require 'securerandom'
36
+ require 'securerandom' unless defined?(SecureRandom)
31
37
  require 'chef/chef_fs/parallelizer'
32
- require 'chef/tsorter'
33
- require 'chef/server'
38
+ require_relative '../tsorter'
39
+ require_relative '../server'
34
40
  end
35
41
 
36
42
  def run
@@ -173,13 +179,14 @@ class Chef
173
179
 
174
180
  def ec_key_import
175
181
  @ec_key_import ||= begin
176
- require 'chef/knife/ec_key_import'
182
+ require_relative 'ec_key_import'
177
183
  k = Chef::Knife::EcKeyImport.new
178
184
  k.name_args = ["#{dest_dir}/key_dump.json", "#{dest_dir}/key_table_dump.json"]
179
185
  k.config[:skip_pivotal] = true
180
- k.config[:skip_ids] = false
186
+ k.config[:skip_ids] = config[:skip_ids]
181
187
  k.config[:sql_host] = config[:sql_host]
182
188
  k.config[:sql_port] = config[:sql_port]
189
+ k.config[:sql_db] = config[:sql_db]
183
190
  k.config[:sql_user] = config[:sql_user]
184
191
  k.config[:sql_password] = config[:sql_password]
185
192
  k
@@ -222,7 +229,7 @@ class Chef
222
229
  ui.msg "Restoring org admin data"
223
230
  chef_fs_config = Chef::ChefFS::Config.new
224
231
 
225
- # Handle Admins, Billing Admins and Public Key Read Access seperately
232
+ # Handle Admins, Billing Admins and Public Key Read Access separately
226
233
  #
227
234
  # admins: We need to upload admins first so that we
228
235
  # can upload all of the other objects as a user in the org
@@ -1,5 +1,5 @@
1
- require 'uri'
2
- require 'openssl'
1
+ require 'uri' unless defined?(URI)
2
+ require 'openssl' unless defined?(OpenSSL)
3
3
  require 'chef/server_api'
4
4
 
5
5
  class Chef
@@ -23,8 +23,7 @@ class Chef
23
23
 
24
24
  def version
25
25
  @version ||= begin
26
- uri = URI.parse("#{root_url}/version")
27
- ver_line = open(uri, {ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE}).each_line.first
26
+ ver_line = Chef::ServerAPI.new(root_url).get('version').each_line.first
28
27
  parse_server_version(ver_line)
29
28
  end
30
29
  end
@@ -1,3 +1,4 @@
1
+ # when you change this to double quotes, also update .expeditor/update_version.sh
1
2
  module KnifeECBackup
2
- VERSION = '2.3.0'
3
+ VERSION = '2.4.12'
3
4
  end
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_hel
2
2
  require 'chef/knife/ec_base'
3
3
  require 'chef/knife'
4
4
  require 'chef/config'
5
- require 'stringio'
5
+ require 'stringio' unless defined?(StringIO)
6
6
 
7
7
  class Tester < Chef::Knife
8
8
  include Chef::Knife::EcBase
@@ -6,7 +6,7 @@ class KeyBaseTester < Chef::Knife
6
6
  end
7
7
 
8
8
  describe Chef::Knife::EcKeyBase do
9
- let (:knife) { Chef::Knife::KeyBaseTester.new }
9
+ let (:knife) { KeyBaseTester.new }
10
10
 
11
11
  let(:running_server_postgresql_sql_config_json) {
12
12
  '{"private_chef": { "opscode-erchef":{}, "postgresql": { "sql_user": "jiminy", "sql_password": "secret"} }, "postgresql": { "sql_user": "jiminy", "sql_password": "secret"} }'
@@ -35,4 +35,3 @@ describe Chef::Knife::EcKeyBase do
35
35
  end
36
36
  end
37
37
  end
38
-
@@ -1,8 +1,8 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
2
2
  require 'chef/knife/ec_key_export'
3
3
  require 'sequel'
4
- require 'json'
5
- require 'securerandom'
4
+ require 'json' unless defined?(JSON)
5
+ require 'securerandom' unless defined?(SecureRandom)
6
6
  require 'fakefs/spec_helpers'
7
7
 
8
8
  def user_record(name)
@@ -58,7 +58,7 @@ describe Chef::Knife::EcRestore do
58
58
  @knife.restore_open_invitations("foo")
59
59
  end
60
60
 
61
- it "does NOT fail if an inivitation already exists" do
61
+ it "does NOT fail if an invitation already exists" do
62
62
  make_org "foo"
63
63
  allow(@rest).to receive(:post).with("organizations/foo/association_requests", {"user" => "bob"}).and_return(net_exception(409))
64
64
  allow(@rest).to receive(:post).with("organizations/foo/association_requests", {"user" => "jane"}).and_return(net_exception(409))
@@ -1,65 +1,70 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper"))
2
2
  require 'chef/server'
3
3
  require 'chef/server_api'
4
- require 'stringio'
4
+ require 'stringio' unless defined?(StringIO)
5
5
 
6
6
  describe Chef::Server do
7
+ before(:each) do
8
+ @rest = double('rest')
9
+ allow(Chef::ServerAPI).to receive(:new).and_return(@rest)
10
+ end
7
11
 
8
12
  it "infers root url from a Chef Server url" do
9
13
  s = Chef::Server.from_chef_server_url("http://api.example.com/organizations/foobar")
10
14
  expect(s.root_url).to eq("http://api.example.com")
11
15
  end
12
16
 
13
- it "determines the running habitat service pkg version" do
17
+ it "determines the running habitat service dockerized pkg version" do
14
18
  s = Chef::Server.new('http://api.example.com')
15
- allow(s).to receive(:open).and_return(StringIO.new("Package: chef-server/chef-server-nginx/12.17.42/20180413212943\nother stuff\nother stuff"))
19
+ allow(@rest).to receive(:get).with("version").and_return(StringIO.new("Package: chef-server/chef-server-nginx/12.17.42/20180413212943\nother stuff\nother stuff"))
16
20
  expect(s.version.to_s).to eq('12.17.42')
17
21
  end
18
22
 
23
+ it "determines the running Automate CS API habitat service pkg version" do
24
+ s = Chef::Server.new('http://api.example.com')
25
+ allow(@rest).to receive(:get).with("version").and_return(StringIO.new("Package: chef/automate-cs-nginx/12.19.31/20190529200833\nHabitat: 0.69.0/20181127183841\nMember: f73decd1025f4a5aa728b4429c297ef1 / ip-10-1-1-200.us-west-1.compute.internal"))
26
+ expect(s.version.to_s).to eq('12.19.31')
27
+ end
28
+
19
29
  it "determines the running omnibus server version" do
20
30
  s = Chef::Server.new('http://api.example.com')
21
- allow(s).to receive(:open).and_return(StringIO.new("Chef Server 1.8.1\nother stuff\nother stuff"))
31
+ allow(@rest).to receive(:get).with("version").and_return(StringIO.new("Chef Server 1.8.1\nother stuff\nother stuff"))
22
32
  expect(s.version.to_s).to eq('1.8.1')
23
33
  end
24
34
 
25
35
  it "ignores git tags when determining the version" do
26
36
  s = Chef::Server.new("http://api.example.com")
27
- allow(s).to receive(:open).and_return(StringIO.new("Chef Server 1.8.1+20141024080718.git.16.08098a5\nother stuff\nother stuff"))
37
+ allow(@rest).to receive(:get).with("version").and_return(StringIO.new("Chef Server 1.8.1+20141024080718.git.16.08098a5\nother stuff\nother stuff"))
28
38
  expect(s.version.to_s).to eq("1.8.1")
29
39
  end
30
40
 
31
41
  it "knows whether the server supports user ACLs via nginx" do
32
42
  s1 = Chef::Server.new("http://api.example.com")
33
- s2 = Chef::Server.new("http://api.example.com")
34
- allow(s1).to receive(:open).and_return(StringIO.new("Chef Server 11.0.0\nother stuff\nother stuff"))
35
- allow(s2).to receive(:open).and_return(StringIO.new("Chef Server 11.0.2\nother stuff\nother stuff"))
36
-
43
+ allow(@rest).to receive(:get).with("version").and_return(StringIO.new("Chef Server 11.0.0\nother stuff\nother stuff"))
37
44
  expect(s1.supports_user_acls?).to eq(false)
45
+ s2 = Chef::Server.new("http://api.example.com")
46
+ allow(@rest).to receive(:get).with("version").and_return(StringIO.new("Chef Server 11.0.2\nother stuff\nother stuff"))
38
47
  expect(s2.supports_user_acls?).to eq(true)
39
48
  end
40
49
 
41
50
  it "knows when account is directly accessible" do
42
51
  s = Chef::Server.new("http://api.example.com")
43
- rest = double('rest')
44
- allow(Chef::ServerAPI).to receive(:new).and_return(rest)
45
- allow(rest).to receive(:get).and_return("")
52
+ allow(@rest).to receive(:get).and_return("")
46
53
  expect(s.direct_account_access?).to eq(true)
47
54
  end
48
55
 
49
56
  it "knows when account is not directly accessible" do
50
57
  s = Chef::Server.new("http://api.example.com")
51
- rest = double('rest')
52
- allow(Chef::ServerAPI).to receive(:new).and_return(rest)
53
- allow(rest).to receive(:get).and_raise(Errno::ECONNREFUSED)
58
+ allow(@rest).to receive(:get).and_raise(Errno::ECONNREFUSED)
54
59
  expect(s.direct_account_access?).to eq(false)
55
60
  end
56
61
 
57
62
  it "knows that public_key_read_access was implemented in 12.5.0" do
58
63
  before = Chef::Server.new("http://api.example.com")
59
- allow(before).to receive(:open).and_return(StringIO.new("Chef Server 12.4.1\nother stuff\nother stuff"))
64
+ allow(@rest).to receive(:get).with("version").and_return(StringIO.new("Chef Server 12.4.1\nother stuff\nother stuff"))
60
65
  expect(before.supports_public_key_read_access?).to eq(false)
61
66
  after = Chef::Server.new("http://api.example.com")
62
- allow(after).to receive(:open).and_return(StringIO.new("Chef Server 12.6.0\nother stuff\nother stuff"))
67
+ allow(@rest).to receive(:get).with("version").and_return(StringIO.new("Chef Server 12.6.0\nother stuff\nother stuff"))
63
68
  expect(after.supports_public_key_read_access?).to eq(true)
64
69
  end
65
70
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-ec-backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Keiser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-18 00:00:00.000000000 Z
11
+ date: 2020-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: knife-tidy
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: Backup and Restore of Enterprise Chef
70
84
  email: jkeiser@chef.io
71
85
  executables: []
@@ -117,8 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
131
  - !ruby/object:Gem::Version
118
132
  version: '0'
119
133
  requirements: []
120
- rubyforge_project:
121
- rubygems_version: 2.7.6
134
+ rubygems_version: 3.0.3
122
135
  signing_key:
123
136
  specification_version: 4
124
137
  summary: Backup and Restore of Enterprise Chef