update dependencies and devDependencies, fix lint issues
[squeep-indie-auther] / test / src / manager.js
index 5acb5bbb17b2ebd5b079b9c7216f207d570b4db7..54e867f38ea0afc3bb52396ddc0babbdb66b0033 100644 (file)
@@ -1,10 +1,7 @@
-/* eslint-env mocha */
-/* eslint-disable capitalized-comments, sonarjs/no-duplicate-string, sonarjs/no-identical-functions */
-
 'use strict';
 
 const assert = require('assert');
-const sinon = require('sinon'); // eslint-disable-line node/no-unpublished-require
+const sinon = require('sinon');
 
 const Manager = require('../../src/manager');
 const Config = require('../../config');
@@ -904,7 +901,7 @@ describe('Manager', function () {
       assert.deepStrictEqual(result, []);
     });
     it('filters invalid scopes', function () {
-      ctx.parsedBody['accepted_scopes'] = ['read', 'email'];
+      ctx.parsedBody['accepted_scopes[]'] = ['read', 'email'];
       ctx.parsedBody['ad_hoc_scopes'] = 'bad"scope  create ';
       const result = manager._parseConsentScopes(ctx);
       assert.deepStrictEqual(result, ['read', 'create']);
@@ -1013,12 +1010,12 @@ describe('Manager', function () {
       assert(ctx.session.error);
     });
     it('removes email scope without profile', async function () {
-      ctx.parsedBody['accepted_scopes'] = ['email', 'create'];
+      ctx.parsedBody['accepted_scopes[]'] = ['email', 'create'];
       await manager.postConsent(res, ctx);
       assert(!ctx.session.acceptedScopes.includes('email'));
     });
     it('merges valid ad-hoc scopes', async function () {
-      ctx.parsedBody['accepted_scopes'] = ['email', 'create'];
+      ctx.parsedBody['accepted_scopes[]'] = ['email', 'create'];
       ctx.parsedBody['ad_hoc_scopes'] = '  my:scope  "badScope';
       await manager.postConsent(res, ctx);
       assert(ctx.session.acceptedScopes.includes('my:scope'));
@@ -1558,13 +1555,13 @@ describe('Manager', function () {
       manager.mysteryBox.unpack.resolves({});
       req.getHeader.returns('Bearer XXX');
       await manager._checkTokenValidationRequest(dbCtx, req, ctx);
-      assert(ctx.session.error)
+      assert(ctx.session.error);
     });
     it('covers no token', async function () {
       manager.mysteryBox.unpack.resolves({ c: 'xxx' });
       req.getHeader.returns('Bearer XXX');
       await manager._checkTokenValidationRequest(dbCtx, req, ctx);
-      assert(ctx.session.error)
+      assert(ctx.session.error);
     });
     it('covers db error', async function () {
       manager.mysteryBox.unpack.resolves({ c: 'xxx' });
@@ -2052,7 +2049,7 @@ describe('Manager', function () {
     describe('save-scopes action', function () {
       beforeEach(function () {
         ctx.parsedBody['action'] = 'save-scopes';
-        ctx.parsedBody['scopes-https://profile/example.com/'] = ['scope1', 'scope2'];
+        ctx.parsedBody['scopes-https://profile/example.com/[]'] = ['scope1', 'scope2'];
       });
       it('covers saving scopes', async function () {
         await manager.postAdmin(res, ctx);
@@ -2210,7 +2207,7 @@ describe('Manager', function () {
   describe('postAdminTicket', function () {
     beforeEach(function () {
       ctx.parsedBody['action'] = 'proffer-ticket';
-      ctx.parsedBody['scopes'] = ['read', 'role:private'];
+      ctx.parsedBody['scopes[]'] = ['read', 'role:private'];
       ctx.parsedBody['adhoc'] = 'adhoc_scope';
       ctx.parsedBody['profile'] = 'https://profile.example.com/';
       ctx.parsedBody['resource'] = 'https://profile.example.com/feed';
@@ -2234,7 +2231,7 @@ describe('Manager', function () {
       ctx.parsedBody['profile'] = 'bad url';
       ctx.parsedBody['resource'] = 'bad url';
       ctx.parsedBody['subject'] = 'bad url';
-      ctx.parsedBody['scopes'] = ['fl"hrgl', 'email'];
+      ctx.parsedBody['scopes[]'] = ['fl"hrgl', 'email'];
       await manager.postAdminTicket(res, ctx);
       assert(res.end.called);
       assert.strictEqual(ctx.errors.length, 5);