forked from puppetlabs/puppetlabs-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregistry_spec.rb
69 lines (58 loc) · 3.95 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
require 'spec_helper'
describe 'docker::registry', :type => :define do
let(:title) { 'localhost:5000' }
let(:facts) { {
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:lsbdistid => 'Debian',
:lsbdistcodename => 'jessie',
:kernelrelease => '3.2.0-4-amd64',
:operatingsystemmajrelease => '8',
} }
let(:params) { { 'version' => '17.06', 'pass_hash' => 'test1234', 'receipt' => false } }
it { should contain_exec('localhost:5000 auth') }
context 'with ensure => present' do
let(:params) { { 'ensure' => 'absent', 'version' => '17.06', 'pass_hash' => 'test1234', 'receipt' => false } }
it { should contain_exec('localhost:5000 auth').with_command('docker logout localhost:5000') }
end
context 'with ensure => present' do
let(:params) { { 'ensure' => 'present', 'version' => '17.06', 'pass_hash' => 'test1234', 'receipt' => false } }
it { should contain_exec('localhost:5000 auth').with_command('docker login localhost:5000') }
end
context 'with ensure => present and username => user1' do
let(:params) { { 'ensure' => 'present', 'username' => 'user1', 'version' => '17.06', 'pass_hash' => 'test1234', 'receipt' => false } }
it { should contain_exec('localhost:5000 auth').with_command('docker login localhost:5000') }
end
context 'with ensure => present and password => secret' do
let(:params) { { 'ensure' => 'present', 'password' => 'secret', 'version' => '17.06', 'pass_hash' => 'test1234', 'receipt' => false } }
it { should contain_exec('localhost:5000 auth').with_command('docker login localhost:5000') }
end
context 'with ensure => present and email => [email protected]' do
let(:params) { { 'ensure' => 'present', 'email' => '[email protected]', 'version' => '17.06', 'pass_hash' => 'test1234', 'receipt' => false } }
it { should contain_exec('localhost:5000 auth').with_command('docker login localhost:5000') }
end
context 'with ensure => present and username => user1, and password => secret and email => [email protected]' do
let(:params) { { 'ensure' => 'present', 'username' => 'user1', 'password' => 'secret', 'email' => '[email protected]', 'version' => '17.06', 'pass_hash' => 'test1234', 'receipt' => false } }
it { should contain_exec('localhost:5000 auth').with_command("docker login -u 'user1' -p \"${password}\" localhost:5000").with_environment(/password=secret/) }
end
context 'with ensure => present and username => user1, and password => secret and email => [email protected] and version < 1.11.0' do
let(:params) { { 'ensure' => 'present', 'username' => 'user1', 'password' => 'secret', 'email' => '[email protected]', 'version' => '1.9.0', 'pass_hash' => 'test1234', 'receipt' => false } }
it { should contain_exec('localhost:5000 auth').with_command("docker login -u 'user1' -p \"${password}\" -e '[email protected]' localhost:5000").with_environment(/password=secret/) }
end
context 'with username => user1, and password => secret' do
let(:params) { { 'username' => 'user1', 'password' => 'secret', 'version' => '17.06', 'pass_hash' => 'test1234', 'receipt' => false } }
it { should contain_exec('localhost:5000 auth').with_command("docker login -u 'user1' -p \"${password}\" localhost:5000").with_environment(/password=secret/) }
end
context 'with username => user1, and password => secret and local_user => testuser' do
let(:params) { { 'username' => 'user1', 'password' => 'secret', 'local_user' => 'testuser', 'version' => '17.06', 'pass_hash' => 'test1234', 'receipt' => false } }
it { should contain_exec('localhost:5000 auth').with_command("docker login -u 'user1' -p \"${password}\" localhost:5000").with_user('testuser').with_environment(/password=secret/) }
end
context 'with an invalid ensure value' do
let(:params) { { 'ensure' => 'not present or absent' } }
it do
expect {
should contain_exec('docker logout localhost:5000')
}.to raise_error(Puppet::Error)
end
end
end