UNPKG

1.48 kBJavaScriptView Raw
1'use strict'
2/* eslint-env node, mocha */
3/* eslint-disable no-unused-expressions */
4
5const expect = require('chai').expect
6const ActiveDirectory = require('../index')
7const config = require('./config')
8
9let server = require('./mockServer')
10
11describe('userExists Method', function () {
12 let ad
13 const settings = require('./settings').userExists
14
15 before(function (done) {
16 server(function (s) {
17 ad = new ActiveDirectory(config)
18 server = s
19 done()
20 })
21 })
22
23 it('should return true if the username (sAMAccountName) exists', function (done) {
24 ad.userExists(settings.username.sAMAccountName, function (err, exists) {
25 expect(err).to.be.null
26 expect(exists).to.be.true
27 done()
28 })
29 })
30
31 it('should return true if the username (userPrincipalName) exists', function (done) {
32 ad.userExists(settings.username.userPrincipalName, function (err, exists) {
33 expect(err).to.be.null
34 expect(exists).to.be.true
35 done()
36 })
37 })
38
39 it('should return true if the username (distinguishedName) exists', function (done) {
40 ad.userExists(settings.username.sAMAccountName, function (err, exists) {
41 expect(err).to.be.null
42 expect(exists).to.be.true
43 done()
44 })
45 })
46
47 it('should return false if the username doesn\'t exist', function (done) {
48 ad.userExists('!!!NON-EXISTENT USER!!!', function (err, exists) {
49 expect(err).to.be.null
50 expect(exists).to.be.false
51 done()
52 })
53 })
54})