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,6 +1,18 @@
|
|
1
|
+
require "savon"
|
2
|
+
require "active_support"
|
3
|
+
require "active_support/core_ext/array"
|
4
|
+
require "active_support/core_ext/object/blank"
|
5
|
+
|
6
|
+
require "akamai_api/eccu/soap_body"
|
7
|
+
require "akamai_api/eccu/update_attribute_request"
|
8
|
+
require "akamai_api/eccu/destroy_request"
|
9
|
+
require "akamai_api/eccu/find_request"
|
10
|
+
require "akamai_api/eccu/publish_request"
|
11
|
+
require "akamai_api/eccu/list_request"
|
12
|
+
|
1
13
|
module AkamaiApi
|
2
|
-
class
|
3
|
-
attr_accessor :file, :status, :code, :notes, :property, :email, :upload_date, :uploaded_by, :
|
14
|
+
class ECCURequest
|
15
|
+
attr_accessor :file, :status, :code, :notes, :property, :email, :upload_date, :uploaded_by, :version
|
4
16
|
|
5
17
|
def initialize attributes = {}
|
6
18
|
attributes.each do |key, value|
|
@@ -8,57 +20,28 @@ module AkamaiApi
|
|
8
20
|
end
|
9
21
|
end
|
10
22
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
resp.body[:set_notes_response][:success]
|
20
|
-
rescue Savon::HTTPError => e
|
21
|
-
raise ::AkamaiApi::Unauthorized if e.http.code == 401
|
22
|
-
raise
|
23
|
-
end
|
24
|
-
|
25
|
-
def update_email! email
|
26
|
-
code = self.code.to_i
|
27
|
-
body = SoapBody.new do
|
28
|
-
integer :fileId, code
|
29
|
-
string :statusChangeEmail, email
|
23
|
+
{
|
24
|
+
notes: :notes,
|
25
|
+
email: :status_change_email
|
26
|
+
}.each do |name, attribute|
|
27
|
+
define_method "update_#{name}!" do |value|
|
28
|
+
successful = AkamaiApi::ECCU::UpdateAttributeRequest.new(code, attribute).execute(value)
|
29
|
+
send "#{name}=", value if successful
|
30
|
+
successful
|
30
31
|
end
|
31
|
-
response = client.call :set_status_change_email, :message => body.to_s
|
32
|
-
successful = response.body[:set_status_change_email_response][:success]
|
33
|
-
self.email = email if successful
|
34
|
-
successful
|
35
|
-
rescue Savon::HTTPError => e
|
36
|
-
raise ::AkamaiApi::Unauthorized if e.http.code == 401
|
37
|
-
raise
|
38
32
|
end
|
39
33
|
|
40
34
|
def destroy
|
41
|
-
|
42
|
-
body = SoapBody.new do
|
43
|
-
integer :fileId, code
|
44
|
-
end
|
45
|
-
response = client.call :delete, :message => body.to_s
|
46
|
-
response.body[:delete_response][:success]
|
47
|
-
rescue Savon::HTTPError => e
|
48
|
-
raise ::AkamaiApi::Unauthorized if e.http.code == 401
|
49
|
-
raise
|
35
|
+
AkamaiApi::ECCU::DestroyRequest.new(code).execute
|
50
36
|
end
|
51
37
|
|
52
38
|
class << self
|
53
39
|
def all_ids
|
54
|
-
|
55
|
-
rescue Savon::HTTPError => e
|
56
|
-
raise ::AkamaiApi::Unauthorized if e.http.code == 401
|
57
|
-
raise
|
40
|
+
AkamaiApi::ECCU::ListRequest.new.execute
|
58
41
|
end
|
59
42
|
|
60
43
|
def all args = {}
|
61
|
-
|
44
|
+
all_ids.map { |v| ECCURequest.find v, args }
|
62
45
|
end
|
63
46
|
|
64
47
|
def last args = {}
|
@@ -70,40 +53,16 @@ module AkamaiApi
|
|
70
53
|
end
|
71
54
|
|
72
55
|
def find code, args = {}
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
:
|
82
|
-
:
|
83
|
-
:file_name => get_if_kind(response_body[:filename], String),
|
84
|
-
:md5_digest => get_if_kind(response_body[:md5_digest], String)
|
85
|
-
},
|
86
|
-
:status => {
|
87
|
-
:extended => get_if_kind(response_body[:extended_status_message], String),
|
88
|
-
:code => response_body[:status_code].to_i,
|
89
|
-
:message => get_if_kind(response_body[:status_message], String),
|
90
|
-
:update_date => get_if_kind(response_body[:status_update_date], String)
|
91
|
-
},
|
92
|
-
:code => response_body[:file_id],
|
93
|
-
:notes => get_if_kind(response_body[:notes], String),
|
94
|
-
:property => {
|
95
|
-
:name => get_if_kind(response_body[:property_name], String),
|
96
|
-
:exact_match => (response_body[:property_name_exact_match] == true),
|
97
|
-
:type => get_if_kind(response_body[:property_type], String)
|
98
|
-
},
|
99
|
-
:email => get_if_kind(response_body[:status_change_email], String),
|
100
|
-
:upload_date => get_if_kind(response_body[:upload_date], String),
|
101
|
-
:uploaded_by => get_if_kind(response_body[:uploaded_by], String),
|
102
|
-
:version_string => get_if_kind(response_body[:version_string], String)
|
103
|
-
})
|
104
|
-
rescue Savon::HTTPError => e
|
105
|
-
raise ::AkamaiApi::Unauthorized if e.http.code == 401
|
106
|
-
raise
|
56
|
+
response = AkamaiApi::ECCU::FindRequest.new(code).execute args.fetch(:verbose, true)
|
57
|
+
new :file => response.file,
|
58
|
+
:status => response.status,
|
59
|
+
:code => response.code,
|
60
|
+
:notes => response.notes,
|
61
|
+
:property => response.property,
|
62
|
+
:email => response.email,
|
63
|
+
:upload_date => response.uploaded_at,
|
64
|
+
:uploaded_by => response.uploaded_by,
|
65
|
+
:version => response.version
|
107
66
|
end
|
108
67
|
|
109
68
|
def publish_file property, file_name, args = {}
|
@@ -112,52 +71,15 @@ module AkamaiApi
|
|
112
71
|
end
|
113
72
|
|
114
73
|
def publish property, content, args = {}
|
115
|
-
|
116
|
-
|
117
|
-
resp.body[:upload_response][:file_id].to_i
|
118
|
-
rescue Savon::HTTPError => e
|
119
|
-
raise ::AkamaiApi::Unauthorized if e.http.code == 401
|
120
|
-
raise
|
74
|
+
args = args.dup
|
75
|
+
AkamaiApi::ECCU::PublishRequest.new(property, extract_property_arguments(args)).execute content, args
|
121
76
|
end
|
122
77
|
|
123
78
|
private
|
124
79
|
|
125
|
-
def
|
126
|
-
|
127
|
-
string :filename, args[:file_name] || ''
|
128
|
-
text :contents, content
|
129
|
-
string :notes, args[:notes] || 'ECCU Request using AkamaiApi gem'
|
130
|
-
string :versionString, args[:version] || ''
|
131
|
-
if args[:emails]
|
132
|
-
string :statusChangeEmail, Array.wrap(args[:emails]).join(' ')
|
133
|
-
end
|
134
|
-
string :propertyName, property
|
135
|
-
string :propertyType, args[:property_type] || 'hostheader'
|
136
|
-
boolean :propertyNameExactMatch, args[:property_exact_match].nil? && true || args[:property_exact_match]
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
# This method is used because, for nil values, savon will respond with an hash containing all other attributes.
|
141
|
-
# If we check that the expected type is matched, we can
|
142
|
-
# prevent to retrieve wrong values
|
143
|
-
def get_if_kind value, kind
|
144
|
-
value.kind_of?(kind) && value || nil
|
145
|
-
end
|
146
|
-
|
147
|
-
def client
|
148
|
-
savon_args = {
|
149
|
-
:wsdl => File.expand_path('../../../wsdls/eccu.wsdl', __FILE__),
|
150
|
-
:basic_auth => AkamaiApi.config[:auth],
|
151
|
-
:log => AkamaiApi.config[:log]
|
152
|
-
}
|
153
|
-
Savon.client savon_args
|
80
|
+
def extract_property_arguments args
|
81
|
+
{ type: args.delete(:property_type), exact_match: args.delete(:property_exact_match) }.reject { |k, v| v.nil? }
|
154
82
|
end
|
155
83
|
end
|
156
|
-
|
157
|
-
private
|
158
|
-
|
159
|
-
def client
|
160
|
-
self.class.send(:client)
|
161
|
-
end
|
162
84
|
end
|
163
85
|
end
|
data/lib/akamai_api/version.rb
CHANGED
data/lib/akamai_api.rb
CHANGED
@@ -1,11 +1,25 @@
|
|
1
|
-
require
|
1
|
+
require "active_support/core_ext/object/blank"
|
2
2
|
|
3
|
-
%w(version
|
3
|
+
%w(version ccu eccu eccu_request).each do |file|
|
4
4
|
require "akamai_api/#{file}"
|
5
5
|
end
|
6
6
|
|
7
7
|
module AkamaiApi
|
8
|
-
|
8
|
+
def self.config
|
9
|
+
@config ||= {
|
10
|
+
:auth => [
|
11
|
+
ENV.fetch('AKAMAI_USERNAME', ''),
|
12
|
+
ENV.fetch('AKAMAI_PASSWORD', '')
|
13
|
+
],
|
14
|
+
:log => false
|
15
|
+
}
|
16
|
+
end
|
9
17
|
|
10
|
-
def self.
|
18
|
+
def self.auth_empty?
|
19
|
+
config[:auth].select { |v| v.blank? }.any?
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.auth
|
23
|
+
{ username: config[:auth].first, password: config[:auth].last }
|
24
|
+
end
|
11
25
|
end
|
@@ -1,60 +1,58 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'Given I request to purge an asset' do
|
4
|
-
subject { AkamaiApi::
|
4
|
+
subject { AkamaiApi::CCU }
|
5
5
|
|
6
6
|
shared_examples 'purge helper' do
|
7
7
|
let(:method) { "#{action}_#{type}" }
|
8
8
|
|
9
9
|
it 'responds with a PurgeResponse object' do
|
10
10
|
VCR.use_cassette "akamai_api_ccu_#{type}_#{action}/single_item" do
|
11
|
-
subject.send
|
11
|
+
expect(subject.send method, items).to be_a AkamaiApi::CCU::Purge::Response
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'raises error when user is not authorized' do
|
16
16
|
VCR.use_cassette "akamai_api_ccu_#{type}_#{action}/invalid_credentials" do
|
17
|
-
AkamaiApi
|
17
|
+
allow(AkamaiApi).to receive(:auth) { { username: 'foo', password: 'bar' } }
|
18
18
|
expect { subject.send(method, items) }.to raise_error AkamaiApi::Unauthorized
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
it '
|
22
|
+
it 'raises an error when data request is invalid' do
|
23
23
|
VCR.use_cassette "akamai_api_ccu_#{type}_#{action}/invalid_item" do
|
24
|
-
|
25
|
-
expect(response).to be_a AkamaiApi::Ccu::Purge::Response
|
26
|
-
expect(response.code).to eq 403
|
24
|
+
expect { subject.send method, items }.to raise_error AkamaiApi::CCU::Error
|
27
25
|
end
|
28
26
|
end
|
29
27
|
|
30
28
|
describe 'when data are correct' do
|
31
29
|
it 'returns the expected response code' do
|
32
30
|
VCR.use_cassette "akamai_api_ccu_#{type}_#{action}/single_item" do
|
33
|
-
subject.send(method, items).code.
|
31
|
+
expect(subject.send(method, items).code).to eq 201
|
34
32
|
end
|
35
33
|
end
|
36
34
|
|
37
35
|
it 'returns a successful message' do
|
38
36
|
VCR.use_cassette "akamai_api_ccu_#{type}_#{action}/single_item" do
|
39
|
-
subject.send(method, items).message.
|
37
|
+
expect(subject.send(method, items).message).to eq 'Request accepted.'
|
40
38
|
end
|
41
39
|
end
|
42
40
|
|
43
41
|
it 'returns a unique purge id' do
|
44
42
|
VCR.use_cassette "akamai_api_ccu_#{type}_#{action}/single_item" do
|
45
|
-
subject.send(method, items).purge_id.
|
43
|
+
expect(subject.send(method, items).purge_id).to eq '12345678-1234-1234-1234-123456789012'
|
46
44
|
end
|
47
45
|
end
|
48
46
|
|
49
47
|
it 'returns a unique support id' do
|
50
48
|
VCR.use_cassette "akamai_api_ccu_#{type}_#{action}/single_item" do
|
51
|
-
subject.send(method, items).support_id.
|
49
|
+
expect(subject.send(method, items).support_id).to eq '12345678901234567890-123456789'
|
52
50
|
end
|
53
51
|
end
|
54
52
|
|
55
53
|
it 'returns the estimated time in seconds' do
|
56
54
|
VCR.use_cassette "akamai_api_ccu_#{type}_#{action}/single_item" do
|
57
|
-
subject.send(method, items).estimated_time.
|
55
|
+
expect(subject.send(method, items).estimated_time).to eq 420
|
58
56
|
end
|
59
57
|
end
|
60
58
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "Given I request a purge status" do
|
4
|
-
subject { AkamaiApi::
|
4
|
+
subject { AkamaiApi::CCU }
|
5
5
|
|
6
6
|
context "when login credentials are ok and progress uri is valid", vcr: { cassette_name: "akamai_api_ccu_purge_status/completed_request" } do
|
7
7
|
let(:progress_uri) { '/ccu/v2/purges/12345678-1234-5678-1234-123456789012' }
|
8
8
|
|
9
9
|
it "responds with a PurgeStatusResponse object" do
|
10
|
-
expect(subject.status progress_uri).to be_a AkamaiApi::
|
10
|
+
expect(subject.status progress_uri).to be_a AkamaiApi::CCU::PurgeStatus::Response
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -15,7 +15,7 @@ describe "Given I request a purge status" do
|
|
15
15
|
let(:progress_uri) { '/ccu/v2/purges/12345678-1234-5678-1234-123456789012' }
|
16
16
|
|
17
17
|
before do
|
18
|
-
AkamaiApi
|
18
|
+
allow(AkamaiApi).to receive(:auth) { { username: 'foo', password: 'bar' } }
|
19
19
|
end
|
20
20
|
|
21
21
|
it "raises an error" do
|
@@ -24,8 +24,8 @@ describe "Given I request a purge status" do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
context "when the given progress uri is invalid", vcr: { cassette_name: "akamai_api_ccu_purge_status/not_found_request" } do
|
27
|
-
it "
|
28
|
-
expect
|
27
|
+
it "raises a NotFound error" do
|
28
|
+
expect { subject.status 'foobarbaz' }.to raise_error AkamaiApi::CCU::PurgeStatus::NotFound
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -3,15 +3,15 @@ require 'spec_helper'
|
|
3
3
|
describe 'Given I request the current status' do
|
4
4
|
context 'and given my login credentials are correct', vcr: { cassette_name: 'akamai_api_ccu_status/valid_credentials' } do
|
5
5
|
it 'I receive a successful response object' do
|
6
|
-
expect(AkamaiApi::
|
6
|
+
expect(AkamaiApi::CCU.status).to be_a AkamaiApi::CCU::Status::Response
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
10
|
context 'and given my login credentials are wrong', vcr: { cassette_name: 'akamai_api_ccu_status/invalid_credentials' } do
|
11
|
-
before { AkamaiApi
|
11
|
+
before { allow(AkamaiApi).to receive(:auth) { { username: 'foo', password: 'bar' } } }
|
12
12
|
|
13
13
|
it 'an error is raised' do
|
14
|
-
expect { AkamaiApi::
|
14
|
+
expect { AkamaiApi::CCU.status }.to raise_error AkamaiApi::Unauthorized
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Given I want to destroy a request" do
|
4
|
+
subject { AkamaiApi::ECCURequest.new code: '1234' }
|
5
|
+
|
6
|
+
context "when login credentials are invalid", vcr: { cassette_name: "akamai_api_eccu_destroy/invalid_credentials" } do
|
7
|
+
before do
|
8
|
+
allow(AkamaiApi).to receive(:config) { { auth: ['foo', 'bar'] } }
|
9
|
+
allow(AkamaiApi::ECCU).to receive(:client) { AkamaiApi::ECCU.send(:build_client) }
|
10
|
+
end
|
11
|
+
|
12
|
+
it "raises Unauthorized" do
|
13
|
+
expect { subject.destroy }.to raise_error AkamaiApi::Unauthorized
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "when request id cannot be found", vcr: { cassette_name: "akamai_api_eccu_destroy/not_found_request" } do
|
18
|
+
it "raises NotFound" do
|
19
|
+
expect { subject.destroy }.to raise_error AkamaiApi::ECCU::NotFound
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "when request id is found", vcr: { cassette_name: "akamai_api_eccu_destroy/successful" } do
|
24
|
+
it "returns true" do
|
25
|
+
expect(subject.destroy).to be_truthy
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Given I want to retrieve a request" do
|
4
|
+
subject { AkamaiApi::ECCURequest }
|
5
|
+
|
6
|
+
context "when login credentials are invalid", vcr: { cassette_name: "akamai_api_eccu_find/invalid_credentials" } do
|
7
|
+
before do
|
8
|
+
allow(AkamaiApi).to receive(:config) { { auth: ['foo', 'bar'] } }
|
9
|
+
allow(AkamaiApi::ECCU).to receive(:client) { AkamaiApi::ECCU.send(:build_client) }
|
10
|
+
end
|
11
|
+
|
12
|
+
it "raises Unauthorized" do
|
13
|
+
expect { subject.find '1234' }.to raise_error AkamaiApi::Unauthorized
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "when request id cannot be found", vcr: { cassette_name: "akamai_api_eccu_find/not_found_request" } do
|
18
|
+
it "raises NotFound" do
|
19
|
+
expect { subject.find '1234' }.to raise_error AkamaiApi::ECCU::NotFound
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "when request id is found", vcr: { cassette_name: "akamai_api_eccu_find/successful" } do
|
24
|
+
it "returns an ECCURequest" do
|
25
|
+
expect(subject.find '1234').to be_a AkamaiApi::ECCURequest
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when request id is found but verbose is false", vcr: { cassette_name: "akamai_api_eccu_find/successful_without_content" } do
|
30
|
+
it "returns an ECCURequest without file content" do
|
31
|
+
expect(subject.find('1234', verbose: false).file).to_not have_key :content
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Given I want to retrieve all submitted request ids" do
|
4
|
+
subject { AkamaiApi::ECCURequest }
|
5
|
+
|
6
|
+
context "when login credentials are invalid", vcr: { cassette_name: "akamai_api_eccu_all_ids/invalid_credentials" } do
|
7
|
+
before do
|
8
|
+
allow(AkamaiApi).to receive(:config) { { auth: ['foo', 'bar'] } }
|
9
|
+
allow(AkamaiApi::ECCU).to receive(:client) { AkamaiApi::ECCU.send(:build_client) }
|
10
|
+
end
|
11
|
+
|
12
|
+
it "raises Unauthorized" do
|
13
|
+
expect { subject.all_ids }.to raise_error AkamaiApi::Unauthorized
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "when credentials are valid", vcr: { cassette_name: "akamai_api_eccu_all_ids/successful" } do
|
18
|
+
it "returns a list of ids" do
|
19
|
+
expect(subject.all_ids).to eq ["12341", "12342", "12343", "12344", "12345", "12346", "12347", "12348", "12349", "12350", "12351", "12352", "12353", "12354", "12355", "12356", "12357", "12358", "12359", "12360", "12361", "12362", "12363", "12364", "12365", "12366", "12367", "12368", "12369", "12370", "12371"]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Given I want to publish a request" do
|
4
|
+
subject { AkamaiApi::ECCURequest }
|
5
|
+
let(:fixture_content) { File.read 'spec/fixtures/eccu_request.xml' }
|
6
|
+
|
7
|
+
context "when login credentials are invalid", vcr: { cassette_name: "akamai_api_eccu_publish/invalid_credentials" } do
|
8
|
+
before do
|
9
|
+
allow(AkamaiApi).to receive(:config) { { auth: ['foo', 'bar'] } }
|
10
|
+
allow(AkamaiApi::ECCU).to receive(:client) { AkamaiApi::ECCU.send(:build_client) }
|
11
|
+
end
|
12
|
+
|
13
|
+
it "raises Unauthorized" do
|
14
|
+
expect { subject.publish 'foo.com', fixture_content, file_name: './publish.xml' }.to raise_error AkamaiApi::Unauthorized
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "when property name is not found", vcr: { cassette_name: "akamai_api_eccu_publish/invalid_domain" } do
|
19
|
+
it "raises InvalidDomain" do
|
20
|
+
expect { subject.publish 'foobarbaz.com', fixture_content, file_name: './publish.xml' }.to raise_error AkamaiApi::ECCU::InvalidDomain
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "when data is correct", vcr: { cassette_name: "akamai_api_eccu_publish/successful" } do
|
25
|
+
it "returns the request id" do
|
26
|
+
expect(subject.publish 'foo.com', fixture_content, file_name: './publish.xml').to be_a Fixnum
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Given I want to update the email of a request" do
|
4
|
+
subject { AkamaiApi::ECCURequest.new code: '1234' }
|
5
|
+
|
6
|
+
context "when login credentials are invalid", vcr: { cassette_name: "akamai_api_eccu_update_email/invalid_credentials" } do
|
7
|
+
before do
|
8
|
+
allow(AkamaiApi).to receive(:config) { { auth: ['foo', 'bar'] } }
|
9
|
+
allow(AkamaiApi::ECCU).to receive(:client) { AkamaiApi::ECCU.send(:build_client) }
|
10
|
+
end
|
11
|
+
|
12
|
+
it "raises Unauthorized" do
|
13
|
+
expect { subject.update_email! 'guest@mikamai.com' }.to raise_error AkamaiApi::Unauthorized
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "when request id cannot be found", vcr: { cassette_name: "akamai_api_eccu_update_email/not_found_request" } do
|
18
|
+
it "raises NotFound" do
|
19
|
+
expect { subject.update_email! 'guest@mikamai.com' }.to raise_error AkamaiApi::ECCU::NotFound
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "when request id is found", vcr: { cassette_name: "akamai_api_eccu_update_email/successful" } do
|
24
|
+
it "returns true" do
|
25
|
+
expect(subject.update_notes! 'guest@mikamai.com').to be_truthy
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Given I want to update the notes of a request" do
|
4
|
+
subject { AkamaiApi::ECCURequest.new code: '1234' }
|
5
|
+
|
6
|
+
context "when login credentials are invalid", vcr: { cassette_name: "akamai_api_eccu_update_notes/invalid_credentials" } do
|
7
|
+
before do
|
8
|
+
allow(AkamaiApi).to receive(:config) { { auth: ['foo', 'bar'] } }
|
9
|
+
allow(AkamaiApi::ECCU).to receive(:client) { AkamaiApi::ECCU.send(:build_client) }
|
10
|
+
end
|
11
|
+
|
12
|
+
it "raises Unauthorized" do
|
13
|
+
expect { subject.update_notes! 'request updated using AkamaiApi' }.to raise_error AkamaiApi::Unauthorized
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "when request id cannot be found", vcr: { cassette_name: "akamai_api_eccu_update_notes/not_found_request" } do
|
18
|
+
it "raises NotFound" do
|
19
|
+
expect { subject.update_notes! 'request updated using AkamaiApi' }.to raise_error AkamaiApi::ECCU::NotFound
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "when request id is found", vcr: { cassette_name: "akamai_api_eccu_update_notes/successful" } do
|
24
|
+
it "returns true" do
|
25
|
+
expect(subject.update_notes! 'request updated using AkamaiApi').to be_truthy
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe AkamaiApi::
|
4
|
-
subject { AkamaiApi::
|
3
|
+
describe AkamaiApi::CCU::BaseResponse do
|
4
|
+
subject { AkamaiApi::CCU::BaseResponse.new 'supportId' => 'foo', 'httpStatus' => 201 }
|
5
5
|
|
6
6
|
it '#support_id returns the supportId attribute' do
|
7
7
|
expect(subject.support_id).to eq 'foo'
|