Skip to content

Commit

Permalink
feat: allow requests with no appVersion header (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
rosvik authored Nov 19, 2024
1 parent 7270cc5 commit 9934015
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/plugins/__tests__/app-version-checker-plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ describe('appVersionCheckerPlugin', () => {
expect(response.statusCode).toBe(200);
});

it('should reject requests if no client app version and no webshop version', async () => {
it('should allow requests if no client app version and no webshop version', async () => {
process.env.MIN_APP_VERSION = '2.25';

let response = await doRequest({});
expect(response.statusCode).toBe(406);
expect(response.statusCode).toBe(200);
});

it('should allow requests if no min app version', async () => {
Expand All @@ -105,10 +105,10 @@ describe('appVersionCheckerPlugin', () => {
expect(response.statusCode).toBe(200);
});

it('should not reject on health endpoint even if no client app version and no webshop version', async () => {
it('should not reject on health endpoint even if app version is below min app version', async () => {
process.env.MIN_APP_VERSION = '2.25';

let response = await doRequest({url: '/health'});
let response = await doRequest({url: '/health', appVersion: '1.1'});
expect(response.statusCode).toBe(200);
});
});
2 changes: 1 addition & 1 deletion src/plugins/app-version-checker-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const isAppVersionTooLow = (
const isRequestFromWebshop = !!request.webshopVersion;
if (isRequestFromWebshop) return false;
if (!minAppVersion) return false;
if (!request.appVersion) return true;
if (!request.appVersion) return false;
return compareVersion(minAppVersion, request.appVersion) > 0;
};

Expand Down

0 comments on commit 9934015

Please sign in to comment.