@@ -29,14 +29,20 @@ class { swift: swift_hash_suffix => string }
29
29
class { 'ssh::server::install': }"
30
30
end
31
31
32
- describe 'with default parameters' do
32
+ describe 'without the proxy local network ip address being specified' do
33
+ it "should fail" do
34
+ expect do
35
+ subject
36
+ end . should raise_error ( Puppet ::Error , /Must pass proxy_local_net_ip/ )
37
+ end
38
+ end
33
39
34
- let :config_file do
35
- File . join ( fixture_dir , 'default_proxy_server' )
40
+ describe 'when proxy_local_net_ip is set' do
41
+
42
+ let :params do
43
+ { :proxy_local_net_ip => '127.0.0.1' }
36
44
end
37
45
38
- it { should contain_package ( 'swift-proxy' ) . with_ensure ( 'present' ) }
39
- it { should_not contain_package ( 'python-swauth' ) }
40
46
it { should contain_service ( 'swift-proxy' ) . with (
41
47
{ :ensure => 'running' ,
42
48
:provider => 'upstart' ,
@@ -49,58 +55,167 @@ class { 'ssh::server::install': }"
49
55
:owner => 'swift' ,
50
56
:group => 'swift' ,
51
57
:mode => '0660' ,
52
- :content => File . read ( config_file ) ,
53
58
:require => 'Package[swift-proxy]'
54
59
}
55
60
) }
61
+
62
+ it 'should contain default config file' do
63
+ content = param_value (
64
+ subject ,
65
+ 'file' , '/etc/swift/proxy-server.conf' ,
66
+ 'content'
67
+ )
68
+ expected_lines =
69
+ [
70
+ '[DEFAULT]' ,
71
+ 'bind_port = 8080' ,
72
+ "workers = #{ facts [ :processorcount ] } " ,
73
+ 'user = swift' ,
74
+ '[pipeline:main]' ,
75
+ 'pipeline = healthcheck cache tempauth proxy-server' ,
76
+ '[app:proxy-server]' ,
77
+ 'use = egg:swift#proxy' ,
78
+ 'allow_account_management = true' ,
79
+ 'account_autocreate = true' ,
80
+ '[filter:healthcheck]' ,
81
+ 'use = egg:swift#healthcheck' ,
82
+ '[filter:cache]' ,
83
+ 'use = egg:swift#memcache' ,
84
+ 'memcache_servers = 127.0.0.1:11211'
85
+ ]
86
+ ( content . split ( "\n " ) & expected_lines ) . should =~ expected_lines
87
+ end
88
+
89
+ describe 'when more parameters are set' do
90
+ let :params do
91
+ {
92
+ :proxy_local_net_ip => '10.0.0.2' ,
93
+ :port => '80' ,
94
+ :workers => 3 ,
95
+ :cache_servers => [ 'foo:1' , 'bar:2' ] ,
96
+ :allow_account_management => true
97
+ }
98
+ end
99
+ it 'should contain default config file' do
100
+ content = param_value (
101
+ subject ,
102
+ 'file' , '/etc/swift/proxy-server.conf' ,
103
+ 'content'
104
+ )
105
+ expected_lines =
106
+ [
107
+ 'bind_port = 80' ,
108
+ "workers = 3" ,
109
+ 'allow_account_management = true' ,
110
+ 'memcache_servers = foo:1,bar:2'
111
+ ]
112
+ ( content . split ( "\n " ) & expected_lines ) . should =~ expected_lines
113
+ end
114
+ end
56
115
# TODO this resource should just be here temporarily until packaging
57
116
# is fixed
58
117
it { should contain_file ( '/etc/init/swift-proxy.conf' ) }
59
118
119
+ describe 'when using tempauth' do
120
+
121
+ it { should_not contain_package ( 'python-swauth' ) }
122
+ it 'should fail when setting account_autocreate to false' do
123
+ params [ :auth_type ] = 'tempauth'
124
+ params [ :account_autocreate ] = false
125
+ expect do
126
+ subject
127
+ end . should raise_error ( Puppet ::Error , /account_autocreate must be set to true when auth type is tempauth/ )
128
+ end
129
+ it 'should contain tempauth configuration' do
130
+ content = param_value (
131
+ subject ,
132
+ 'file' , '/etc/swift/proxy-server.conf' ,
133
+ 'content'
134
+ )
135
+ expected_lines =
136
+ [
137
+ 'pipeline = healthcheck cache tempauth proxy-server' ,
138
+ '[filter:tempauth]' ,
139
+ 'use = egg:swift#tempauth' ,
140
+ 'user_admin_admin = admin .admin .reseller_admin' ,
141
+ 'user_test_tester = testing .admin' ,
142
+ 'user_test2_tester2 = testing2 .admin' ,
143
+ 'user_test_tester3 = testing3'
144
+ ]
145
+ ( content . split ( "\n " ) & expected_lines ) . should =~ expected_lines
146
+ end
147
+ end
148
+
149
+ describe 'when supplying bad values for parameters' do
150
+ [ :account_autocreate , :allow_account_management ] . each do |param |
151
+ it "should fail when #{ param } is not passed a boolean" do
152
+ params [ param ] = 'false'
153
+ expect do
154
+ subject
155
+ end . should raise_error ( Puppet ::Error , /is not a boolean/ )
156
+ end
157
+ end
158
+ end
60
159
end
61
160
62
161
describe 'when using swauth' do
63
162
64
163
let :params do
65
- { :auth_type => 'swauth' }
164
+ { :proxy_local_net_ip => '127.0.0.1' ,
165
+ :auth_type => 'swauth' }
66
166
end
67
167
68
168
describe 'with defaults' do
69
169
70
- let :config_file do
71
- File . join ( fixture_dir , 'swauth_default_proxy_server' )
72
- end
73
-
74
170
it { should contain_package ( 'python-swauth' ) . with (
75
171
{ :ensure => 'present' ,
76
172
:before => 'Package[swift-proxy]'
77
173
}
78
174
) }
79
- it { should contain_file ( '/etc/swift/proxy-server.conf' ) . with (
80
- { :content => File . read ( config_file ) }
81
- ) }
175
+ it 'should create a config file with default swauth config' do
176
+ content = param_value (
177
+ subject ,
178
+ 'file' , '/etc/swift/proxy-server.conf' ,
179
+ 'content'
180
+ )
181
+ expected_lines =
182
+ [
183
+ '[filter:swauth]' ,
184
+ 'use = egg:swauth#swauth' ,
185
+ 'default_swift_cluster = local#127.0.0.1' ,
186
+ 'super_admin_key = swauthkey'
187
+ ]
188
+ ( content . split ( "\n " ) & expected_lines ) . should =~ expected_lines
189
+
190
+ end
82
191
end
83
192
84
193
describe 'with parameter overrides' do
85
194
86
195
let :params do
87
- { :auth_type => 'swauth' ,
196
+ { :proxy_local_net_ip => '127.0.0.1' ,
197
+ :auth_type => 'swauth' ,
88
198
:swauth_endpoint => '10.0.0.1' ,
89
199
:swauth_super_admin_key => 'key'
90
200
}
91
201
end
92
- let :config_file do
93
- File . join ( fixture_dir , 'swauth_overrides_proxy_server' )
94
- end
95
-
96
- it { should contain_file ( '/etc/swift/proxy-server.conf' ) . with (
97
- { :content => File . read ( config_file ) }
98
- ) }
99
202
203
+ it 'should create a config file with default swauth config' do
204
+ content = param_value (
205
+ subject ,
206
+ 'file' , '/etc/swift/proxy-server.conf' ,
207
+ 'content'
208
+ )
209
+ expected_lines =
210
+ [
211
+ '[filter:swauth]' ,
212
+ 'use = egg:swauth#swauth' ,
213
+ 'default_swift_cluster = local#10.0.0.1' ,
214
+ 'super_admin_key = key'
215
+ ]
216
+ ( content . split ( "\n " ) & expected_lines ) . should =~ expected_lines
217
+ end
100
218
end
101
-
102
219
end
103
-
104
220
end
105
-
106
221
end
0 commit comments