mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add mocking support for HP CDN provider.
This commit is contained in:
parent
65ecc5bbe9
commit
4b72f88d91
6 changed files with 99 additions and 1 deletions
|
@ -26,7 +26,9 @@ module Fog
|
||||||
|
|
||||||
def self.data
|
def self.data
|
||||||
@data ||= Hash.new do |hash, key|
|
@data ||= Hash.new do |hash, key|
|
||||||
hash[key] = {}
|
hash[key] = {
|
||||||
|
:cdn_containers => {}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,21 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock # :nodoc:all
|
||||||
|
def delete_container(name)
|
||||||
|
response = Excon::Response.new
|
||||||
|
if self.data[:cdn_containers][name]
|
||||||
|
self.data[:cdn_containers].delete(name)
|
||||||
|
response.status = 204
|
||||||
|
response.body = ""
|
||||||
|
response
|
||||||
|
else
|
||||||
|
raise Fog::CDN::HP::NotFound
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -26,6 +26,19 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock # :nodoc:all
|
||||||
|
|
||||||
|
def get_containers(options = {})
|
||||||
|
response = Excon::Response.new
|
||||||
|
data = self.data[:cdn_containers].map {|_,v| v}
|
||||||
|
response.body = data
|
||||||
|
response.status = 200
|
||||||
|
response
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,6 +26,25 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock # :nodoc:all
|
||||||
|
def head_container(name)
|
||||||
|
response = Excon::Response.new
|
||||||
|
headers = {}
|
||||||
|
if data = self.data[:cdn_containers][name]
|
||||||
|
data.each do |k,_|
|
||||||
|
headers[k] = data[k] if data[k]
|
||||||
|
end
|
||||||
|
response.headers = headers
|
||||||
|
response.status = 204
|
||||||
|
response.body = ""
|
||||||
|
response
|
||||||
|
else
|
||||||
|
raise Fog::CDN::HP::NotFound
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,6 +23,30 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock # :nodoc:all
|
||||||
|
def post_container(name, options = {})
|
||||||
|
response = Excon::Response.new
|
||||||
|
container_id = Fog::Mock.random_hex(33)
|
||||||
|
if data = self.data[:cdn_containers][name]
|
||||||
|
options.each do |k,v|
|
||||||
|
data[k] = options[k] if options[k]
|
||||||
|
end
|
||||||
|
response.headers = {
|
||||||
|
"X-Cdn-Ssl-Uri" => "https://a111.cdn.net/cdn-test.net/#{container_id}/abc",
|
||||||
|
"X-Cdn-Uri" => "http://#{container_id}.cdn-test.net",
|
||||||
|
"X-Trans-Id" => Fog::Mock.random_hex(34)
|
||||||
|
}
|
||||||
|
response.status = 202
|
||||||
|
response.body = "202 Accepted\n\nThe request is accepted for processing.\n\n "
|
||||||
|
self.data[:cdn_containers][name] = data
|
||||||
|
response
|
||||||
|
else
|
||||||
|
raise Fog::CDN::HP::NotFound
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,6 +23,31 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock # :nodoc:all
|
||||||
|
def put_container(name, options = {})
|
||||||
|
response = Excon::Response.new
|
||||||
|
container_id = Fog::Mock.random_hex(33)
|
||||||
|
data = {
|
||||||
|
'x-cdn-ssl-uri' => "https://a111.cdn.net/cdn-test.net/#{container_id}/abc",
|
||||||
|
'cdn_enabled' => true,
|
||||||
|
'name' => name,
|
||||||
|
'x-cdn-uri' => "http://#{container_id}.cdn-test.net",
|
||||||
|
'ttl' => 86400,
|
||||||
|
'log_retention' => false
|
||||||
|
}
|
||||||
|
response.headers = {
|
||||||
|
"X-Cdn-Ssl-Uri" => "https://a111.cdn.net/cdn-test.net/#{container_id}/abc",
|
||||||
|
"X-Cdn-Uri" => "http://#{container_id}.cdn-test.net",
|
||||||
|
"X-Trans-Id" => Fog::Mock.random_hex(34)
|
||||||
|
}
|
||||||
|
response.status = 201
|
||||||
|
response.body = "201 Created\n\n\n\n "
|
||||||
|
self.data[:cdn_containers][name] = data
|
||||||
|
response
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue