|
1141 | 1141 | end
|
1142 | 1142 | end
|
1143 | 1143 |
|
| 1144 | + describe 'gitlab_shell_secret' do |
| 1145 | + let(:templatesymlink) { chef_run.templatesymlink('Create a gitlab_shell_secret and create a symlink to Rails root') } |
| 1146 | + |
| 1147 | + context 'by default' do |
| 1148 | + cached(:chef_run) do |
| 1149 | + ChefSpec::SoloRunner.new.converge('gitlab::default') |
| 1150 | + end |
| 1151 | + |
| 1152 | + it 'creates the template' do |
| 1153 | + expect(chef_run).to create_templatesymlink("Create a gitlab_pages_secret and create a symlink to Rails root").with( |
| 1154 | + owner: 'root', |
| 1155 | + group: 'root', |
| 1156 | + mode: '0644' |
| 1157 | + ) |
| 1158 | + end |
| 1159 | + |
| 1160 | + it 'template triggers notifications' do |
| 1161 | + expect(templatesymlink).to notify('runit_service[gitaly]').to(:restart).delayed |
| 1162 | + expect(templatesymlink).to notify('runit_service[puma]').to(:restart).delayed |
| 1163 | + expect(templatesymlink).to notify('sidekiq_service[sidekiq]').to(:restart).delayed |
| 1164 | + end |
| 1165 | + end |
| 1166 | + |
| 1167 | + context 'with gitlab-sshd enabled' do |
| 1168 | + let(:templatesymlink) { chef_run.templatesymlink('Create a gitlab_shell_secret and create a symlink to Rails root') } |
| 1169 | + |
| 1170 | + cached(:chef_run) do |
| 1171 | + RSpec::Mocks.with_temporary_scope do |
| 1172 | + stub_gitlab_rb( |
| 1173 | + gitlab_sshd: { enable: true } |
| 1174 | + ) |
| 1175 | + end |
| 1176 | + |
| 1177 | + ChefSpec::SoloRunner.new.converge('gitlab::default') |
| 1178 | + end |
| 1179 | + |
| 1180 | + it 'creates the template' do |
| 1181 | + expect(chef_run).to create_templatesymlink("Create a gitlab_pages_secret and create a symlink to Rails root").with( |
| 1182 | + owner: 'root', |
| 1183 | + group: 'root', |
| 1184 | + mode: '0644' |
| 1185 | + ) |
| 1186 | + end |
| 1187 | + |
| 1188 | + it 'template triggers notifications' do |
| 1189 | + expect(templatesymlink).to notify('runit_service[gitlab-sshd]').to(:restart).delayed |
| 1190 | + expect(templatesymlink).to notify('runit_service[gitaly]').to(:restart).delayed |
| 1191 | + expect(templatesymlink).to notify('runit_service[puma]').to(:restart).delayed |
| 1192 | + expect(templatesymlink).to notify('sidekiq_service[sidekiq]').to(:restart).delayed |
| 1193 | + end |
| 1194 | + end |
| 1195 | + |
| 1196 | + context 'with specific gitlab_shell_secret' do |
| 1197 | + let(:gitlab_shell_secret_token) { SecureRandom.base64(32) } |
| 1198 | + |
| 1199 | + cached(:chef_run) do |
| 1200 | + RSpec::Mocks.with_temporary_scope do |
| 1201 | + stub_gitlab_rb( |
| 1202 | + gitlab_shell: { secret_token: gitlab_shell_secret_token } |
| 1203 | + ) |
| 1204 | + end |
| 1205 | + |
| 1206 | + ChefSpec::SoloRunner.new.converge('gitlab::default') |
| 1207 | + end |
| 1208 | + |
| 1209 | + it 'renders the correct node attribute' do |
| 1210 | + expect(chef_run).to create_templatesymlink("Create a gitlab_shell_secret and create a symlink to Rails root").with_variables( |
| 1211 | + secret_token: gitlab_shell_secret_token |
| 1212 | + ) |
| 1213 | + end |
| 1214 | + |
| 1215 | + it 'uses the correct owner and permissions' do |
| 1216 | + expect(chef_run).to create_templatesymlink('Create a gitlab_shell_secret and create a symlink to Rails root').with( |
| 1217 | + owner: 'root', |
| 1218 | + group: 'root', |
| 1219 | + mode: '0644' |
| 1220 | + ) |
| 1221 | + end |
| 1222 | + |
| 1223 | + it 'template triggers notifications' do |
| 1224 | + expect(templatesymlink).to notify('runit_service[gitaly]').to(:restart).delayed |
| 1225 | + expect(templatesymlink).to notify('runit_service[puma]').to(:restart).delayed |
| 1226 | + expect(templatesymlink).to notify('sidekiq_service[sidekiq]').to(:restart).delayed |
| 1227 | + end |
| 1228 | + end |
| 1229 | + end |
| 1230 | + |
1144 | 1231 | describe 'gitlab_pages_secret' do
|
1145 | 1232 | let(:templatesymlink) { chef_run.templatesymlink('Create a gitlab_pages_secret and create a symlink to Rails root') }
|
1146 | 1233 |
|
|
0 commit comments