e2e test for stricter security in mermaid

This commit is contained in:
Knut Sveidqvist
2019-07-14 02:05:59 -07:00
parent 31576f8f55
commit 5abedab095
11 changed files with 220 additions and 6 deletions

View File

@@ -1,19 +1,23 @@
/* eslint-env jest */
import { Base64 } from 'js-base64'
export const mermaidUrl = (graphStr, options) => {
export const mermaidUrl = (graphStr, options, api) => {
const obj = {
code: graphStr,
mermaid: options
}
const objStr = JSON.stringify(obj)
// console.log(Base64)
return 'http://localhost:9000/e2e.html?graph=' + Base64.encodeURI(objStr)
let url = 'http://localhost:9000/e2e.html?graph=' + Base64.encodeURI(objStr)
if (api) {
url = 'http://localhost:9000/xss.html?graph=' + graphStr
}
return url
}
export const imgSnapshotTest = async (page, graphStr, options) => {
export const imgSnapshotTest = async (page, graphStr, options, api) => {
return new Promise(async resolve => {
const url = mermaidUrl(graphStr, options)
const url = mermaidUrl(graphStr, options, api)
await page.goto(url)