diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2017-02-26 15:53:22 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2017-02-28 11:19:49 -0800 |
commit | 80547d21f52630d65a321975a6b9d19d9f2f49f4 (patch) | |
tree | 7e21d9e64025caa17325a5758b6570afa36044d6 /spec/unit | |
parent | f539a7f985c9c7f92b6197b883d8f6c201cf70e8 (diff) | |
download | chef-80547d21f52630d65a321975a6b9d19d9f2f49f4.tar.gz |
Chef-13: Remove supports API from all user providers
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec/unit')
-rw-r--r-- | spec/unit/provider/user/linux_spec.rb | 48 | ||||
-rw-r--r-- | spec/unit/provider/user/pw_spec.rb | 14 | ||||
-rw-r--r-- | spec/unit/resource/user_spec.rb | 10 |
3 files changed, 13 insertions, 59 deletions
diff --git a/spec/unit/provider/user/linux_spec.rb b/spec/unit/provider/user/linux_spec.rb index b04ada2511..063ca934c3 100644 --- a/spec/unit/provider/user/linux_spec.rb +++ b/spec/unit/provider/user/linux_spec.rb @@ -1,7 +1,7 @@ # # Author:: Adam Jacob (<adam@chef.io>) # Author:: Daniel DeLeo (<dan@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # # License:: Apache License, Version 2.0 # @@ -45,56 +45,18 @@ describe Chef::Provider::User::Linux do @current_resource = Chef::Resource::User::LinuxUser.new("adam", @run_context) end - it "supports manage_home does not exist", chef: ">= 13" do - expect( @new_resource.supports.key?(:manage_home) ).to be false + it "throws an error when trying to set supports manage_home: true" do + expect { @new_resource.supports( manage_home: true ) }.to raise_error(Chef::Exceptions::User) end - it "supports non_unique does not exist", chef: ">= 13" do - expect( @new_resource.supports.key?(:non_unique) ).to be false - end - - # supports is a method on the superclass so can't totally be removed, but we should aggressively NOP it to decisively break it - it "disables the supports API", chef: ">= 13" do - @new_resource.supports( manage_home: true ) - expect( @new_resource.supports.key?(:manage_home) ).to be false - end - - it "sets supports manage_home to false" do - expect( @new_resource.supports[:manage_home] ).to be false - end - - it "sets supports non-unique to false" do - expect( @new_resource.supports[:non_unique] ).to be false - end - - it "throws a deprecation warning on setting supports[:non_unique]" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false - expect(Chef).to receive(:deprecated).with(:supports_property, "supports { non_unique: true } on the user resource is deprecated and will be removed in Chef 13, set non_unique true instead") - @new_resource.supports( non_unique: true ) - end - - it "throws a deprecation warning on setting supports[:manage_home]" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false - expect(Chef).to receive(:deprecated).with(:supports_property, "supports { manage_home: true } on the user resource is deprecated and will be removed in Chef 13, set manage_home true instead") - @new_resource.supports( manage_home: true ) + it "throws an error when trying to set supports non_unique: true" do + expect { @new_resource.supports( non_unique: true ) }.to raise_error(Chef::Exceptions::User) end it "defaults manage_home to false" do expect( @new_resource.manage_home ).to be false end - it "supports[:manage_home] (incorectly) acts like manage_home" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false - @new_resource.supports(manage_home: true) - expect( provider.useradd_options ).to eql(["-m"]) - end - - it "supports[:manage_home] does not change behavior of manage_home: false", chef: ">= 13" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false - @new_resource.supports(manage_home: true) - expect( provider.useradd_options ).to eql(["-M"]) - end - it "by default manage_home is false and we use -M" do expect( provider.useradd_options ).to eql(["-M"]) end diff --git a/spec/unit/provider/user/pw_spec.rb b/spec/unit/provider/user/pw_spec.rb index 2f44d6f3e3..3637ce0b95 100644 --- a/spec/unit/provider/user/pw_spec.rb +++ b/spec/unit/provider/user/pw_spec.rb @@ -1,6 +1,6 @@ # # Author:: Stephen Haynes (<sh@nomitor.com>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -32,9 +32,7 @@ describe Chef::Provider::User::Pw do @new_resource.shell "/usr/bin/zsh" @new_resource.password "abracadabra" - # XXX: rip out in Chef-13 - Chef::Config[:treat_deprecation_warnings_as_errors] = false - @new_resource.supports manage_home: true + @new_resource.manage_home true @current_resource = Chef::Resource::User::PwUser.new("adam") @current_resource.comment "Adam Jacob" @@ -67,12 +65,6 @@ describe Chef::Provider::User::Pw do allow(@new_resource).to receive(attribute).and_return("hola") expect(@provider.set_options).to eql([ @new_resource.username, option, @new_resource.send(attribute), "-m"]) end - - it "should set the option for #{attribute} if the new resources #{attribute} is not null, without homedir management" do - allow(@new_resource).to receive(:supports).and_return(manage_home: false) - allow(@new_resource).to receive(attribute).and_return("hola") - expect(@provider.set_options).to eql([@new_resource.username, option, @new_resource.send(attribute)]) - end end it "should combine all the possible options" do @@ -123,7 +115,7 @@ describe Chef::Provider::User::Pw do describe "remove_user" do it "should run pw userdel with the new resources user name" do - @new_resource.supports manage_home: false + @new_resource.manage_home false expect(@provider).to receive(:shell_out!).with("pw", "userdel", @new_resource.username).and_return(true) @provider.remove_user end diff --git a/spec/unit/resource/user_spec.rb b/spec/unit/resource/user_spec.rb index 138ffb1bfe..afd3969164 100644 --- a/spec/unit/resource/user_spec.rb +++ b/spec/unit/resource/user_spec.rb @@ -1,6 +1,6 @@ # # Author:: Adam Jacob (<adam@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -46,12 +46,12 @@ describe Chef::Resource::User, "initialize" do expect(@resource.action).to eql([:create]) end - it "should set supports[:manage_home] to false" do - expect(@resource.supports[:manage_home]).to eql(false) + it "should set manage_home to false" do + expect(@resource.manage_home).to eql(false) end - it "should set supports[:non_unique] to false" do - expect(@resource.supports[:non_unique]).to eql(false) + it "should set non_unique to false" do + expect(@resource.non_unique).to eql(false) end it "should set force to false" do |