Used unauth 401 standard HTTP code
MODIFY
src/types/HTTPError.ts
src/types/HTTPError.ts
@@ -59,5 +59,5 @@ export enum HTTPError {
}
export enum HTTPAuthError {
- ERROR = 560,
+ ERROR = StatusCodes.UNAUTHORIZED,
}

MODIFY
test/api/CarTest.ts
test/api/CarTest.ts
@@ -53,27 +53,27 @@ describe('Car Tests', function() {
});
it('Should not be able to get car catalogs', async () => {
const response = await testData.centralService.carApi.readCarCatalogs({});
- expect(response.status).to.equal(560);
+ expect(response.status).to.equal(401);
});
it('Should not be able to get car catalog by ID', async () => {
const response = await testData.centralService.carApi.readCarCatalog(null);
- expect(response.status).to.equal(560);
+ expect(response.status).to.equal(401);
});
it('Should not be able to get image of a car', async () => {
const response = await testData.centralService.carApi.readCarImages(null);
- expect(response.status).to.equal(560);
+ expect(response.status).to.equal(401);
});
it('Should not be able to get car makers', async () => {
const response = await testData.centralService.carApi.readCarMakers({});
- expect(response.status).to.equal(560);
+ expect(response.status).to.equal(401);
});
it('Should not be able to get a detailed car catalog', async () => {
const response = await testData.centralService.carApi.readCarCatalog(null);
- expect(response.status).to.equal(560);
+ expect(response.status).to.equal(401);
});
});
});
@@ -371,12 +371,12 @@ describe('Car Tests', function() {
it('Should not be able to get cars from super tenant', async () => {
const response = await testData.centralService.carApiSuperTenant.readCars({});
- expect(response.status).to.equal(560);
+ expect(response.status).to.equal(401);
});
it('Should not be able to get car from super tenant', async () => {
const response = await testData.centralService.carApiSuperTenant.readCar({});
- expect(response.status).to.equal(560);
+ expect(response.status).to.equal(401);
});
it('Should not be able to create a car from super tenant', async () => {
@@ -386,7 +386,7 @@ describe('Car Tests', function() {
Factory.car.build(),
false
);
- expect(response.status).to.equal(560);
+ expect(response.status).to.equal(401);
});
});
});

