akamai_api 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +13 -0
- data/.yardopts +4 -0
- data/Gemfile +16 -0
- data/README.md +53 -52
- data/Thorfile +7 -1
- data/akamai_api.gemspec +1 -7
- data/bin/akamai_api +2 -1
- data/cassettes/akamai_api_ccu_arl_invalidate/invalid_credentials.yml +1 -1
- data/cassettes/akamai_api_ccu_arl_invalidate/invalid_item.yml +1 -1
- data/cassettes/akamai_api_ccu_arl_invalidate/multiple_items.yml +1 -1
- data/cassettes/akamai_api_ccu_arl_invalidate/single_item.yml +1 -1
- data/cassettes/akamai_api_ccu_arl_remove/invalid_credentials.yml +1 -1
- data/cassettes/akamai_api_ccu_arl_remove/invalid_item.yml +2 -2
- data/cassettes/akamai_api_ccu_arl_remove/multiple_items.yml +1 -1
- data/cassettes/akamai_api_ccu_arl_remove/single_item.yml +1 -1
- data/cassettes/akamai_api_ccu_cpcode_invalidate/invalid_credentials.yml +1 -1
- data/cassettes/akamai_api_ccu_cpcode_invalidate/invalid_item.yml +1 -1
- data/cassettes/akamai_api_ccu_cpcode_invalidate/multiple_items.yml +1 -1
- data/cassettes/akamai_api_ccu_cpcode_invalidate/single_item.yml +1 -1
- data/cassettes/akamai_api_ccu_cpcode_remove/invalid_credentials.yml +1 -1
- data/cassettes/akamai_api_ccu_cpcode_remove/invalid_item.yml +1 -1
- data/cassettes/akamai_api_ccu_cpcode_remove/multiple_items.yml +1 -1
- data/cassettes/akamai_api_ccu_cpcode_remove/single_item.yml +1 -1
- data/cassettes/akamai_api_eccu_all_ids/invalid_credentials.yml +68 -0
- data/cassettes/akamai_api_eccu_all_ids/successful.yml +72 -0
- data/cassettes/akamai_api_eccu_destroy/invalid_credentials.yml +69 -0
- data/cassettes/akamai_api_eccu_destroy/not_found_request.yml +55 -0
- data/cassettes/akamai_api_eccu_destroy/successful.yml +57 -0
- data/cassettes/akamai_api_eccu_find/invalid_credentials.yml +69 -0
- data/cassettes/akamai_api_eccu_find/not_found_request.yml +55 -0
- data/cassettes/akamai_api_eccu_find/successful.yml +70 -0
- data/cassettes/akamai_api_eccu_find/successful_without_content.yml +70 -0
- data/cassettes/akamai_api_eccu_publish/invalid_credentials.yml +5 -5
- data/cassettes/akamai_api_eccu_publish/invalid_domain.yml +7 -7
- data/cassettes/akamai_api_eccu_publish/successful.yml +8 -8
- data/cassettes/akamai_api_eccu_update_email/invalid_credentials.yml +69 -0
- data/cassettes/akamai_api_eccu_update_email/not_found_request.yml +55 -0
- data/cassettes/akamai_api_eccu_update_email/successful.yml +57 -0
- data/cassettes/akamai_api_eccu_update_notes/invalid_credentials.yml +70 -0
- data/cassettes/akamai_api_eccu_update_notes/not_found_request.yml +56 -0
- data/cassettes/akamai_api_eccu_update_notes/successful.yml +58 -0
- data/features/ccu_arl_invalidate.feature +5 -9
- data/features/ccu_arl_remove.feature +5 -9
- data/features/ccu_cpcode_invalidate.feature +2 -6
- data/features/ccu_cpcode_remove.feature +2 -6
- data/features/ccu_purge_status.feature +2 -2
- data/features/eccu_publish.feature +6 -42
- data/features/step_definitions/file_named_with_content_steps.rb +3 -0
- data/features/support/env.rb +12 -3
- data/lib/akamai_api/ccu/base_response.rb +27 -0
- data/lib/akamai_api/ccu/error.rb +38 -0
- data/lib/akamai_api/ccu/purge/request.rb +58 -11
- data/lib/akamai_api/ccu/purge/response.rb +15 -9
- data/lib/akamai_api/ccu/purge.rb +14 -3
- data/lib/akamai_api/ccu/purge_status/not_found.rb +18 -0
- data/lib/akamai_api/ccu/purge_status/request.rb +41 -7
- data/lib/akamai_api/ccu/purge_status/response.rb +49 -3
- data/lib/akamai_api/ccu/purge_status.rb +17 -9
- data/lib/akamai_api/ccu/status/request.rb +20 -7
- data/lib/akamai_api/ccu/status/response.rb +8 -2
- data/lib/akamai_api/ccu/status.rb +13 -2
- data/lib/akamai_api/ccu/unrecognized_option.rb +6 -0
- data/lib/akamai_api/ccu.rb +132 -23
- data/lib/akamai_api/cli/app.rb +15 -13
- data/lib/akamai_api/cli/ccu/arl.rb +10 -4
- data/lib/akamai_api/cli/ccu/base.rb +11 -3
- data/lib/akamai_api/cli/ccu/cp_code.rb +10 -4
- data/lib/akamai_api/cli/ccu/purge_renderer.rb +1 -1
- data/lib/akamai_api/cli/ccu/status_renderer.rb +46 -26
- data/lib/akamai_api/cli/ccu.rb +2 -4
- data/lib/akamai_api/cli/command.rb +60 -25
- data/lib/akamai_api/cli/eccu/base.rb +59 -0
- data/lib/akamai_api/cli/eccu/entry_renderer.rb +5 -3
- data/lib/akamai_api/cli/eccu.rb +2 -56
- data/lib/akamai_api/cli.rb +2 -6
- data/lib/akamai_api/eccu/base_edit_request.rb +51 -0
- data/lib/akamai_api/eccu/base_request.rb +32 -0
- data/lib/akamai_api/eccu/destroy_request.rb +30 -0
- data/lib/akamai_api/eccu/find_request.rb +45 -0
- data/lib/akamai_api/eccu/find_response.rb +110 -0
- data/lib/akamai_api/eccu/invalid_domain.rb +7 -0
- data/lib/akamai_api/eccu/list_request.rb +21 -0
- data/lib/akamai_api/eccu/not_found.rb +6 -0
- data/lib/akamai_api/eccu/publish_request.rb +75 -0
- data/lib/akamai_api/eccu/soap_body.rb +99 -0
- data/lib/akamai_api/eccu/update_attribute_request.rb +62 -0
- data/lib/akamai_api/eccu.rb +19 -0
- data/lib/akamai_api/eccu_request.rb +39 -117
- data/lib/akamai_api/error.rb +5 -0
- data/lib/akamai_api/unauthorized.rb +6 -0
- data/lib/akamai_api/version.rb +1 -1
- data/lib/akamai_api.rb +18 -4
- data/spec/features/ccu/purge_request_spec.rb +10 -12
- data/spec/features/ccu/purge_status_request_spec.rb +5 -5
- data/spec/features/ccu/status_request_spec.rb +3 -3
- data/spec/features/eccu/destroy_spec.rb +28 -0
- data/spec/features/eccu/find_request_spec.rb +34 -0
- data/spec/features/eccu/list_request_spec.rb +22 -0
- data/spec/features/eccu/publish_request_spec.rb +29 -0
- data/spec/features/eccu/update_email_spec.rb +28 -0
- data/spec/features/eccu/update_notes_spec.rb +28 -0
- data/spec/lib/akamai_api/ccu/{response_spec.rb → base_response_spec.rb} +2 -2
- data/spec/lib/akamai_api/ccu/purge/request_spec.rb +26 -20
- data/spec/lib/akamai_api/ccu/purge/response_spec.rb +16 -26
- data/spec/lib/akamai_api/ccu/purge_status/not_found_response_spec.rb +34 -34
- data/spec/lib/akamai_api/ccu/purge_status/request_spec.rb +24 -12
- data/spec/lib/akamai_api/ccu/purge_status/{successful_response_spec.rb → response_spec.rb} +8 -8
- data/spec/lib/akamai_api/ccu/status/request_spec.rb +6 -6
- data/spec/lib/akamai_api/ccu/status/response_spec.rb +2 -2
- data/spec/lib/akamai_api/ccu_spec.rb +7 -7
- data/spec/lib/akamai_api/cli/ccu/status_renderer_spec.rb +5 -17
- data/spec/lib/akamai_api/eccu/destroy_request_spec.rb +75 -0
- data/spec/lib/akamai_api/eccu/find_request_spec.rb +74 -0
- data/spec/lib/akamai_api/eccu/find_response_spec.rb +159 -0
- data/spec/lib/akamai_api/eccu/list_request_spec.rb +43 -0
- data/spec/lib/akamai_api/eccu/publish_request_spec.rb +133 -0
- data/spec/lib/akamai_api/eccu/soap_body_spec.rb +46 -0
- data/spec/lib/akamai_api/eccu/update_attribute_request_spec.rb +86 -0
- data/spec/lib/akamai_api/eccu_request_spec.rb +149 -158
- data/spec/spec_helper.rb +11 -3
- metadata +90 -104
- data/lib/akamai_api/ccu/purge_status/not_found_response.rb +0 -9
- data/lib/akamai_api/ccu/purge_status/successful_response.rb +0 -25
- data/lib/akamai_api/ccu/response.rb +0 -18
- data/lib/akamai_api/soap_body.rb +0 -40
- data/spec/lib/akamai_api/soap_body_spec.rb +0 -48
- data/spec/support/savon_backports.rb +0 -10
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module AkamaiApi
|
4
|
-
describe
|
4
|
+
describe ECCURequest do
|
5
5
|
include Savon::SpecHelper
|
6
6
|
|
7
7
|
before(:all) { savon.mock! }
|
@@ -14,69 +14,68 @@ module AkamaiApi
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'returns the id list of all available requests' do
|
17
|
-
|
17
|
+
expect(ECCURequest.all_ids).to match_array ['42994282', '43000154']
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
describe '::find' do
|
22
|
-
|
22
|
+
subject { ECCURequest }
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
it 'delegates to FindRequest' do
|
25
|
+
fake_request = double
|
26
|
+
expect(fake_request).to receive(:execute).with(true).and_return AkamaiApi::ECCU::FindResponse.new({})
|
27
|
+
expect(AkamaiApi::ECCU::FindRequest).to receive(:new).with('1234').and_return fake_request
|
28
|
+
subject.find '1234'
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
EccuRequest.find('1234567')
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'sets to return file content if verbose is specified' do
|
39
|
-
body = soap_body(1234567, true).to_s
|
40
|
-
savon.expects(:get_info).with(:message => body).returns(fixture)
|
41
|
-
EccuRequest.find('1234567', :verbose => true)
|
42
|
-
end
|
31
|
+
it "returns an ECCURequest" do
|
32
|
+
response = AkamaiApi::ECCU::FindResponse.new({})
|
33
|
+
expect_any_instance_of(AkamaiApi::ECCU::FindRequest).to receive(:execute).and_return response
|
34
|
+
subject.find '1234'
|
43
35
|
end
|
44
36
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
37
|
+
{
|
38
|
+
file: :file,
|
39
|
+
status: :status,
|
40
|
+
code: :code,
|
41
|
+
notes: :notes,
|
42
|
+
property: :property,
|
43
|
+
email: :email,
|
44
|
+
upload_date: :uploaded_at,
|
45
|
+
uploaded_by: :uploaded_by,
|
46
|
+
version: :version
|
47
|
+
}.each do |local_name, remote_name|
|
48
|
+
it "maps response '#{remote_name}' to '#{local_name}'" do
|
49
|
+
response = AkamaiApi::ECCU::FindResponse.new({})
|
50
|
+
allow(response).to receive(remote_name) { "foobarbaz" }
|
51
|
+
expect_any_instance_of(AkamaiApi::ECCU::FindRequest).to receive(:execute).and_return response
|
52
|
+
expect(subject.find('1234').send local_name).to eq "foobarbaz"
|
53
|
+
end
|
50
54
|
end
|
51
55
|
end
|
52
56
|
|
53
57
|
describe '::last' do
|
54
58
|
it 'find the most recent entry' do
|
55
|
-
|
56
|
-
|
57
|
-
|
59
|
+
allow(ECCURequest).to receive(:all_ids) { %w(a b) }
|
60
|
+
allow(ECCURequest).to receive(:find).with('b', anything()).and_return :a
|
61
|
+
expect(ECCURequest.last).to eq :a
|
58
62
|
end
|
59
63
|
end
|
60
64
|
|
61
65
|
describe '::first' do
|
62
66
|
it 'find the oldest entry' do
|
63
|
-
|
64
|
-
|
65
|
-
|
67
|
+
allow(ECCURequest).to receive(:all_ids) { %w(a b) }
|
68
|
+
allow(ECCURequest).to receive(:find).with('a', anything()).and_return :a
|
69
|
+
expect(ECCURequest.first).to eq :a
|
66
70
|
end
|
67
71
|
end
|
68
72
|
|
69
73
|
describe '::all' do
|
70
74
|
it 'returns the detail for each enlisted id' do
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
end
|
76
|
-
it 'returns the detail for each enlisted id even if only one id is returned' do
|
77
|
-
EccuRequest.stub :all_ids => "a"
|
78
|
-
EccuRequest.should_receive(:find).with('a', anything()).and_return(:a)
|
79
|
-
EccuRequest.all.should =~ [:a]
|
75
|
+
allow(ECCURequest).to receive(:all_ids) { %w(a b) }
|
76
|
+
allow(ECCURequest).to receive(:find).with('a', anything()).and_return(:a)
|
77
|
+
allow(ECCURequest).to receive(:find).with('b', anything()).and_return(:b)
|
78
|
+
expect(ECCURequest.all).to match_array [:a, :b]
|
80
79
|
end
|
81
80
|
end
|
82
81
|
|
@@ -87,80 +86,44 @@ module AkamaiApi
|
|
87
86
|
describe '::publish_file' do
|
88
87
|
it 'calls publish with the content of the specified file' do
|
89
88
|
args = {}
|
90
|
-
|
91
|
-
|
89
|
+
allow(ECCURequest).to receive(:publish).with('foo', xml_request_content, args)
|
90
|
+
ECCURequest.publish_file('foo', xml_request, args)
|
92
91
|
end
|
93
92
|
end
|
94
93
|
|
95
94
|
describe '::publish' do
|
96
|
-
|
97
|
-
before do
|
98
|
-
fixture = File.read 'spec/fixtures/eccu/upload/fault.xml'
|
99
|
-
savon.expects(:upload).with(:message => :any).returns(fixture)
|
100
|
-
end
|
95
|
+
let(:subject) { ECCURequest }
|
101
96
|
|
102
|
-
|
103
|
-
|
104
|
-
|
97
|
+
it 'does not alter given arguments' do
|
98
|
+
expect_any_instance_of(AkamaiApi::ECCU::PublishRequest).to receive :execute
|
99
|
+
args = { property_type: 'asd' }
|
100
|
+
expect { subject.publish 'foo.com', 'asd', args }.to_not change args, :count
|
105
101
|
end
|
106
102
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
EccuRequest.publish('', xml_request_content).should be_a Fixnum
|
113
|
-
end
|
114
|
-
|
115
|
-
it 'assigns the fields correctly' do
|
116
|
-
content = xml_request_content
|
117
|
-
body = SoapBody.new do
|
118
|
-
string :filename, 'eccu_request.xml'
|
119
|
-
text :contents, content
|
120
|
-
string :notes, 'sample notes'
|
121
|
-
string :versionString, 'v2'
|
122
|
-
string :statusChangeEmail, 'foo@foo.com bar@bar.com'
|
123
|
-
string :propertyName, 'foo.com'
|
124
|
-
string :propertyType, 'prop'
|
125
|
-
boolean :propertyNameExactMatch, false
|
126
|
-
end
|
127
|
-
savon.expects(:upload).with(:message => body.to_s).returns(fixture)
|
128
|
-
EccuRequest.publish('foo.com', xml_request_content, {
|
129
|
-
:file_name => 'eccu_request.xml',
|
130
|
-
:notes => 'sample notes',
|
131
|
-
:version => 'v2',
|
132
|
-
:emails => %w(foo@foo.com bar@bar.com),
|
133
|
-
:property_type => 'prop',
|
134
|
-
:property_exact_match => false
|
135
|
-
})
|
136
|
-
end
|
103
|
+
it 'correctly builds a PublishRequest' do
|
104
|
+
expected_args = ['foo.com', { type: 'hostheader', exact_match: true }]
|
105
|
+
expect(AkamaiApi::ECCU::PublishRequest).to receive(:new).with(*expected_args).and_return double(execute: nil)
|
106
|
+
subject.publish 'foo.com', 'asd', property_type: 'hostheader', property_exact_match: true
|
107
|
+
end
|
137
108
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
EccuRequest.publish '', xml_request_content
|
143
|
-
end
|
109
|
+
it 'does not pass nil values to constructor arguments' do
|
110
|
+
expect(AkamaiApi::ECCU::PublishRequest).to receive(:new).with('foo.com', {}).and_return double(execute: nil)
|
111
|
+
subject.publish 'foo.com', 'asd', property_type: nil, property_exact_match: nil
|
112
|
+
end
|
144
113
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
end
|
114
|
+
it 'delegates to PublishRequest#execute' do
|
115
|
+
expect_any_instance_of(AkamaiApi::ECCU::PublishRequest).to receive(:execute).and_return 1
|
116
|
+
expect(subject.publish 'foo.com', 'asd').to eq 1
|
117
|
+
end
|
150
118
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
EccuRequest.publish '', xml_request_content
|
156
|
-
end
|
119
|
+
it 'pass content and given arguments to execute' do
|
120
|
+
expect_any_instance_of(AkamaiApi::ECCU::PublishRequest).to receive(:execute).with 'asd', emails: 'foo@bar.com'
|
121
|
+
subject.publish 'foo.com', 'asd', emails: 'foo@bar.com'
|
122
|
+
end
|
157
123
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
savon.expects(:upload).with(:message => :any).returns(fixture)
|
162
|
-
EccuRequest.publish '', xml_request_content
|
163
|
-
end
|
124
|
+
it 'removed unnecessary arguments when calling execute' do
|
125
|
+
expect_any_instance_of(AkamaiApi::ECCU::PublishRequest).to receive(:execute).with 'asd', emails: 'foo@bar.com'
|
126
|
+
subject.publish 'foo.com', 'asd', emails: 'foo@bar.com', property_exact_match: false
|
164
127
|
end
|
165
128
|
end
|
166
129
|
end
|
@@ -168,90 +131,118 @@ module AkamaiApi
|
|
168
131
|
describe 'instance' do
|
169
132
|
describe 'constructor' do
|
170
133
|
it 'assigns the attributes hash to the accessors' do
|
171
|
-
req =
|
172
|
-
req.status.
|
173
|
-
req.notes.
|
134
|
+
req = ECCURequest.new :status => 'foo', :notes => 'bar'
|
135
|
+
expect(req.status).to eq 'foo'
|
136
|
+
expect(req.notes).to eq 'bar'
|
174
137
|
end
|
175
138
|
end
|
176
139
|
|
177
140
|
describe '#update_notes!' do
|
178
|
-
|
179
|
-
|
180
|
-
it '
|
181
|
-
|
182
|
-
|
183
|
-
expect
|
184
|
-
|
185
|
-
}.to change(req, :notes).to 'foo'
|
141
|
+
subject { ECCURequest.new code: '1234' }
|
142
|
+
|
143
|
+
it 'delegates to UpdateAttributeRequest' do
|
144
|
+
fake_request = double
|
145
|
+
expect(fake_request).to receive(:execute).with('foo').and_return true
|
146
|
+
expect(AkamaiApi::ECCU::UpdateAttributeRequest).to receive(:new).with('1234', :notes).and_return fake_request
|
147
|
+
subject.update_notes! 'foo'
|
186
148
|
end
|
187
149
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
150
|
+
context 'when the update is successful' do
|
151
|
+
before do
|
152
|
+
expect_any_instance_of(AkamaiApi::ECCU::UpdateAttributeRequest).to receive(:execute).and_return true
|
153
|
+
end
|
154
|
+
|
155
|
+
it "returns true" do
|
156
|
+
expect(subject.update_notes! 'foo').to be_truthy
|
157
|
+
end
|
158
|
+
|
159
|
+
it "updates notes attribute" do
|
160
|
+
expect { subject.update_notes! 'foo' }.to change(subject, :notes).to 'foo'
|
192
161
|
end
|
193
|
-
savon.expects(:set_notes).with(:message => body.to_s).returns(fixture)
|
194
|
-
EccuRequest.new(:code => '1234').update_notes! 'foo'
|
195
162
|
end
|
196
163
|
|
197
|
-
|
198
|
-
|
199
|
-
|
164
|
+
context 'when the update is not successful' do
|
165
|
+
before do
|
166
|
+
expect_any_instance_of(AkamaiApi::ECCU::UpdateAttributeRequest).to receive(:execute).and_return false
|
167
|
+
end
|
168
|
+
|
169
|
+
it "returns false" do
|
170
|
+
expect(subject.update_notes! 'foo').to be_falsy
|
171
|
+
end
|
172
|
+
|
173
|
+
it "does not update the notes attribute" do
|
174
|
+
expect { subject.update_notes! 'foo' }.to_not change { subject.notes }
|
175
|
+
end
|
200
176
|
end
|
201
177
|
end
|
202
178
|
|
203
|
-
describe '#update_email' do
|
204
|
-
|
179
|
+
describe '#update_email!' do
|
180
|
+
subject { ECCURequest.new code: '1234' }
|
205
181
|
|
206
|
-
it '
|
207
|
-
|
208
|
-
|
209
|
-
expect
|
210
|
-
|
211
|
-
}.to change(req, :email).to 'foo'
|
182
|
+
it 'delegates to UpdateEmailRequest' do
|
183
|
+
fake_request = double
|
184
|
+
expect(fake_request).to receive(:execute).with('foo').and_return true
|
185
|
+
expect(AkamaiApi::ECCU::UpdateAttributeRequest).to receive(:new).with('1234', :status_change_email).and_return fake_request
|
186
|
+
subject.update_email! 'foo'
|
212
187
|
end
|
213
188
|
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
189
|
+
context 'when the update is successful' do
|
190
|
+
before do
|
191
|
+
expect_any_instance_of(AkamaiApi::ECCU::UpdateAttributeRequest).to receive(:execute).and_return true
|
192
|
+
end
|
193
|
+
|
194
|
+
it "returns true" do
|
195
|
+
expect(subject.update_email! 'foo').to be_truthy
|
218
196
|
end
|
219
|
-
savon.expects(:set_status_change_email).with(:message => body.to_s).returns(fixture)
|
220
|
-
EccuRequest.new(:code => '1234').update_email! 'foo'
|
221
|
-
end
|
222
197
|
|
223
|
-
|
224
|
-
|
225
|
-
|
198
|
+
it "updates notes attribute" do
|
199
|
+
expect { subject.update_email! 'foo' }.to change(subject, :email).to 'foo'
|
200
|
+
end
|
226
201
|
end
|
227
202
|
|
228
|
-
context 'when
|
229
|
-
|
203
|
+
context 'when the update is not successful' do
|
204
|
+
before do
|
205
|
+
expect_any_instance_of(AkamaiApi::ECCU::UpdateAttributeRequest).to receive(:execute).and_return false
|
206
|
+
end
|
207
|
+
|
208
|
+
it "returns false" do
|
209
|
+
expect(subject.update_email! 'foo').to be_falsy
|
210
|
+
end
|
230
211
|
|
231
|
-
it
|
232
|
-
|
233
|
-
req = EccuRequest.new :code => '1234'
|
234
|
-
expect {
|
235
|
-
req.update_email! 'foo'
|
236
|
-
}.to_not change(req, :email)
|
212
|
+
it "does not update the email attribute" do
|
213
|
+
expect { subject.update_email! 'foo' }.to_not change { subject.email }
|
237
214
|
end
|
238
215
|
end
|
239
216
|
end
|
240
217
|
|
241
218
|
describe '#destroy' do
|
242
|
-
|
219
|
+
subject { ECCURequest.new code: '1234' }
|
220
|
+
|
221
|
+
it 'delegates to DestroyRequest' do
|
222
|
+
fake_request = double
|
223
|
+
expect(fake_request).to receive(:execute).and_return true
|
224
|
+
expect(AkamaiApi::ECCU::DestroyRequest).to receive(:new).with('1234').and_return fake_request
|
225
|
+
subject.destroy
|
226
|
+
end
|
227
|
+
|
228
|
+
context 'when the update is successful' do
|
229
|
+
before do
|
230
|
+
expect_any_instance_of(AkamaiApi::ECCU::DestroyRequest).to receive(:execute).and_return true
|
231
|
+
end
|
243
232
|
|
244
|
-
|
245
|
-
|
246
|
-
integer :fileId, 1234
|
233
|
+
it "returns true" do
|
234
|
+
expect(subject.destroy).to be_truthy
|
247
235
|
end
|
248
|
-
savon.expects(:delete).with(:message => body.to_s).returns(fixture)
|
249
|
-
EccuRequest.new(:code => '1234').destroy
|
250
236
|
end
|
251
237
|
|
252
|
-
|
253
|
-
|
254
|
-
|
238
|
+
context 'when the update is not successful' do
|
239
|
+
before do
|
240
|
+
expect_any_instance_of(AkamaiApi::ECCU::DestroyRequest).to receive(:execute).and_return false
|
241
|
+
end
|
242
|
+
|
243
|
+
it "returns false" do
|
244
|
+
expect(subject.destroy).to be_falsy
|
245
|
+
end
|
255
246
|
end
|
256
247
|
end
|
257
248
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,25 +1,34 @@
|
|
1
1
|
require File.expand_path '../../lib/akamai_api', __FILE__
|
2
2
|
require File.expand_path '../../lib/akamai_api/cli', __FILE__
|
3
|
-
require File.expand_path '../auth.rb', __FILE__
|
4
3
|
|
4
|
+
begin
|
5
|
+
require File.expand_path '../auth.rb', __FILE__
|
6
|
+
rescue LoadError
|
7
|
+
AkamaiApi.config[:auth] = ['test_username', 'test_password']
|
8
|
+
end
|
5
9
|
require 'savon/mock/spec_helper'
|
6
10
|
require 'webmock/rspec'
|
7
11
|
require 'vcr'
|
12
|
+
require 'coveralls'
|
13
|
+
Coveralls.wear_merged!
|
8
14
|
|
9
15
|
VCR.configure do |c|
|
10
16
|
c.cassette_library_dir = 'cassettes'
|
11
17
|
c.hook_into :webmock
|
12
18
|
c.default_cassette_options = {
|
13
|
-
record: :once
|
19
|
+
record: :once,
|
20
|
+
match_requests_on: [:method, :uri, :body]
|
14
21
|
}
|
15
22
|
c.configure_rspec_metadata!
|
16
23
|
c.after_http_request do |request|
|
17
24
|
request.uri.gsub! AkamaiApi.config[:auth].first, 'USERNAME'
|
18
25
|
request.uri.gsub! AkamaiApi.config[:auth].last, 'PASSWORD'
|
26
|
+
request.body.gsub! "AkamaiApi #{AkamaiApi::VERSION}", "AkamaiApi VERSION"
|
19
27
|
end
|
20
28
|
c.before_playback do |i|
|
21
29
|
i.request.uri.gsub! 'USERNAME', AkamaiApi.config[:auth].first
|
22
30
|
i.request.uri.gsub! 'PASSWORD', AkamaiApi.config[:auth].last
|
31
|
+
i.request.body.gsub! "AkamaiApi VERSION", "AkamaiApi #{AkamaiApi::VERSION}"
|
23
32
|
end
|
24
33
|
end
|
25
34
|
|
@@ -29,7 +38,6 @@ Dir[File.expand_path '../support/**/*.rb', __FILE__].each do |f|
|
|
29
38
|
end
|
30
39
|
|
31
40
|
RSpec.configure do |config|
|
32
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
33
41
|
config.run_all_when_everything_filtered = true
|
34
42
|
config.filter_run :focus
|
35
43
|
|