-
Notifications
You must be signed in to change notification settings - Fork 321
/
Copy pathregistry_spec.rb
152 lines (138 loc) · 3.81 KB
/
registry_spec.rb
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
152
# frozen_string_literal: true
require 'spec_helper'
tests = {
'with ensure => absent' => {
'ensure' => 'absent',
'version' => '17.06',
'pass_hash' => 'test1234',
'receipt' => false,
},
'with ensure => present' => {
'ensure' => 'present',
'version' => '17.06',
'pass_hash' => 'test1234',
'receipt' => false,
},
'with ensure => present and username => user1' => {
'ensure' => 'present',
'username' => 'user1',
'version' => '17.06',
'pass_hash' => 'test1234',
'receipt' => false,
},
'with ensure => present and password => secret' => {
'ensure' => 'present',
'password' => 'secret',
'version' => '17.06',
'pass_hash' => 'test1234',
'receipt' => false,
},
'with ensure => present and email => [email protected]' => {
'ensure' => 'present',
'email' => '[email protected]',
'version' => '17.06',
'pass_hash' => 'test1234',
'receipt' => false,
},
'with ensure => present and username => user1, and password => secret and email => [email protected]' => {
'ensure' => 'present',
'username' => 'user1',
'password' => 'secret',
'email' => '[email protected]',
'version' => '17.06',
'pass_hash' => 'test1234',
'receipt' => false,
},
'with ensure => present and username => user1, and password => secret and email => [email protected] and version < 1.11.0' => {
'ensure' => 'present',
'username' => 'user1',
'password' => 'secret',
'email' => '[email protected]',
'version' => '1.9.0',
'pass_hash' => 'test1234',
'receipt' => false,
},
'with username => user1, and password => secret' => {
'username' => 'user1',
'password' => 'secret',
'version' => '17.06',
'pass_hash' => 'test1234',
'receipt' => false,
},
'with username => user1, and password => secret and local_user => testuser' => {
'username' => 'user1',
'password' => 'secret',
'local_user' => 'testuser',
'version' => '17.06',
'pass_hash' => 'test1234',
'receipt' => false,
},
}
describe 'docker::registry', type: :define do
on_supported_os.each do |os, os_facts|
##
## set some needed facts
##
if %r{windows}.match?(os)
facts = windows_facts.merge(
'docker_home_dirs' => {
'user' => '/home/user',
'root' => '/root',
},
).merge(os_facts)
docker_params = {
'docker_ee' => true,
}
else
facts = {
docker_home_dirs: {
'user' => '/home/user',
'root' => '/root',
},
}.merge(os_facts)
docker_params = {}
end
##
## get defaults values from params
##
defaults = get_defaults(facts)
context "on #{os}" do
tests.each do |title, local_params|
context title do
params = {
'server' => title,
'ensure' => 'present',
'username' => :undef,
'password' => :undef,
'pass_hash' => :undef,
'email' => :undef,
'local_user' => 'root',
'version' => defaults['version'],
'receipt' => true,
}.merge(local_params)
let(:facts) do
facts
end
let(:params) do
params
end
let(:title) do
title
end
let :pre_condition do
<<-MANIFEST
function pw_hash($foo, $bar, $asdf) {
return '$6$foobar$v8j5roVj0D8t.Ipwvk0RrMHiZfZRoBMeVQDywxUKFtdRI2EFRi2X6tbOigjpOsa9UDVzgIBtcl2ZEGcM.jnZZ.'
}
class { 'docker':
version => "#{params['version']}",
* => #{docker_params},
}
MANIFEST
end
include_examples 'registry', title, params, facts, defaults
end
end
end
end
end