diff options
Diffstat (limited to 'spec/unit/api_client/registration_spec.rb')
-rw-r--r-- | spec/unit/api_client/registration_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/unit/api_client/registration_spec.rb b/spec/unit/api_client/registration_spec.rb index 55348ec8ee..d6230afb6a 100644 --- a/spec/unit/api_client/registration_spec.rb +++ b/spec/unit/api_client/registration_spec.rb @@ -209,6 +209,28 @@ describe Chef::ApiClient::Registration do registration.write_key expect(IO.read(key_location)).to eq("--begin rsa key etc--") end + + context 'when the client key location is a symlink' do + it 'does not follow the symlink', :unix_only do + expected_flags = (File::CREAT|File::TRUNC|File::RDWR) + + if defined?(File::NOFOLLOW) + expected_flags |= File::NOFOLLOW + end + + expect(registration.file_flags).to eq(expected_flags) + end + + context 'with follow_client_key_symlink set to true' do + before do + Chef::Config[:follow_client_key_symlink] = true + end + + it 'follows the symlink', :unix_only do + expect(registration.file_flags).to eq(File::CREAT|File::TRUNC|File::RDWR) + end + end + end end describe "when registering a client" do |