From 10a596db655dc27f4acfef203c38362fb779cc25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20S=C3=B3jko?= Date: Wed, 15 Mar 2023 11:20:24 +0100 Subject: [PATCH] fix(syncing-server): remove unused methods from auth http service --- .../Domain/Auth/AuthHttpServiceInterface.ts | 1 - .../CloudBackupRequestedEventHandler.spec.ts | 1 - .../src/Infra/HTTP/AuthHttpService.spec.ts | 36 ------------------- .../src/Infra/HTTP/AuthHttpService.ts | 19 ---------- 4 files changed, 57 deletions(-) diff --git a/packages/syncing-server/src/Domain/Auth/AuthHttpServiceInterface.ts b/packages/syncing-server/src/Domain/Auth/AuthHttpServiceInterface.ts index 4469f569b..2a3ebc8f2 100644 --- a/packages/syncing-server/src/Domain/Auth/AuthHttpServiceInterface.ts +++ b/packages/syncing-server/src/Domain/Auth/AuthHttpServiceInterface.ts @@ -2,5 +2,4 @@ import { KeyParamsData } from '@standardnotes/responses' export interface AuthHttpServiceInterface { getUserKeyParams(dto: { email?: string; uuid?: string; authenticated: boolean }): Promise - getUserSetting(userUuid: string, settingName: string): Promise<{ uuid: string; value: string | null }> } diff --git a/packages/syncing-server/src/Domain/Handler/CloudBackupRequestedEventHandler.spec.ts b/packages/syncing-server/src/Domain/Handler/CloudBackupRequestedEventHandler.spec.ts index 6df564c37..1f630be78 100644 --- a/packages/syncing-server/src/Domain/Handler/CloudBackupRequestedEventHandler.spec.ts +++ b/packages/syncing-server/src/Domain/Handler/CloudBackupRequestedEventHandler.spec.ts @@ -37,7 +37,6 @@ describe('CloudBackupRequestedEventHandler', () => { authHttpService = {} as jest.Mocked authHttpService.getUserKeyParams = jest.fn().mockReturnValue({ foo: 'bar' }) - // authHttpService.getUserSetting = jest.fn().mockReturnValue extensionsHttpService = {} as jest.Mocked extensionsHttpService.triggerCloudBackupOnExtensionsServer = jest.fn() diff --git a/packages/syncing-server/src/Infra/HTTP/AuthHttpService.spec.ts b/packages/syncing-server/src/Infra/HTTP/AuthHttpService.spec.ts index 55ce6a7f1..1b40f7cf1 100644 --- a/packages/syncing-server/src/Infra/HTTP/AuthHttpService.spec.ts +++ b/packages/syncing-server/src/Infra/HTTP/AuthHttpService.spec.ts @@ -3,7 +3,6 @@ import 'reflect-metadata' import { AxiosInstance } from 'axios' import { AuthHttpService } from './AuthHttpService' -import { SettingName } from '@standardnotes/settings' describe('AuthHttpService', () => { let httpClient: AxiosInstance @@ -36,39 +35,4 @@ describe('AuthHttpService', () => { validateStatus: expect.any(Function), }) }) - - it('should send a request to auth service in order to get user setting', async () => { - httpClient.request = jest.fn().mockReturnValue({ - data: { - setting: [ - { - uuid: '1-2-3', - value: 'yes', - }, - ], - }, - }) - - await createService().getUserSetting('1-2-3', SettingName.NAMES.MuteFailedBackupsEmails) - - expect(httpClient.request).toHaveBeenCalledWith({ - method: 'GET', - headers: { - Accept: 'application/json', - }, - url: 'https://auth-server/internal/users/1-2-3/settings/MUTE_FAILED_BACKUPS_EMAILS', - validateStatus: expect.any(Function), - }) - }) - - it('should throw an error if a request to auth service in order to get user setting fails', async () => { - let error = null - try { - await createService().getUserSetting('1-2-3', SettingName.NAMES.MuteFailedCloudBackupsEmails) - } catch (caughtError) { - error = caughtError - } - - expect(error).not.toBeNull() - }) }) diff --git a/packages/syncing-server/src/Infra/HTTP/AuthHttpService.ts b/packages/syncing-server/src/Infra/HTTP/AuthHttpService.ts index bcb3fc3ae..1e2d35d36 100644 --- a/packages/syncing-server/src/Infra/HTTP/AuthHttpService.ts +++ b/packages/syncing-server/src/Infra/HTTP/AuthHttpService.ts @@ -6,25 +6,6 @@ import { AuthHttpServiceInterface } from '../../Domain/Auth/AuthHttpServiceInter export class AuthHttpService implements AuthHttpServiceInterface { constructor(private httpClient: AxiosInstance, private authServerUrl: string) {} - async getUserSetting(userUuid: string, settingName: string): Promise<{ uuid: string; value: string | null }> { - const response = await this.httpClient.request({ - method: 'GET', - headers: { - Accept: 'application/json', - }, - url: `${this.authServerUrl}/internal/users/${userUuid}/settings/${settingName}`, - validateStatus: - /* istanbul ignore next */ - (status: number) => status >= 200 && status < 500, - }) - - if (!response.data.setting) { - throw new Error('Missing user setting from auth service response') - } - - return response.data.setting - } - async getUserKeyParams(dto: { email?: string; uuid?: string; authenticated: boolean }): Promise { const keyParamsResponse = await this.httpClient.request({ method: 'GET',