Sha256: 8c3a4451ae121224f84ea51ca50b91da71aca539557431cafd511ab3dbf36c30

Contents?: true

Size: 843 Bytes

Versions: 1

Compression:

Stored size: 843 Bytes

Contents

# 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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tynn-2.0.0.alpha test/secure_headers_test.rb