diff options
author | John McCrae <jmccrae@chef.io> | 2021-05-11 09:46:20 -0700 |
---|---|---|
committer | John McCrae <jmccrae@chef.io> | 2021-05-11 09:46:20 -0700 |
commit | 4e3669815085211c4dc5a414078570fd79e9e714 (patch) | |
tree | eff768ff5b5fd38000a7b32a01665f51214fb48b | |
parent | 682c6d1b15742511d63dd14b7b9f195b2ffbff81 (diff) | |
download | chef-4e3669815085211c4dc5a414078570fd79e9e714.tar.gz |
I updated the hostname resource to use Rename-Computer over WMI. I removed a test-kitchen test which fails when the test nodes are domain joined. I added a functional test to replace it.
Signed-off-by: John McCrae <jmccrae@chef.io>
-rw-r--r-- | spec/functional/resource/windows_hostname_spec.rb | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/spec/functional/resource/windows_hostname_spec.rb b/spec/functional/resource/windows_hostname_spec.rb index 71f9a09ca1..97443d0e8b 100644 --- a/spec/functional/resource/windows_hostname_spec.rb +++ b/spec/functional/resource/windows_hostname_spec.rb @@ -27,7 +27,7 @@ describe Chef::Resource::Hostname, :windows_only do end let(:new_hostname) { "New-Hostname" } - let(:local_domain_user) { "chef" } + let(:local_domain_user) { "DOMAIN\\Groucho" } let(:local_domain_password) { "P@ssw0rd" } let(:local_windows_reboot) { false } let(:domain_status) { get_domain_status } @@ -44,7 +44,7 @@ describe Chef::Resource::Hostname, :windows_only do end subject do - new_resource = Chef::Resource::Hostname.new("fakey-fakerson", run_context) + new_resource = Chef::Resource::Hostname.new("oldhostname", run_context) new_resource.hostname = "foobar" new_resource.domain_user = "chef" new_resource.domain_password = "P@ssw0rd" @@ -53,11 +53,23 @@ describe Chef::Resource::Hostname, :windows_only do end describe "Changing machine names" do - context "the system does not get renamed when in a domain" do - it "does not change" do - subject.windows_reboot false - expect(subject).to_not be_updated_by_last_action + context "The system can be renamed without a user or password when in a Workgroup" do + let(:hostname) { "Cucumber" } + it "does change" do + subject.run_action(:set) + expect(subject).to be_updated_by_last_action + end + end + + context "the system gets renamed when in a domain" do + let(:hostname) { "Gherkin" } + it "does change the domain account" do + subject.windows_reboot true + subject.domain_user local_domain_user + subject.domain_password local_domain_password + subject.run_action(:set) + expect(subject).to be_updated_by_last_action end end end -end
\ No newline at end of file +end |