From 0ec188f88120b2dee63611955edf8d5d4cf08306 Mon Sep 17 00:00:00 2001 From: joyja Date: Thu, 24 Sep 2020 22:57:28 +0000 Subject: [PATCH] fixed npm audit vulnerabilities --- jest.config.js | 4 +- package-lock.json | 31 +++-- package.json | 2 +- src/__tests__/auth.js | 32 ++--- src/__tests__/tag.js | 2 +- src/database/__tests__/model.js | 6 +- src/database/index.js | 2 +- src/device/index.js | 2 +- src/resolvers/DeviceConfig.js | 2 +- src/resolvers/MqttPrimaryHost.js | 4 +- src/resolvers/Mutation/auth.js | 2 +- src/resolvers/Mutation/index.js | 2 +- src/resolvers/Mutation/service/index.js | 2 +- src/resolvers/Query/device.js | 2 +- src/resolvers/Query/index.js | 2 +- src/resolvers/Query/service.js | 2 +- src/resolvers/Query/tag.js | 2 +- src/resolvers/Query/user.js | 2 +- src/resolvers/Source.js | 2 +- src/resolvers/Subscription/device.js | 4 +- src/resolvers/Subscription/index.js | 2 +- src/resolvers/__tests__/resolvers.js | 148 ++++++++++++------------ src/resolvers/index.js | 2 +- test/db.js | 2 +- test/graphql/index.js | 2 +- test/graphql/query.js | 2 +- 26 files changed, 138 insertions(+), 129 deletions(-) diff --git a/jest.config.js b/jest.config.js index adb3c17..6e7ae73 100644 --- a/jest.config.js +++ b/jest.config.js @@ -14,6 +14,6 @@ module.exports = { watchPlugins: [ require.resolve('jest-watch-select-projects'), require.resolve('jest-watch-typeahead/filename'), - require.resolve('jest-watch-typeahead/testname') - ] + require.resolve('jest-watch-typeahead/testname'), + ], } diff --git a/package-lock.json b/package-lock.json index d85d203..50adc56 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4254,17 +4254,19 @@ "graphql-tools": "^4.0.5" } }, - "graphql-playground-html": { - "version": "1.6.12", - "resolved": "https://registry.npmjs.org/graphql-playground-html/-/graphql-playground-html-1.6.12.tgz", - "integrity": "sha512-yOYFwwSMBL0MwufeL8bkrNDgRE7eF/kTHiwrqn9FiR9KLcNIl1xw9l9a+6yIRZM56JReQOHpbQFXTZn1IuSKRg==" - }, "graphql-playground-middleware-express": { "version": "1.7.11", "resolved": "https://registry.npmjs.org/graphql-playground-middleware-express/-/graphql-playground-middleware-express-1.7.11.tgz", "integrity": "sha512-sKItB4s3FxqlwCgXdMfwRAfssSoo31bcFsGAAg/HzaZLicY6CDlofKXP8G5iPDerB6NaoAcAaBLutLzl9sd4fQ==", "requires": { "graphql-playground-html": "1.6.12" + }, + "dependencies": { + "graphql-playground-html": { + "version": "1.6.12", + "resolved": "https://registry.npmjs.org/graphql-playground-html/-/graphql-playground-html-1.6.12.tgz", + "integrity": "sha512-yOYFwwSMBL0MwufeL8bkrNDgRE7eF/kTHiwrqn9FiR9KLcNIl1xw9l9a+6yIRZM56JReQOHpbQFXTZn1IuSKRg==" + } } }, "graphql-playground-middleware-lambda": { @@ -4273,6 +4275,13 @@ "integrity": "sha512-fJ1Y0Ck5ctmfaQFoWv7vNnVP7We19P3miVmOT85YPrjpzbMYv0wPfxm4Zjt8nnqXr0KU9nGW53tz3K7/Lvzxtw==", "requires": { "graphql-playground-html": "1.6.12" + }, + "dependencies": { + "graphql-playground-html": { + "version": "1.6.12", + "resolved": "https://registry.npmjs.org/graphql-playground-html/-/graphql-playground-html-1.6.12.tgz", + "integrity": "sha512-yOYFwwSMBL0MwufeL8bkrNDgRE7eF/kTHiwrqn9FiR9KLcNIl1xw9l9a+6yIRZM56JReQOHpbQFXTZn1IuSKRg==" + } } }, "graphql-request": { @@ -6433,9 +6442,9 @@ } }, "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + "version": "4.17.20", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", + "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==" }, "lodash.includes": { "version": "4.3.0", @@ -6777,9 +6786,9 @@ }, "dependencies": { "bl": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz", - "integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==", + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.3.tgz", + "integrity": "sha512-pvcNpa0UU69UT341rO6AYy4FVAIkUHuZXRIWbq+zHnsVcRzDDjIAhGuuYoi0d//cwIwtt4pkpKycWEfjdV+vww==", "requires": { "readable-stream": "^2.3.5", "safe-buffer": "^5.1.1" diff --git a/package.json b/package.json index 863d26a..c268749 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "express": "^4.17.1", "graphql-yoga": "^1.18.3", "jsonwebtoken": "^8.5.1", - "lodash": "^4.17.15", + "lodash": "^4.17.20", "make-promises-safe": "^5.1.0", "modbus-serial": "^8.0.1", "mqtt": "^4.0.1", diff --git a/src/__tests__/auth.js b/src/__tests__/auth.js index 9fc6135..447c22a 100644 --- a/src/__tests__/auth.js +++ b/src/__tests__/auth.js @@ -57,9 +57,9 @@ describe(`User:`, () => { const context = { request: { headers: { - authorization: `Bearer ${token}` - } - } + authorization: `Bearer ${token}`, + }, + }, } const user = await User.getUserFromContext(context) expect(user.username).toBe(`admin`) @@ -70,9 +70,9 @@ describe(`User:`, () => { const context = { connection: { context: { - Authorization: `Bearer ${token}` - } - } + Authorization: `Bearer ${token}`, + }, + }, } const user = await User.getUserFromContext(context) expect(user.username).toBe(`admin`) @@ -106,9 +106,9 @@ describe(`User:`, () => { const context = { request: { headers: { - authorization: `Bearer ${token}` - } - } + authorization: `Bearer ${token}`, + }, + }, } expect( await User.changePassword( @@ -123,9 +123,9 @@ describe(`User:`, () => { const context = { request: { headers: { - authorization: `Bearer ${token}` - } - } + authorization: `Bearer ${token}`, + }, + }, } const user = await User.changePassword(context, 'password', 'newPassword') expect(await bcrypt.compare(`newPassword`, user.password)).toBe(true) @@ -133,16 +133,16 @@ describe(`User:`, () => { test(`getUserFromContext without valid token returns an error.`, async () => { const token = jwt.sign( { - userId: 123 + userId: 123, }, `aSecret` ) const context = { request: { headers: { - authorization: `Bearer ${token}` - } - } + authorization: `Bearer ${token}`, + }, + }, } expect( await User.getUserFromContext(context).catch((e) => e) diff --git a/src/__tests__/tag.js b/src/__tests__/tag.js index d44d87b..328d8e1 100644 --- a/src/__tests__/tag.js +++ b/src/__tests__/tag.js @@ -7,7 +7,7 @@ const { ScanClass, Device, Service, - MqttSource + MqttSource, } = require('../relations') const fromUnixTime = require('date-fns/fromUnixTime') diff --git a/src/database/__tests__/model.js b/src/database/__tests__/model.js index 33ebf71..11201b9 100644 --- a/src/database/__tests__/model.js +++ b/src/database/__tests__/model.js @@ -36,7 +36,7 @@ TestModel.table = 'test' describe(`executeQuery:`, () => { test('Called with undefined params calls db.all with empty object.', () => { const mockdb = { - all: jest.fn((sql, params, callback) => callback()) + all: jest.fn((sql, params, callback) => callback()), } const sql = `` const params = undefined @@ -54,7 +54,7 @@ describe(`executeQuery:`, () => { test('executeUpdate: Called with undefined params calls db.run with empty object.', () => { const mockdb = { - run: jest.fn((sql, params, callback) => callback()) + run: jest.fn((sql, params, callback) => callback()), } const sql = `` const params = undefined @@ -165,7 +165,7 @@ describe(`Model:`, () => { const result = await new Promise((resolve, reject) => { return db.run( `INSERT INTO test (testField) VALUES ("testValue")`, - function(error) { + function (error) { if (error) { reject(error) } else { diff --git a/src/database/index.js b/src/database/index.js index fb36b5f..3a990b1 100644 --- a/src/database/index.js +++ b/src/database/index.js @@ -1,5 +1,5 @@ const model = require('./model') module.exports = { - ...model + ...model, } diff --git a/src/device/index.js b/src/device/index.js index 6c6c6e3..cbdad94 100644 --- a/src/device/index.js +++ b/src/device/index.js @@ -7,5 +7,5 @@ module.exports = { Modbus, ModbusSource, EthernetIP, - EthernetIPSource + EthernetIPSource, } diff --git a/src/resolvers/DeviceConfig.js b/src/resolvers/DeviceConfig.js index 44b3a61..1aa00e5 100644 --- a/src/resolvers/DeviceConfig.js +++ b/src/resolvers/DeviceConfig.js @@ -3,5 +3,5 @@ async function __resolveType(parent, args, context, info) { } module.exports = { - __resolveType + __resolveType, } diff --git a/src/resolvers/MqttPrimaryHost.js b/src/resolvers/MqttPrimaryHost.js index a112cd6..2eb4742 100644 --- a/src/resolvers/MqttPrimaryHost.js +++ b/src/resolvers/MqttPrimaryHost.js @@ -1,7 +1,7 @@ -const recordCount = async function(parent, args, context, info) { +const recordCount = async function (parent, args, context, info) { return parent.getRecordCount() } module.exports = { - recordCount + recordCount, } diff --git a/src/resolvers/Mutation/auth.js b/src/resolvers/Mutation/auth.js index 9abb223..e013027 100644 --- a/src/resolvers/Mutation/auth.js +++ b/src/resolvers/Mutation/auth.js @@ -10,5 +10,5 @@ async function changePassword(root, args, context, info) { module.exports = { login, - changePassword + changePassword, } diff --git a/src/resolvers/Mutation/index.js b/src/resolvers/Mutation/index.js index e3c0eb7..7cd9343 100644 --- a/src/resolvers/Mutation/index.js +++ b/src/resolvers/Mutation/index.js @@ -7,5 +7,5 @@ module.exports = { ...auth, ...tag, ...device, - ...service + ...service, } diff --git a/src/resolvers/Mutation/service/index.js b/src/resolvers/Mutation/service/index.js index 466a33e..ae81a25 100644 --- a/src/resolvers/Mutation/service/index.js +++ b/src/resolvers/Mutation/service/index.js @@ -1,5 +1,5 @@ const mqtt = require('./mqtt') module.exports = { - ...mqtt + ...mqtt, } diff --git a/src/resolvers/Query/device.js b/src/resolvers/Query/device.js index 1c1e78a..6c31310 100644 --- a/src/resolvers/Query/device.js +++ b/src/resolvers/Query/device.js @@ -6,5 +6,5 @@ async function devices(root, args, context, info) { } module.exports = { - devices + devices, } diff --git a/src/resolvers/Query/index.js b/src/resolvers/Query/index.js index 71ee849..1792c1e 100644 --- a/src/resolvers/Query/index.js +++ b/src/resolvers/Query/index.js @@ -7,5 +7,5 @@ module.exports = { ...user, ...tag, ...device, - ...service + ...service, } diff --git a/src/resolvers/Query/service.js b/src/resolvers/Query/service.js index 6be6a8f..177fd04 100644 --- a/src/resolvers/Query/service.js +++ b/src/resolvers/Query/service.js @@ -6,5 +6,5 @@ async function services(root, args, context, info) { } module.exports = { - services + services, } diff --git a/src/resolvers/Query/tag.js b/src/resolvers/Query/tag.js index cb3169e..6b655df 100644 --- a/src/resolvers/Query/tag.js +++ b/src/resolvers/Query/tag.js @@ -12,5 +12,5 @@ async function scanClasses(root, args, context, info) { module.exports = { tags, - scanClasses + scanClasses, } diff --git a/src/resolvers/Query/user.js b/src/resolvers/Query/user.js index c3be9bc..108f7b9 100644 --- a/src/resolvers/Query/user.js +++ b/src/resolvers/Query/user.js @@ -5,5 +5,5 @@ async function user(root, args, context, info) { } module.exports = { - user + user, } diff --git a/src/resolvers/Source.js b/src/resolvers/Source.js index 44b3a61..1aa00e5 100644 --- a/src/resolvers/Source.js +++ b/src/resolvers/Source.js @@ -3,5 +3,5 @@ async function __resolveType(parent, args, context, info) { } module.exports = { - __resolveType + __resolveType, } diff --git a/src/resolvers/Subscription/device.js b/src/resolvers/Subscription/device.js index 6762756..13b0928 100644 --- a/src/resolvers/Subscription/device.js +++ b/src/resolvers/Subscription/device.js @@ -1,9 +1,9 @@ const deviceUpdate = { subscribe: (root, args, context) => { return context.pubsub.asyncIterator(`deviceUpdate`) - } + }, } module.exports = { - deviceUpdate + deviceUpdate, } diff --git a/src/resolvers/Subscription/index.js b/src/resolvers/Subscription/index.js index 3b3ad21..345dab9 100644 --- a/src/resolvers/Subscription/index.js +++ b/src/resolvers/Subscription/index.js @@ -5,5 +5,5 @@ const service = require('./service') module.exports = { ...device, ...service, - ...tag + ...tag, } diff --git a/src/resolvers/__tests__/resolvers.js b/src/resolvers/__tests__/resolvers.js index de0d6c4..a98d443 100644 --- a/src/resolvers/__tests__/resolvers.js +++ b/src/resolvers/__tests__/resolvers.js @@ -19,7 +19,7 @@ const { EthernetIPSource, Service, Mqtt, - MqttSource + MqttSource, } = require('../../relations') const mockSparkplug = { on: jest.fn((state, callback) => { @@ -33,7 +33,7 @@ const mockSparkplug = { publishDeviceDeath: jest.fn(), stop: jest.fn(), on: jest.fn(), - subscribePrimaryHost: jest.fn() + subscribePrimaryHost: jest.fn(), } const bcrypt = require('bcryptjs') @@ -45,10 +45,10 @@ let db = undefined let user = undefined const pubsub = { publish: jest.fn(), - asyncIterator: jest.fn() + asyncIterator: jest.fn(), } let context = { - pubsub + pubsub, } let unauthorizedContext = {} @@ -90,11 +90,11 @@ beforeAll(async () => { const { token } = await User.login(user.username, `password`) context.request = { headers: { - authorization: `Bearer ${token}` - } + authorization: `Bearer ${token}`, + }, } unauthorizedContext.request = { - headers: {} + headers: {}, } context.scanClasses = ScanClass.instances context.tags = Tag.instances @@ -215,7 +215,7 @@ describe(`Mutations: `, () => { test(`login returns the appropriate payload`, async () => { args = { username: user.username, - password: 'password' + password: 'password', } const payload = await resolvers.Mutation.login({}, args, context, {}).catch( (error) => { @@ -224,13 +224,13 @@ describe(`Mutations: `, () => { ) expect(payload).toEqual({ token: expect.any(String), - user + user, }) }) test(`login with incorrect username causes an error.`, async () => { args = { username: `bogusUsername`, - password: 'password' + password: 'password', } expect( await resolvers.Mutation.login({}, args, context, {}).catch((e) => e) @@ -239,7 +239,7 @@ describe(`Mutations: `, () => { test(`login with incorrect password causes an error.`, async () => { args = { username: user.username, - password: 'bogusPassword' + password: 'bogusPassword', } expect( await resolvers.Mutation.login({}, args, context, {}).catch((e) => e) @@ -248,7 +248,7 @@ describe(`Mutations: `, () => { test(`changePassword changes the password`, async () => { args = { newPassword: `aNewPassword`, - oldPassword: `password` + oldPassword: `password`, } const changedUser = await resolvers.Mutation.changePassword( {}, @@ -265,7 +265,7 @@ describe(`Mutations: `, () => { test(`createScanClass creates a scan class with the selected settings.`, async () => { prevCount = ScanClass.instances.length const args = { - rate: 1000 + rate: 1000, } scanClass = await resolvers.Mutation.createScanClass( {}, @@ -282,7 +282,7 @@ describe(`Mutations: `, () => { prevCount = ScanClass.instances.length const args = { id: scanClass.id, - rate: 2000 + rate: 2000, } updatedScanClass = await resolvers.Mutation.updateScanClass( {}, @@ -299,7 +299,7 @@ describe(`Mutations: `, () => { test(`updateScanClass updates a scan class with the selected settings.`, async () => { prevCount = ScanClass.instances.length const args = { - id: scanClass.id + id: scanClass.id, } updatedScanClass = await resolvers.Mutation.updateScanClass( {}, @@ -316,7 +316,7 @@ describe(`Mutations: `, () => { prevCount = ScanClass.instances.length const args = { id: 1234567, - rate: 2000 + rate: 2000, } expect( await resolvers.Mutation.updateScanClass({}, args, context, {}).catch( @@ -330,7 +330,7 @@ describe(`Mutations: `, () => { test(`deleteScanClass with invalid id throws error.`, async () => { prevCount = ScanClass.instances.length const args = { - id: 1234567 + id: 1234567, } expect( await resolvers.Mutation.deleteScanClass({}, args, context, {}).catch( @@ -344,7 +344,7 @@ describe(`Mutations: `, () => { test(`deleteScanClass deletes a scan class.`, async () => { prevCount = ScanClass.instances.length const args = { - id: scanClass.id + id: scanClass.id, } const deletedScanClass = await resolvers.Mutation.deleteScanClass( {}, @@ -364,7 +364,7 @@ describe(`Mutations: `, () => { name: `TestTag`, description: `Test Tag`, value: 123, - scanClassId: ScanClass.instances[0].id + scanClassId: ScanClass.instances[0].id, } tag = await resolvers.Mutation.createTag({}, args, context, {}).catch( (error) => { @@ -380,7 +380,7 @@ describe(`Mutations: `, () => { name: `TagWithNewName`, description: `Test Tag with different description`, value: 321, - scanClassId: ScanClass.instances[1].id + scanClassId: ScanClass.instances[1].id, } updatedTag = await resolvers.Mutation.updateTag( {}, @@ -395,7 +395,7 @@ describe(`Mutations: `, () => { test(`updateTag without args (other than id still completes successfully).`, async () => { prevCount = Tag.instances.length const args = { - id: tag.id + id: tag.id, } updatedTag = await resolvers.Mutation.updateTag( {}, @@ -414,7 +414,7 @@ describe(`Mutations: `, () => { name: `TagWithNewName`, description: `Test Tag with different description`, value: 321, - scanClassId: ScanClass.instances[1].id + scanClassId: ScanClass.instances[1].id, } expect( await resolvers.Mutation.updateTag({}, args, context, {}).catch( @@ -426,7 +426,7 @@ describe(`Mutations: `, () => { test(`deleteTag deletes a scan class.`, async () => { prevCount = Tag.instances.length const args = { - id: tag.id + id: tag.id, } const deletedTag = await resolvers.Mutation.deleteTag( {}, @@ -442,7 +442,7 @@ describe(`Mutations: `, () => { test(`deleteTag with invalid id throws an error.`, async () => { prevCount = Tag.instances.length const args = { - id: 1234567 + id: 1234567, } expect( await resolvers.Mutation.deleteTag({}, args, context, {}).catch( @@ -461,7 +461,7 @@ describe(`Mutations: `, () => { port: 502, reverseBits: true, reverseWords: true, - zeroBased: true + zeroBased: true, } device = await resolvers.Mutation.createModbus({}, args, context, {}) expect(Modbus.instances.length).toBe(prevCount + 1) @@ -483,7 +483,7 @@ describe(`Mutations: `, () => { port: 503, reverseBits: false, reverseWords: false, - zeroBased: false + zeroBased: false, } const updatedDevice = await resolvers.Mutation.updateModbus( {}, @@ -506,7 +506,7 @@ describe(`Mutations: `, () => { test(`updateModbus updates a modbus device with the selected settings.`, async () => { prevCount = Modbus.instances.length const args = { - id: device.id + id: device.id, } const updatedDevice = await resolvers.Mutation.updateModbus( {}, @@ -522,7 +522,7 @@ describe(`Mutations: `, () => { test(`updateModbus with invalid id throws error.`, async () => { prevCount = Modbus.instances.length const args = { - id: 1234567 + id: 1234567, } expect( await resolvers.Mutation.updateModbus({}, args, context, {}).catch( @@ -534,7 +534,7 @@ describe(`Mutations: `, () => { test(`deleteModbus deletes a modbus device with the selected settings.`, async () => { prevCount = Modbus.instances.length const args = { - id: device.id + id: device.id, } const deletedDevice = await resolvers.Mutation.deleteModbus( {}, @@ -550,7 +550,7 @@ describe(`Mutations: `, () => { test(`deleteModbus with invalid id throws error.`, async () => { prevCount = Modbus.instances.length const args = { - id: 1234567 + id: 1234567, } expect( await resolvers.Mutation.deleteModbus({}, args, context, {}).catch( @@ -565,7 +565,7 @@ describe(`Mutations: `, () => { deviceId: Modbus.instances[0].device.id, tagId: Tag.instances[0].id, register: 12345, - registerType: `BOOLEAN` + registerType: `BOOLEAN`, } modbusSource = await resolvers.Mutation.createModbusSource( {}, @@ -591,7 +591,7 @@ describe(`Mutations: `, () => { deviceId: Modbus.instances[0].device.id, tagId: 1234567, register: 12345, - registerType: `BOOLEAN` + registerType: `BOOLEAN`, } expect( await resolvers.Mutation.createModbusSource({}, args, context, {}).catch( @@ -604,7 +604,7 @@ describe(`Mutations: `, () => { deviceId: 1234567, tagId: Tag.instances[0].id, register: 12345, - registerType: `BOOLEAN` + registerType: `BOOLEAN`, } expect( await resolvers.Mutation.createModbusSource({}, args, context, {}).catch( @@ -628,7 +628,7 @@ describe(`Mutations: `, () => { deviceId: nonModbusDevice.id, tagId: Tag.instances[0].id, register: 12345, - registerType: `BOOLEAN` + registerType: `BOOLEAN`, } expect( await resolvers.Mutation.createModbusSource({}, args, context, {}).catch( @@ -653,7 +653,7 @@ describe(`Mutations: `, () => { const args = { tagId: Tag.instances[0].id, register: 45321, - registerType: `FLOAT` + registerType: `FLOAT`, } const updatedModbusSource = await resolvers.Mutation.updateModbusSource( {}, @@ -672,7 +672,7 @@ describe(`Mutations: `, () => { test(`updateModbusSource updates a modbus device with the selected settings.`, async () => { prevCount = ModbusSource.instances.length const args = { - tagId: Tag.instances[0].id + tagId: Tag.instances[0].id, } const updatedModbusSource = await resolvers.Mutation.updateModbusSource( {}, @@ -687,7 +687,7 @@ describe(`Mutations: `, () => { test(`updateModbusSource with invalid id throws error.`, async () => { prevCount = Modbus.instances.length const args = { - tagId: 1234567 + tagId: 1234567, } expect( await resolvers.Mutation.updateModbusSource({}, args, context, {}).catch( @@ -699,7 +699,7 @@ describe(`Mutations: `, () => { test(`deleteModbusSource deletes a modbus device with the selected settings.`, async () => { prevCount = ModbusSource.instances.length const args = { - tagId: Tag.instances[0].id + tagId: Tag.instances[0].id, } const deletedModbusSource = await resolvers.Mutation.deleteModbusSource( {}, @@ -715,7 +715,7 @@ describe(`Mutations: `, () => { test(`deleteModbusSource with invalid id throws error.`, async () => { prevCount = Modbus.instances.length const args = { - tagId: 1234567 + tagId: 1234567, } expect( await resolvers.Mutation.deleteModbusSource({}, args, context, {}).catch( @@ -730,7 +730,7 @@ describe(`Mutations: `, () => { name: `resolverTestEthernetIP`, description: `Resolver Test EthernetIP`, host: 'localhost', - slot: 0 + slot: 0, } device = await resolvers.Mutation.createEthernetIP( {}, @@ -753,7 +753,7 @@ describe(`Mutations: `, () => { name: `resolverTestEthernetIPUpdated`, description: `Resolver Test EthernetIP Updated`, host: '192.168.1.123', - slot: 3 + slot: 3, } const updatedDevice = await resolvers.Mutation.updateEthernetIP( {}, @@ -773,7 +773,7 @@ describe(`Mutations: `, () => { test(`updateEthernetIP without arguments is valid.`, async () => { prevCount = EthernetIP.instances.length const args = { - id: device.id + id: device.id, } const updatedDevice = await resolvers.Mutation.updateEthernetIP( {}, @@ -789,7 +789,7 @@ describe(`Mutations: `, () => { test(`updateEthernetIP with invalid id throws error.`, async () => { prevCount = EthernetIP.instances.length const args = { - id: 1234567 + id: 1234567, } expect( await resolvers.Mutation.updateEthernetIP({}, args, context, {}).catch( @@ -800,7 +800,7 @@ describe(`Mutations: `, () => { test(`deleteEthernetIP deletes a ethernetip device with the selected settings.`, async () => { prevCount = EthernetIP.instances.length const args = { - id: device.id + id: device.id, } const deletedDevice = await resolvers.Mutation.deleteEthernetIP( {}, @@ -816,7 +816,7 @@ describe(`Mutations: `, () => { test(`deleteEthernetIP with invalid id throws error.`, async () => { prevCount = EthernetIP.instances.length const args = { - id: 1234567 + id: 1234567, } expect( await resolvers.Mutation.deleteEthernetIP({}, args, context, {}).catch( @@ -830,7 +830,7 @@ describe(`Mutations: `, () => { const args = { deviceId: EthernetIP.instances[0].device.id, tagId: 1234567, - tagname: `Tagname` + tagname: `Tagname`, } expect( await resolvers.Mutation.createEthernetIPSource( @@ -847,7 +847,7 @@ describe(`Mutations: `, () => { const args = { deviceId: 1234567, tagId: Tag.instances[0].id, - tagname: `Tagname` + tagname: `Tagname`, } expect( await resolvers.Mutation.createEthernetIPSource( @@ -870,7 +870,7 @@ describe(`Mutations: `, () => { const args = { deviceId: nonEthernetIPDevice.id, tagId: Tag.instances[0].id, - tagname: `Tagname` + tagname: `Tagname`, } expect( await resolvers.Mutation.createEthernetIPSource( @@ -889,7 +889,7 @@ describe(`Mutations: `, () => { const args = { deviceId: EthernetIP.instances[0].device.id, tagId: Tag.instances[0].id, - tagname: `Tagname` + tagname: `Tagname`, } ethernetipSource = await resolvers.Mutation.createEthernetIPSource( {}, @@ -910,7 +910,7 @@ describe(`Mutations: `, () => { prevCount = EthernetIPSource.instances.length const args = { tagId: Tag.instances[0].id, - tagname: `aDifferentTagname` + tagname: `aDifferentTagname`, } const updatedEthernetIPSource = await resolvers.Mutation.updateEthernetIPSource( {}, @@ -930,7 +930,7 @@ describe(`Mutations: `, () => { test(`updateEthernetIPSource update without args still works.`, async () => { prevCount = EthernetIPSource.instances.length const args = { - tagId: Tag.instances[0].id + tagId: Tag.instances[0].id, } const updatedEthernetIPSource = await resolvers.Mutation.updateEthernetIPSource( {}, @@ -947,7 +947,7 @@ describe(`Mutations: `, () => { }) test(`updateEthernetIPSource with invalid id throws error.`, async () => { const args = { - id: 1234567 + id: 1234567, } expect( await resolvers.Mutation.updateEthernetIPSource( @@ -971,7 +971,7 @@ describe(`Mutations: `, () => { test(`deleteEthernetIP deletes a modbus device with the selected settings.`, async () => { prevCount = EthernetIP.instances.length const args = { - tagId: Tag.instances[0].id + tagId: Tag.instances[0].id, } const deletedEthernetIPSource = await resolvers.Mutation.deleteEthernetIPSource( {}, @@ -986,7 +986,7 @@ describe(`Mutations: `, () => { }) test(`deleteEthernetIPSource with invalid id throws error.`, async () => { const args = { - id: 1234567 + id: 1234567, } expect( await resolvers.Mutation.deleteEthernetIPSource( @@ -1010,7 +1010,7 @@ describe(`Mutations: `, () => { username: `mqttUser`, password: `mqttPassword`, devices: [Device.instances[0].id], - rate: 1000 + rate: 1000, } service = await resolvers.Mutation.createMqtt({}, args, context, {}).catch( (error) => { @@ -1028,7 +1028,7 @@ describe(`Mutations: `, () => { expect(service.config.password).toBe(args.password) expect(service.config.rate).toBe(args.rate) expect([service.config.sources[0].device]).toStrictEqual([ - Device.findById(args.devices[0]) + Device.findById(args.devices[0]), ]) }) test(`updateMqtt updates a mqtt service with the selected settings.`, async () => { @@ -1043,7 +1043,7 @@ describe(`Mutations: `, () => { node: `aDifferentNode`, username: `anotherMqttUser`, password: `anotherMqttPassword`, - rate: 1000 + rate: 1000, } const updatedService = await resolvers.Mutation.updateMqtt( {}, @@ -1067,7 +1067,7 @@ describe(`Mutations: `, () => { test(`updateMqtt without args still returns.`, async () => { prevCount = Mqtt.instances.length const args = { - id: service.id + id: service.id, } const updatedService = await resolvers.Mutation.updateMqtt( {}, @@ -1082,7 +1082,7 @@ describe(`Mutations: `, () => { test(`updateMqtt with invalid id throws an error.`, async () => { prevCount = Mqtt.instances.length const args = { - id: 1234567 + id: 1234567, } expect( await resolvers.Mutation.updateMqtt({}, args, context, {}).catch((e) => e) @@ -1093,7 +1093,7 @@ describe(`Mutations: `, () => { const prevLength = service.config.primaryHosts.length const args = { id: 1234567, - name: 'yetAnotherPrimaryHost' + name: 'yetAnotherPrimaryHost', } expect( await resolvers.Mutation.addMqttPrimaryHost({}, args, context, {}).catch( @@ -1109,7 +1109,7 @@ describe(`Mutations: `, () => { const prevLength = service.config.primaryHosts.length const args = { id: service.id, - name: 'yetAnotherPrimaryHost' + name: 'yetAnotherPrimaryHost', } await resolvers.Mutation.addMqttPrimaryHost({}, args, context, {}) expect(service.config.primaryHosts.length).toBe(prevLength + 1) @@ -1126,7 +1126,7 @@ describe(`Mutations: `, () => { ) const args = { id: nonMqttService.id, - name: 'yetAnotherPrimaryHost' + name: 'yetAnotherPrimaryHost', } expect( await resolvers.Mutation.addMqttPrimaryHost({}, args, context, {}).catch( @@ -1140,7 +1140,7 @@ describe(`Mutations: `, () => { const prevLength = service.config.primaryHosts.length const args = { id: 1234567, - name: 'yetAnotherPrimaryHost' + name: 'yetAnotherPrimaryHost', } expect( await resolvers.Mutation.deleteMqttPrimaryHost( @@ -1159,7 +1159,7 @@ describe(`Mutations: `, () => { const prevLength = service.config.primaryHosts.length const args = { id: service.id, - name: 'yetAnotherPrimaryHost' + name: 'yetAnotherPrimaryHost', } await resolvers.Mutation.deleteMqttPrimaryHost({}, args, context, {}) expect(service.config.primaryHosts.length).toBe(prevLength - 1) @@ -1176,7 +1176,7 @@ describe(`Mutations: `, () => { ) const args = { id: nonMqttService.id, - name: 'yetAnotherPrimaryHost' + name: 'yetAnotherPrimaryHost', } expect( await resolvers.Mutation.deleteMqttPrimaryHost( @@ -1211,7 +1211,7 @@ describe(`Mutations: `, () => { const prevLength = mqtt.service.config.sources.length const args = { id: 1234567, - deviceId: device.id + deviceId: device.id, } expect( await resolvers.Mutation.addMqttSource({}, args, context, {}).catch( @@ -1230,7 +1230,7 @@ describe(`Mutations: `, () => { const prevLength = mqtt.service.config.sources.length const args = { id: mqtt.service.id, - deviceId: device.id + deviceId: device.id, } await resolvers.Mutation.addMqttSource({}, args, context, {}) expect(mqtt.service.config.sources.length).toBe(prevLength + 1) @@ -1248,7 +1248,7 @@ describe(`Mutations: `, () => { ) const args = { id: nonMqttService.id, - deviceId: device.id + deviceId: device.id, } expect( await resolvers.Mutation.addMqttSource({}, args, context, {}).catch( @@ -1263,7 +1263,7 @@ describe(`Mutations: `, () => { const prevLength = service.config.sources.length const args = { id: 1234567, - deviceId: device.id + deviceId: device.id, } expect( await resolvers.Mutation.deleteMqttSource({}, args, context, {}).catch( @@ -1280,7 +1280,7 @@ describe(`Mutations: `, () => { const prevLength = mqtt.service.config.sources.length const args = { id: mqtt.service.id, - deviceId: device.id + deviceId: device.id, } await resolvers.Mutation.deleteMqttSource({}, args, context, {}) expect(mqtt.service.config.sources.length).toBe(prevLength - 1) @@ -1298,7 +1298,7 @@ describe(`Mutations: `, () => { ) const args = { id: nonMqttService.id, - deviceId: device.id + deviceId: device.id, } expect( await resolvers.Mutation.deleteMqttSource({}, args, context, {}).catch( @@ -1311,7 +1311,7 @@ describe(`Mutations: `, () => { test(`updateMqtt with invalid id throws an error.`, async () => { prevCount = Mqtt.instances.length const args = { - id: 1234567 + id: 1234567, } expect( await resolvers.Mutation.updateMqtt({}, args, context, {}).catch((e) => e) @@ -1321,7 +1321,7 @@ describe(`Mutations: `, () => { test(`deleteMqtt deletes a mqtt service with the selected settings.`, async () => { prevCount = Mqtt.instances.length const args = { - id: service.id + id: service.id, } const deletedService = await resolvers.Mutation.deleteMqtt( {}, @@ -1337,7 +1337,7 @@ describe(`Mutations: `, () => { test(`deleteMqtt with invalid id throws an error.`, async () => { prevCount = Mqtt.instances.length const args = { - id: 1234567 + id: 1234567, } expect( await resolvers.Mutation.deleteMqtt({}, args, context, {}).catch((e) => e) diff --git a/src/resolvers/index.js b/src/resolvers/index.js index c85945d..3848d3b 100644 --- a/src/resolvers/index.js +++ b/src/resolvers/index.js @@ -11,5 +11,5 @@ module.exports = { Subscription, Source, DeviceConfig, - MqttPrimaryHost + MqttPrimaryHost, } diff --git a/test/db.js b/test/db.js index c582f68..8478612 100644 --- a/test/db.js +++ b/test/db.js @@ -47,5 +47,5 @@ async function deleteTestDb(db) { module.exports = { createTestDb, - deleteTestDb + deleteTestDb, } diff --git a/test/graphql/index.js b/test/graphql/index.js index b77aa19..a662456 100644 --- a/test/graphql/index.js +++ b/test/graphql/index.js @@ -5,5 +5,5 @@ const mutation = require('./mutation') module.exports = { fragment, query, - mutation + mutation, } diff --git a/test/graphql/query.js b/test/graphql/query.js index 9a53f10..7e7b3e9 100644 --- a/test/graphql/query.js +++ b/test/graphql/query.js @@ -29,5 +29,5 @@ const services = ` module.exports = { tags, devices, - services + services, }