# frozen_string_literal: true require_relative "helper" require_relative "../lib/tynn/secure_headers" class SecureHeadersTest < Minitest::Test HEADERS = Tynn::SecureHeaders::HEADERS def setup @app = Class.new(Tynn) end def test_dont_override_default_headers @app.set(:default_headers, "Content-Type" => "application/json") @app.plugin(Tynn::SecureHeaders) assert @app.default_headers.key?("Content-Type") end def test_dont_override_if_exists @app.set(:default_headers, "X-Frame-Options" => "DENY") @app.plugin(Tynn::SecureHeaders) assert_equal "DENY", @app.default_headers["X-Frame-Options"] end def test_respond_with_secure_headers @app.plugin(Tynn::SecureHeaders) @app.define {} ts = Tynn::Test.new(@app) ts.get("/") assert_equal HEADERS, ts.res.headers end end