File: openstack_extras_auth_file_spec.rb

package info (click to toggle)
puppet-module-openstack-extras 25.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 492 kB
  • sloc: ruby: 844; sh: 62; python: 36; makefile: 10
file content (151 lines) | stat: -rw-r--r-- 5,307 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
require 'spec_helper'

describe 'openstack_extras::auth_file' do
  shared_examples 'openstack_extras::auth_file' do
    context 'when only passing default class parameters' do
      let :params do
        {
          :password => 'admin'
        }
      end

      it { is_expected.to contain_file('/root/openrc').with(
        :owner     => 'root',
        :group     => 'root',
        :mode      => '0700',
        :show_diff => false,
        :tag       => ['openrc'],
      )}

      it {
        verify_contents(catalogue, '/root/openrc', [
          'export OS_NO_CACHE=\'true\'',
          'export OS_PROJECT_NAME=\'openstack\'',
          'export OS_USERNAME=\'admin\'',
          'export OS_PASSWORD=\'admin\'',
          'export OS_AUTH_URL=\'http://127.0.0.1:5000/v3/\'',
          'export OS_AUTH_STRATEGY=\'keystone\'',
          'export OS_REGION_NAME=\'RegionOne\'',
          'export OS_PROJECT_DOMAIN_NAME=\'Default\'',
          'export OS_USER_DOMAIN_NAME=\'Default\'',
          'export OS_INTERFACE=\'public\'',
          'export OS_ENDPOINT_TYPE=\'publicURL\'',
          'export CINDER_ENDPOINT_TYPE=\'publicURL\'',
          'export GLANCE_ENDPOINT_TYPE=\'publicURL\'',
          'export KEYSTONE_ENDPOINT_TYPE=\'publicURL\'',
          'export NOVA_ENDPOINT_TYPE=\'publicURL\'',
          'export NEUTRON_ENDPOINT_TYPE=\'publicURL\'',
          'export OS_IDENTITY_API_VERSION=\'3\'',
        ])
      }
    end

    context 'when overriding parameters' do
      let :params do
        {
          :password                 => 'admin',
          :auth_url                 => 'http://127.0.0.2:5000/v3/',
          :service_token            => 'servicetoken',
          :service_endpoint         => 'http://127.0.0.2:5000/v3/',
          :username                 => 'myuser',
          :project_name             => 'myproject',
          :region_name              => 'myregion',
          :use_no_cache             => 'false',
          :os_interface             => 'internal',
          :os_endpoint_type         => 'internalURL',
          :cinder_endpoint_type     => 'internalURL',
          :glance_endpoint_type     => 'internalURL',
          :keystone_endpoint_type   => 'internalURL',
          :nova_endpoint_type       => 'internalURL',
          :neutron_endpoint_type    => 'internalURL',
          :auth_strategy            => 'no_auth',
          :path                     => '/path/to/file',
          :user_domain_name         => 'anotherdomain',
          :project_domain_name      => 'anotherdomain',
          :compute_api_version      => '2.1',
          :network_api_version      => '2.0',
          :image_api_version        => '2',
          :volume_api_version       => '2',
          :identity_api_version     => '3.1',
          :object_api_version       => '1',
        }
      end

      it { is_expected.to contain_file('/path/to/file').with(
        :owner     => 'root',
        :group     => 'root',
        :mode      => '0700',
        :show_diff => false,
        :tag       => ['openrc'],
      )}

      it {
        verify_contents(catalogue, '/path/to/file', [
          'export OS_SERVICE_TOKEN=\'servicetoken\'',
          'export OS_SERVICE_ENDPOINT=\'http://127.0.0.2:5000/v3/\'',
          'export OS_NO_CACHE=\'false\'',
          'export OS_PROJECT_NAME=\'myproject\'',
          'export OS_USERNAME=\'myuser\'',
          'export OS_PASSWORD=\'admin\'',
          'export OS_AUTH_URL=\'http://127.0.0.2:5000/v3/\'',
          'export OS_AUTH_STRATEGY=\'no_auth\'',
          'export OS_REGION_NAME=\'myregion\'',
          'export OS_PROJECT_DOMAIN_NAME=\'anotherdomain\'',
          'export OS_USER_DOMAIN_NAME=\'anotherdomain\'',
          'export OS_INTERFACE=\'internal\'',
          'export OS_ENDPOINT_TYPE=\'internalURL\'',
          'export CINDER_ENDPOINT_TYPE=\'internalURL\'',
          'export GLANCE_ENDPOINT_TYPE=\'internalURL\'',
          'export KEYSTONE_ENDPOINT_TYPE=\'internalURL\'',
          'export NOVA_ENDPOINT_TYPE=\'internalURL\'',
          'export NEUTRON_ENDPOINT_TYPE=\'internalURL\'',
          'export OS_COMPUTE_API_VERSION=\'2.1\'',
          'export OS_NETWORK_API_VERSION=\'2.0\'',
          'export OS_IMAGE_API_VERSION=\'2\'',
          'export OS_VOLUME_API_VERSION=\'2\'',
          'export OS_IDENTITY_API_VERSION=\'3.1\'',
          'export OS_OBJECT_API_VERSION=\'1\'',
        ])
      }
    end

    context 'handle password and token with single quotes' do
      let :params do
        {
          :password      => 'singlequote\'',
          :service_token => 'key\'stone'
        }
      end

      it {
        verify_contents(catalogue, '/root/openrc', [
          'export OS_SERVICE_TOKEN=\'key\\\'stone\'',
          'export OS_PASSWORD=\'singlequote\\\'\'',
        ])
      }
    end

    context 'when the file is in /tmp' do
      let :params do
        {
          :password => 'secret',
          :path     => '/tmp/openrc'
        }
      end

      it { should contain_file('/tmp/openrc')}
    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 'openstack_extras::auth_file'
    end
  end
end