X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=spec%2Funit%2Fpuppet%2Ftype%2Fapt_key_spec.rb;h=b17c8aed0ddb8056e704eacd557780f7eb671a95;hb=249a6d586279ab96ffa8f645dcdd0e44210fd4e6;hp=cfdd16b38ff81ffc1ce766e4fb1491cd4feda22a;hpb=0a93286ff8d28a75e3eccdabe0bd944f993430bf;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/spec/unit/puppet/type/apt_key_spec.rb b/spec/unit/puppet/type/apt_key_spec.rb index cfdd16b..b17c8ae 100644 --- a/spec/unit/puppet/type/apt_key_spec.rb +++ b/spec/unit/puppet/type/apt_key_spec.rb @@ -7,23 +7,23 @@ describe Puppet::Type::type(:apt_key) do :id => '4BD6EC30' )} it 'id is set' do - resource[:id].should eq '4BD6EC30' + expect(resource[:id]).to eq '4BD6EC30' end it 'name is set to id' do - resource[:name].should eq '4BD6EC30' + expect(resource[:name]).to eq '4BD6EC30' end it 'keyserver is default' do - resource[:server].should eq :'keyserver.ubuntu.com' + expect(resource[:server]).to eq :'keyserver.ubuntu.com' end it 'source is not set' do - resource[:source].should eq nil + expect(resource[:source]).to eq nil end it 'content is not set' do - resource[:content].should eq nil + expect(resource[:content]).to eq nil end end @@ -32,7 +32,7 @@ describe Puppet::Type::type(:apt_key) do :id => '4bd6ec30' )} it 'id is set' do - resource[:id].should eq '4BD6EC30' + expect(resource[:id]).to eq '4BD6EC30' end end @@ -41,7 +41,7 @@ describe Puppet::Type::type(:apt_key) do :id => 'FFFFFFFF4BD6EC30' )} it 'id is set' do - resource[:id].should eq '4BD6EC30' + expect(resource[:id]).to eq 'FFFFFFFF4BD6EC30' end end @@ -50,7 +50,7 @@ describe Puppet::Type::type(:apt_key) do :id => '0x4BD6EC30' )} it 'id is set' do - resource[:id].should eq '4BD6EC30' + expect(resource[:id]).to eq '4BD6EC30' end end @@ -59,7 +59,7 @@ describe Puppet::Type::type(:apt_key) do :id => '0x4bd6ec30' )} it 'id is set' do - resource[:id].should eq '4BD6EC30' + expect(resource[:id]).to eq '4BD6EC30' end end @@ -68,7 +68,7 @@ describe Puppet::Type::type(:apt_key) do :id => '0xFFFFFFFF4BD6EC30' )} it 'id is set' do - resource[:id].should eq '4BD6EC30' + expect(resource[:id]).to eq 'FFFFFFFF4BD6EC30' end end @@ -79,10 +79,10 @@ describe Puppet::Type::type(:apt_key) do )} it 'source is set to the URL' do - resource[:source].should eq 'http://apt.puppetlabs.com/pubkey.gpg' + expect(resource[:source]).to eq 'http://apt.puppetlabs.com/pubkey.gpg' end end - + context 'with content' do let(:resource) { Puppet::Type.type(:apt_key).new( :id => '4BD6EC30', @@ -90,10 +90,10 @@ describe Puppet::Type::type(:apt_key) do )} it 'content is set to the string' do - resource[:content].should eq 'http://apt.puppetlabs.com/pubkey.gpg' + expect(resource[:content]).to eq 'http://apt.puppetlabs.com/pubkey.gpg' end end - + context 'with keyserver' do let(:resource) { Puppet::Type.type(:apt_key).new( :id => '4BD6EC30', @@ -101,7 +101,7 @@ describe Puppet::Type::type(:apt_key) do )} it 'keyserver is set to Debian' do - resource[:server].should eq 'http://keyring.debian.org' + expect(resource[:server]).to eq 'http://keyring.debian.org' end end @@ -136,6 +136,13 @@ describe Puppet::Type::type(:apt_key) do )}.to_not raise_error end + it 'allows the http URI with username and password' do + expect { Puppet::Type.type(:apt_key).new( + :id => '4BD6EC30', + :source => 'http://testme:Password2@pgp.mit.edu' + )}.to_not raise_error + end + it 'allows the https URI scheme in source' do expect { Puppet::Type.type(:apt_key).new( :id => '4BD6EC30', @@ -143,11 +150,39 @@ describe Puppet::Type::type(:apt_key) do )}.to_not raise_error end + it 'allows the https URI with username and password' do + expect { Puppet::Type.type(:apt_key).new( + :id => '4BD6EC30', + :source => 'https://testme:Password2@pgp.mit.edu' + )}.to_not raise_error + end + + it 'allows the ftp URI scheme in source' do + expect { Puppet::Type.type(:apt_key).new( + :id => '4BD6EC30', + :source => 'ftp://pgp.mit.edu' + )}.to_not raise_error + end + it 'allows an absolute path in source' do expect { Puppet::Type.type(:apt_key).new( :id => '4BD6EC30', :source => '/path/to/a/file' )}.to_not raise_error end + + it 'allows 5-digit ports' do + expect { Puppet::Type.type(:apt_key).new( + :id => '4BD6EC30', + :source => 'http://pgp.mit.edu:12345/key' + )}.to_not raise_error + end + + it 'allows 5-digit ports when using key servers' do + expect { Puppet::Type.type(:apt_key).new( + :id => '4BD6EC30', + :server => 'http://pgp.mit.edu:12345' + )}.to_not raise_error + end end end