Skip to content

Commit f03fcf1

Browse files
committed
add ssl test for https prerender_service_url
1 parent 1b5ea17 commit f03fcf1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/lib/prerender_rails.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,17 @@
7474
end
7575

7676

77+
it "should set use_ssl to true for https prerender_service_url" do
78+
@prerender = Rack::Prerender.new(@app, prerender_service_url: 'https://service.prerender.io/')
79+
80+
request = Rack::MockRequest.env_for "/search/things/123/page?_escaped_fragment_=", "HTTP_USER_AGENT" => bot
81+
stub_request(:get, @prerender.build_api_url(request)).to_return(:body => "<html></html>")
82+
response = @prerender.call(request)
83+
84+
assert_equal ["<html></html>"], response[2].body
85+
end
86+
87+
7788
it "should return a prerendered response if the url is part of the regex specific whitelist" do
7889
request = Rack::MockRequest.env_for "/search/things/123/page?_escaped_fragment_=", "HTTP_USER_AGENT" => bot
7990
stub_request(:get, @prerender.build_api_url(request)).to_return(:body => "<html></html>")
@@ -164,6 +175,13 @@
164175
end
165176

166177

178+
it "should build the correct https api url with an initialization variable url" do
179+
@prerender = Rack::Prerender.new(@app, prerender_service_url: 'https://prerenderurl.com')
180+
request = Rack::MockRequest.env_for "https://google.com/search?q=javascript"
181+
assert_equal 'https://prerenderurl.com/https://google.com/search?q=javascript', @prerender.build_api_url(request)
182+
end
183+
184+
167185
# Check CF-Visitor header in order to Work behind CloudFlare with Flexible SSL (https://support.cloudflare.com/hc/en-us/articles/200170536)
168186
it "should build the correct api url for the Cloudflare Flexible SSL support" do
169187
request = Rack::MockRequest.env_for "http://google.com/search?q=javascript", { 'CF-VISITOR' => '"scheme":"https"'}

0 commit comments

Comments
 (0)