summaryrefslogtreecommitdiffstats
path: root/spec/unit/type/user_spec.rb
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch '2.7.x'Jacob Helwig2011-07-211-0/+8
|\ | | | | | | | | | | | | | | * 2.7.x: (#7123) Make `find` the default action... (#7123) Support runtime setting of 'default' on actions. (#6787) Add `default_to` for options. (#6857) Password disclosure when changing a user's password
| * Merge branch '2.6.x' into 2.7.xJacob Helwig2011-07-211-0/+8
| |\ | | | | | | | | | | | | * 2.6.x: (#6857) Password disclosure when changing a user's password
| | * (#6857) Password disclosure when changing a user's passwordBen Hughes2011-06-011-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | Make the should_to_s and is_to_s functions to return a form of 'redacted'. Rather than send the password hash to system logs in cases of failure or running in --noop mode, just state whether it's the new or old hash. We're already doing this with password changes that work, so this just brings it inline with those, albeit via a slightly different pair of methods.
* | | Maint: Tagged spec tests that are known to fail on WindowsJosh Cooper2011-07-191-1/+1
|/ / | | | | | | | | | | | | | | | | | | | | | | Many spec tests fail on Windows because there are no default providers implemented for Windows yet. Several others are failing due to Puppet::Util::Cacher not working correctly, so for now the tests that are known to fail are marked with :fails_on_windows => true. To skip these tests, you can run: rspec --tag ~fails_on_windows spec Reviewed-by: Jacob Helwig <jacob@puppetlabs.com>
* | maint: clean up the spec test headers in bulk.Daniel Pittman2011-04-131-2/+1
| | | | | | | | | | | | | | We now use a shebang of: #!/usr/bin/env rspec This enables the direct execution of spec tests again, which was lost earlier during the transition to more directly using the rspec2 runtime environment.
* | maint: just require 'spec_helper', thanks rspec2Daniel Pittman2011-04-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | rspec2 automatically sets a bunch of load-path stuff we were by hand, so we can just stop. As a side-effect we can now avoid a whole pile of stupid things to try and include the spec_helper.rb file... ...and then we can stop protecting spec_helper from evaluating twice, since we now require it with a consistent name. Yay. Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
* | Merge branch '2.6.x' into nextMatt Robinson2011-03-181-0/+4
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 2.6.x: (36 commits) Updated CHANGELOG for 2.6.7rc1 (#5073) Download plugins even if you're filtering on tags Fix #5610: Prevent unnecessary RAL lookups Revert "Merge branch 'ticket/2.6.x/5605' of git://github.com/stschulte/puppet into 2.6.next" (#6723) Fix withenv environment restoration bug (#6689) Remove extraneous include of Puppet::Util in InventoryActiveRecord Remove extra trailing whitespace from lib/puppet/resource.rb (#5428) More fully "stub" Puppet::Resource::Reference for use with storedconfigs (#6707) Fix typo in rest_authconfig.rb (#6689) Make inventory_active_record terminus search quickly (#5392) Give a better error when realizing a non-existant resource (#2645) Adding a less-stubby test to verify the "system" attribute's behavior Update CHANGELOG for 2.6.6 maint: Remove serialization of InventoryFact values maint: Rename InventoryHost to InventoryNode Fixed #2645 - Added support for creating system users maint: Remove spec run noise maint:Refactor of mount provider integration tests (#6338) Support searching on metadata in InventoryActiveRecord terminus (#6338) Implement search for InventoryActiveRecord facts terminus ... This merge includes essentially reverting #4904's change to the mount type since tests that came in from 2.6.x specified different behavior and what's correct is not clear to me. I've reopened #4904 and added it to our backlog, and talked to Nigel about the RFC that's currently out on the puppet-users mailing list for a bigger refactor of how the mount provider works. Manually Resolved Conflicts: spec/spec_helper.rb spec/unit/indirector/queue_spec.rb
| * Fixed #2645 - Added support for creating system usersJames Turnbull2011-03-091-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On Red Hat, Ubuntu, Debian and deriatives the -r flag allows creation of "system" users with a UID below that defined in /etc/login.defs. This commit adds support for a system parameter and a system_users feature which can be used like so: user { "foo": system => true, ensure => present, } This will create a user with a lower UID. The system parameter defaults to false.
* | Merge branch '2.6.x' into nextMatt Robinson2011-02-021-3/+31
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 2.6.x: (46 commits) Augmentation of tests for prior commit Fix to fix for #5755 -- backref serialization issues in zaml Fixed #5564 - Added some more fqdn_rand documentation Fixed #4968 - Updated list of options turned on by --test in documentation (#5061) - allow special hostclass/define variables to be evaluated as defaults. (#6107) Fix an error when auditing a file with empty content Remove already initialized constant warning from file_spec.rb tests (#5566) Treat source only File checksums as syntax errors when used with content Rename variable used in File type validation to be more clear Remove invalid "timestamp" and "time", and add missing "ctime" File checksum types. Remove order dependency when specifying source and checksum on File type Bug #5755 -- ZAML generates extra newline in some hash backreferences. bug #5681 -- code fix to handle AIX mount output Bug #5681 -- parse AIX mount command output. Spec for #5681 to allow parsing of AIX mount output in mount provider Fixed #6091 - Changed POSIX path matching to allow multiple leading slashes Bug #6091 -- test leading double-slash in filenames are allowed. Fixed #6071 - Fixed typo and improved exec path error message Fixed #6061 - Allowed -1 as password min/max age Bug #6061 -- verify that negative {min,max}_password_age are accepted. ... Manually Resolved Conflicts: lib/puppet/util/zaml.rb spec/unit/util/zaml_spec.rb
| * Bug #6061 -- verify that negative {min,max}_password_age are accepted.Daniel Pittman2011-01-281-0/+28
| | | | | | | | | | | | | | Setting the age value to -1 will disable the specific aging value; we should accept that, but continue to reject null or empty values as invalid. Add tests to verify that this code enforces as expected.
| * (#5931) Prevent errors when calling insync? on audited propertiesPaul Berry2011-01-251-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | Created a method safe_insync? which first checks whether the property has a "should" value of nil, and if so returns true. Most insync? methods were already doing this, but a few were not, leading to bugs if a property was being audited but not set. Types should continue to override the insync? method, but callers of insync? should call safe_insync? instead. Paired-with: Jesse Wolfe <jesse@puppetlabs.com>
* | maint: Use expand_path when requiring spec_helper or puppettestMatt Robinson2010-12-061-1/+1
|/ | | | | | | | | Doing a require to a relative path can cause files to be required more than once when they're required from different relative paths. If you expand the path fully, this won't happen. Ruby 1.9 also requires that you use expand_path when doing these requires. Paired-with: Jesse Wolfe
* Adds #3046 - support for password min/max ageNick Lewis2010-09-291-1/+5
| | | | | | | This adds a new feature to user providers "manages_password_age", along with properties password_min_age and password_max_age to the user type. These represent password min and max age in days. The useradd and user_role_add providers now support these new properties.
* Add user account expiry to the useradd type and providerDean Wilson2010-09-291-1/+15
|
* [#4756] addendum for #4756Jesse Wolfe2010-09-141-0/+5
| | | | | | | | | | | This fixes spec and unit tests indirectly related to the previous patch-revert. One failure was from trying to test the User Type's roles, when, on many platforms, the roles feature wasn't supported by the default Provider. Other tests could fail on some platforms because they assumed that unsupported attributes would be ignored with a warning, but the code was crashing instead.
* Code smell: Two space indentationMarkus Roberts2010-07-091-220/+220
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replaced 106806 occurances of ^( +)(.*$) with The ruby community almost universally (i.e. everyone but Luke, Markus, and the other eleven people who learned ruby in the 1900s) uses two-space indentation. 3 Examples: The code: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") becomes: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") The code: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object becomes: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object The code: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end becomes: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end
* Code smell: Line modifiers are preferred to one-line blocks.Markus Roberts2010-07-091-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Replaced 6 occurances of (while .*?) *do$ with The do is unneeded in the block header form and causes problems with the block-to-one-line transformation. 3 Examples: The code: while line = f.gets do becomes: while line = f.gets The code: while line = shadow.gets do becomes: while line = shadow.gets The code: while wrapper = zeros.pop do becomes: while wrapper = zeros.pop * Replaced 19 occurances of ((if|unless) .*?) *then$ with The then is unneeded in the block header form and causes problems with the block-to-one-line transformation. 3 Examples: The code: if f = test_files_for(failed).find { |f| failed_trace =~ Regexp.new(f) } then becomes: if f = test_files_for(failed).find { |f| failed_trace =~ Regexp.new(f) } The code: unless defined?(@spec_command) then becomes: unless defined?(@spec_command) The code: if c == ?\n then becomes: if c == ?\n * Replaced 758 occurances of ((?:if|unless|while|until) .*) (.*) end with The one-line form is preferable provided: * The condition is not used to assign a variable * The body line is not already modified * The resulting line is not too long 3 Examples: The code: if Puppet.features.libshadow? has_feature :manages_passwords end becomes: has_feature :manages_passwords if Puppet.features.libshadow? The code: unless (defined?(@current_pool) and @current_pool) @current_pool = process_zpool_data(get_pool_data) end becomes: @current_pool = process_zpool_data(get_pool_data) unless (defined?(@current_pool) and @current_pool) The code: if Puppet[:trace] puts detail.backtrace end becomes: puts detail.backtrace if Puppet[:trace]
* Code smell: Use string interpolationMarkus Roberts2010-07-091-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Replaced 83 occurances of (.*)" *[+] *([$@]?[\w_0-9.:]+?)(.to_s\b)?(?! *[*(%\w_0-9.:{\[]) with \1#{\2}" 3 Examples: The code: puts "PUPPET " + status + ": " + process + ", " + state becomes: puts "PUPPET " + status + ": " + process + ", #{state}" The code: puts "PUPPET " + status + ": #{process}" + ", #{state}" becomes: puts "PUPPET #{status}" + ": #{process}" + ", #{state}" The code: }.compact.join( "\n" ) + "\n" + t + "]\n" becomes: }.compact.join( "\n" ) + "\n#{t}" + "]\n" * Replaced 21 occurances of (.*)" *[+] *" with \1 3 Examples: The code: puts "PUPPET #{status}" + ": #{process}" + ", #{state}" becomes: puts "PUPPET #{status}" + ": #{process}, #{state}" The code: puts "PUPPET #{status}" + ": #{process}, #{state}" becomes: puts "PUPPET #{status}: #{process}, #{state}" The code: res = self.class.name + ": #{@name}" + "\n" becomes: res = self.class.name + ": #{@name}\n" * Don't use string concatenation to split lines unless they would be very long. Replaced 11 occurances of (.*)(['"]) *[+] *(['"])(.*) with 3 Examples: The code: o.define_head "The check_puppet Nagios plug-in checks that specified " + "Puppet process is running and the state file is no " + becomes: o.define_head "The check_puppet Nagios plug-in checks that specified Puppet process is running and the state file is no " + The code: o.separator "Mandatory arguments to long options are mandatory for " + "short options too." becomes: o.separator "Mandatory arguments to long options are mandatory for short options too." The code: o.define_head "The check_puppet Nagios plug-in checks that specified Puppet process is running and the state file is no " + "older than specified interval." becomes: o.define_head "The check_puppet Nagios plug-in checks that specified Puppet process is running and the state file is no older than specified interval." * Replaced no occurances of do (.*?) end with {\1} * Replaced 1488 occurances of "([^"\n]*%s[^"\n]*)" *% *(.+?)(?=$| *\b(do|if|while|until|unless|#)\b) with 20 Examples: The code: args[0].split(/\./).map do |s| "dc=%s"%[s] end.join(",") becomes: args[0].split(/\./).map do |s| "dc=#{s}" end.join(",") The code: puts "%s" % Puppet.version becomes: puts "#{Puppet.version}" The code: raise "Could not find information for %s" % node becomes: raise "Could not find information for #{node}" The code: raise Puppet::Error, "Cannot create %s: basedir %s is a file" % [dir, File.join(path)] becomes: raise Puppet::Error, "Cannot create #{dir}: basedir #{File.join(path)} is a file" The code: Puppet.err "Could not run %s: %s" % [client_class, detail] becomes: Puppet.err "Could not run #{client_class}: #{detail}" The code: raise "Could not find handler for %s" % arg becomes: raise "Could not find handler for #{arg}" The code: Puppet.err "Will not start without authorization file %s" % Puppet[:authconfig] becomes: Puppet.err "Will not start without authorization file #{Puppet[:authconfig]}" The code: raise Puppet::Error, "Could not deserialize catalog from pson: %s" % detail becomes: raise Puppet::Error, "Could not deserialize catalog from pson: #{detail}" The code: raise "Could not find facts for %s" % Puppet[:certname] becomes: raise "Could not find facts for #{Puppet[:certname]}" The code: raise ArgumentError, "%s is not readable" % path becomes: raise ArgumentError, "#{path} is not readable" The code: raise ArgumentError, "Invalid handler %s" % name becomes: raise ArgumentError, "Invalid handler #{name}" The code: debug "Executing '%s' in zone %s with '%s'" % [command, @resource[:name], str] becomes: debug "Executing '#{command}' in zone #{@resource[:name]} with '#{str}'" The code: raise Puppet::Error, "unknown cert type '%s'" % hash[:type] becomes: raise Puppet::Error, "unknown cert type '#{hash[:type]}'" The code: Puppet.info "Creating a new certificate request for %s" % Puppet[:certname] becomes: Puppet.info "Creating a new certificate request for #{Puppet[:certname]}" The code: "Cannot create alias %s: object already exists" % [name] becomes: "Cannot create alias #{name}: object already exists" The code: return "replacing from source %s with contents %s" % [metadata.source, metadata.checksum] becomes: return "replacing from source #{metadata.source} with contents #{metadata.checksum}" The code: it "should have a %s parameter" % param do becomes: it "should have a #{param} parameter" do The code: describe "when registring '%s' messages" % log do becomes: describe "when registring '#{log}' messages" do The code: paths = %w{a b c d e f g h}.collect { |l| "/tmp/iteration%stest" % l } becomes: paths = %w{a b c d e f g h}.collect { |l| "/tmp/iteration#{l}test" } The code: assert_raise(Puppet::Error, "Check '%s' did not fail on false" % check) do becomes: assert_raise(Puppet::Error, "Check '#{check}' did not fail on false") do
* [#3994-part 3] rename spec tests from *_spec_spec to *_spec.rbMarkus Roberts2010-06-281-0/+283
| | | | Part 2 re-did the change on the spec files, which it shouldn't have.
* [#3994-part 2] rename integration tests to *_spec.rbMarkus Roberts2010-06-281-283/+0
| | | | | | | | | Some spec files like active_record.rb had names that would confuse the load path and get loaded instead of the intended implentation when the spec was run from the same directory as the file. Author: Matt Robinson <matt@puppetlabs.com> Date: Fri Jun 11 15:29:33 2010 -0700
* Fix tests broken by level-violation fixJesse Wolfe2010-06-251-2/+0
|
* [#3994] rename the specs to have _spec.rb at the endMarkus Roberts2010-06-231-0/+285
Some spec files like active_record.rb had names that would confuse the load path and get loaded instead of the intended implentation when the spec was run from the same directory as the file. Author: Matt Robinson <matt@puppetlabs.com> Date: Fri Jun 11 15:29:33 2010 -0700