Skip to content

Commit

Permalink
feat: expose getLogoutResponseUrlAsync publicly (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marsup committed Oct 23, 2022
1 parent 27acce1 commit cc75f48
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/saml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ class SAML {
)(callback);
}

protected async getLogoutResponseUrlAsync(
async getLogoutResponseUrlAsync(
samlLogoutRequest: Profile,
RelayState: string,
options: AuthenticateOptions & AuthorizeOptions,
Expand Down
39 changes: 39 additions & 0 deletions test/samlTests.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use strict";
import * as sinon from "sinon";
import { URL } from "url";
import { expect } from "chai";
import * as assert from "assert";
Expand All @@ -18,6 +19,7 @@ describe("SAML.js", function () {
logoutUrl: "https://exampleidp.com/path?key=value",
cert: FAKE_CERT,
issuer: "onesaml_login",
generateUniqueId: () => "uniqueId",
});
req = {
protocol: "https",
Expand Down Expand Up @@ -193,5 +195,42 @@ describe("SAML.js", function () {
});
});
});

describe("getLogoutResponseUrlAsync", function () {
let fakeClock: sinon.SinonFakeTimers;

beforeEach(function () {
fakeClock = sinon.useFakeTimers(Date.parse("2020-09-25T16:59:00Z"));
});

afterEach(function () {
fakeClock.restore();
});

it("resolves with the same target as getLogoutResponseUrl", function (done) {
saml.getLogoutResponseUrl(
req.samlLogoutRequest,
"",
{},
true,
async function (err, cbTarget) {
try {
const asyncTarget = await saml.getLogoutResponseUrlAsync(
req.samlLogoutRequest,
"",
{},
true
);
assertRequired(cbTarget);
assertRequired(asyncTarget);
assert.strictEqual(asyncTarget, cbTarget);
done();
} catch (err2) {
done(err2);
}
}
);
});
});
});
});

0 comments on commit cc75f48

Please sign in to comment.