Use https for the pod_uri if require_ssl is true
This commit is contained in:
parent
08c6d485e4
commit
8d725160f9
2 changed files with 17 additions and 3 deletions
|
|
@ -6,15 +6,16 @@ module Configuration
|
||||||
return @pod_uri.dup unless @pod_uri.nil?
|
return @pod_uri.dup unless @pod_uri.nil?
|
||||||
|
|
||||||
url = environment.url.get
|
url = environment.url.get
|
||||||
url = "http://#{url}" unless url =~ /^(https?:\/\/)/
|
|
||||||
url << "/" unless url.end_with?("/")
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@pod_uri = Addressable::URI.parse(url)
|
@pod_uri = Addressable::URI.heuristic_parse(url)
|
||||||
rescue
|
rescue
|
||||||
puts "WARNING: pod url #{url} is not a legal URI"
|
puts "WARNING: pod url #{url} is not a legal URI"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@pod_uri.scheme = "https" if environment.require_ssl?
|
||||||
|
@pod_uri.path = "/"
|
||||||
|
|
||||||
@pod_uri.dup
|
@pod_uri.dup
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ describe Configuration::Methods do
|
||||||
describe "#pod_uri" do
|
describe "#pod_uri" do
|
||||||
before do
|
before do
|
||||||
@settings.environment.url = nil
|
@settings.environment.url = nil
|
||||||
|
@settings.environment.require_ssl = false
|
||||||
@settings.instance_variable_set(:@pod_uri, nil)
|
@settings.instance_variable_set(:@pod_uri, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -36,6 +37,18 @@ describe Configuration::Methods do
|
||||||
expect(@settings.pod_uri.to_s).to eq("http://example.org/")
|
expect(@settings.pod_uri.to_s).to eq("http://example.org/")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "adds https:// on the front if require_ssl is true" do
|
||||||
|
@settings.environment.require_ssl = true
|
||||||
|
@settings.environment.url = "example.org"
|
||||||
|
expect(@settings.pod_uri.to_s).to eq("https://example.org/")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "changes http to https if require_ssl is true" do
|
||||||
|
@settings.environment.require_ssl = true
|
||||||
|
@settings.environment.url = "http://example.org/"
|
||||||
|
expect(@settings.pod_uri.to_s).to eq("https://example.org/")
|
||||||
|
end
|
||||||
|
|
||||||
it "does not add a prefix if there already is https:// on the front" do
|
it "does not add a prefix if there already is https:// on the front" do
|
||||||
@settings.environment.url = "https://example.org/"
|
@settings.environment.url = "https://example.org/"
|
||||||
expect(@settings.pod_uri.to_s).to eq("https://example.org/")
|
expect(@settings.pod_uri.to_s).to eq("https://example.org/")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue