Added issuer to asset
MODIFY
src/server/rest/v1/service/AssetService.ts
src/server/rest/v1/service/AssetService.ts
@@ -406,6 +406,7 @@ export default class AssetService {
name: filteredRequest.name,
siteAreaID: filteredRequest.siteAreaID,
siteID: siteArea ? siteArea.siteID : null,
+ issuer: true,
assetType: filteredRequest.assetType,
excludeFromSmartCharging: filteredRequest.excludeFromSmartCharging,
fluctuationPercent: filteredRequest.fluctuationPercent,

MODIFY
src/server/rest/v1/service/UtilsService.ts
src/server/rest/v1/service/UtilsService.ts
@@ -364,17 +364,16 @@ export default class UtilsService {
// Check
for (const asset of assets.result) {
// External Asset
- // TODO: Uncomment when the bug will be fixed: https://github.com/sap-labs-france/ev-dashboard/issues/2266
- // if (!asset.issuer) {
- // throw new AppError({
- // source: Constants.CENTRAL_SERVER,
- // errorCode: HTTPError.GENERAL_ERROR,
- // message: `Asset ID '${asset.id}' not issued by the organization`,
- // module: MODULE_NAME, method: 'checkSiteAreaAssetsAuthorization',
- // user: userToken,
- // action: action
- // });
- // }
+ if (!asset.issuer) {
+ throw new AppError({
+ source: Constants.CENTRAL_SERVER,
+ errorCode: HTTPError.GENERAL_ERROR,
+ message: `Asset ID '${asset.id}' not issued by the organization`,
+ module: MODULE_NAME, method: 'checkSiteAreaAssetsAuthorization',
+ user: userToken,
+ action: action
+ });
+ }
}
return assets.result;
}

MODIFY
test/api/AssetTest.ts
test/api/AssetTest.ts
@@ -155,6 +155,7 @@ describe('Asset Test', function() {
testData.userService.assetApi,
testData.newAsset
);
+ expect(createdAsset.issuer).to.equal(true);
expect(createdAsset.siteID).to.equal(testData.createdSiteAreas[0].siteID);
});

Added issuer to asset