Sha256: 559d53f12249951f0d34e03af2b6e38ded53e1df8020b05e4514a260b2feb3b8

Contents?: true

Size: 1.43 KB

Versions: 278

Compression:

Stored size: 1.43 KB

Contents

#! /usr/bin/env ruby
require 'spec_helper'

require 'puppet/util/user_attr'

describe UserAttr do
  before do
    user_attr = ["foo::::type=role", "bar::::type=normal;profile=foobar"]
    File.stubs(:readlines).returns(user_attr)
  end

  describe "when getting attributes by name" do
    it "should return nil if there is no entry for that name" do
      expect(UserAttr.get_attributes_by_name('baz')).to eq(nil)
    end

    it "should return a hash if there is an entry in /etc/user_attr" do
      expect(UserAttr.get_attributes_by_name('foo').class).to eq(Hash)
    end

    it "should return a hash with the name value from /etc/user_attr" do
      expect(UserAttr.get_attributes_by_name('foo')[:name]).to eq('foo')
    end

    #this test is contrived
    #there are a bunch of possible parameters that could be in the hash
    #the role/normal is just a the convention of the file
    describe "when the name is a role" do
      it "should contain :type = role" do
        expect(UserAttr.get_attributes_by_name('foo')[:type]).to eq('role')
      end
    end

    describe "when the name is not a role" do
      it "should contain :type = normal" do
        expect(UserAttr.get_attributes_by_name('bar')[:type]).to eq('normal')
      end
    end

    describe "when the name has more attributes" do
      it "should contain all the attributes" do
        expect(UserAttr.get_attributes_by_name('bar')[:profile]).to eq('foobar')
      end
    end
  end
end

Version data entries

278 entries across 278 versions & 1 rubygems

Version Path
puppet-5.5.6 spec/unit/util/user_attr_spec.rb
puppet-5.5.6-x86-mingw32 spec/unit/util/user_attr_spec.rb
puppet-5.5.6-x64-mingw32 spec/unit/util/user_attr_spec.rb
puppet-5.5.6-universal-darwin spec/unit/util/user_attr_spec.rb
puppet-5.5.3 spec/unit/util/user_attr_spec.rb
puppet-5.5.3-x86-mingw32 spec/unit/util/user_attr_spec.rb
puppet-5.5.3-x64-mingw32 spec/unit/util/user_attr_spec.rb
puppet-5.5.3-universal-darwin spec/unit/util/user_attr_spec.rb
puppet-5.5.2 spec/unit/util/user_attr_spec.rb
puppet-5.5.2-x86-mingw32 spec/unit/util/user_attr_spec.rb
puppet-5.5.2-x64-mingw32 spec/unit/util/user_attr_spec.rb
puppet-5.5.2-universal-darwin spec/unit/util/user_attr_spec.rb
puppet-5.3.7 spec/unit/util/user_attr_spec.rb
puppet-5.3.7-x86-mingw32 spec/unit/util/user_attr_spec.rb
puppet-5.3.7-x64-mingw32 spec/unit/util/user_attr_spec.rb
puppet-5.3.7-universal-darwin spec/unit/util/user_attr_spec.rb
puppet-4.10.12 spec/unit/util/user_attr_spec.rb
puppet-4.10.12-x86-mingw32 spec/unit/util/user_attr_spec.rb
puppet-4.10.12-x64-mingw32 spec/unit/util/user_attr_spec.rb
puppet-4.10.12-universal-darwin spec/unit/util/user_attr_spec.rb