summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn McCrae <jmccrae@chef.io>2021-05-11 09:46:20 -0700
committerJohn McCrae <jmccrae@chef.io>2021-05-11 11:55:19 -0700
commit974d23e2294cf520023e856e7b78a992e05cf8b3 (patch)
treee2a7c092d0564c81644a0e5403d492d6dddc05e1
parentddbd425fcb7f069b3287011b78e5bea90aafe088 (diff)
downloadchef-974d23e2294cf520023e856e7b78a992e05cf8b3.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.rb26
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