File: octavia_service_auth_spec.rb

package info (click to toggle)
puppet-module-octavia 25.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,588 kB
  • sloc: ruby: 3,940; python: 38; makefile: 12; sh: 10
file content (77 lines) | stat: -rw-r--r-- 3,436 bytes parent folder | download
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
require 'spec_helper'

describe 'octavia::service_auth' do

  shared_examples_for 'service-auth' do

    let :params do
      {
        :password => 'secrete'
      }
    end

    context 'with default params' do
      it 'configures default auth' do
        is_expected.to contain_octavia_config('service_auth/auth_url').with_value('http://localhost:5000')
        is_expected.to contain_octavia_config('service_auth/username').with_value('octavia')
        is_expected.to contain_octavia_config('service_auth/project_name').with_value('services')
        is_expected.to contain_octavia_config('service_auth/password').with_value('secrete').with_secret(true)
        is_expected.to contain_octavia_config('service_auth/user_domain_name').with_value('Default')
        is_expected.to contain_octavia_config('service_auth/project_domain_name').with_value('Default')
        is_expected.to contain_octavia_config('service_auth/system_scope').with_value('<SERVICE DEFAULT>')
        is_expected.to contain_octavia_config('service_auth/auth_type').with_value('password')
        is_expected.to contain_octavia_config('service_auth/region_name').with_value('<SERVICE DEFAULT>')
      end
    end

    context 'when credentials are configured' do
      before do
        params.merge!({
          :auth_url            => 'http://127.0.0.1:5000',
          :username            => 'some_user',
          :project_name        => 'some_project_name',
          :user_domain_name    => 'my_domain_name',
          :project_domain_name => 'our_domain_name',
          :auth_type           => 'v3password',
          :region_name         => 'regionOne',
        })
      end

      it 'configures credentials' do
        is_expected.to contain_octavia_config('service_auth/auth_url').with_value('http://127.0.0.1:5000')
        is_expected.to contain_octavia_config('service_auth/username').with_value('some_user')
        is_expected.to contain_octavia_config('service_auth/project_name').with_value('some_project_name')
        is_expected.to contain_octavia_config('service_auth/password').with_value('secrete').with_secret(true)
        is_expected.to contain_octavia_config('service_auth/user_domain_name').with_value('my_domain_name')
        is_expected.to contain_octavia_config('service_auth/project_domain_name').with_value('our_domain_name')
        is_expected.to contain_octavia_config('service_auth/system_scope').with_value('<SERVICE DEFAULT>')
        is_expected.to contain_octavia_config('service_auth/auth_type').with_value('v3password')
        is_expected.to contain_octavia_config('service_auth/region_name').with_value('regionOne')
      end
    end

    context 'when system_scope is set' do
      before do
        params.merge!(
          :system_scope => 'all'
        )
      end
      it 'configures system-scoped credential' do
        is_expected.to contain_octavia_config('service_auth/project_domain_name').with_value('<SERVICE DEFAULT>')
        is_expected.to contain_octavia_config('service_auth/project_name').with_value('<SERVICE DEFAULT>')
        is_expected.to contain_octavia_config('service_auth/system_scope').with_value('all')
      end
    end
  end

  on_supported_os({
    :supported_os => OSDefaults.get_supported_os
  }).each do |os,facts|
    context "on #{os}" do
      let (:facts) do
        facts.merge!(OSDefaults.get_facts())
      end
      it_behaves_like 'service-auth'
    end
  end
end