Sha256: 34c294ca1f491000d5e940c630d976265b5d4a267735e03756d25498fcb3e5d7

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

RSpec.describe "X-Content-Type-Options header", type: :integration do
  it "returns default value" do
    with_project do
      generate "action web home#index --url=/"

      server do
        get "/"

        expect(last_response.status).to                            eq(200)
        expect(last_response.headers["X-Content-Type-Options"]).to eq("nosniff")
      end
    end
  end

  it "returns custom value" do
    with_project do
      generate "action web home#index --url=/"

      replace "apps/web/app.rb", "security.x_content_type_options 'nosniff'", "security.x_content_type_options 'foo'"

      server do
        get "/"

        expect(last_response.status).to                            eq(200)
        expect(last_response.headers["X-Content-Type-Options"]).to eq("foo")
      end
    end
  end

  it "doesn't send header if setting is removed" do
    with_project do
      generate "action web home#index --url=/"

      replace "apps/web/app.rb", "security.x_content_type_options 'nosniff'", ""

      server do
        get "/"

        expect(last_response.status).to      eq(200)
        expect(last_response.headers).to_not have_key("X-Content-Type-Options")
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hanami-2.0.0.beta2 spec/integration/security/x_content_type_options_spec.rb
hanami-2.0.0.beta1.1 spec/integration/security/x_content_type_options_spec.rb
hanami-2.0.0.beta1 spec/integration/security/x_content_type_options_spec.rb