michaelleeallen / mocha-junit-reporter

A JUnit XML reporter for mocha.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

failure message is not properly escaped

ggrossetie opened this issue · comments

This is a junit.xml file produced when running Cypress:

<?xml version="1.0"?>
<testsuites failures="17" errors="0" tests="17" skipped="0">
  <testsuite name="Root Suite" timestamp="2023-01-04T11:53:31" tests="0" file="src/e2e/my.spec.js" time="0.000" failures="0"/>
  <testsuite name="Import" timestamp="2023-01-04T11:53:31" tests="1" time="7.026" failures="1">
    <testcase name="Something &quot;before each&quot; hook for &quot;TP-123 - successfully import something&quot;" time="0.000" classname="&quot;before each&quot; hook for &quot;TP-123 - successfully import something&quot;">
      <failure message="`cy.request()` failed on:

https://domain.com/api?clientId=123&amp;spaceId=e00c157f-693c-4a57-9cf4-64be11755830%3Ae00c157f-693c-4a57-9cf4-64be11755830

The response we received from your web server was:

  &gt; 500: Internal Server Error

This was considered a failure because the status code was not `2xx` or `3xx`.

If you do not want status codes to cause failures pass the option: `failOnStatusCode: false`

-----------------------------------------------------------

The request we sent was:

Method: POST
URL: https://domain.com/api?clientId=123&spaceId=456
Headers: {
  &quot;Connection&quot;: &quot;keep-alive&quot;,
  &quot;user-agent&quot;: &quot;Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/108.0.5359.98 Safari/537.36&quot;,
  &quot;accept&quot;: &quot;*/*&quot;,
  &quot;cookie&quot;: &quot;DG_COOKIE={\&quot;loginData\&quot;:{\&quot;useAutoLogin\&quot;:true,\&quot;loginToken\&quot;:\&quot;111.222.333\&quot;,\&quot;userLanguageCode\&quot;:\&quot;fr\&quot;}}&quot;,
  &quot;accept-encoding&quot;: &quot;gzip, deflate&quot;,
  &quot;content-type&quot;: &quot;application/json&quot;,
  &quot;content-length&quot;: 83
}
Body: {&quot;UserSessionId&quot;:&quot;123_master@domain.com&quot;}

-----------------------------------------------------------

The response we got was:

Status: 500 - Internal Server Error
Headers: {
  &quot;date&quot;: &quot;Wed, 04 Jan 2023 11:53:37 GMT&quot;,
  &quot;content-type&quot;: &quot;application/json&quot;,
  &quot;transfer-encoding&quot;: &quot;chunked&quot;,
  &quot;connection&quot;: &quot;keep-alive&quot;,
  &quot;cache-control&quot;: &quot;no-cache, no-store, must-revalidate&quot;,
  &quot;expires&quot;: &quot;-1&quot;,
  &quot;pragma&quot;: &quot;no-cache&quot;,
  &quot;strict-transport-security&quot;: &quot;max-age=31536000; includeSubDomains; preload&quot;,
  &quot;x-frame-options&quot;: &quot;sameorigin&quot;,
  &quot;x-xss-protection&quot;: &quot;1;mode=block&quot;,
  &quot;x-content-type-options&quot;: &quot;nosniff&quot;
}
Body: {
  &quot;StatusCode&quot;: 500,
  &quot;ErrorCode&quot;: 0,
  &quot;ErrorCodeString&quot;: &quot;UnknownErrorCode&quot;,
  &quot;Message&quot;: &quot;Response status code does not indicate success: 500 (Internal Server Error).&quot;,
  &quot;RequestNumber&quot;: 108,
  &quot;RequestXid&quot;: null,
  &quot;ServerXid&quot;: &quot;888&quot;
}


https://on.cypress.io/request

Because this error occurred during a `before each` hook we are skipping the remaining tests in the current suite: `Something`" type="CypressError"><![CDATA[CypressError: `cy.request()` failed on:

https://domain.com/api?clientId=123&spaceId=456

The response we received from your web server was:

  > 500: Internal Server Error

This was considered a failure because the status code was not `2xx` or `3xx`.

If you do not want status codes to cause failures pass the option: `failOnStatusCode: false`

-----------------------------------------------------------

The request we sent was:

Method: POST
URL: https://domain.com/api?clientId=123&spaceId=e00c157f-693c-4a57-9cf4-64be11755830%3Ae00c157f-693c-4a57-9cf4-64be11755830
Headers: {
  "Connection": "keep-alive",
  "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/108.0.5359.98 Safari/537.36",
  "accept": "*/*",
  "cookie": "DG_COOKIE={\"loginData\":{\"useAutoLogin\":true,\"loginToken\":\"111.222.333\",\"userLanguageCode\":\"fr\"}}",
  "accept-encoding": "gzip, deflate",
  "content-type": "application/json",
  "content-length": 83
}
Body: {"UserSessionId":"123_master@domain.com"}

-----------------------------------------------------------

The response we got was:

Status: 500 - Internal Server Error
Headers: {
  "date": "Wed, 04 Jan 2023 11:53:37 GMT",
  "content-type": "application/json",
  "transfer-encoding": "chunked",
  "connection": "keep-alive",
  "cache-control": "no-cache, no-store, must-revalidate",
  "expires": "-1",
  "pragma": "no-cache",
  "strict-transport-security": "max-age=31536000; includeSubDomains; preload",
  "x-frame-options": "sameorigin",
  "x-xss-protection": "1;mode=block",
  "x-content-type-options": "nosniff"
}
Body: {
  "StatusCode": 500,
  "ErrorCode": 0,
  "ErrorCodeString": "UnknownErrorCode",
  "Message": "Response status code does not indicate success: 500 (Internal Server Error).",
  "RequestNumber": 108,
  "RequestXid": null,
  "ServerXid": "888"
}


https://on.cypress.io/request

Because this error occurred during a `before each` hook we are skipping the remaining tests in the current suite: `Looker`
    at <unknown> (https://domain.com/__cypress/runner/cypress_runner.js:144155:80)
    at tryCatcher (https://domain.com/__cypress/runner/cypress_runner.js:11318:23)
    at Promise._settlePromiseFromHandler (https://domain.com/__cypress/runner/cypress_runner.js:9253:31)
    at Promise._settlePromise (https://domain.com/__cypress/runner/cypress_runner.js:9310:18)
    at Promise._settlePromise0 (https://domain.com/__cypress/runner/cypress_runner.js:9355:10)
    at Promise._settlePromises (https://domain.com/__cypress/runner/cypress_runner.js:9435:18)
    at _drainQueueStep (https://domain.com/__cypress/runner/cypress_runner.js:6025:12)
    at _drainQueue (https://domain.com/__cypress/runner/cypress_runner.js:6018:9)
    at ../../node_modules/bluebird/js/release/async.js.Async._drainQueues (https://domain.com/__cypress/runner/cypress_runner.js:6034:5)
    at Async.drainQueues (https://domain.com/__cypress/runner/cypress_runner.js:5904:14)
From Your Spec Code:
    at Context.eval (webpack:///./src/support/commands.ts:215:11)]]></failure>
    </testcase>
  </testsuite>
</testsuites>

As you can see & is not escaped:

image

23:	124	The reference to entity "spaceId" must end with the ';' delimiter.
Line 23, col 49 EntityRef: expecting ';'

Can you share an example of dummy cypress code forcing generation of such invalid message?

I wasn't able to reproduce it using a dummy/simplified Cypress code 🤔
I will try to find out what's the root cause.

I found the culprit! junit-report-merger transform &amp; back to & 😬