Need to URI encode before parsing
Some endpoints don't have valid paths
This commit is contained in:
@@ -26,8 +26,8 @@ module ::Openstack
|
||||
# and construct the URI object from the endpoint parts.
|
||||
def endpoint name
|
||||
ep = endpoint_for name
|
||||
if ep && ep.has_key?("uri")
|
||||
::URI.parse ep["uri"]
|
||||
if ep && ep['uri']
|
||||
::URI.parse ::URI.encode(ep['uri'])
|
||||
elsif ep
|
||||
uri_from_hash ep
|
||||
end
|
||||
|
||||
@@ -20,6 +20,20 @@ describe ::Openstack do
|
||||
@subject.instance_variable_set :@node, @chef_run.node
|
||||
@subject.endpoint("nonexisting").should be_nil
|
||||
end
|
||||
it "handles a URI needing escaped" do
|
||||
uri_hash = {
|
||||
"openstack" => {
|
||||
"endpoints" => {
|
||||
"compute-api" => {
|
||||
"uri" => "http://localhost:8080/v2/%(tenant_id)s"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@subject.instance_variable_set :@node, uri_hash
|
||||
result = @subject.endpoint "compute-api"
|
||||
result.path.should == "/v2/%25(tenant_id)s"
|
||||
end
|
||||
it "returns endpoint URI object when uri key in endpoint hash" do
|
||||
uri_hash = {
|
||||
"openstack" => {
|
||||
|
||||
Reference in New Issue
Block a user