Sha256: 211f1621e559b51e77a49a318f6f77cef69601050ba7ec2b0140238590be4c3a

Contents?: true

Size: 1.3 KB

Versions: 6

Compression:

Stored size: 1.3 KB

Contents

#! /usr/bin/env ruby
require 'spec_helper'
require 'puppet_spec/files'
require 'puppet_spec/compiler'

describe Puppet::Type.type(:user), '(integration)', :unless => Puppet.features.microsoft_windows? do
  include PuppetSpec::Files
  include PuppetSpec::Compiler

  context "when set to purge ssh keys from a file" do
    let(:tempfile) { file_containing('user_spec', "# comment\nssh-rsa KEY-DATA key-name\nssh-rsa KEY-DATA key name\n") }
    # must use an existing user, or the generated key resource
    # will fail on account of an invalid user for the key
    # - root should be a safe default
    let(:manifest) { "user { 'root': purge_ssh_keys => '#{tempfile}' }" }

    it "should purge authorized ssh keys" do
      apply_compiled_manifest(manifest)
      File.read(tempfile).should_not =~ /key-name/
    end

    it "should purge keys with spaces in the comment string" do
      apply_compiled_manifest(manifest)
      File.read(tempfile).should_not =~ /key name/
    end

    context "with other prefetching resources evaluated first" do
      let(:manifest) { "host { 'test': before => User[root] } user { 'root': purge_ssh_keys => '#{tempfile}' }" }

      it "should purge authorized ssh keys" do
        apply_compiled_manifest(manifest)
        File.read(tempfile).should_not =~ /key-name/
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
puppet-3.7.1 spec/integration/type/user_spec.rb
puppet-3.7.1-x86-mingw32 spec/integration/type/user_spec.rb
puppet-3.7.1-x64-mingw32 spec/integration/type/user_spec.rb
puppet-3.7.0 spec/integration/type/user_spec.rb
puppet-3.7.0-x86-mingw32 spec/integration/type/user_spec.rb
puppet-3.7.0-x64-mingw32 spec/integration/type/user_spec.rb