Add some more token scope tests
This commit is contained in:
@@ -42,6 +42,27 @@ describe('Tokens', function () {
|
||||
expect(error.reason).to.be(BoxError.BAD_FIELD);
|
||||
});
|
||||
|
||||
it('add fails with unknown scope', async function () {
|
||||
const badToken = Object.assign({}, TOKEN_0);
|
||||
badToken.scope = { 'foobar': 'rw', '*': 'r' };
|
||||
const [error] = await safe(tokens.add(badToken));
|
||||
expect(error.reason).to.be(BoxError.BAD_FIELD);
|
||||
});
|
||||
|
||||
it('add fails with invalid scope rule', async function () {
|
||||
const badToken = Object.assign({}, TOKEN_0);
|
||||
badToken.scope = { '*': 'rw ' };
|
||||
const [error] = await safe(tokens.add(badToken));
|
||||
expect(error.reason).to.be(BoxError.BAD_FIELD);
|
||||
});
|
||||
|
||||
it('add fails with bad name', async function () {
|
||||
const badToken = Object.assign({}, TOKEN_0);
|
||||
badToken.name = new Array(100).fill('x').join('');
|
||||
const [error] = await safe(tokens.add(badToken));
|
||||
expect(error.reason).to.be(BoxError.BAD_FIELD);
|
||||
});
|
||||
|
||||
it('get succeeds', async function () {
|
||||
const result = await tokens.get(TOKEN_0.id);
|
||||
expect(result).to.be.eql(TOKEN_0);
|
||||
|
||||
Reference in New Issue
Block a user