blob: fc1ac1a0e812d860faa3361e2f98b72bc869ca35 (
plain)
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
|
require 'spec_helper'
require 'puppet/forge'
describe Puppet::Forge::Errors do
describe 'SSLVerifyError' do
subject { Puppet::Forge::Errors::SSLVerifyError }
let(:exception) { subject.new(:uri => 'https://fake.com:1111') }
it 'should return a valid single line error' do
exception.message.should == 'Unable to verify the SSL certificate at https://fake.com:1111'
end
it 'should return a valid multiline error' do
exception.multiline.should == <<-EOS.chomp
Could not connect via HTTPS to https://fake.com:1111
Unable to verify the SSL certificate
The certificate may not be signed by a valid CA
The CA bundle included with OpenSSL may not be valid or up to date
EOS
end
end
describe 'CommunicationError' do
subject { Puppet::Forge::Errors::CommunicationError }
let(:socket_exception) { SocketError.new('There was a problem') }
let(:exception) { subject.new(:uri => 'http://fake.com:1111', :original => socket_exception) }
it 'should return a valid single line error' do
exception.message.should == 'Unable to connect to the server at http://fake.com:1111. Detail: There was a problem.'
end
it 'should return a valid multiline error' do
exception.multiline.should == <<-EOS.chomp
Could not connect to http://fake.com:1111
There was a network communications problem
The error we caught said 'There was a problem'
Check your network connection and try again
EOS
end
end
describe 'ResponseError' do
subject { Puppet::Forge::Errors::ResponseError }
let(:response) { stub(:body => '{}', :code => '404', :message => "not found") }
context 'without message' do
let(:exception) { subject.new(:uri => 'http://fake.com:1111', :response => response, :input => 'user/module') }
it 'should return a valid single line error' do
exception.message.should == 'Request to Puppet Forge failed. Detail: 404 not found.'
end
it 'should return a valid multiline error' do
exception.multiline.should == <<-eos.chomp
Request to Puppet Forge failed.
The server being queried was http://fake.com:1111
The HTTP response we received was '404 not found'
eos
end
end
context 'with message' do
let(:exception) { subject.new(:uri => 'http://fake.com:1111', :response => response, :input => 'user/module', :message => 'no such module') }
it 'should return a valid single line error' do
exception.message.should == 'Request to Puppet Forge failed. Detail: no such module / 404 not found.'
end
it 'should return a valid multiline error' do
exception.multiline.should == <<-eos.chomp
Request to Puppet Forge failed.
The server being queried was http://fake.com:1111
The HTTP response we received was '404 not found'
The message we received said 'no such module'
eos
end
end
end
end
|