Replaced 550 Http Error codes by 401
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"547": {
"$ref": "#/components/responses/SiteAreaTreeChildrenMaxPower"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"543": {
"$ref": "#/components/responses/SiteAreaHierarchyDependencyError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"520": {
"description": "The End-user License Agreement is mandatory"
},
- "550": {
+ "404": {
"description": "Unknown tenant, user does not exists, or credentials are invalid"
},
"590": {
"520": {
"description": "End-user License Agreement has not been accepted"
},
- "550": {
+ "404": {
"description": "User tried to register with an unknown tenant"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"description": "Unknown tenant or user does not exist"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"description": "Unknown tenant"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"description": "Unknown tenant"
}
}
"540": {
"description": "Invalid verification token"
},
- "550": {
+ "404": {
"description": "Unknown tenant or user does not exist"
},
"591": {
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"description": "Unknown tenant or user does not exist"
},
"591": {
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"description": "Charging Station does not exist"
},
"570": {
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"510": {
"$ref": "#/components/responses/EmailAlreadyUsed"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"510": {
"description": "User cannot be deleted due to billing constraints"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"description": "User does not exist"
},
"576": {
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
},
"575": {
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
},
"576": {
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
},
"585": {
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"description": "Asset does not exist"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
"500": {
"$ref": "#/components/responses/BackendError"
},
- "550": {
+ "404": {
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}

MODIFY
src/server/rest/v1/service/AuthService.ts
src/server/rest/v1/service/AuthService.ts
@@ -63,7 +63,7 @@ export default class AuthService {
const tenant = await AuthService.getTenant(filteredRequest.tenant);
if (!tenant) {
throw new AppError({
- errorCode: HTTPError.OBJECT_DOES_NOT_EXIST_ERROR,
+ errorCode: StatusCodes.NOT_FOUND,
message: `User with Email '${filteredRequest.email}' tried to log in with an unknown tenant '${filteredRequest.tenant}'!`,
module: MODULE_NAME,
method: 'handleLogIn',
@@ -130,7 +130,7 @@ export default class AuthService {
const tenant = await AuthService.getTenant(filteredRequest.tenant);
if (!tenant.id) {
throw new AppError({
- errorCode: HTTPError.OBJECT_DOES_NOT_EXIST_ERROR,
+ errorCode: StatusCodes.NOT_FOUND,
message: `User is trying to register with an unknown tenant '${filteredRequest.tenant}'!`,
module: MODULE_NAME,
method: 'handleRegisterUser'
@@ -319,7 +319,7 @@ export default class AuthService {
const tenant = await AuthService.getTenant(filteredRequest.tenant);
if (!tenant) {
throw new AppError({
- errorCode: HTTPError.OBJECT_DOES_NOT_EXIST_ERROR,
+ errorCode: StatusCodes.NOT_FOUND,
message: `User is trying to access resource with an unknown tenant '${filteredRequest.tenant}'!`,
module: MODULE_NAME,
method: 'handleUserPasswordReset',
@@ -386,7 +386,7 @@ export default class AuthService {
const tenant = await AuthService.getTenant(filteredRequest.Tenant);
if (!tenant) {
throw new AppError({
- errorCode: HTTPError.OBJECT_DOES_NOT_EXIST_ERROR,
+ errorCode: StatusCodes.NOT_FOUND,
action: action,
module: MODULE_NAME,
method: 'handleVerifyEmail',
@@ -404,7 +404,7 @@ export default class AuthService {
}
if (!tenant) {
throw new AppError({
- errorCode: HTTPError.OBJECT_DOES_NOT_EXIST_ERROR,
+ errorCode: StatusCodes.NOT_FOUND,
action: action,
module: MODULE_NAME,
method: 'handleVerifyEmail',
@@ -503,7 +503,7 @@ export default class AuthService {
const tenant = await AuthService.getTenant(filteredRequest.tenant);
if (!tenant) {
throw new AppError({
- errorCode: HTTPError.OBJECT_DOES_NOT_EXIST_ERROR,
+ errorCode: StatusCodes.NOT_FOUND,
message: `User is trying to access resource with an unknown tenant '${filteredRequest.tenant}'!`,
module: MODULE_NAME,
method: 'handleResendVerificationEmail',
@@ -613,7 +613,7 @@ export default class AuthService {
// Save User Nbr Password Trials
await UserStorage.saveUserPassword(tenant, user.id, { passwordWrongNbrTrials });
throw new AppError({
- errorCode: HTTPError.OBJECT_DOES_NOT_EXIST_ERROR,
+ errorCode: StatusCodes.NOT_FOUND,
message: `User failed to log in, ${centralSystemRestConfig.passwordWrongNumberOfTrial - user.passwordWrongNbrTrials} trial(s) remaining`,
module: MODULE_NAME,
method: 'checkUserLogin',
@@ -693,7 +693,7 @@ export default class AuthService {
// User Found?
if (!user) {
throw new AppError({
- errorCode: HTTPError.OBJECT_DOES_NOT_EXIST_ERROR,
+ errorCode: StatusCodes.NOT_FOUND,
message: `Unknown user tried to log in with email '${filteredRequest.email}'`,
module: MODULE_NAME,
method: 'checkUserLogin',

MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -757,7 +757,7 @@ export default class ChargingStationService {
if (chargingStation.deleted) {
throw new AppError({
action,
- errorCode: HTTPError.OBJECT_DOES_NOT_EXIST_ERROR,
+ errorCode: StatusCodes.NOT_FOUND,
message: `Charging Station with ID '${chargingStationID}' is already deleted`,
module: MODULE_NAME,
method: 'handleDeleteChargingStation',

MODIFY
src/server/rest/v1/service/TenantService.ts
src/server/rest/v1/service/TenantService.ts
@@ -52,7 +52,7 @@ export default class TenantService {
// Check if current tenant
if (tenant.id === req.tenant.id) {
throw new AppError({
- errorCode: HTTPError.OBJECT_DOES_NOT_EXIST_ERROR,
+ errorCode: StatusCodes.NOT_FOUND,
message: `Your own tenant with id '${tenant.id}' cannot be deleted`,
module: MODULE_NAME, method: 'handleDeleteTenant',
user: req.user,

MODIFY
src/server/rest/v1/service/UtilsService.ts
src/server/rest/v1/service/UtilsService.ts
@@ -41,6 +41,7 @@ import Site from '../../../../types/Site';
import SiteArea from '../../../../types/SiteArea';
import SiteAreaStorage from '../../../../storage/mongodb/SiteAreaStorage';
import SiteStorage from '../../../../storage/mongodb/SiteStorage';
+import { StatusCodes } from 'http-status-codes';
import Tag from '../../../../types/Tag';
import TagStorage from '../../../../storage/mongodb/TagStorage';
import { TransactionInErrorType } from '../../../../types/InError';
@@ -137,7 +138,7 @@ export default class UtilsService {
if (chargingStation?.deleted) {
throw new AppError({
...LoggingHelper.getChargingStationProperties(chargingStation),
- errorCode: HTTPError.OBJECT_DOES_NOT_EXIST_ERROR,
+ errorCode: StatusCodes.NOT_FOUND,
message: `ChargingStation with ID '${chargingStation.id}' is logically deleted`,
module: MODULE_NAME,
method: 'checkAndGetChargingStationAuthorization',
@@ -861,7 +862,7 @@ export default class UtilsService {
if (!object) {
throw new AppError({
action,
- errorCode: HTTPError.OBJECT_DOES_NOT_EXIST_ERROR,
+ errorCode: StatusCodes.NOT_FOUND,
message: errorMsg,
module: module,
method: method,

MODIFY
src/types/HTTPError.ts
src/types/HTTPError.ts
@@ -4,7 +4,6 @@ export enum HTTPError {
GENERAL_ERROR = StatusCodes.INTERNAL_SERVER_ERROR,
NOT_IMPLEMENTED_ERROR = StatusCodes.NOT_IMPLEMENTED,
MISSING_SETTINGS = 505,
- OBJECT_DOES_NOT_EXIST_ERROR = 550,
FEATURE_NOT_SUPPORTED_ERROR = 585,
REFUND_SESSION_OTHER_USER_ERROR = 551,

MODIFY
test/api/AuthenticationTest.ts
test/api/AuthenticationTest.ts
@@ -260,7 +260,7 @@ describe('Authentication Service (utall)', () => {
async () => {
// Call
const response = await CentralServerService.defaultInstance.authenticationApi.login(testData.adminEmail, 'A_M4tch1ng_P4ssw0rd', true);
- expect(response.status).to.be.eql(HTTPError.OBJECT_DOES_NOT_EXIST_ERROR);
+ expect(response.status).to.be.eql(StatusCodes.NOT_FOUND);
expect(response.data).to.not.have.property('token');
}
);
@@ -300,19 +300,19 @@ describe('Authentication Service (utall)', () => {
it('Should not allow authentication of unknown email', async () => {
// Call
const response = await CentralServerService.defaultInstance.authenticationApi.login('unknown@sap.com', testData.adminPassword, true);
- expect(response.status).to.be.eql(HTTPError.OBJECT_DOES_NOT_EXIST_ERROR);
+ expect(response.status).to.be.eql(StatusCodes.NOT_FOUND);
expect(response.data).to.not.have.property('token');
});
it('should not allow authentication without tenant', async () => {
const response = await CentralServerService.defaultInstance.authenticationApi.login('unknown@sap.com', testData.adminPassword, true, null);
- expect(response.status).to.be.eql(HTTPError.OBJECT_DOES_NOT_EXIST_ERROR);
+ expect(response.status).to.be.eql(StatusCodes.NOT_FOUND);
expect(response.data).to.not.have.property('token');
});
it('should not allow authentication of unknown tenant', async () => {
const response = await CentralServerService.defaultInstance.authenticationApi.login('unknown@sap.com', testData.adminPassword, true, 'unknown');
- expect(response.status).to.be.eql(HTTPError.OBJECT_DOES_NOT_EXIST_ERROR);
+ expect(response.status).to.be.eql(StatusCodes.NOT_FOUND);
expect(response.data).to.not.have.property('token');
});

MODIFY
test/api/CarTest.ts
test/api/CarTest.ts
@@ -296,7 +296,7 @@ describe('Car', () => {
testData.createdCars[1],
false
);
- expect(response.status).to.equal(HTTPError.OBJECT_DOES_NOT_EXIST_ERROR);
+ expect(response.status).to.equal(StatusCodes.NOT_FOUND);
});
it('Should not be able to update a car to a pool car', async () => {

MODIFY
test/api/SiteAreaOrgTest.ts
test/api/SiteAreaOrgTest.ts
@@ -493,7 +493,7 @@ describe('Site Area', () => {
testData.userService.siteAreaApi,
testData.siteAreaWithoutSiteAdmin, false
);
- expect(response.status).to.equal(HTTPError.OBJECT_DOES_NOT_EXIST_ERROR);
+ expect(response.status).to.equal(StatusCodes.NOT_FOUND);
});
it(
@@ -565,7 +565,7 @@ describe('Site Area', () => {
expect(chargingStations.status).to.equal(StatusCodes.OK);
const response = await testData.userService.siteAreaApi.removeChargingStations(
testData.siteAreaWithoutSiteAdmin.id, [chargingStations.data.result[0].id]);
- expect(response.status).to.equal(HTTPError.OBJECT_DOES_NOT_EXIST_ERROR);
+ expect(response.status).to.equal(StatusCodes.NOT_FOUND);
}
);
@@ -578,7 +578,7 @@ describe('Site Area', () => {
it('Should not be able to remove Assets from SiteArea', async () => {
const response = await testData.userService.siteAreaApi.removeAssets(
testData.siteAreaWithoutSiteAdmin.id, [testData.testAsset.id]);
- expect(response.status).to.equal(HTTPError.OBJECT_DOES_NOT_EXIST_ERROR);
+ expect(response.status).to.equal(StatusCodes.NOT_FOUND);
});
it(
@@ -609,7 +609,7 @@ describe('Site Area', () => {
testData.siteAreaWithoutSiteAdmin,
false
);
- expect(response.status).to.equal(HTTPError.OBJECT_DOES_NOT_EXIST_ERROR);
+ expect(response.status).to.equal(StatusCodes.NOT_FOUND);
});
it(
@@ -691,7 +691,7 @@ describe('Site Area', () => {
testData.userService.siteAreaApi,
testData.newSubSubSiteArea, false
);
- expect(response.status).to.equal(HTTPError.OBJECT_DOES_NOT_EXIST_ERROR);
+ expect(response.status).to.equal(StatusCodes.NOT_FOUND);
const newSubSubSiteAreaResponse = testData.newSubSubSiteArea = await testData.userService.getEntityById(
testData.userService.siteAreaApi,
testData.newSubSubSiteArea, false

MODIFY
test/api/TagTest.ts
test/api/TagTest.ts
@@ -198,7 +198,7 @@ describe('Tag', () => {
response = await testData.userService.tagApi.deleteTag(testData.newTag.id);
expect(response.status).to.equal(StatusCodes.OK);
response = (await testData.userService.tagApi.readTag(testData.newTag.id));
- expect(response.status).to.equal(HTTPError.OBJECT_DOES_NOT_EXIST_ERROR);
+ expect(response.status).to.equal(StatusCodes.NOT_FOUND);
});
it('Should be able to export tag list', async () => {
@@ -303,7 +303,7 @@ describe('Tag', () => {
let response = await testData.userService.tagApi.unassignTag(testData.newTagUnassigned);
expect(response.status).to.equal(StatusCodes.OK);
response = await testData.userService.tagApi.readTagByVisualID(testData.newTagUnassigned.visualID);
- expect(response.status).to.equal(HTTPError.OBJECT_DOES_NOT_EXIST_ERROR);
+ expect(response.status).to.equal(StatusCodes.NOT_FOUND);
});
});
@@ -346,7 +346,7 @@ describe('Tag', () => {
'Should be not be able to read badge of user not assigned to his site',
async () => {
const response = await testData.userService.tagApi.readTag(testData.newTag.id);
- expect(response.status).to.equal(HTTPError.OBJECT_DOES_NOT_EXIST_ERROR);
+ expect(response.status).to.equal(StatusCodes.NOT_FOUND);
}
);

MODIFY
test/api/TenantTest.ts
test/api/TenantTest.ts
@@ -159,7 +159,7 @@ describe('Tenant', () => {
// Exec
const response = await CentralServerService.defaultInstance.getEntityById(
CentralServerService.defaultInstance.tenantApi, { id: '123456789012345678901234' }, false);
- expect(response.status).to.equal(HTTPError.OBJECT_DOES_NOT_EXIST_ERROR);
+ expect(response.status).to.equal(StatusCodes.NOT_FOUND);
});
it('Should not be possible to create a tenant without email', async () => {

MODIFY
test/api/TransactionCommonTests.ts
test/api/TransactionCommonTests.ts
@@ -67,7 +67,7 @@ export default class TransactionCommonTests {
public async testReadNonExistingTransaction() {
const response = await this.transactionUserService.transactionApi.readById(faker.datatype.number(100000));
- expect(response.status).to.equal(HTTPError.OBJECT_DOES_NOT_EXIST_ERROR);
+ expect(response.status).to.equal(StatusCodes.NOT_FOUND);
}
public async testReadTransactionWithInvalidId() {
@@ -1047,7 +1047,7 @@ export default class TransactionCommonTests {
}
const transactionResponse = await this.transactionUserService.transactionApi.readById(transactionId);
if (allowed) {
- expect(transactionResponse.status).to.equal(HTTPError.OBJECT_DOES_NOT_EXIST_ERROR);
+ expect(transactionResponse.status).to.equal(StatusCodes.NOT_FOUND);
} else {
expect(transactionResponse.status).to.equal(StatusCodes.OK);
}
@@ -1074,7 +1074,7 @@ export default class TransactionCommonTests {
}
const transactionResponse = await this.transactionUserService.transactionApi.readById(transactionId);
if (allowed) {
- expect(transactionResponse.status).to.equal(HTTPError.OBJECT_DOES_NOT_EXIST_ERROR);
+ expect(transactionResponse.status).to.equal(StatusCodes.NOT_FOUND);
} else {
expect(transactionResponse.status).to.equal(StatusCodes.OK);
}
@@ -1110,7 +1110,7 @@ export default class TransactionCommonTests {
}
const transactionResponse = await this.transactionUserService.transactionApi.readById(transactionId);
if (allowed) {
- expect(transactionResponse.status).to.equal(HTTPError.OBJECT_DOES_NOT_EXIST_ERROR);
+ expect(transactionResponse.status).to.equal(StatusCodes.NOT_FOUND);
} else {
expect(transactionResponse.status).to.equal(StatusCodes.OK);
}
@@ -1138,9 +1138,9 @@ export default class TransactionCommonTests {
expect(transactionsDeleted.data.inSuccess).to.equal(2);
expect(transactionsDeleted.data.inError).to.equal(0);
let transactionResponse = await this.transactionUserService.transactionApi.readById(transactionId);
- expect(transactionResponse.status).to.equal(HTTPError.OBJECT_DOES_NOT_EXIST_ERROR);
+ expect(transactionResponse.status).to.equal(StatusCodes.NOT_FOUND);
transactionResponse = await this.transactionUserService.transactionApi.readById(secondTransactionId);
- expect(transactionResponse.status).to.equal(HTTPError.OBJECT_DOES_NOT_EXIST_ERROR);
+ expect(transactionResponse.status).to.equal(StatusCodes.NOT_FOUND);
}

MODIFY
test/api/client/CentralServerService.ts
test/api/client/CentralServerService.ts
@@ -239,7 +239,7 @@ export default class CentralServerService {
const response = await entityApi.readById(entity.id);
if (performCheck) {
// Check if not found
- expect(response.status).to.equal(HTTPError.OBJECT_DOES_NOT_EXIST_ERROR);
+ expect(response.status).to.equal(StatusCodes.NOT_FOUND);
} else {
// Let the caller to handle response
return response;

Replaced 550 Http Error codes by 401