From 6e62d97ed0d327e643e82a2dcfb10e310b9792cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20Jedlicska?= Date: Thu, 28 Apr 2022 15:40:04 +0200 Subject: [PATCH] test(server default apps): test default app update borkage doesn't screw up the app data --- .../server/modules/auth/tests/apps.spec.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/server/modules/auth/tests/apps.spec.js b/packages/server/modules/auth/tests/apps.spec.js index 25bf94c9c..29a1f6cdb 100644 --- a/packages/server/modules/auth/tests/apps.spec.js +++ b/packages/server/modules/auth/tests/apps.spec.js @@ -293,6 +293,30 @@ describe('Services @apps-services', () => { }) }) + it('Updating a default app with bad data should leave the app in an untouched state', async () => { + const speckleAppId = 'explorer' + const existingApp = await getApp({ id: speckleAppId }) + try { + await updateDefaultApp( + { + name: 'updated test application', + id: speckleAppId, + scopes: ['aWeird:Scope'] + }, + existingApp + ) + throw new Error('This should have failed') + } catch (err) { + // check that the weird:Scope violates a foreign key constraint... + // leaky abstractions i know, but no better way to test this for now + expect(err.message).to.contain('server_apps_scopes_scopename_foreign') + } + const notUpdatedApp = await getApp({ id: speckleAppId }) + // check that no harm was done + expect(notUpdatedApp.name).to.equal(existingApp.name) + expect(notUpdatedApp.scopes).to.equalInAnyOrder(existingApp.scopes) + }) + it('Should revoke access for a given user', async () => { const secondUser = { name: 'Dimitrie Stefanescu',