From 26f45b4a76ea345a96f07cc3f8ac06397921e93e Mon Sep 17 00:00:00 2001 From: Mario Reder Date: Wed, 13 Feb 2019 08:09:08 +0100 Subject: [PATCH 1/3] fix: warn user if api key is wrong --- .travis.yml | 2 +- package.json | 2 +- src/WebHook.spec.ts | 2 +- src/WebHook.ts | 5 +++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3389f9b..e7c341b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ node_js: env: global: - CXX=g++-4.8 - - PACKAGE_VERSION="2.2.1" + - PACKAGE_VERSION="2.2.2" addons: apt: diff --git a/package.json b/package.json index 5c0a876..ad6c7d2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "net64plus-server", - "version": "2.2.1", + "version": "2.2.2", "compatVersion": "1.0", "description": "Net64+ Dedicated Server", "main": "dist/index.js", diff --git a/src/WebHook.spec.ts b/src/WebHook.spec.ts index ddf6ad9..8d6719e 100644 --- a/src/WebHook.spec.ts +++ b/src/WebHook.spec.ts @@ -69,6 +69,6 @@ describe('WebHook', () => { }) await new Promise((resolve) => setTimeout(resolve(), 0)) - expect(console.error).toHaveBeenCalledWith('Your API key seems to be wrong. Please check your settings!\nWebHook was disabled now') + expect(console.error).toHaveBeenCalledWith('Your API key seems to be wrong. Please check your settings!\nYour server won\'t be publicly visible') }) }) diff --git a/src/WebHook.ts b/src/WebHook.ts index 27c7d90..b32dd59 100644 --- a/src/WebHook.ts +++ b/src/WebHook.ts @@ -83,8 +83,9 @@ export class WebHook { )).data this.id = res.id } catch (err) { - if (err.response && err.response.status === 401) { - console.error('Your API key seems to be wrong. Please check your settings!\nWebHook was disabled now') + if (err.response && err.response.status === 400) { + console.warn('WARNING: Your API key seems to be wrong. Please check your settings!\nYour server won\'t be publicly visible') + return } else { // fail silently. Server might be unreachable } From 8ab6efc13b8cc4182367103efd39634908a5e96a Mon Sep 17 00:00:00 2001 From: Mario Reder Date: Wed, 13 Feb 2019 08:10:11 +0100 Subject: [PATCH 2/3] build: update changelog --- changelog/2.2.2.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 changelog/2.2.2.md diff --git a/changelog/2.2.2.md b/changelog/2.2.2.md new file mode 100644 index 0000000..8f6a2ba --- /dev/null +++ b/changelog/2.2.2.md @@ -0,0 +1,6 @@ +## [2.2.2](https://github.com/Tarnadas/net64plus-server/compare/2.1.2...2.2.2) (2019-02-13) + + +### Bug Fixes + +* warn user if api key is wrong ([26f45b4](https://github.com/Tarnadas/net64plus-server/commit/26f45b4)) From c840438f251f1b5f869276086fa70f4900de66a1 Mon Sep 17 00:00:00 2001 From: Mario Reder Date: Wed, 13 Feb 2019 08:12:36 +0100 Subject: [PATCH 3/3] test: fix webhook test --- src/WebHook.spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/WebHook.spec.ts b/src/WebHook.spec.ts index 8d6719e..3f3c80b 100644 --- a/src/WebHook.spec.ts +++ b/src/WebHook.spec.ts @@ -2,7 +2,7 @@ import { WebHook, URL_API } from './WebHook' import mockAxios from 'jest-mock-axios' beforeEach(() => { - console.error = jest.fn() + console.warn = jest.fn() }) afterEach(() => { @@ -64,11 +64,11 @@ describe('WebHook', () => { it('should display error message on wrong apiKey', async () => { mockAxios.mockError({ response: { - status: 401 + status: 400 } }) await new Promise((resolve) => setTimeout(resolve(), 0)) - expect(console.error).toHaveBeenCalledWith('Your API key seems to be wrong. Please check your settings!\nYour server won\'t be publicly visible') + expect(console.warn).toHaveBeenCalledWith('WARNING: Your API key seems to be wrong. Please check your settings!\nYour server won\'t be publicly visible') }) })