File: selboolean_spec.rb

package info (click to toggle)
puppet 5.5.10-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 21,116 kB
  • sloc: ruby: 250,669; sh: 1,620; xml: 218; makefile: 151; sql: 103
file content (36 lines) | stat: -rw-r--r-- 1,214 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#! /usr/bin/env ruby
require 'spec_helper'

provider_class = Puppet::Type.type(:selboolean).provider(:getsetsebool)

describe provider_class do
  before :each do
    @resource = stub("resource", :name => "foo")
    @resource.stubs(:[]).returns "foo"
    @provider = provider_class.new(@resource)
  end

  it "should return :on when getsebool returns on" do
    @provider.expects(:getsebool).with("foo").returns "foo --> on\n"
    expect(@provider.value).to eq(:on)
  end

  it "should return :off when getsebool returns on" do
    @provider.expects(:getsebool).with("foo").returns "foo --> off\n"
    expect(@provider.value).to eq(:off)
  end

  it "should call execpipe when updating boolean setting" do
    @provider.expects(:command).with(:setsebool).returns "/usr/sbin/setsebool"
    @provider.expects(:execpipe).with("/usr/sbin/setsebool  foo off")
    @provider.value = :off
  end

  it "should call execpipe with -P when updating persistent boolean setting" do
    @resource.stubs(:[]).with(:persistent).returns :true
    @provider.expects(:command).with(:setsebool).returns "/usr/sbin/setsebool"
    @provider.expects(:execpipe).with("/usr/sbin/setsebool -P foo off")
    @provider.value = :off
  end

end