Need to URI encode before parsing

Some endpoints don't have valid paths
This commit is contained in:
John Dewey
2012-11-26 13:47:54 -08:00
parent baba5e9993
commit 8b3447c5a1
2 changed files with 16 additions and 2 deletions

View File

@@ -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

View File

@@ -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" => {