瀏覽代碼

fix(syncing-server): remove unused methods from auth http service

Karol Sójko 2 年之前
父節點
當前提交
10a596db65

+ 0 - 1
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<KeyParamsData>
-  getUserSetting(userUuid: string, settingName: string): Promise<{ uuid: string; value: string | null }>
 }

+ 0 - 1
packages/syncing-server/src/Domain/Handler/CloudBackupRequestedEventHandler.spec.ts

@@ -37,7 +37,6 @@ describe('CloudBackupRequestedEventHandler', () => {
 
     authHttpService = {} as jest.Mocked<AuthHttpServiceInterface>
     authHttpService.getUserKeyParams = jest.fn().mockReturnValue({ foo: 'bar' })
-    // authHttpService.getUserSetting = jest.fn().mockReturnValue
 
     extensionsHttpService = {} as jest.Mocked<ExtensionsHttpServiceInterface>
     extensionsHttpService.triggerCloudBackupOnExtensionsServer = jest.fn()

+ 0 - 36
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()
-  })
 })

+ 0 - 19
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<KeyParamsData> {
     const keyParamsResponse = await this.httpClient.request({
       method: 'GET',