Sha256: 10eaf5b3fe46f18bfbb764e127e7069e9740b2276856024f695fcaf58966cd45

Contents?: true

Size: 1.36 KB

Versions: 5

Compression:

Stored size: 1.36 KB

Contents

module SecureHeaders
  describe XXssProtection do
    specify { XXssProtection.new.name.should == X_XSS_PROTECTION_HEADER_NAME}
    specify { XXssProtection.new.value.should == "1"}
    specify { XXssProtection.new("0").value.should == "0"}
    specify { XXssProtection.new(:value => 1, :mode => 'block').value.should == '1; mode=block' }

    context "with invalid configuration" do
      it "should raise an error when providing a string that is not valid" do
        lambda {
          XXssProtection.new("asdf")
        }.should raise_error(XXssProtectionBuildError)

        lambda {
          XXssProtection.new("asdf; mode=donkey")
        }.should raise_error(XXssProtectionBuildError)
      end

      context "when using a hash value" do
        it "should raise an error if no value key is supplied" do
          lambda {
            XXssProtection.new(:mode => 'block')
          }.should raise_error(XXssProtectionBuildError)
        end

        it "should raise an error if an invalid key is supplied" do
          lambda {
            XXssProtection.new(:value => 123)
          }.should raise_error(XXssProtectionBuildError)
        end

        it "should raise an error if mode != block" do
          lambda {
            XXssProtection.new(:value => 1, :mode => "donkey")
          }.should raise_error(XXssProtectionBuildError)
        end
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
secure_headers-0.3.0 spec/lib/secure_headers/headers/x_xss_protection_spec.rb
secure_headers-0.2.1 spec/lib/secure_headers/headers/x_xss_protection_spec.rb
secure_headers-0.2.0 spec/lib/secure_headers/headers/x_xss_protection_spec.rb
secure_headers-0.1.1 spec/lib/secure_headers/headers/x_xss_protection_spec.rb
secure_headers-0.1.0 spec/lib/secure_headers/headers/x_xss_protection_spec.rb