Skip to content

Commit

Permalink
Update @xmldom/xmldom (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjbarth committed Nov 12, 2022
1 parent 3618410 commit 9c047c0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@types/xml-crypto": "^1.4.2",
"@types/xml-encryption": "^1.2.1",
"@types/xml2js": "^0.4.11",
"@xmldom/xmldom": "^0.8.3",
"@xmldom/xmldom": "^0.8.6",
"debug": "^4.3.4",
"xml-crypto": "^3.0.0",
"xml-encryption": "^3.0.1",
Expand Down
1 change: 1 addition & 0 deletions src/xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ export const parseDomFromString = (xml: string): Promise<Document> => {
(n) => n.tagName != null && n.childNodes != null
).length !== 1
) {
// This will never happen due to updates in @xmldom/xmldom@0.8.5
return reject(new Error("Malformed XML; multiple roots detected"));
}

Expand Down
9 changes: 3 additions & 6 deletions test/test-signatures.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ const cert = fs.readFileSync(__dirname + "/static/cert.pem", "ascii");

describe("Signatures", function () {
const INVALID_SIGNATURE = "Invalid signature";
const INVALID_DOCUMENT = "Malformed XML; multiple roots detected";
const INVALID_DOCUMENT_SIGNATURE = "Invalid document signature";
const INVALID_ENCRYPTED_SIGNATURE = "Invalid signature from encrypted assertion";
const INVALID_TOO_MANY_TRANSFORMS = "Invalid signature, too many transforms";
const XMLDOM_ERROR =
"[xmldom error]\telement parse error: Error: Hierarchy request error: Only one element can be added and only after doctype\n@#[line:57,col:1]";

const createBody = (pathToXml: string) => ({
SAMLResponse: fs.readFileSync(__dirname + "/static/signatures" + pathToXml, "base64"),
Expand Down Expand Up @@ -71,11 +72,7 @@ describe("Signatures", function () {
describe("Signatures - multiple roots are considered invalid", () => {
it(
"multiple roots => invalid",
testOneResponse(
"/invalid/response.root-signed.multiple-root-elements.xml",
INVALID_DOCUMENT,
0
)
testOneResponse("/invalid/response.root-signed.multiple-root-elements.xml", XMLDOM_ERROR, 0)
);
});

Expand Down

0 comments on commit 9c047c0

Please sign in to comment.