Add some more token scope tests

This commit is contained in:
Johannes Zellner
2022-09-24 18:52:41 +02:00
parent 858c85ee85
commit 6d7f7fbc9a
+21
View File
@@ -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);