~ubuntu-branches/ubuntu/wily/puppet/wily

« back to all changes in this revision

Viewing changes to spec/unit/util/windows/access_control_entry_spec.rb

  • Committer: Package Import Robot
  • Author(s): Stig Sandbeck Mathisen
  • Date: 2014-01-07 12:04:39 UTC
  • mfrom: (3.1.57 sid)
  • Revision ID: package-import@ubuntu.com-20140107120439-42anap22xfs9260x
Tags: 3.4.2-1
ImportedĀ upstreamĀ releaseĀ 3.4.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env ruby
 
2
require 'spec_helper'
 
3
require 'puppet/util/windows'
 
4
 
 
5
describe "Puppet::Util::Windows::AccessControlEntry", :if => Puppet.features.microsoft_windows? do
 
6
  let(:klass) { Puppet::Util::Windows::AccessControlEntry }
 
7
  let(:sid) { 'S-1-5-18' }
 
8
  let(:mask) { Windows::File::FILE_ALL_ACCESS }
 
9
 
 
10
  it "creates an access allowed ace" do
 
11
    ace = klass.new(sid, mask)
 
12
 
 
13
    ace.type.should == klass::ACCESS_ALLOWED_ACE_TYPE
 
14
  end
 
15
 
 
16
  it "creates an access denied ace" do
 
17
    ace = klass.new(sid, mask, 0, klass::ACCESS_DENIED_ACE_TYPE)
 
18
 
 
19
    ace.type.should == klass::ACCESS_DENIED_ACE_TYPE
 
20
  end
 
21
 
 
22
  it "creates a non-inherited ace by default" do
 
23
    ace = klass.new(sid, mask)
 
24
 
 
25
    ace.should_not be_inherited
 
26
  end
 
27
 
 
28
  it "creates an inherited ace" do
 
29
    ace = klass.new(sid, mask, klass::INHERITED_ACE)
 
30
 
 
31
    ace.should be_inherited
 
32
  end
 
33
 
 
34
  it "creates a non-inherit-only ace by default" do
 
35
    ace = klass.new(sid, mask)
 
36
 
 
37
    ace.should_not be_inherit_only
 
38
  end
 
39
 
 
40
  it "creates an inherit-only ace" do
 
41
    ace = klass.new(sid, mask, klass::INHERIT_ONLY_ACE)
 
42
 
 
43
    ace.should be_inherit_only
 
44
  end
 
45
 
 
46
  context "when comparing aces" do
 
47
    let(:ace1) { klass.new(sid, mask, klass::INHERIT_ONLY_ACE, klass::ACCESS_DENIED_ACE_TYPE) }
 
48
    let(:ace2) { klass.new(sid, mask, klass::INHERIT_ONLY_ACE, klass::ACCESS_DENIED_ACE_TYPE) }
 
49
 
 
50
    it "returns true if different objects have the same set of values" do
 
51
    ace1.should == ace2
 
52
    end
 
53
 
 
54
    it "returns false if different objects have different sets of values" do
 
55
      ace = klass.new(sid, mask)
 
56
      ace.should_not == ace1
 
57
    end
 
58
 
 
59
    it "returns true when testing if two objects are eql?" do
 
60
      ace1.eql?(ace2)
 
61
    end
 
62
 
 
63
    it "returns false when comparing object identity" do
 
64
      ace1.should_not be_equal(ace2)
 
65
    end
 
66
  end
 
67
end