summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--DOC_CHANGES.md9
-rw-r--r--MAINTAINERS.toml6
-rw-r--r--lib/chef/application/windows_service.rb14
-rw-r--r--lib/chef/knife/core/node_presenter.rb2
-rw-r--r--lib/chef/node.rb8
-rw-r--r--lib/chef/provider/package/solaris.rb2
-rw-r--r--lib/chef/provider/package/yum.rb14
-rw-r--r--lib/chef/provider/remote_file/cache_control_data.rb41
-rw-r--r--lib/chef/provider/script.rb1
-rw-r--r--lib/chef/recipe.rb8
-rw-r--r--lib/chef/resource/ksh.rb32
-rw-r--r--lib/chef/resources.rb1
-rw-r--r--spec/unit/node_spec.rb2
-rw-r--r--spec/unit/provider/package/yum_spec.rb6
-rw-r--r--spec/unit/provider/remote_file/cache_control_data_spec.rb98
-rw-r--r--spec/unit/recipe_spec.rb18
-rw-r--r--spec/unit/resource/chef_gem_spec.rb2
-rw-r--r--spec/unit/resource/ksh_spec.rb40
-rw-r--r--spec/unit/windows_service_spec.rb7
19 files changed, 237 insertions, 74 deletions
diff --git a/DOC_CHANGES.md b/DOC_CHANGES.md
index 003fb84a54..b2e2c3d117 100644
--- a/DOC_CHANGES.md
+++ b/DOC_CHANGES.md
@@ -8,6 +8,8 @@ Description of the required change.
### `chef_version` and `ohai_version`
+see: https://docs.chef.io/release/12-6/release_notes.html#new-metadata-rb-settings
+
The metadata.rb DSL is extended to support `chef_version` and `ohai_version` to establish ranges
of chef and ohai versions that the cookbook supports.
@@ -47,3 +49,10 @@ There is currently no support in supermarket for making this metadata visible in
depsolvers, or support in Berksfile/PolicyFile for automatically pruning cookbooks that fail
to match.
+### `chocolatey_package` and `ksh` resources
+
+Assuming both of those make 12.6, placeholder pages:
+
+chocolatey_package: https://docs.chef.io/release/12-6/resource_chocolatey_package.html
+
+ksh: https://docs.chef.io/release/12-6/resource_ksh.html
diff --git a/MAINTAINERS.toml b/MAINTAINERS.toml
index 12eb536fa3..e2548d37b8 100644
--- a/MAINTAINERS.toml
+++ b/MAINTAINERS.toml
@@ -194,7 +194,7 @@ The specific components of Chef related to a given platform - including (but not
maintainers = [
"Aevin1387",
"tBunnyMan",
- "agentmeerkat"
+ "AgentMeerkat"
]
[Org.Components.Subsystems.OpenBSD]
@@ -237,9 +237,9 @@ The specific components of Chef related to a given platform - including (but not
Name = "Cory Stephenson"
GitHub = "Aevin1387"
- [people.agentmeerkat]
+ [people.AgentMeerkat]
Name = "Bryant Lippert"
- GitHub = "agentmeerkat"
+ GitHub = "AgentMeerkat"
[people.btm]
Name = "Bryan McLellan"
diff --git a/lib/chef/application/windows_service.rb b/lib/chef/application/windows_service.rb
index 932f7e9c36..2f938059ca 100644
--- a/lib/chef/application/windows_service.rb
+++ b/lib/chef/application/windows_service.rb
@@ -188,7 +188,11 @@ class Chef
# Pass config params to the new process
config_params = " --no-fork"
config_params += " -c #{Chef::Config[:config_file]}" unless Chef::Config[:config_file].nil?
- config_params += " -L #{resolve_log_location}" unless Chef::Config[:log_location] == STDOUT
+ # log_location might be an event logger and if so we cannot pass as a command argument
+ # but shed no tears! If the logger is an event logger, it must have been configured
+ # as such in the config file and chef-client will use that when no arg is passed here
+ config_params += " -L #{resolve_log_location}" if resolve_log_location.is_a?(String)
+
# Starts a new process and waits till the process exits
result = shell_out(
@@ -266,13 +270,9 @@ class Chef
Chef::Config[:log_level] == :auto
end
- # Check if we have a log location and it's not STDOUT
def resolve_log_location
- if Chef::Config[:log_location] && Chef::Config[:log_location].is_a?(String)
- Chef::Config[:log_location]
- else
- DEFAULT_LOG_LOCATION
- end
+ # STDOUT is the default log location, but makes no sense for a windows service
+ Chef::Config[:log_location] == STDOUT ? DEFAULT_LOG_LOCATION : Chef::Config[:log_location]
end
# if log_level is `:auto`, convert it to :warn (when using output formatter)
diff --git a/lib/chef/knife/core/node_presenter.rb b/lib/chef/knife/core/node_presenter.rb
index d9ea8c7669..5192c53f51 100644
--- a/lib/chef/knife/core/node_presenter.rb
+++ b/lib/chef/knife/core/node_presenter.rb
@@ -125,7 +125,7 @@ ROLES
summarized << <<-SUMMARY
#{key('Recipes:')} #{Array(node[:recipes]).join(', ')}
#{key('Platform:')} #{node[:platform]} #{node[:platform_version]}
-#{key('Tags:')} #{Array(node[:tags]).join(', ')}
+#{key('Tags:')} #{node.tags.join(', ')}
SUMMARY
if config[:medium_output] || config[:long_output]
summarized +=<<-MORE
diff --git a/lib/chef/node.rb b/lib/chef/node.rb
index 83ec7e2550..b04e607624 100644
--- a/lib/chef/node.rb
+++ b/lib/chef/node.rb
@@ -376,12 +376,12 @@ class Chef
normal[:tags]
end
- def tag(*tags)
- tags.each do |tag|
- self.normal[:tags].push(tag.to_s) unless self[:tags].include? tag.to_s
+ def tag(*args)
+ args.each do |tag|
+ tags.push(tag.to_s) unless tags.include? tag.to_s
end
- self[:tags]
+ tags
end
# Extracts the run list from +attrs+ and applies it. Returns the remaining attributes
diff --git a/lib/chef/provider/package/solaris.rb b/lib/chef/provider/package/solaris.rb
index e62f37d27b..c0d2beec36 100644
--- a/lib/chef/provider/package/solaris.rb
+++ b/lib/chef/provider/package/solaris.rb
@@ -125,6 +125,8 @@ class Chef
end
end
+ alias_method :upgrade_package, :install_package
+
def remove_package(name, version)
if @new_resource.options.nil?
shell_out_with_timeout!( "pkgrm -n #{name}" )
diff --git a/lib/chef/provider/package/yum.rb b/lib/chef/provider/package/yum.rb
index aff8dc9326..6258472a65 100644
--- a/lib/chef/provider/package/yum.rb
+++ b/lib/chef/provider/package/yum.rb
@@ -785,7 +785,7 @@ class Chef
def python_bin
yum_executable = which(yum_binary)
if yum_executable && shabang?(yum_executable)
- extract_interpreter(yum_executable)
+ shabang_or_fallback(extract_interpreter(yum_executable))
else
Chef::Log.warn("Yum executable not found or doesn't start with #!. Using default python.")
"/usr/bin/python"
@@ -797,7 +797,17 @@ class Chef
end
def extract_interpreter(file)
- ::File.open(file, 'r', &:readline)[2..-1].chomp
+ ::File.open(file, 'r', &:readline)[2..-1].strip
+ end
+
+ # dnf based systems have a yum shim that has /bin/bash as the interpreter. Don't use this.
+ def shabang_or_fallback(interpreter)
+ if interpreter == '/bin/bash'
+ Chef::Log.warn("Yum executable interpreter is /bin/bash. Falling back to default python.")
+ "/usr/bin/python"
+ else
+ interpreter
+ end
end
def shabang?(file)
diff --git a/lib/chef/provider/remote_file/cache_control_data.rb b/lib/chef/provider/remote_file/cache_control_data.rb
index f9b729362c..3f39dac625 100644
--- a/lib/chef/provider/remote_file/cache_control_data.rb
+++ b/lib/chef/provider/remote_file/cache_control_data.rb
@@ -145,18 +145,51 @@ class Chef
end
def load_json_data
- Chef::FileCache.load("remote_file/#{sanitized_cache_file_basename}")
+ path = sanitized_cache_file_path(sanitized_cache_file_basename)
+ if Chef::FileCache.has_key?(path)
+ Chef::FileCache.load(path)
+ else
+ old_path = sanitized_cache_file_path(sanitized_cache_file_basename_md5)
+ if Chef::FileCache.has_key?(old_path)
+ # We found an old cache control data file. We started using sha256 instead of md5
+ # to name these. Upgrade the file to the new name.
+ Chef::Log.debug("Found old cache control data file at #{old_path}. Moving to #{path}.")
+ Chef::FileCache.load(old_path).tap do |data|
+ Chef::FileCache.store(path, data)
+ Chef::FileCache.delete(old_path)
+ end
+ else
+ raise Chef::Exceptions::FileNotFound
+ end
+ end
end
- def sanitized_cache_file_basename
+ def sanitized_cache_file_path(basename)
+ "remote_file/#{basename}"
+ end
+
+ def scrubbed_uri
# Scrub and truncate in accordance with the goals of keeping the name
# human-readable but within the bounds of local file system
# path length limits
- scrubbed_uri = uri.gsub(/\W/, '_')[0..63]
+ uri.gsub(/\W/, '_')[0..63]
+ end
+
+ def sanitized_cache_file_basename
+ uri_sha2 = Chef::Digester.instance.generate_checksum(StringIO.new(uri))
+ cache_file_basename(uri_sha2[0,32])
+ end
+
+
+ def sanitized_cache_file_basename_md5
+ # Old way of creating the file basename
uri_md5 = Chef::Digester.instance.generate_md5_checksum(StringIO.new(uri))
- "#{scrubbed_uri}-#{uri_md5}.json"
+ cache_file_basename(uri_md5)
end
+ def cache_file_basename(checksum)
+ "#{scrubbed_uri}-#{checksum}.json"
+ end
end
end
end
diff --git a/lib/chef/provider/script.rb b/lib/chef/provider/script.rb
index e8b5235b7a..2f2001dbf9 100644
--- a/lib/chef/provider/script.rb
+++ b/lib/chef/provider/script.rb
@@ -27,6 +27,7 @@ class Chef
provides :bash
provides :csh
+ provides :ksh
provides :perl
provides :python
provides :ruby
diff --git a/lib/chef/recipe.rb b/lib/chef/recipe.rb
index 262560f754..0f9bf2655b 100644
--- a/lib/chef/recipe.rb
+++ b/lib/chef/recipe.rb
@@ -97,10 +97,8 @@ class Chef
# true<TrueClass>:: If all the parameters are present
# false<FalseClass>:: If any of the parameters are missing
def tagged?(*tags)
- return false if run_context.node[:tags].nil?
-
tags.each do |tag|
- return false unless run_context.node[:tags].include?(tag)
+ return false unless run_context.node.tags.include?(tag)
end
true
end
@@ -111,10 +109,10 @@ class Chef
# tags<Array>:: A list of tags
#
# === Returns
- # tags<Array>:: The current list of run_context.node[:tags]
+ # tags<Array>:: The current list of run_context.node.tags
def untag(*tags)
tags.each do |tag|
- run_context.node.normal[:tags].delete(tag)
+ run_context.node.tags.delete(tag)
end
end
diff --git a/lib/chef/resource/ksh.rb b/lib/chef/resource/ksh.rb
new file mode 100644
index 0000000000..b41b717f5f
--- /dev/null
+++ b/lib/chef/resource/ksh.rb
@@ -0,0 +1,32 @@
+#
+# Author:: Nolan Davidson (<nolan.davidson@gmail.com>)
+# Copyright:: Copyright (c) 2015 Chef Software, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource/script'
+
+class Chef
+ class Resource
+ class Ksh < Chef::Resource::Script
+
+ def initialize(name, run_context=nil)
+ super
+ @interpreter = "ksh"
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/resources.rb b/lib/chef/resources.rb
index af4dd8a642..70cb40f8db 100644
--- a/lib/chef/resources.rb
+++ b/lib/chef/resources.rb
@@ -43,6 +43,7 @@ require 'chef/resource/group'
require 'chef/resource/http_request'
require 'chef/resource/homebrew_package'
require 'chef/resource/ifconfig'
+require 'chef/resource/ksh'
require 'chef/resource/link'
require 'chef/resource/log'
require 'chef/resource/macports_package'
diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb
index 17e085a465..4b57a93009 100644
--- a/spec/unit/node_spec.rb
+++ b/spec/unit/node_spec.rb
@@ -793,7 +793,7 @@ describe Chef::Node do
end
it "should not set the tags attribute to an empty array if it is already defined" do
- node.normal[:tags] = [ "radiohead" ]
+ node.tag("radiohead")
node.consume_external_attrs(@ohai_data, {})
expect(node.tags).to eql([ "radiohead" ])
end
diff --git a/spec/unit/provider/package/yum_spec.rb b/spec/unit/provider/package/yum_spec.rb
index 3fc0b807c9..b37a675bf2 100644
--- a/spec/unit/provider/package/yum_spec.rb
+++ b/spec/unit/provider/package/yum_spec.rb
@@ -1844,6 +1844,12 @@ EOF
expect(@yc.python_bin).to eq("/usr/bin/python")
end
+ it "should return /usr/bin/python if the interpreter is /bin/bash" do
+ other = StringIO.new("#!/bin/bash\n# The yum executable redirecting to dnf from dnf-yum compatible package.")
+ allow(::File).to receive(:open).with("/usr/bin/yum", "r") { |&b| r = b.call(other); other.rewind; r}
+ expect(@yc.python_bin).to eq("/usr/bin/python")
+ end
+
it "should return the interpreter for yum" do
other = StringIO.new("#!/usr/bin/super_python\n\nlasjdfdsaljf\nlasdjfs")
allow(::File).to receive(:open).with("/usr/bin/yum", "r") { |&b| r = b.call(other); other.rewind; r}
diff --git a/spec/unit/provider/remote_file/cache_control_data_spec.rb b/spec/unit/provider/remote_file/cache_control_data_spec.rb
index 11f2af3edc..c154c4228e 100644
--- a/spec/unit/provider/remote_file/cache_control_data_spec.rb
+++ b/spec/unit/provider/remote_file/cache_control_data_spec.rb
@@ -20,12 +20,12 @@ require 'spec_helper'
require 'uri'
CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH = 64
-CACHE_FILE_MD5_HEX_LENGTH = 32
+CACHE_FILE_CHECKSUM_HEX_LENGTH = 32
CACHE_FILE_JSON_FILE_EXTENSION_LENGTH = 5
CACHE_FILE_PATH_LIMIT =
CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH +
1 +
- CACHE_FILE_MD5_HEX_LENGTH +
+ CACHE_FILE_CHECKSUM_HEX_LENGTH +
CACHE_FILE_JSON_FILE_EXTENSION_LENGTH # {friendly}-{md5hex}.json == 102
describe Chef::Provider::RemoteFile::CacheControlData do
@@ -36,7 +36,8 @@ describe Chef::Provider::RemoteFile::CacheControlData do
Chef::Provider::RemoteFile::CacheControlData.load_and_validate(uri, current_file_checksum)
end
- let(:cache_path) { "remote_file/http___www_google_com_robots_txt-9839677abeeadf0691026e0cabca2339.json" }
+ let(:cache_path) { "remote_file/http___www_google_com_robots_txt-6dc1b24315d0cff764d30344199c6f7b.json" }
+ let(:old_cache_path) { "remote_file/http___www_google_com_robots_txt-9839677abeeadf0691026e0cabca2339.json" }
# the checksum of the file we have on disk already
let(:current_file_checksum) { "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" }
@@ -44,7 +45,8 @@ describe Chef::Provider::RemoteFile::CacheControlData do
context "when loading data for an unknown URI" do
before do
- expect(Chef::FileCache).to receive(:load).with(cache_path).and_raise(Chef::Exceptions::FileNotFound, "nope")
+ expect(Chef::FileCache).to receive(:has_key?).with(cache_path).and_return(false)
+ expect(Chef::FileCache).to receive(:has_key?).with(old_cache_path).and_return(false)
end
context "and there is no current copy of the file" do
@@ -64,7 +66,8 @@ describe Chef::Provider::RemoteFile::CacheControlData do
context "and the URI contains a password" do
let(:uri) { URI.parse("http://bob:password@example.org/") }
- let(:cache_path) { "remote_file/http___bob_XXXX_example_org_-f121caacb74c05a35bcefdf578ed5fc9.json" }
+ let(:cache_path) { "remote_file/http___bob_XXXX_example_org_-44be109aa176a165ef599c12d97af792.json" }
+ let(:old_cache_path) { "remote_file/http___bob_XXXX_example_org_-f121caacb74c05a35bcefdf578ed5fc9.json" }
it "loads the cache data from a path based on a sanitized URI" do
Chef::Provider::RemoteFile::CacheControlData.load_and_validate(uri, current_file_checksum)
@@ -88,51 +91,73 @@ describe Chef::Provider::RemoteFile::CacheControlData do
Chef::JSONCompat.to_json(cache)
end
- before do
- expect(Chef::FileCache).to receive(:load).with(cache_path).and_return(cache_json_data)
- end
-
- context "and there is no on-disk copy of the file" do
- let(:current_file_checksum) { nil }
-
- it "returns empty cache control data" do
- expect(cache_control_data.etag).to be_nil
- expect(cache_control_data.mtime).to be_nil
+ context "when the cache control data uses sha256 for its name" do
+ before do
+ expect(Chef::FileCache).to receive(:has_key?).with(cache_path).and_return(true)
+ expect(Chef::FileCache).to receive(:load).with(cache_path).and_return(cache_json_data)
end
- end
- context "and the cached checksum does not match the on-disk copy" do
- let(:current_file_checksum) { "e2a8938cc31754f6c067b35aab1d0d4864272e9bf8504536ef3e79ebf8432305" }
+ context "and there is no on-disk copy of the file" do
+ let(:current_file_checksum) { nil }
- it "returns empty cache control data" do
- expect(cache_control_data.etag).to be_nil
- expect(cache_control_data.mtime).to be_nil
+ it "returns empty cache control data" do
+ expect(cache_control_data.etag).to be_nil
+ expect(cache_control_data.mtime).to be_nil
+ end
end
- end
- context "and the cached checksum matches the on-disk copy" do
+ context "and the cached checksum does not match the on-disk copy" do
+ let(:current_file_checksum) { "e2a8938cc31754f6c067b35aab1d0d4864272e9bf8504536ef3e79ebf8432305" }
- it "populates the cache control data" do
- expect(cache_control_data.etag).to eq(etag)
- expect(cache_control_data.mtime).to eq(mtime)
+ it "returns empty cache control data" do
+ expect(cache_control_data.etag).to be_nil
+ expect(cache_control_data.mtime).to be_nil
+ end
end
- end
-
- context "and the cached checksum data is corrupted" do
- let(:cache_json_data) { '{"foo",,"bar" []}' }
- it "returns empty cache control data" do
- expect(cache_control_data.etag).to be_nil
- expect(cache_control_data.mtime).to be_nil
+ context "and the cached checksum matches the on-disk copy" do
+ context "when the filename uses sha256" do
+ before do
+ expect(Chef::FileCache).not_to receive(:has_key?).with(old_cache_path)
+ end
+ it "populates the cache control data" do
+ expect(cache_control_data.etag).to eq(etag)
+ expect(cache_control_data.mtime).to eq(mtime)
+ end
+ end
end
- context "and it still is valid JSON" do
- let(:cache_json_data) { '' }
+ context "and the cached checksum data is corrupted" do
+ let(:cache_json_data) { '{"foo",,"bar" []}' }
it "returns empty cache control data" do
expect(cache_control_data.etag).to be_nil
expect(cache_control_data.mtime).to be_nil
end
+
+ context "and it still is valid JSON" do
+ let(:cache_json_data) { '' }
+
+ it "returns empty cache control data" do
+ expect(cache_control_data.etag).to be_nil
+ expect(cache_control_data.mtime).to be_nil
+ end
+ end
+ end
+ end
+
+ context "when the filename uses md5" do
+ before do
+ expect(Chef::FileCache).to receive(:has_key?).with(cache_path).and_return(false)
+ expect(Chef::FileCache).to receive(:has_key?).with(old_cache_path).and_return(true)
+ expect(Chef::FileCache).to receive(:load).with(old_cache_path).and_return(cache_json_data)
+ end
+
+ it "populates the cache control data and creates the cache control data file with the correct path" do
+ expect(Chef::FileCache).to receive(:store).with(cache_path, cache_json_data)
+ expect(Chef::FileCache).to receive(:delete).with(old_cache_path)
+ expect(cache_control_data.etag).to eq(etag)
+ expect(cache_control_data.mtime).to eq(mtime)
end
end
end
@@ -174,7 +199,8 @@ describe Chef::Provider::RemoteFile::CacheControlData do
context "and the URI contains a password" do
let(:uri) { URI.parse("http://bob:password@example.org/") }
- let(:cache_path) { "remote_file/http___bob_XXXX_example_org_-f121caacb74c05a35bcefdf578ed5fc9.json" }
+ let(:cache_path) { "remote_file/http___bob_XXXX_example_org_-44be109aa176a165ef599c12d97af792.json" }
+ let(:old_cache_path) { "remote_file/http___bob_XXXX_example_org_-f121caacb74c05a35bcefdf578ed5fc9.json" }
it "writes the data to the cache with a sanitized path name" do
json_data = cache_control_data.json_data
diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb
index ea3ab44c16..b242f28e11 100644
--- a/spec/unit/recipe_spec.rb
+++ b/spec/unit/recipe_spec.rb
@@ -35,7 +35,7 @@ describe Chef::Recipe do
let(:cookbook_collection) { Chef::CookbookCollection.new(cookbook_loader) }
let(:node) do
- Chef::Node.new.tap {|n| n.normal[:tags] = [] }
+ Chef::Node.new
end
let(:events) do
@@ -615,21 +615,25 @@ describe Chef::Recipe do
end
end
+ it "should initialize tags to an empty Array" do
+ expect(node.tags).to eql([])
+ end
+
it "should set tags via tag" do
recipe.tag "foo"
- expect(node[:tags]).to include("foo")
+ expect(node.tags).to include("foo")
end
it "should set multiple tags via tag" do
recipe.tag "foo", "bar"
- expect(node[:tags]).to include("foo")
- expect(node[:tags]).to include("bar")
+ expect(node.tags).to include("foo")
+ expect(node.tags).to include("bar")
end
it "should not set the same tag twice via tag" do
recipe.tag "foo"
recipe.tag "foo"
- expect(node[:tags]).to eql([ "foo" ])
+ expect(node.tags).to eql([ "foo" ])
end
it "should return the current list of tags from tag with no arguments" do
@@ -653,13 +657,13 @@ describe Chef::Recipe do
it "should remove a tag from the tag list via untag" do
recipe.tag "foo"
recipe.untag "foo"
- expect(node[:tags]).to eql([])
+ expect(node.tags).to eql([])
end
it "should remove multiple tags from the tag list via untag" do
recipe.tag "foo", "bar"
recipe.untag "bar", "foo"
- expect(node[:tags]).to eql([])
+ expect(node.tags).to eql([])
end
end
diff --git a/spec/unit/resource/chef_gem_spec.rb b/spec/unit/resource/chef_gem_spec.rb
index 7352a8f5fe..fe788075fd 100644
--- a/spec/unit/resource/chef_gem_spec.rb
+++ b/spec/unit/resource/chef_gem_spec.rb
@@ -52,7 +52,7 @@ describe Chef::Resource::ChefGem, "gem_binary" do
context "when building the resource" do
let(:node) do
- Chef::Node.new.tap {|n| n.normal[:tags] = [] }
+ Chef::Node.new
end
let(:run_context) do
diff --git a/spec/unit/resource/ksh_spec.rb b/spec/unit/resource/ksh_spec.rb
new file mode 100644
index 0000000000..04bd8148fd
--- /dev/null
+++ b/spec/unit/resource/ksh_spec.rb
@@ -0,0 +1,40 @@
+#
+# Author:: Nolan Davidson (<nolan.davidson@gmail.com>)
+# Copyright:: Copyright (c) 2015 Chef Software, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'spec_helper'
+
+describe Chef::Resource::Ksh do
+
+ before(:each) do
+ @resource = Chef::Resource::Ksh.new("fakey_fakerton")
+ end
+
+ it "should create a new Chef::Resource::Ksh" do
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::Ksh)
+ end
+
+ it "should have a resource name of :ksh" do
+ expect(@resource.resource_name).to eql(:ksh)
+ end
+
+ it "should have an interpreter of ksh" do
+ expect(@resource.interpreter).to eql("ksh")
+ end
+
+end
diff --git a/spec/unit/windows_service_spec.rb b/spec/unit/windows_service_spec.rb
index d4f2da9892..031a3124f8 100644
--- a/spec/unit/windows_service_spec.rb
+++ b/spec/unit/windows_service_spec.rb
@@ -24,6 +24,7 @@ describe "Chef::Application::WindowsService", :windows_only do
let(:shell_out_result) { double('shellout', stdout: nil, stderr: nil) }
let(:config_options) do
{
+ log_location: STDOUT,
config_file: "test_config_file",
log_level: :info
}
@@ -48,7 +49,7 @@ describe "Chef::Application::WindowsService", :windows_only do
subject { Chef::Application::WindowsService.new }
- it "passes config params to new process with default options" do
+ it "passes DEFAULT_LOG_LOCATION to chef-client instead of STDOUT" do
expect(subject).to receive(:shell_out).with(
"chef-client --no-fork -c test_config_file -L #{Chef::Application::WindowsService::DEFAULT_LOG_LOCATION}",
shellout_options
@@ -78,10 +79,10 @@ describe "Chef::Application::WindowsService", :windows_only do
subject.service_main
end
- context 'configured to STDOUT' do
+ context 'configured to Event Logger' do
let(:config_options) do
{
- log_location: STDOUT,
+ log_location: Chef::Log::WinEvt.new,
config_file: "test_config_file",
log_level: :info
}