Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@existdb/node-exist

Package Overview
Dependencies
Maintainers
3
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@existdb/node-exist - npm Package Compare versions

Comparing version
4.9.2
to
5.0.0
+1
-8
package.json

@@ -10,9 +10,2 @@ {

},
"bin": {
"exist-tree": "spec/examples/exist-tree",
"exist-ls": "spec/examples/exist-ls",
"exist-upload": "spec/examples/exist-upload",
"exist-install": "spec/examples/exist-install",
"exist-exec": "spec/examples/exist-exec"
},
"standard": {

@@ -62,3 +55,3 @@ "ignore": [

},
"version": "4.9.2"
"version": "5.0.0"
}
+7
-19

@@ -23,2 +23,4 @@ # node-exist

__NOTE:__ If you are looking for a command line client have a look at [xst](https://github.com/line-o/xst)
## Use

@@ -489,27 +491,13 @@

You can use this library to interact with local or remote existdb instances on the command line.
You can find a few basic [examples](spec/examples) in this repository.
You can use this library to build a command line interface that interacts with existdb instances.
A few basic [examples](spec/examples) how to do this are included in this repository.
To give you a taste all example scripts are exposed as binaries in the __node_modules/.bin__ folder when you install this package.
Example:
You can run them using `npx`
```bash
npx -p @existdb/node-exist exist-ls /db/apps
spec/examples/exist-ls /db/apps
```
If you want you can even install this package globally and then use these scripts like `ls` or `cd`.
__NOTE:__ Have a look at [xst](https://github.com/line-o/xst) for a CLI client built with node-exist.
```bash
npm install -g @existdb/node-exist
```
Now you can type
```bash
exist-ls /db/apps
```
anywhere on the system.
## Test

@@ -516,0 +504,0 @@

/**
* Gather connection options suitable for automated and manual testing
* of an off-the-shelf exist-db instance (e.g. in a CI environment)
* Allows overriding specific setting via environment variables.
*
* EXISTDB_SERVER - URL to the exist-db you want to connect to
* EXISTDB_USER - username of the user the queries should be executed with
* defaults to "admin"
* EXISTDB_PASS - password to authenticate EXISTDB_USER
* must be set for EXISTDB_USER to take effect
*/
/**
* @type {import('../components/connection').NodeExistConnectionOptions}
*/
const { readOptionsFromEnv } = require('../index')
const envOptions = readOptionsFromEnv()
// test with admin user by default
if (!envOptions.basic_auth) {
envOptions.basic_auth = { user: 'admin', pass: '' }
}
// console.log(envOptions)
module.exports = envOptions
const { connect } = require('../../index')
const connectionOptions = require('../connection')
const db = connect(connectionOptions)
const collection = 'foO0o'
db.collections.create(collection)
.then(function (result) {
console.log('created:', result)
return db.collections.describe(collection)
})
.then(function (result) {
console.log('description:', result)
return db.collections.remove(collection)
})
.then(function (result) {
console.log('removed:', result)
return db.collections.remove(collection)
})
.catch(function (e) {
console.log('fail', e)
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

# node-exist Command Line Scripts
- `exist-ls` list the contents of a collection in eXist-db
- `exist-tree` list the contents of a collection in eXist-db as a tree
- `exist-upload` upload a files and folders to a collection in eXist-db
- `exist-install` upload and install a package into eXist-db
- `exist-exec` execute queries in an eXist-db
**NOTE:** These scripts connect to a running eXist-db instance and XML-RPC has
to be enabled.
## connecting to your eXist-db instance
The command line scripts allow you to connect to any instance that has XML-RPC
enabled. By default they will attempt to connect to a local development server
with default passwords.
Override any of the default connection parameters by setting environment
variables prefixed with `EXISTDB`. In the following table you see a list of the
parameters with their default values and a description.
| variable name | default | description
|----|----|----
| `EXISTDB_USER` | `admin` | the user used to connect to the database and to execute queries with
| `EXISTDB_PASS` | _empty_ | the password to authenticate the user against the database
| `EXISTDB_SERVER` | `https://localhost:8443` | the URL of the database instance to connect to (only http and https protocols are allowed)
## dotenv
dotenv(-cli) is a small script that allows you to read environment variables from a file in the filesystem.
### preparation
- Install [dotenv-cli](https://www.npmjs.com/package/dotenv-cli) globally
```bash
npm install -g dotenv-cli
```
- create .env file in a folder with the settings that you need
```bash
EXISTDB_USER=admin
EXISTDB_PASS=
EXISTDB_SERVER=http://localhost:8080
```
### use
prepend command line script with `dotenv` in the folder you created the .env file in
#### Examples
If you installed node-exist globally (`npm install -g @existdb/node-exist`)
```bash
dotenv exist-ls /db/apps
```
If you installed node-exist as a local package (npm dependency)
```bash
dotenv node_modules/.bin/exist-ls /db/apps
```
If you cloned this repository
```bash
dotenv spec/examples/exist-ls /db/apps
```
That also works when running the tests (on a remote server maybe or a different user)
```bash
dotenv npm test
```

Sorry, the diff of this file is not supported yet

<?xml version="1.0" encoding="UTF-8"?>
<collection>
<item property />
</collection>

Sorry, the diff of this file is not supported yet

<!doctype html><html><body><input readonly></body></html>

Sorry, the diff of this file is not supported yet

<?xml version="1.0" encoding="UTF-8"?>
<collection>
<item property="value"/>
</collection>

Sorry, the diff of this file is not supported yet

const fs = require('fs')
const test = require('tape')
const app = require('../../components/app')
const { connect } = require('../../index')
const connectionOptions = require('../connection')
test('app component exports install method', function (t) {
t.equal(typeof app.install, 'function')
t.end()
})
test('app component exports remove method', function (t) {
t.equal(typeof app.remove, 'function')
t.end()
})
test('app component exports upload method', function (t) {
t.equal(typeof app.upload, 'function')
t.end()
})
test('upload and install application XAR', function (t) {
const db = connect(connectionOptions)
const xarBuffer = fs.readFileSync('spec/files/test-app.xar')
const xarName = 'test-app.xar'
const packageUri = 'http://exist-db.org/apps/test-app'
const packageTarget = '/db/apps/test-app'
t.test('upload app', function (st) {
st.plan(1)
db.app.upload(xarBuffer, xarName)
.then(result => st.equal(result.success, true))
.catch(e => {
st.fail(e)
st.end()
})
})
t.test('install app', function (st) {
db.app.install(xarName)
.then(response => {
if (!response.success) { return Promise.reject(response.error) }
st.plan(3)
st.equal(response.success, true, 'the application should have been installed')
st.equal(response.result.update, false, 'there should be no previous installation')
st.equal(response.result.target, packageTarget, 'the correct target should be returned')
})
.catch(e => {
st.fail(e)
st.end()
})
})
t.test('re-install app', function (st) {
db.app.install(xarName)
.then(response => {
if (!response.success) { return Promise.reject(response.error) }
st.plan(3)
st.equal(response.success, true)
st.equal(response.result.update, true)
st.equal(response.result.target, packageTarget, 'the correct target should be returned')
})
.catch(e => {
st.fail(e)
st.end()
})
})
t.test('remove installed app', function (st) {
st.plan(2)
db.app.remove(packageUri)
.then(response => st.equal(response.success, true, 'uninstalled'))
.then(_ => db.documents.remove(`${app.packageCollection}/test-app.xar`))
.then(response => st.equal(response, true, 'removed'))
.catch(e => st.fail(e))
})
})
test('empty application XAR', function (t) {
const db = connect(connectionOptions)
const xarBuffer = Buffer.from('')
const xarName = 'test-empty-app.xar'
t.test('upload app', function (st) {
st.plan(1)
db.app.upload(xarBuffer, xarName)
.then(response => st.equal(response.success, true))
.catch(e => st.fail(e))
})
t.test('install app', function (st) {
db.app.install(xarName)
.then(response => {
st.plan(2)
st.equal(response.success, false)
st.equal(response.error.message, `experr:EXPATH00 Missing descriptor from package: ${app.packageCollection}/test-empty-app.xar`)
})
.catch(e => {
st.fail(e)
st.end()
})
})
t.test('cleanup', function (st) {
st.plan(1)
db.documents.remove(`${app.packageCollection}/test-empty-app.xar`)
.then(response => st.equal(response, true))
.catch(e => st.fail(e))
})
})
const test = require('tape')
const { connect } = require('../../index')
const connectionOptions = require('../connection')
const asGuest = Object.assign({},
connectionOptions,
{ basic_auth: { user: 'guest', pass: 'guest' } }
)
test('get collection info', function (t) {
const db = connect(connectionOptions)
db.collections.describe('/db')
.then(function (info) {
t.equal(info.owner, 'SYSTEM')
t.end()
})
.catch(function (e) {
t.fail(e)
t.end()
})
})
test('get info for non existent collection', function (t) {
const db = connect(connectionOptions)
db.collections.describe('/foo')
.then(function (r) {
t.fail(r, 'no error')
t.end()
})
.catch(function (e) {
if (!e.faultString) {
t.fail(e, 'no faultString, something else must have gone wrong')
t.end()
return
}
t.ok(e.faultString.match(/\/foo not found!$/), 'not found error')
t.end()
})
})
test('create collection', function (t) {
const db = connect(connectionOptions)
db.collections.create('new-test-collection')
.then(function (r) {
console.log(r, 'create')
t.ok(r, 'created')
t.end()
})
.catch(function (e) {
t.fail(e, 'creation error')
t.end()
})
})
test('remove collection', function (t) {
const db = connect(connectionOptions)
const testCollection = '/remove-collection'
db.collections.create(testCollection)
.then(function () {
return db.collections.remove(testCollection)
})
.then(function (success) {
t.ok(success, 'removed')
t.end()
})
.catch(function (e) {
t.fail(e, 'remove failed')
t.end()
})
})
test('collection exists and guest cannot open it', function (t) {
const db = connect(asGuest)
db.collections.existsAndCanOpen('/db/system/security')
.then(function () {
t.fail()
t.end()
})
.catch(function (e) {
t.ok(e, '/db/system/security exists and user guest cannot access it')
t.end()
})
})
test('collection exists and guest can open it', function (t) {
const db = connect(asGuest)
db.collections.existsAndCanOpen('/db/apps')
.then(function (success) {
t.true(success, '/db/apps exists and user guest can access it')
t.end()
})
.catch(function (e) {
t.fail(e)
t.end()
})
})
test('collection does not exist (guest)', function (t) {
const db = connect(asGuest)
db.collections.existsAndCanOpen('/db/apps/asdf')
.then(function (success) {
t.false(success, '/db/apps/asdf does not exist')
t.end()
})
.catch(function (e) {
t.fail(e)
t.end()
})
})
test('collection exists and admin can open it', function (t) {
const db = connect(connectionOptions)
db.collections.existsAndCanOpen('/db/system/security')
.then(function (success) {
t.true(success)
t.end()
})
.catch(function (e) {
t.fail(e)
t.end()
})
})
test('collection does not exist (admin)', function (t) {
const db = connect(connectionOptions)
db.collections.existsAndCanOpen('/db/apps/asdf')
.then(function (success) {
t.false(success, '/db/apps/asdf does not exist')
t.end()
})
.catch(function (e) {
t.fail(e)
t.end()
})
})
const test = require('tape')
const fs = require('fs')
const { connect } = require('../../index')
const connectionOptions = require('../connection')
test('upload document', function (t) {
const db = connect(connectionOptions)
const buffer = Buffer.from('test')
db.documents.upload(buffer, buffer.length)
.then(function (result) {
t.ok(result >= 0, 'returned filehandle')
t.end()
})
.catch(function (e) {
t.fail(e)
t.end()
})
})
test('upload invalid XML', function (t) {
const db = connect(connectionOptions)
const buffer = fs.readFileSync('spec/files/invalid.xml')
db.documents.upload(buffer, buffer.length)
.then(function (result) {
t.ok(result >= 0, 'returned filehandle')
return db.documents.parseLocal(result, '/tmp/testfile.xml')
})
.then(function (result) {
t.fail(result, 'was not rejected')
t.end()
})
.catch(function (e) {
t.ok(e, 'was rejected')
t.end()
})
})
test('upload valid XML', function (t) {
const db = connect(connectionOptions)
const remoteFileName = '/test.xml'
db.documents.upload(fs.readFileSync('spec/files/test.xml'))
.then(function (fh) {
t.ok(fh >= 0, 'returned filehandle')
return db.documents.parseLocal(fh, remoteFileName, {})
})
.then(function (result) {
t.ok(result, 'file could be parsed')
return db.resources.describe(remoteFileName)
})
.then(function (result) {
t.ok(result, 'file was written to collection')
t.end()
})
.catch(function (e) {
t.fail(e, 'errored')
t.end()
})
})
test('download test.xml', function (t) {
const db = connect(connectionOptions)
const localContents = fs.readFileSync('spec/files/test.xml').toString()
const expectedContents = localContents.substr(0, localContents.length - 1) // for some reason the last newline is removed
const options = { 'omit-xml-declaration': 'no' } // xml header is cut off by default
const remoteFileName = '/test.xml'
db.documents.read(remoteFileName, options)
.then(function (result) {
t.equal(result.toString(), expectedContents, 'expected file contents received')
t.end()
})
.catch(function (e) {
t.fail(e, 'errored')
t.end()
})
})
// well formed xml
test('well-formed-xml', function (t) {
t.skip('not implemented yet')
t.end()
})
// xquery file with permission changes
test('xql-change-perms', function (t) {
t.skip('not implemented yet')
t.end()
})
// upload HTML5 file without retry
test('up-html5-no-retry', function (t) {
t.skip('not implemented yet')
t.end()
})
// upload HTML5 file with retry
test('up-html5-with-retry', function (t) {
t.skip('not implemented yet')
t.end()
})
test('non well formed XML will not be uploaded as binary', function (t) {
t.skip('not implemented yet')
t.end()
})
// tests
const test = require('tape')
const { connect, getMimeType, defineMimeTypes } = require('../../index')
const connectionOptions = require('../connection')
test('check for default mime type extensions', function (t) {
t.equal(getMimeType('test.xq'), 'application/xquery')
t.equal(getMimeType('test.xqs'), 'application/xquery')
t.equal(getMimeType('test.xquery'), 'application/xquery')
t.equal(getMimeType('test.xql'), 'application/xquery')
t.equal(getMimeType('test.xqm'), 'application/xquery')
t.equal(getMimeType('test.xconf'), 'application/xml')
t.equal(getMimeType('test.odd'), 'application/xml')
t.end()
})
test('extend mime type definitions', function (t) {
const testPath = 'test.bar'
const testExtension = 'bar'
const testMimeType = 'text/x-test'
const testTypeMap = {}
testTypeMap[testMimeType] = [testExtension]
t.notEqual(getMimeType(testPath), testMimeType, 'previously undefined extension for ' + testExtension)
defineMimeTypes(testTypeMap)
t.equal(getMimeType(testPath), testMimeType, 'added new extension for ' + testExtension)
t.end()
})
test('create connection with default settings', function (t) {
const db = connect()
const components = ['collections', 'queries', 'documents', 'users', 'indices']
components.forEach(function (component) {
t.ok(component in db, 'component ' + component + ' found')
})
t.ok(db.client.isSecure, 'secure client used')
t.end()
})
test('create connection using http://', function (t) {
const db = connect({ secure: false, port: 8080 })
t.equal(db.client.isSecure, false, 'insecure client used')
t.end()
})
test('get collection permissions', function (t) {
const db = connect(connectionOptions)
db.resources.getPermissions('/db')
.then(function (result) {
t.ok(result)
t.end()
})
.catch(function (e) {
t.fail(e)
t.end()
})
})
const test = require('tape')
const { connect } = require('../../index')
const connectionOptions = require('../connection')
test('call remote procedure through methodCall', function (t) {
const db = connect(connectionOptions)
let resultHandle = null
const queryString = '<result>{for $i in (1,2) return <i>{$i + $a}</i>}</result>'
const queryOptions = { variables: { a: 1 } }
const resultMatcher = /^<result>\s*<i>2<\/i>\s*<i>3<\/i>\s*<\/result>$/
db.queries.execute(queryString, queryOptions, null)
.then(function (handle) {
resultHandle = handle
t.ok(handle >= 0, 'got handle')
return db.queries.count(handle)
})
.then(function (hits) {
t.equal(hits, 1, 'got one hit')
return db.queries.retrieveAll(resultHandle, hits)
})
.then(function (results) {
const concatenatedBuffers = Buffer.concat(results)
t.ok(resultMatcher.test(concatenatedBuffers.toString()), 'got expected result')
return db.queries.releaseResult(resultHandle)
})
.then(function () {
t.end()
})
.catch(function (e) {
t.fail(e)
t.end()
})
})
test('call promised query', function (t) {
const db = connect(connectionOptions)
const queryString = 'for $i in (1, 2, 3) return $i'
const options = { start: 2, limit: 1 }
const expectedResult = '<exist:result xmlns:exist="http://exist.sourceforge.net/NS/exist" hits="3" start="2" count="1">\n<exist:value type="xs:integer">2</exist:value>\n</exist:result>'
db.queries.read(queryString, options)
.then(function (result) {
t.equal(result.toString(), expectedResult, 'got expected result')
t.end()
})
.catch(function (e) {
t.fail(e)
t.end()
})
})
test('call queryAll method', function (t) {
const db = connect(connectionOptions)
const queryString = 'for $i in (1,2) return $i + $a'
const queryOptions = { variables: { a: 10 } }
const expectedResult = '11,12'
db.queries.readAll(queryString, queryOptions)
.then(function (result) {
const csv = result.pages.map(function (p) { return p.toString() }).join(',')
t.equal(result.pages.length, result.hits, 'all pages retrieved')
t.equal(csv, expectedResult, 'got expected result')
t.end()
})
.catch(function (e) {
t.fail(e)
t.end()
})
})
test('run query, expect XML', function (t) {
t.skip('not implemented yet')
t.end()
})
test('run query, expect json', function (t) {
t.skip('not implemented yet')
t.end()
})
const test = require('tape')
const { readOptionsFromEnv } = require('../../index')
test('connection options from environment', function (t) {
const optionsFromEnv = readOptionsFromEnv()
const userIsSet = process.env.EXISTDB_USER && process.env.EXISTDB_PASS
const serverIsSet = 'EXISTDB_SERVER' in process.env
if (serverIsSet) {
const { hostname, port, protocol } = new URL(process.env.EXISTDB_SERVER)
t.equal(optionsFromEnv.port, port)
t.equal(optionsFromEnv.secure, protocol === 'https:')
t.equal(optionsFromEnv.host, hostname)
} else {
t.false('port' in optionsFromEnv)
t.false('secure' in optionsFromEnv)
t.false('host' in optionsFromEnv)
}
if (userIsSet) {
t.ok(optionsFromEnv.basic_auth)
t.equal(optionsFromEnv.basic_auth.user, process.env.EXISTDB_USER)
t.equal(optionsFromEnv.basic_auth.pass, process.env.EXISTDB_PASS)
} else {
t.false('basic_auth' in optionsFromEnv)
}
t.end()
})
test('test user set in env', function (t) {
process.env.EXISTDB_USER = 'test'
process.env.EXISTDB_PASS = 'test'
const optionsFromEnv = readOptionsFromEnv()
t.ok(optionsFromEnv.basic_auth)
t.equal(optionsFromEnv.basic_auth.user, 'test')
t.equal(optionsFromEnv.basic_auth.pass, 'test')
t.end()
})
test('test user set in env with empty password', function (t) {
process.env.EXISTDB_USER = 'test'
process.env.EXISTDB_PASS = ''
const optionsFromEnv = readOptionsFromEnv()
t.ok(optionsFromEnv.basic_auth)
t.equal(optionsFromEnv.basic_auth.user, 'test')
t.equal(optionsFromEnv.basic_auth.pass, '')
t.end()
})
test('empty user set in env', function (t) {
process.env.EXISTDB_USER = ''
process.env.EXISTDB_PASS = 'test1234'
const optionsFromEnv = readOptionsFromEnv()
t.false('basic_auth' in optionsFromEnv)
t.end()
})
test('only user set in env', function (t) {
process.env.EXISTDB_USER = 'test'
delete process.env.EXISTDB_PASS
const optionsFromEnv = readOptionsFromEnv()
t.notOk(optionsFromEnv.basic_auth)
t.end()
})
const test = require('tape')
const { connect } = require('../../index')
const connectionOptions = require('../connection')
const testCollection = '/tests'
const db = connect(connectionOptions)
function testGetPermissions (t) {
// setup
db.resources.getPermissions(testCollection)
.then(function (result) {
t.equal(result.owner, 'admin', 'expected owner')
t.equal(result.permissions, 493, 'expected permissions')
t.deepEqual(result.acl, [], 'expected acl')
t.equal(result.group, 'dba', 'expected group')
t.end()
})
.catch(function (e) {
t.fail(e)
t.end()
})
}
function testDescribeResource (t) {
const expectedInfo = {
owner: 'admin',
'content-length': 1,
'mime-type': 'application/xquery',
'content-length-64bit': '1',
permissions: 420,
created: new Date(),
name: testCollection + '/test.xql',
modified: new Date(),
acl: [],
type: 'BinaryResource',
group: 'dba'
}
db.resources.describe(testCollection + '/test.xql')
.then(function (info) {
t.equal(info.name, expectedInfo.name, 'returns expected path')
t.equal(info.owner, expectedInfo.owner, 'returns expected owner')
t.equal(info.permissions, expectedInfo.permissions, 'returns expected owner')
t.equal(info['content-length'], expectedInfo['content-length'], 'returns expected length')
t.end()
})
.catch(function (e) {
t.fail(e)
t.end()
})
}
function testSetPermissions (t) {
const resourcePath = testCollection + '/test.xql'
const permissions = 666
db.resources.setPermissions(resourcePath, permissions)
.then(function (result) {
t.ok(result, 'permissions set successfully')
return db.resources.getPermissions(resourcePath)
})
.then(function (result) {
t.equal(result.permissions, permissions, 'expected permissions')
t.end()
})
.catch(function (e) {
t.fail(e)
t.end()
})
}
test('resources:', function (t) {
const db = connect(connectionOptions)
t.test('setup', function (setup) {
db.collections.create(testCollection)
.then(function () {
return db.documents.upload(Buffer.from('1'))
})
.then(function (fh) {
return db.documents.parseLocal(fh, testCollection + '/test.xql', {})
})
.then(function (r) {
setup.ok(r, 'setup ended')
setup.end()
})
.catch(function (e) {
t.fail('setup failed')
t.end()
})
})
t.test('describe resource', testDescribeResource)
t.test('get resource permissions', testGetPermissions)
t.test('set resource permissions', testSetPermissions)
t.test('tearDown', function tearDown (td) {
db.collections.remove(testCollection)
.then(function (r) {
td.ok(r, 'tearDown ended')
td.end()
})
.catch(function (e) {
td.fail(e)
td.end()
})
})
})
const test = require('tape')
const { connect } = require('../../index')
const connectionOptions = require('../connection')
const asGuest = Object.assign({},
connectionOptions,
{ basic_auth: { user: 'guest', pass: 'guest' } }
)
test('list users', function (t) {
const db = connect(connectionOptions)
db.users.list()
.then(function (list) {
t.plan(4)
t.ok(list.length, 'Returns a non-empty list of users')
const names = list.map(u => u.name)
t.true(names.includes('SYSTEM'), 'found user SYSTEM')
t.true(names.includes('admin'), 'found user admin')
t.true(names.includes('guest'), 'found user guest')
// when testing on a package-less installation these users will not be created
// t.true(names.includes('monex'), 'found user monex')
// t.true(names.includes('eXide'), 'found user eXide')
// t.true(names.includes('packageservice'), 'found user packageservice')
// exist 4.7.1 does not have this user
// t.true(names.includes('nobody'), 'found user nobody')
t.end()
})
.catch(function (e) {
t.fail()
t.end()
})
})
test('list users as guest', function (t) {
const db = connect(asGuest)
db.users.list()
.then(function (list) {
t.ok(list.length, 'Returns a non-empty list of users')
t.end()
})
.catch(function (e) {
t.fail(e)
t.end()
})
})
test('get user info for admin', function (t) {
const db = connect(connectionOptions)
db.users.getUserInfo('admin')
.then(function (info) {
t.ok(info)
t.end()
})
.catch(function (e) {
t.fail()
t.end()
})
})
test('get user info for guest', function (t) {
const db = connect(connectionOptions)
db.users.getUserInfo('guest')
.then(function (info) {
t.ok(info)
t.end()
})
.catch(function (e) {
t.fail()
t.end()
})
})
test('get user info for non-existent user', function (t) {
const db = connect(connectionOptions)
db.users.getUserInfo('thisuserschouldnotexist')
.then(function (info) {
t.fail()
t.end()
})
.catch(function (e) {
t.ok(e)
t.end()
})
})