wangzhibo
2026-05-09 53418655c061ac26f66058253f39200aced1ab1d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'use strict'
 
const tap = require('tap')
const { BerReader } = require('@ldapjs/asn1')
const LdapMessage = require('../../ldap-message')
const {
  basicResponse,
  withGeneratedPasswordBytes
} = require('./_fixtures/password-modify')
const PasswordModifyResponse = require('./password-modify')
 
tap.test('parses a response with a generated password', async t => {
  const reader = new BerReader(Buffer.from(withGeneratedPasswordBytes))
  let res = LdapMessage.parse(reader)
  res = PasswordModifyResponse.fromResponse(res)
  t.type(res, PasswordModifyResponse)
  t.equal(res.responseName, undefined)
  t.equal(res.responseValue, 'AdapterStevensonGrainPlaymate')
})
 
tap.test('parses a response with an empty value', async t => {
  const reader = new BerReader(Buffer.from(basicResponse))
  let res = LdapMessage.parse(reader)
  res = PasswordModifyResponse.fromResponse(res)
  t.type(res, PasswordModifyResponse)
  t.equal(res.responseName, undefined)
  t.equal(res.responseValue, undefined)
})