From a302cb4c511ae5421177c60ab9a4d32dc9334675 Mon Sep 17 00:00:00 2001 From: ahaenggli Date: Sun, 4 Feb 2024 17:44:47 +0100 Subject: [PATCH] PasswordPolicyControl with value=null #956 --- lib/controls/password-policy-control.js | 4 ++++ lib/controls/password-policy-control.test.js | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/lib/controls/password-policy-control.js b/lib/controls/password-policy-control.js index b10a083..de1b55a 100644 --- a/lib/controls/password-policy-control.js +++ b/lib/controls/password-policy-control.js @@ -44,6 +44,10 @@ class PasswordPolicyControl extends Control { return } + if (options.value === null) { + return + } + if (Buffer.isBuffer(options.value)) { this.#parse(options.value) } else if (isObject(options.value)) { diff --git a/lib/controls/password-policy-control.test.js b/lib/controls/password-policy-control.test.js index a55ccfa..000c6be 100644 --- a/lib/controls/password-policy-control.test.js +++ b/lib/controls/password-policy-control.test.js @@ -50,6 +50,12 @@ tap.test('contructor', t => { t.throws(() => new PPC({ value: { timeBeforeExpiration: 1, graceAuthNsRemaining: 2 } })) }) + // null value should not fail #956 + t.test('no value shall not fail', async t => { + const control = new PPC({ value: null }) + t.same(control.value, {}) + }) + t.end() })