mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
add get_node_list request again, add test for get_all_records request
This commit is contained in:
parent
25b69f8289
commit
20fbbf9ee0
3 changed files with 65 additions and 0 deletions
|
@ -18,6 +18,7 @@ module Fog
|
|||
request_path 'fog/dynect/requests/dns'
|
||||
request :delete_record
|
||||
request :delete_zone
|
||||
request :get_node_list
|
||||
request :get_all_records
|
||||
request :get_record
|
||||
request :get_zone
|
||||
|
|
56
lib/fog/dynect/requests/dns/get_node_list.rb
Normal file
56
lib/fog/dynect/requests/dns/get_node_list.rb
Normal file
|
@ -0,0 +1,56 @@
|
|||
module Fog
|
||||
module DNS
|
||||
class Dynect
|
||||
class Real
|
||||
|
||||
# Get one or more node lists
|
||||
#
|
||||
# ==== Parameters
|
||||
# * zone<~String> - zone to lookup node lists for
|
||||
# * options<~Hash>
|
||||
# * fqdn<~String> - fully qualified domain name of node to lookup
|
||||
|
||||
def get_node_list(zone, options = {})
|
||||
requested_fqdn = options['fqdn'] || options[:fqdn]
|
||||
request(
|
||||
:expects => 200,
|
||||
:idempotent => true,
|
||||
:method => :get,
|
||||
:path => ['AllRecord', zone, requested_fqdn].compact.join('/')
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def get_node_list(zone, options = {})
|
||||
raise Fog::DNS::Dynect::NotFound unless zone = self.data[:zones][zone]
|
||||
|
||||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
|
||||
data = [zone[:zone]]
|
||||
|
||||
if fqdn = options[:fqdn]
|
||||
data = data | zone[:records].collect { |type, records| records.select { |record| record[:fqdn] == fqdn } }.flatten.compact
|
||||
else
|
||||
data = data | zone[:records].collect { |type, records| records.collect { |record| record[:fqdn] } }.flatten
|
||||
end
|
||||
|
||||
response.body = {
|
||||
"status" => "success",
|
||||
"data" => data,
|
||||
"job_id" => Fog::Dynect::Mock.job_id,
|
||||
"msgs" => [{
|
||||
"INFO" => "get_tree: Here is your zone tree",
|
||||
"SOURCE" => "BLL",
|
||||
"ERR_CD" => nil,
|
||||
"LVL" => "INFO"
|
||||
}]
|
||||
}
|
||||
|
||||
response
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -116,6 +116,14 @@ Shindo.tests('Dynect::dns | DNS requests', ['dynect', 'dns']) do
|
|||
@dns.get_node_list(@domain).body
|
||||
end
|
||||
|
||||
get_all_records_format = shared_format.merge({
|
||||
'data' => [String]
|
||||
})
|
||||
|
||||
tests("get_all_records('#{@domain}')").formats(get_all_records_format) do
|
||||
@dns.get_all_records(@domain).body
|
||||
end
|
||||
|
||||
get_records_format = shared_format.merge({
|
||||
'data' => [String]
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue