File: openstacklib_policy_base_spec.rb

package info (click to toggle)
puppet-module-openstacklib 27.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 956 kB
  • sloc: ruby: 4,549; python: 33; sh: 22; makefile: 10
file content (50 lines) | stat: -rw-r--r-- 1,562 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
require 'spec_helper_acceptance'

describe 'policy file management' do

  context 'with policy.yaml' do
    it 'should work with no errors' do
      pp= <<-EOS
      Exec { logoutput => 'on_failure' }
      openstacklib::policy::base { 'is_admin':
        file_path   => '/tmp/policy.yaml',
        key         => 'is_admin',
        value       => 'role:admin',
        file_format => 'yaml',
      }
      openstacklib::policy::base { 'is_member':
        file_path   => '/tmp/policy.yaml',
        key         => 'is_member',
        value       => 'role:member',
        file_format => 'yaml',
      }
      openstacklib::policy::base { 'get_router':
        file_path   => '/tmp/policy.yaml',
        key         => 'get_router',
        value       => 'rule:admin_or_owner',
        file_format => 'yaml',
      }
      openstacklib::policy::base { 'get_router:distributed':
        file_path   => '/tmp/policy.yaml',
        key         => 'get_router:distributed',
        value       => 'rule:admin_only',
        file_format => 'yaml',
      }

      EOS

      # Run it twice and test for idempotency
      apply_manifest(pp, :catch_failures => true)
      apply_manifest(pp, :catch_changes => true)
    end

    describe file('/tmp/policy.yaml') do
      it { should exist }
      it { should contain("'is_admin': 'role:admin'") }
      it { should contain("'is_member': 'role:member'") }
      it { should contain("'get_router': 'rule:admin_or_owner'") }
      it { should contain("'get_router:distributed': 'rule:admin_only'") }
    end
  end

end