Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should update user preference', function (done) {
var data = {
preference: 'autoRefreshTicketGrid',
value: false
}
request
.put('/api/v1/users/trudesk/updatepreferences')
.set('accesstoken', tdapikey)
.set('Content-Type', 'application/json')
.send(data)
.set('Accept', 'application/json')
.expect(function (res) {
if (res.body.success !== true || res.body.user.preferences.autoRefreshTicketGrid !== false)
throw new Error('Unable to update user')
})
.expect(200, done)
})
function (err, u) {
if (err) return done(err)
request
.put('/api/v1/users/fake.user')
.set('accesstoken', tdapikey)
.set('Content-Type', 'application/json')
.send(u)
.set('Accept', 'application/json')
.expect(function (res) {
if (res.body.success !== true) throw new Error('Unable to update user')
})
.expect(200, done)
}
)
userSchema.getUserByUsername('trudesk', function (err, user) {
expect(err).to.not.exist
var u = {
aFullname: user.fullname,
aEmail: user.email,
aGrps: [group._id],
saveGroups: true
}
request
.put('/api/v1/users/trudesk')
.set('accesstoken', tdapikey)
.set('Content-Type', 'application/json')
.send(u)
.set('Accept', 'application/json')
.expect(200, function () {
groupSchema.getGroupByName('TEST', function (err, grp) {
expect(err).to.not.exist
expect(grp.isMember(user._id)).to.equal(true)
done()
})
})
})
})
it("should fail to write a missing file name", function(done) {
request
.put("")
.type("text")
.send("")
.expect(500, done);
});
function bypassBlockNew(name, next) {
if (BLOCK_NEW) {
var params = {
name: name,
bypass: true
};
request
.put("")
.query(params)
.expect("Content-Type", /^text\/plain/)
.expect(200, "", next);
} else {
next();
}
}
forFiles(goodFiles, function(file, next) {
request
.put("")
.query(getCreateQueryParams(file.name, ".previous"))
.type("text")
.send(file.data)
.expect("Content-Type", /^text\/plain/)
.expect(200, "", next);
}, done);
};