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

This commit is contained in:
Karol Sójko 2023-03-15 11:20:24 +01:00
parent c76302cf98
commit 10a596db65
No known key found for this signature in database
GPG key ID: 50D9C5A8D4B8D73F
4 changed files with 0 additions and 57 deletions

View file

@ -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 }>
}

View file

@ -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()

View file

@ -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()
})
})

View file

@ -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',