diff options
author | John McCrae <john.mccrae@progress.com> | 2022-04-18 08:13:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-18 08:13:34 -0700 |
commit | 749bd65c5243be61b16a52767515fa464eaa7131 (patch) | |
tree | 9b70b1e0e7fa5d0873b7c5a86c35ac8b142ccc70 | |
parent | 5781d1fcc9f5c11aace78c3658b53eaa73de4e2e (diff) | |
parent | ff462b24c7b2fab69d368488941c8aaccc16cfc0 (diff) | |
download | chef-749bd65c5243be61b16a52767515fa464eaa7131.tar.gz |
Merge branch 'chef-17' into jfm/client_pem_update_chef17jfm/client_pem_update_chef17
-rw-r--r-- | CHANGELOG.md | 7 | ||||
-rw-r--r-- | Gemfile.lock | 16 | ||||
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | chef-bin/lib/chef-bin/version.rb | 2 | ||||
-rw-r--r-- | chef-config/lib/chef-config/version.rb | 2 | ||||
-rw-r--r-- | chef-utils/lib/chef-utils/version.rb | 2 | ||||
-rw-r--r-- | knife/lib/chef/knife/user_create.rb | 8 | ||||
-rw-r--r-- | knife/lib/chef/knife/version.rb | 2 | ||||
-rw-r--r-- | knife/spec/unit/knife/user_create_spec.rb | 42 | ||||
-rw-r--r-- | lib/chef/version.rb | 2 |
10 files changed, 57 insertions, 28 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index c16735c221..d6c62a2e02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,17 +1,18 @@ <!-- usage documentation: http://expeditor-docs.es.chef.io/configuration/changelog/ --> This changelog lists individual merged pull requests to Chef Infra Client and geared towards developers. For a list of significant changes per release see the [Chef Infra Client Release Notes](https://docs.chef.io/release_notes_client/). -<!-- latest_release 17.10.8 --> -## [v17.10.8](https://github.com/chef/chef/tree/v17.10.8) (2022-04-07) +<!-- latest_release 17.10.9 --> +## [v17.10.9](https://github.com/chef/chef/tree/v17.10.9) (2022-04-12) #### Merged Pull Requests -- pin libxml2 to 2.9.13 and libxslt to 1.1.34 on windows [#12768](https://github.com/chef/chef/pull/12768) ([jayashrig158](https://github.com/jayashrig158)) +- Fix pem generation when user created [#12772](https://github.com/chef/chef/pull/12772) ([sanjain-progress](https://github.com/sanjain-progress)) <!-- latest_release --> <!-- release_rollup since=17.10.0 --> ### Changes not yet released to stable #### Merged Pull Requests +- Fix pem generation when user created [#12772](https://github.com/chef/chef/pull/12772) ([sanjain-progress](https://github.com/sanjain-progress)) <!-- 17.10.9 --> - pin libxml2 to 2.9.13 and libxslt to 1.1.34 on windows [#12768](https://github.com/chef/chef/pull/12768) ([jayashrig158](https://github.com/jayashrig158)) <!-- 17.10.8 --> - Fix attribute performance issues in node.read (Chef-17) [#12743](https://github.com/chef/chef/pull/12743) ([lamont-granquist](https://github.com/lamont-granquist)) <!-- 17.10.7 --> - Updating Gemfile.locks to corroborate the libxml2 version update [#12741](https://github.com/chef/chef/pull/12741) ([johnmccrae](https://github.com/johnmccrae)) <!-- 17.10.6 --> diff --git a/Gemfile.lock b/Gemfile.lock index c76649a4c6..8847004a74 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -35,12 +35,12 @@ GIT PATH remote: . specs: - chef (17.10.8) + chef (17.10.9) addressable aws-sdk-s3 (~> 1.91) aws-sdk-secretsmanager (~> 1.46) - chef-config (= 17.10.8) - chef-utils (= 17.10.8) + chef-config (= 17.10.9) + chef-utils (= 17.10.9) chef-vault chef-zero (>= 14.0.11) corefoundation (~> 0.3.4) @@ -70,15 +70,15 @@ PATH PATH remote: chef-bin specs: - chef-bin (17.10.8) - chef (= 17.10.8) + chef-bin (17.10.9) + chef (= 17.10.9) PATH remote: chef-config specs: - chef-config (17.10.8) + chef-config (17.10.9) addressable - chef-utils (= 17.10.8) + chef-utils (= 17.10.9) fuzzyurl mixlib-config (>= 2.2.12, < 4.0) mixlib-shellout (>= 2.0, < 4.0) @@ -87,7 +87,7 @@ PATH PATH remote: chef-utils specs: - chef-utils (17.10.8) + chef-utils (17.10.9) concurrent-ruby GEM @@ -1 +1 @@ -17.10.8
\ No newline at end of file +17.10.9
\ No newline at end of file diff --git a/chef-bin/lib/chef-bin/version.rb b/chef-bin/lib/chef-bin/version.rb index 1393e05678..8df91dea59 100644 --- a/chef-bin/lib/chef-bin/version.rb +++ b/chef-bin/lib/chef-bin/version.rb @@ -21,7 +21,7 @@ module ChefBin CHEFBIN_ROOT = File.expand_path("..", __dir__) - VERSION = "17.10.8".freeze + VERSION = "17.10.9".freeze end # diff --git a/chef-config/lib/chef-config/version.rb b/chef-config/lib/chef-config/version.rb index 9d7900abda..6f29fc8321 100644 --- a/chef-config/lib/chef-config/version.rb +++ b/chef-config/lib/chef-config/version.rb @@ -15,5 +15,5 @@ module ChefConfig CHEFCONFIG_ROOT = File.expand_path("..", __dir__) - VERSION = "17.10.8".freeze + VERSION = "17.10.9".freeze end diff --git a/chef-utils/lib/chef-utils/version.rb b/chef-utils/lib/chef-utils/version.rb index 25219a72ad..3de2cbdcc1 100644 --- a/chef-utils/lib/chef-utils/version.rb +++ b/chef-utils/lib/chef-utils/version.rb @@ -16,5 +16,5 @@ module ChefUtils CHEFUTILS_ROOT = File.expand_path("..", __dir__) - VERSION = "17.10.8" + VERSION = "17.10.9" end diff --git a/knife/lib/chef/knife/user_create.rb b/knife/lib/chef/knife/user_create.rb index 009f193d46..158e8d11cd 100644 --- a/knife/lib/chef/knife/user_create.rb +++ b/knife/lib/chef/knife/user_create.rb @@ -128,6 +128,7 @@ class Chef display_name: "#{user.first_name} #{user.last_name}", email: user.email, password: password, + create_key: user.create_key, } else user_hash = { @@ -137,6 +138,7 @@ class Chef display_name: user.display_name, email: user.email, password: password, + create_key: user.create_key, } end @@ -159,13 +161,13 @@ class Chef end ui.info("Created #{user.username}") - if final_user["private_key"] + if final_user["chef_key"] && final_user["chef_key"]["private_key"] if config[:file] File.open(config[:file], "w") do |f| - f.print(final_user["private_key"]) + f.print(final_user["chef_key"]["private_key"]) end else - ui.msg final_user["private_key"] + ui.msg final_user["chef_key"]["private_key"] end end end diff --git a/knife/lib/chef/knife/version.rb b/knife/lib/chef/knife/version.rb index aef8645c05..012c8e2074 100644 --- a/knife/lib/chef/knife/version.rb +++ b/knife/lib/chef/knife/version.rb @@ -17,7 +17,7 @@ class Chef class Knife KNIFE_ROOT = File.expand_path("../..", __dir__) - VERSION = "17.10.8".freeze + VERSION = "17.10.9".freeze end end diff --git a/knife/spec/unit/knife/user_create_spec.rb b/knife/spec/unit/knife/user_create_spec.rb index 1257d92ee9..32a3448205 100644 --- a/knife/spec/unit/knife/user_create_spec.rb +++ b/knife/spec/unit/knife/user_create_spec.rb @@ -16,7 +16,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - require "knife_spec_helper" Chef::Knife::UserCreate.load_deps @@ -80,7 +79,7 @@ describe Chef::Knife::UserCreate do before :each do @user = double("Chef::User") @key = "You don't come into cooking to get rich - Ramsay" - allow(@user).to receive(:[]).with("private_key").and_return(@key) + allow(@user).to receive(:[]).with("chef_key").and_return(@key) knife.config[:passwordprompt] = true knife.name_args = name_args end @@ -97,7 +96,7 @@ describe Chef::Knife::UserCreate do before do @user = double("Chef::User") @key = "You don't come into cooking to get rich - Ramsay" - allow(@user).to receive(:[]).with("private_key").and_return(@key) + allow(@user).to receive(:[]).with("chef_key").and_return(@key) knife.name_args = %w{some_user some_display_name some_first_name some_last_name some_email some_password} end @@ -177,17 +176,39 @@ describe Chef::Knife::UserCreate do describe "with user_name, first_name, last_name, email and password" do let(:name_args) { %w{some_user some_display_name some_first_name some_last_name test@email.com some_password} } + before :each do + @user = double("Chef::User") + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(root_rest) + expect(root_rest).to receive(:post).and_return(@user) + @key = IO.read(File.join(CHEF_SPEC_DATA, "ssl", "private_key.pem")) + allow(@user).to receive(:[]).with("chef_key").and_return(nil) + knife.name_args = name_args + end + + it "creates an user without private key" do + expect(knife.ui).to_not receive(:msg).with(@key) + knife.run + end + end + describe "with user_name, first_name, last_name, email and password" do + let(:name_args) { %w{some_user some_display_name some_first_name some_last_name test@email.com some_password} } before :each do @user = double("Chef::User") expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(root_rest) expect(root_rest).to receive(:post).and_return(@user) - @key = "You don't come into cooking to get rich - Ramsay" - allow(@user).to receive(:[]).with("private_key").and_return(@key) + @username = "Created #{name_args.first}" + @key = IO.read(File.join(CHEF_SPEC_DATA, "ssl", "private_key.pem")) + allow(@user).to receive(:[]).with("chef_key").and_return("private_key" => @key) knife.name_args = name_args end it "creates an user" do + expect(knife.ui).to receive(:info).with(@username) + knife.run + end + + it "creates an user private key" do expect(knife.ui).to receive(:msg).with(@key) knife.run end @@ -204,7 +225,6 @@ describe Chef::Knife::UserCreate do } it "creates an user, associates a user, and adds it to the admins group" do - expect(root_rest).to receive(:post).with("organizations/ramsay/association_requests", request_body).and_return(@user) expect(root_rest).to receive(:put).with("users/some_user/association_requests/1", { response: "accept" }) knife.run @@ -219,14 +239,20 @@ describe Chef::Knife::UserCreate do @user = double("Chef::User") expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(root_rest) expect(root_rest).to receive(:post).and_return(@user) - @key = "You don't come into cooking to get rich - Ramsay" - allow(@user).to receive(:[]).with("private_key").and_return(@key) + @username = "Created #{name_args.first}" + @key = IO.read(File.join(CHEF_SPEC_DATA, "ssl", "private_key.pem")) + allow(@user).to receive(:[]).with("chef_key").and_return("private_key" => @key) knife.name_args = name_args knife.config[:email] = "test@email.com" knife.config[:password] = "some_password" end it "creates an user" do + expect(knife.ui).to receive(:info).with(@username) + knife.run + end + + it "creates an user private key" do expect(knife.ui).to receive(:msg).with(@key) knife.run end diff --git a/lib/chef/version.rb b/lib/chef/version.rb index 4937b2ba18..df0faaed59 100644 --- a/lib/chef/version.rb +++ b/lib/chef/version.rb @@ -23,7 +23,7 @@ require_relative "version_string" class Chef CHEF_ROOT = File.expand_path("..", __dir__) - VERSION = Chef::VersionString.new("17.10.8") + VERSION = Chef::VersionString.new("17.10.9") end # |