diff --git a/packages/sasl2/test.js b/packages/sasl2/test.js index e311e264..5c733a39 100644 --- a/packages/sasl2/test.js +++ b/packages/sasl2/test.js @@ -1,4 +1,6 @@ import { mockClient, promise } from "@xmpp/test"; +// eslint-disable-next-line n/no-extraneous-import +import { datetime } from "@xmpp/time"; const username = "foo"; const password = "bar"; @@ -102,12 +104,24 @@ test("with function credentials", async () => { expect(entity.jid.toString()).toBe(jid); }); -test("with FAST token", async () => { +// https://github.com/xmppjs/xmpp.js/pull/1045#discussion_r1904611099 +test("with FAST token only", async () => { const mech = "HT-SHA-256-NONE"; + function onAuthenticate(authenticate, mechanisms, fast) { expect(mechanisms).toEqual([]); expect(fast.mechanism).toEqual(mech); - return authenticate({ token: { token: "hai", mechanism: fast.mechanism } }, null, userAgent); + return authenticate( + { + token: { + token: "hai", + expiry: datetime(new Date()), + mechanism: fast.mechanism, + }, + }, + null, + userAgent, + ); } const { entity } = mockClient({ credentials: onAuthenticate }); @@ -126,7 +140,9 @@ test("with FAST token", async () => { expect(await promise(entity, "send")).toEqual( - bnVsbACNMNimsTBnxS04m8x7wgKjBHdDUL/nXPU4J4vqxqjBIg== + + bnVsbACNMNimsTBnxS04m8x7wgKjBHdDUL/nXPU4J4vqxqjBIg== + {userAgent} ,