Skip to content

Commit

Permalink
Merge pull request mizzy#683 from eimlav/min_max_days_fix
Browse files Browse the repository at this point in the history
Support user_max/min_days on SLES 11 + Solaris 11
  • Loading branch information
mizzy authored May 3, 2019
2 parents d58f568 + dc4f8f0 commit 77f37de
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/specinfra/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ module Command
require 'specinfra/command/sles'
require 'specinfra/command/sles/base'
require 'specinfra/command/sles/base/service'
require 'specinfra/command/sles/v11'
require 'specinfra/command/sles/v11/user'
require 'specinfra/command/sles/v12'
require 'specinfra/command/sles/v12/service'

Expand Down Expand Up @@ -332,6 +334,10 @@ module Command
require 'specinfra/command/solaris/v10/package'
require 'specinfra/command/solaris/v10/user'

# Solaris 11 (inherit Solaris)
require 'specinfra/command/solaris/v11'
require 'specinfra/command/solaris/v11/user'

# SmartOS (inherit Solaris)
require 'specinfra/command/smartos'
require 'specinfra/command/smartos/base'
Expand Down
2 changes: 2 additions & 0 deletions lib/specinfra/command/sles/v11.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Specinfra::Command::Sles::V11 < Specinfra::Command::Sles::Base
end
11 changes: 11 additions & 0 deletions lib/specinfra/command/sles/v11/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Specinfra::Command::Sles::V11::User < Specinfra::Command::Sles::Base::User
class << self
def get_minimum_days_between_password_change(user)
"chage -l #{escape(user)} | sed -n 's/^Minimum://p' | sed 's|^[[:blank:]]*||g'"
end

def get_maximum_days_between_password_change(user)
"chage -l #{escape(user)} | sed -n 's/^Maximum://p' | sed 's|^[[:blank:]]*||g'"
end
end
end
2 changes: 2 additions & 0 deletions lib/specinfra/command/solaris/v11.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Specinfra::Command::Solaris::V11 < Specinfra::Command::Solaris::Base
end
11 changes: 11 additions & 0 deletions lib/specinfra/command/solaris/v11/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Specinfra::Command::Solaris::V11::User < Specinfra::Command::Solaris::Base::User
class << self
def get_minimum_days_between_password_change(user)
"passwd -s #{escape(user)} | sed 's/ \\{1,\\}/%/g' | tr '%' '\n' | sed '4q;d'"
end

def get_maximum_days_between_password_change(user)
"passwd -s #{escape(user)} | sed 's/ \\{1,\\}/%/g' | tr '%' '\n' | sed '5q;d'"
end
end
end
12 changes: 12 additions & 0 deletions spec/command/sles11/user_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'spec_helper'

property[:os] = nil
set :os, :family => 'sles', :release => '11'

describe get_command(:get_user_minimum_days_between_password_change, 'foo') do
it { should eq "chage -l foo | sed -n 's/^Minimum://p' | sed 's|^[[:blank:]]*||g'" }
end

describe get_command(:get_user_maximum_days_between_password_change, 'foo') do
it { should eq "chage -l foo | sed -n 's/^Maximum://p' | sed 's|^[[:blank:]]*||g'" }
end
12 changes: 12 additions & 0 deletions spec/command/solaris11/user_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'spec_helper'

property[:os] = nil
set :os, :family => 'solaris', :release => '11'

describe get_command(:get_user_minimum_days_between_password_change, 'foo') do
it { should eq "passwd -s foo | sed 's/ \\{1,\\}/%/g' | tr '%' '\n' | sed '4q;d'" }
end

describe get_command(:get_user_maximum_days_between_password_change, 'foo') do
it { should eq "passwd -s foo | sed 's/ \\{1,\\}/%/g' | tr '%' '\n' | sed '5q;d'" }
end

0 comments on commit 77f37de

Please sign in to comment.