MODIFY
test/api/OCPPCommonTests.ts
test/api/OCPPCommonTests.ts
@@ -710,7 +710,7 @@ export default class OCPPCommonTests {
expect(this.newTransaction).to.not.be.null;
let response = await this.transactionStartUserService.transactionApi.delete(this.newTransaction.id);
if (noAuthorization) {
- expect(response.status).to.equal(560);
+ expect(response.status).to.equal(401);
// Transaction must be deleted by Admin user
response = await this.centralUserService.transactionApi.delete(this.newTransaction.id);
}

MODIFY
test/api/SiteAreaOrgTest.ts
test/api/SiteAreaOrgTest.ts
@@ -207,7 +207,7 @@ describe('Site Area tests', function() {
testData.userService.siteAreaApi,
Factory.siteArea.build({ siteID: testData.siteContext.getSite().id }), false
);
- expect(response.status).to.equal(560);
+ expect(response.status).to.equal(401);
});
it('Should not be able to update the site area', async () => {
@@ -218,7 +218,7 @@ describe('Site Area tests', function() {
testData.userService.siteAreaApi,
testData.newSiteArea, false
);
- expect(response.status).to.equal(560);
+ expect(response.status).to.equal(401);
});
it('Should not be able to delete the created site area', async () => {
@@ -228,7 +228,7 @@ describe('Site Area tests', function() {
testData.newSiteArea,
false
);
- expect(response.status).to.equal(560);
+ expect(response.status).to.equal(401);
});
it('Should not be able to create a site area without a site', async () => {

MODIFY
test/api/StatisticsTest.ts
test/api/StatisticsTest.ts
@@ -90,73 +90,73 @@ describe('Statistics tests', function() {
it('Is not authorized to access consumption data', async () => {
let adminUserListResponse = await adminUserServerServiceNothing.statisticsApi.readChargingStationConsumption({ Year: firstYear });
- expect(adminUserListResponse.status).to.be.eql(560);
+ expect(adminUserListResponse.status).to.be.eql(401);
expect(adminUserListResponse.data.message).to.contain('not authorized');
adminUserListResponse = await adminUserServerServiceNothing.statisticsApi.readUserConsumption({ Year: firstYear });
- expect(adminUserListResponse.status).to.be.eql(560);
+ expect(adminUserListResponse.status).to.be.eql(401);
expect(adminUserListResponse.data.message).to.contain('not authorized');
});
it('Is not authorized to access usage data', async () => {
let adminUserListResponse = await adminUserServerServiceNothing.statisticsApi.readChargingStationUsage({ Year: firstYear });
- expect(adminUserListResponse.status).to.be.eql(560);
+ expect(adminUserListResponse.status).to.be.eql(401);
expect(adminUserListResponse.data.message).to.contain('not authorized');
adminUserListResponse = await adminUserServerServiceNothing.statisticsApi.readUserUsage({ Year: firstYear });
- expect(adminUserListResponse.status).to.be.eql(560);
+ expect(adminUserListResponse.status).to.be.eql(401);
expect(adminUserListResponse.data.message).to.contain('not authorized');
});
it('Is not authorized to access inactivity data', async () => {
let adminUserListResponse = await adminUserServerServiceNothing.statisticsApi.readChargingStationInactivity({ Year: firstYear });
- expect(adminUserListResponse.status).to.be.eql(560);
+ expect(adminUserListResponse.status).to.be.eql(401);
expect(adminUserListResponse.data.message).to.contain('not authorized');
adminUserListResponse = await adminUserServerServiceNothing.statisticsApi.readUserInactivity({ Year: firstYear });
- expect(adminUserListResponse.status).to.be.eql(560);
+ expect(adminUserListResponse.status).to.be.eql(401);
expect(adminUserListResponse.data.message).to.contain('not authorized');
});
it('Is not authorized to access sessions data', async () => {
let adminUserListResponse = await adminUserServerServiceNothing.statisticsApi.readChargingStationTransactions({ Year: firstYear });
- expect(adminUserListResponse.status).to.be.eql(560);
+ expect(adminUserListResponse.status).to.be.eql(401);
expect(adminUserListResponse.data.message).to.contain('not authorized');
adminUserListResponse = await adminUserServerServiceNothing.statisticsApi.readUserTransactions({ Year: firstYear });
- expect(adminUserListResponse.status).to.be.eql(560);
+ expect(adminUserListResponse.status).to.be.eql(401);
expect(adminUserListResponse.data.message).to.contain('not authorized');
});
it('Is not authorized to access pricing data', async () => {
let adminUserListResponse = await adminUserServerServiceNothing.statisticsApi.readChargingStationPricing({ Year: firstYear });
- expect(adminUserListResponse.status).to.be.eql(560);
+ expect(adminUserListResponse.status).to.be.eql(401);
expect(adminUserListResponse.data.message).to.contain('not authorized');
adminUserListResponse = await adminUserServerServiceNothing.statisticsApi.readUserPricing({ Year: firstYear });
- expect(adminUserListResponse.status).to.be.eql(560);
+ expect(adminUserListResponse.status).to.be.eql(401);
expect(adminUserListResponse.data.message).to.contain('not authorized');
});
it('Is not authorized to export data to file', async () => {
let adminUserListResponse = await adminUserServerServiceNothing.statisticsApi.exportStatistics({ Year: firstYear, DataType: 'Consumption', DataCategory: 'C', DataScope: 'month' });
- expect(adminUserListResponse.status).to.be.eql(560);
+ expect(adminUserListResponse.status).to.be.eql(401);
expect(adminUserListResponse.data.message).to.contain('not authorized');
adminUserListResponse = await adminUserServerServiceNothing.statisticsApi.exportStatistics({ Year: firstYear, DataType: 'Usage', DataCategory: 'U', DataScope: 'month' });
- expect(adminUserListResponse.status).to.be.eql(560);
+ expect(adminUserListResponse.status).to.be.eql(401);
expect(adminUserListResponse.data.message).to.contain('not authorized');
adminUserListResponse = await adminUserServerServiceNothing.statisticsApi.exportStatistics({ Year: firstYear, DataType: 'Inactivity', DataCategory: 'U', DataScope: 'total' });
- expect(adminUserListResponse.status).to.be.eql(560);
+ expect(adminUserListResponse.status).to.be.eql(401);
expect(adminUserListResponse.data.message).to.contain('not authorized');
adminUserListResponse = await adminUserServerServiceNothing.statisticsApi.exportStatistics({ Year: firstYear, DataType: 'Transactions', DataCategory: 'C', DataScope: 'total' });
- expect(adminUserListResponse.status).to.be.eql(560);
+ expect(adminUserListResponse.status).to.be.eql(401);
expect(adminUserListResponse.data.message).to.contain('not authorized');
adminUserListResponse = await adminUserServerServiceNothing.statisticsApi.exportStatistics({ Year: firstYear, DataType: 'Pricing', DataCategory: 'U', DataScope: 'month' });
- expect(adminUserListResponse.status).to.be.eql(560);
+ expect(adminUserListResponse.status).to.be.eql(401);
expect(adminUserListResponse.data.message).to.contain('not authorized');
});

Used unauth 401 standard HTTP code