billing settings - status code changed + fix test import
MODIFY
src/server/rest/v1/service/BillingService.ts
src/server/rest/v1/service/BillingService.ts
@@ -6,14 +6,12 @@ import { NextFunction, Request, Response } from 'express';
import AppAuthError from '../../../../exception/AppAuthError';
import AppError from '../../../../exception/AppError';
import Authorizations from '../../../../authorization/Authorizations';
-import BackendError from '../../../../exception/BackendError';
import BillingFactory from '../../../../integration/billing/BillingFactory';
import BillingSecurity from './security/BillingSecurity';
import { BillingSettings } from '../../../../types/Setting';
import BillingStorage from '../../../../storage/mongodb/BillingStorage';
import BillingValidator from '../validator/BillingValidator';
import Constants from '../../../../utils/Constants';
-import Cypher from '../../../../utils/Cypher';
import { DataResult } from '../../../../types/DataResult';
import LockingHelper from '../../../../locking/LockingHelper';
import LockingManager from '../../../../locking/LockingManager';
@@ -804,7 +802,7 @@ export default class BillingService {
// Attempt to switch it OFF
throw new AppError({
source: Constants.CENTRAL_SERVER,
- errorCode: HTTPError.MISSING_SETTINGS,
+ errorCode: StatusCodes.METHOD_NOT_ALLOWED,
message: 'Switching OFF the billing of transactions is forbidden',
module: MODULE_NAME,
method: 'handleUpdateBillingSetting'

MODIFY
test/api/BillingTest.ts
test/api/BillingTest.ts
@@ -343,7 +343,7 @@ describe('Billing Settings', function() {
// Let's attempt to switch the transaction billing OFF
billingSettings.billing.isTransactionBillingActivated = false;
response = await testData.userService.billingApi.updateBillingSetting(billingSettings);
- assert(response.status === HTTPError.MISSING_SETTINGS, 'Response status should be 505');
+ assert(response.status === StatusCodes.METHOD_NOT_ALLOWED, 'Response status should be 405');
// Check again the billing connection to STRIPE
response = await testData.userService.billingApi.checkBillingConnection();
assert(response.status === StatusCodes.OK, 'Response status should be 200');

MODIFY
test/api/context/BillingContext.ts
test/api/context/BillingContext.ts
@@ -2,11 +2,10 @@ import { BillingSettings, BillingSettingsType } from '../../../src/types/Setting
import BackendError from '../../../src/exception/BackendError';
import BillingFactory from '../../../src/integration/billing/BillingFactory';
-import BillingStorage from '../../../src/storage/mongodb/BillingStorage';
import Constants from '../../../src/utils/Constants';
import ContextDefinition from './ContextDefinition';
import Cypher from '../../../src/utils/Cypher';
-import SettingStorage from '../../storage/mongodb/SettingStorage';
+import SettingStorage from '../../../src/storage/mongodb/SettingStorage';
import TenantComponents from '../../../src/types/TenantComponents';
import TenantContext from './TenantContext';
import User from '../../../src/types/User';

billing settings - status code changed + fix test import