-
Notifications
You must be signed in to change notification settings - Fork 62
Fix user provider specs #604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ | |
|
|
||
| let(:shadow_entry) { | ||
| return unless Puppet.features.libshadow? | ||
| entry = Etc::PasswdEntry.new | ||
| entry = Shadow::Passwd::Entry.new | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this requried? did the API for the ruby-shadow gem change?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I mentioned in the OP, If you look at dd3df54 it sounds like the intention was to change it to |
||
| entry[:sp_namp] = 'myuser' # login name | ||
| entry[:sp_loginclass] = 'staff' # login class | ||
| entry | ||
|
|
@@ -47,7 +47,11 @@ | |
| allow(Facter).to receive(:value).with('os.family').and_return('OpenBSD') | ||
| allow(Facter).to receive(:value).with('os.release.major') | ||
| resource[:expiry] = "1997-06-01" | ||
| expect(provider.addcmd).to eq(['/usr/sbin/useradd', '-e', 'June 01 1997', 'myuser']) | ||
| if Puppet.features.libshadow? | ||
| expect(provider.addcmd).to eq(['/usr/sbin/useradd', '-e', 'June 01 1997', '-L', 'staff', 'myuser']) | ||
| else | ||
| expect(provider.addcmd).to eq(['/usr/sbin/useradd', '-e', 'June 01 1997', 'myuser']) | ||
| end | ||
| end | ||
| end | ||
|
|
||
|
|
@@ -58,19 +62,19 @@ | |
|
|
||
| it "should return the loginclass if set", :if => Puppet.features.libshadow? do | ||
| expect(Shadow::Passwd).to receive(:getspnam).with('myuser').and_return(shadow_entry) | ||
| provider.send(:loginclass).should == 'staff' | ||
| expect(provider.send(:loginclass)).to eq('staff') | ||
| end | ||
|
|
||
| it "should return the empty string when loginclass isn't set", :if => Puppet.features.libshadow? do | ||
| shadow_entry[:sp_loginclass] = '' | ||
| expect(Shadow::Passwd).to receive(:getspnam).with('myuser').and_return(shadow_entry) | ||
| provider.send(:loginclass).should == '' | ||
| expect(provider.send(:loginclass)).to eq('') | ||
| end | ||
|
|
||
| it "should return nil when loginclass isn't available", :if => Puppet.features.libshadow? do | ||
| shadow_entry[:sp_loginclass] = nil | ||
| expect(Shadow::Passwd).to receive(:getspnam).with('myuser').and_return(shadow_entry) | ||
| provider.send(:loginclass).should be_nil | ||
| expect(provider.send(:loginclass)).to be_nil | ||
| end | ||
| end | ||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we never executed that test in CI because the ruby-shadow gem is missing and then the return hits?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(we need to get the gem into our CI)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I think that's correct. Installing the gem in CI would be well-advised, IMHO.