Sha256: 702f9f475cd57d6cc7233fae3a291567096c701cc977ea5d7a1d39e18ec8d02a

Contents?: true

Size: 1.72 KB

Versions: 33

Compression:

Stored size: 1.72 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) do
      file_containing('user_spec', <<-EOF)
        # comment
        ssh-rsa KEY-DATA key-name
        ssh-rsa KEY-DATA key name
        EOF
    end
    # 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

    context "with multiple unnamed keys" do
      let(:tempfile) do
        file_containing('user_spec', <<-EOF)
          # comment
          ssh-rsa KEY-DATA1
          ssh-rsa KEY-DATA2
          EOF
      end

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

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
puppet-3.8.7 spec/integration/type/user_spec.rb
puppet-3.8.7-x86-mingw32 spec/integration/type/user_spec.rb
puppet-3.8.7-x64-mingw32 spec/integration/type/user_spec.rb
puppet-3.8.6 spec/integration/type/user_spec.rb
puppet-3.8.6-x86-mingw32 spec/integration/type/user_spec.rb
puppet-3.8.6-x64-mingw32 spec/integration/type/user_spec.rb
puppet-3.8.5 spec/integration/type/user_spec.rb
puppet-3.8.5-x86-mingw32 spec/integration/type/user_spec.rb
puppet-3.8.5-x64-mingw32 spec/integration/type/user_spec.rb
puppet-3.8.4 spec/integration/type/user_spec.rb
puppet-3.8.4-x86-mingw32 spec/integration/type/user_spec.rb
puppet-3.8.4-x64-mingw32 spec/integration/type/user_spec.rb
puppet-3.8.3 spec/integration/type/user_spec.rb
puppet-3.8.3-x86-mingw32 spec/integration/type/user_spec.rb
puppet-3.8.3-x64-mingw32 spec/integration/type/user_spec.rb
puppet-3.8.2 spec/integration/type/user_spec.rb
puppet-3.8.2-x86-mingw32 spec/integration/type/user_spec.rb
puppet-3.8.2-x64-mingw32 spec/integration/type/user_spec.rb
puppet-3.8.1 spec/integration/type/user_spec.rb
puppet-3.8.1-x86-mingw32 spec/integration/type/user_spec.rb