-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy patherrors.js
More file actions
40 lines (34 loc) · 1.23 KB
/
errors.js
File metadata and controls
40 lines (34 loc) · 1.23 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
/*
* Copyright (c) 2015-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
*/
var should = require('should');
var testconfig = require('../etc/test-config.js');
var marklogic = require('../');
var dbReader = marklogic.createDatabaseClient(testconfig.restReaderConnection);
describe('error generated from a server call', function() {
it('should have a stack trace', function(done){
// Writing as a reader fails with a 403 error
dbReader.documents.write({
uri: '/test/negative/writeAsReader1.txt',
content: 'the text'
}).
result(function(response){
response.should.equal('SHOULD HAVE FAILED');
done();
}, function(error){
try {
error.statusCode.should.equal(403);
// verify client-side stack
error.should.have.property('stack');
const errorResponse = error.body.errorResponse;
errorResponse.statusCode.should.equal(403);
errorResponse.status.should.equal('Forbidden');
errorResponse.messageCode.should.equal('SEC-PRIV');
errorResponse.message.should.equal('You do not have permission to this method and URL.');
done();
} catch(error){
done(error);
}
});
});
});