test/node/test_front.rb in zold-0.14.23 vs test/node/test_front.rb in zold-0.14.24
- old
+ new
@@ -176,6 +176,45 @@
end
end
sec = (Time.now - start) / total
test_log.info("Average response time is #{sec.round(2)}s")
end
+
+ def app
+ Zold::Front
+ end
+
+ def test_headers_are_being_set_correctly
+ Time.stub :now, Time.at(0) do
+ FakeNode.new(log: test_log).run(['--ignore-score-weakness']) do |port|
+ response = Zold::Http.new(uri: URI("http://localhost:#{port}/"), score: nil).get
+ assert_equal(
+ 'no-cache',
+ response.header['Cache-Control']
+ )
+ assert_equal(
+ 'close',
+ response.header['Connection']
+ )
+ assert_equal(
+ app.settings.version,
+ response.header['X-Zold-Version']
+ )
+ assert_equal(
+ app.settings.protocol.to_s,
+ response.header[Zold::Http::PROTOCOL_HEADER]
+ )
+ assert_equal(
+ '*',
+ response.header['Access-Control-Allow-Origin']
+ )
+ score = Zold::Score.new(
+ time: Time.now, host: 'localhost', port: port, invoice: 'NOPREFIX@ffffffffffffffff', strength: 2
+ )
+ assert_equal(
+ score.to_s,
+ response.header[Zold::Http::SCORE_HEADER]
+ )
+ end
+ end
+ end
end