diff --git a/test/xss/info-sanitization.js b/test/xss/info-sanitization.js new file mode 100644 index 00000000..6549aa11 --- /dev/null +++ b/test/xss/info-sanitization.js @@ -0,0 +1,33 @@ +/* eslint-env mocha */ +import React from "react" +import expect from "expect" +import { render } from "enzyme" +import { fromJS } from "immutable" +import Info from "components/info" +import Markdown from "components/providers/markdown" + +describe.only(" Sanitization", function(){ + const dummyComponent = () => null + const components = { + Markdown + } + const props = { + getComponent: c => components[c] || dummyComponent, + info: fromJS({ + title: "Test Title **strong** ", + description: "Description *with* " + }), + host: "example.test", + basePath: "/api" + } + + it("renders sanitized .title content", function(){ + let wrapper = render() + expect(wrapper.find(".title").html()).toEqual("Test Title **strong** <script>alert(1)</script>") + }) + + it("renders sanitized .description content", function() { + let wrapper = render() + expect(wrapper.find(".description").html()).toEqual("

Description with

\n
") + }) +}) diff --git a/test/xss/markdown-script-sanitization.js b/test/xss/markdown-script-sanitization.js index 4a353316..ef374dd7 100644 --- a/test/xss/markdown-script-sanitization.js +++ b/test/xss/markdown-script-sanitization.js @@ -12,6 +12,12 @@ describe.only("Markdown Script Sanitization", function() { const el = render() expect(el.html()).toEqual(`

script

\n
`) }) + + it("sanitizes elements", function() { + const str = `` + const el = render() + expect(el.html()).toEqual(`

\n
`) + }) }) describe("OAS 3", function() { @@ -20,5 +26,11 @@ describe.only("Markdown Script Sanitization", function() { const el = render() expect(el.html()).toEqual(`

script

`) }) + + it("sanitizes elements", function() { + const str = `` + const el = render() + expect(el.html()).toEqual(`
`) + }) }) })