Skip to content

Commit

Permalink
added test case for invalid xml in parseLogoutResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
keptt committed Dec 18, 2024
1 parent addf79c commit 3efd734
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/lib/logout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { parseLogoutResponse, createLogoutRequest } from '../../lib/logout';

const response = fs.readFileSync('./test/assets/logout-response.xml').toString();
const responseFailed = fs.readFileSync('./test/assets/logout-response-failed.xml').toString();
const responseInvalid = 'invalid_data';

describe('logout.ts', function () {
it('response ok', async function () {
Expand Down Expand Up @@ -34,4 +35,16 @@ describe('logout.ts', function () {
assert.strictEqual(!!req.id, true);
assert.strictEqual(!!req.xml, true);
});

it('should throw an expected error for response containing invalid xml', async function () {
await assert.rejects(
async () => {
await parseLogoutResponse(responseInvalid);
},
(error: any) => {
assert.strictEqual(error.message.includes('Non-whitespace before first tag'), true);
return true;
}
);
});
});

0 comments on commit 3efd734

Please sign in to comment.