remove dummy indexes
MODIFY
test/api/OCPPAllVersionsTest.ts
test/api/OCPPAllVersionsTest.ts
@@ -129,6 +129,10 @@ describe('OCPP tests (all versions)', function() {
await testData.ocppCommonTests.testDataTransfer();
});
+ it('Should not be able to remote start transaction without a badge', async () => {
+ await testData.ocppCommonTests.testRemoteStartTransactionWithNoBadge();
+ });
+
});
describe('Where basic user', () => {
@@ -159,6 +163,20 @@ describe('OCPP tests (all versions)', function() {
});
+ describe('Where external user', () => {
+
+ before(() => {
+ testData.ocppCommonTests.setUsers(
+ testData.tenantContext.getUserContext(ContextDefinition.USER_CONTEXTS.EXTERNAL_USER)
+ );
+ });
+
+ it('Should not be authorized on a remote start transaction', async () => {
+ await testData.ocppCommonTests.testRemoteStartTransactionWithExternalUser();
+ });
+
+ });
+
});
describe('For OCPP Version 1.6 (JSON)', () => {
@@ -234,6 +252,10 @@ describe('OCPP tests (all versions)', function() {
await testData.ocppCommonTests.testDataTransfer();
});
+ it('Should not be able to remote start transaction without a badge', async () => {
+ await testData.ocppCommonTests.testRemoteStartTransactionWithNoBadge();
+ });
+
});
describe('Where basic user', () => {
@@ -264,6 +286,20 @@ describe('OCPP tests (all versions)', function() {
});
+ describe('Where external user', () => {
+
+ before(() => {
+ testData.ocppCommonTests.setUsers(
+ testData.tenantContext.getUserContext(ContextDefinition.USER_CONTEXTS.EXTERNAL_USER)
+ );
+ });
+
+ it('Should not be authorized on a remote start transaction', async () => {
+ await testData.ocppCommonTests.testRemoteStartTransactionWithExternalUser();
+ });
+
+ });
+
});
});
@@ -383,6 +419,20 @@ describe('OCPP tests (all versions)', function() {
});
+ describe('Where external user', () => {
+
+ before(() => {
+ testData.ocppCommonTests.setUsers(
+ testData.tenantContext.getUserContext(ContextDefinition.USER_CONTEXTS.EXTERNAL_USER)
+ );
+ });
+
+ it('Should not be authorized on a remote start transaction', async () => {
+ await testData.ocppCommonTests.testRemoteStartTransactionWithExternalUser();
+ });
+
+ });
+
});
describe('With charger not assigned to a site area', () => {
@@ -408,6 +458,10 @@ describe('OCPP tests (all versions)', function() {
await testData.ocppCommonTests.testStartTransaction(false);
});
+ it('Should not be authorized on a remote start transaction', async () => {
+ await testData.ocppCommonTests.testRemoteStartTransactionWithUnassignedChargingStation();
+ });
+
});
describe('Where unassigned basic user', () => {
@@ -422,6 +476,10 @@ describe('OCPP tests (all versions)', function() {
await testData.ocppCommonTests.testStartTransaction(false);
});
+ it('Should not be authorized on a remote start transaction', async () => {
+ await testData.ocppCommonTests.testRemoteStartTransactionWithUnassignedChargingStation();
+ });
+
});
describe('Where admin user', () => {
@@ -436,6 +494,10 @@ describe('OCPP tests (all versions)', function() {
await testData.ocppCommonTests.testStartTransaction(false);
});
+ it('Should not be authorized on a remote start transaction', async () => {
+ await testData.ocppCommonTests.testRemoteStartTransactionWithUnassignedChargingStation();
+ });
+
});
describe('Where unassigned admin user', () => {
@@ -450,6 +512,24 @@ describe('OCPP tests (all versions)', function() {
await testData.ocppCommonTests.testStartTransaction(false);
});
+ it('Should not be authorized on a remote start transaction', async () => {
+ await testData.ocppCommonTests.testRemoteStartTransactionWithUnassignedChargingStation();
+ });
+
+ });
+
+ describe('Where external user', () => {
+
+ before(() => {
+ testData.ocppCommonTests.setUsers(
+ testData.tenantContext.getUserContext(ContextDefinition.USER_CONTEXTS.EXTERNAL_USER)
+ );
+ });
+
+ it('Should not be authorized on a remote start transaction', async () => {
+ await testData.ocppCommonTests.testRemoteStartTransactionWithUnassignedChargingStation();
+ });
+
});
});
@@ -554,6 +634,20 @@ describe('OCPP tests (all versions)', function() {
});
+ describe('Where external user', () => {
+
+ before(() => {
+ testData.ocppCommonTests.setUsers(
+ testData.tenantContext.getUserContext(ContextDefinition.USER_CONTEXTS.EXTERNAL_USER)
+ );
+ });
+
+ it('Should not be authorized on a remote start transaction', async () => {
+ await testData.ocppCommonTests.testRemoteStartTransactionWithExternalUser();
+ });
+
+ });
+
});
describe('With charger not assigned to a site area', () => {
@@ -593,6 +687,10 @@ describe('OCPP tests (all versions)', function() {
await testData.ocppCommonTests.testStartTransaction(false);
});
+ it('Should not be authorized on a remote start transaction', async () => {
+ await testData.ocppCommonTests.testRemoteStartTransactionWithUnassignedChargingStation();
+ });
+
});
describe('Where admin user', () => {
@@ -607,6 +705,10 @@ describe('OCPP tests (all versions)', function() {
await testData.ocppCommonTests.testStartTransaction(false);
});
+ it('Should not be authorized on a remote start transaction', async () => {
+ await testData.ocppCommonTests.testRemoteStartTransactionWithUnassignedChargingStation();
+ });
+
});
describe('Where unassigned admin user', () => {
@@ -621,6 +723,24 @@ describe('OCPP tests (all versions)', function() {
await testData.ocppCommonTests.testStartTransaction(false);
});
+ it('Should not be authorized on a remote start transaction', async () => {
+ await testData.ocppCommonTests.testRemoteStartTransactionWithUnassignedChargingStation();
+ });
+
+ });
+
+ describe('Where external user', () => {
+
+ before(() => {
+ testData.ocppCommonTests.setUsers(
+ testData.tenantContext.getUserContext(ContextDefinition.USER_CONTEXTS.EXTERNAL_USER)
+ );
+ });
+
+ it('Should not be authorized on a remote start transaction', async () => {
+ await testData.ocppCommonTests.testRemoteStartTransactionWithUnassignedChargingStation();
+ });
+
});
});
@@ -719,6 +839,10 @@ describe('OCPP tests (all versions)', function() {
await testData.ocppCommonTests.testDataTransfer();
});
+ it('Should not be able to remote start transaction without a badge', async () => {
+ await testData.ocppCommonTests.testRemoteStartTransactionWithNoBadge();
+ });
+
});
describe('Where basic user as start and stop user', () => {
@@ -889,6 +1013,10 @@ describe('OCPP tests (all versions)', function() {
await testData.ocppCommonTests.testDataTransfer();
});
+ it('Should not be able to remote start transaction without a badge', async () => {
+ await testData.ocppCommonTests.testRemoteStartTransactionWithNoBadge();
+ });
+
});
describe('Where basic user as start and stop user', () => {

MODIFY
test/api/OCPPCommonTests.ts
test/api/OCPPCommonTests.ts
@@ -4,6 +4,7 @@ import chai, { expect } from 'chai';
import CentralServerService from './client/CentralServerService';
import ChargingStationContext from './context/ChargingStationContext';
+import { Command } from '../../src/types/ChargingStation';
import Constants from '../../src/utils/Constants';
import Factory from '../factories/Factory';
import { OCPPStatus } from '../../src/types/ocpp/OCPPClient';
@@ -429,6 +430,52 @@ export default class OCPPCommonTests {
expect(this.newTransaction.id).to.not.equal(transactionId);
}
+ public async testRemoteStartTransactionWithNoBadge() {
+ const response = await this.centralUserService.chargingStationApi.remoteStartTransaction({
+ 'chargeBoxID': this.chargingStationContext.getChargingStation().id,
+ 'args': {
+ 'connectorId': this.chargingStationContext.getChargingStation().connectors[0].connectorId
+ }
+ });
+ expect(response.status).to.equal(570);
+ }
+
+ public async testRemoteStartTransactionWithExternalUser() {
+ const response = await this.centralUserService.chargingStationApi.remoteStartTransaction({
+ 'chargeBoxID': this.chargingStationContext.getChargingStation().id,
+ 'args': {
+ 'tagID': this.transactionStartUser.tags[0].id,
+ 'connectorId': this.chargingStationContext.getChargingStation().connectors[0].connectorId
+ }
+ });
+ expect(response.status).to.equal(500);
+ expect(response.data.message).to.equal(`User not issued by the organization execute command '${Command.REMOTE_START_TRANSACTION}'`);
+ }
+
+ public async testRemoteStartTransactionWithUnassignedChargingStation() {
+ const response = await this.centralUserService.chargingStationApi.remoteStartTransaction({
+ 'chargeBoxID': this.chargingStationContext.getChargingStation().id,
+ 'args': {
+ 'tagID': this.transactionStartUser.tags[0].id,
+ 'connectorId': this.chargingStationContext.getChargingStation().connectors[0].connectorId
+ }
+ });
+ expect(response.status).to.equal(500);
+ expect(response.data.message).to.equal(`Charging Station '${this.chargingStationContext.getChargingStation().id}' is not assigned to a Site Area!`);
+ }
+
+ public async testRemoteStartTransactionWithBasicUser() {
+ const response = await this.centralUserService.chargingStationApi.remoteStartTransaction({
+ 'chargeBoxID': this.chargingStationContext.getChargingStation().id,
+ 'args': {
+ 'tagID': this.transactionStopUser.tags[0].id,
+ 'connectorId': this.chargingStationContext.getChargingStation().connectors[0].connectorId
+ }
+ });
+ expect(response.status).to.equal(500);
+ expect(response.data.message).to.equal(`Charging Station '${this.chargingStationContext.getChargingStation().id}' is not assigned to a Site Area!`);
+ }
+
public async testSendMeterValues(withSoC = false, withSignedData = false) {
// Check on Transaction
expect(this.newTransaction).to.not.be.null;

MODIFY
test/api/client/ChargingStationApi.ts
test/api/client/ChargingStationApi.ts
@@ -56,6 +56,10 @@ export default class ChargingStationApi extends CrudApi {
return super.update(data, '/client/api/ChargingStationUpdateParams');
}
+ public async remoteStartTransaction(data) {
+ return super.create(data, '/client/api/ChargingStationRemoteStartTransaction');
+ }
+
public async checkConnector(chargingStation, connectorId, connectorData) {
// Check
expect(chargingStation).to.not.be.null;

MODIFY
test/api/context/ContextBuilder.ts
test/api/context/ContextBuilder.ts
@@ -226,7 +226,7 @@ export default class ContextBuilder {
const userDef = ContextDefinition.TENANT_USER_LIST[index];
const createUser = UserFactory.build();
createUser.email = userDef.emailPrefix + defaultAdminUser.email;
- createUser.issuer = true;
+ createUser.issuer = Utils.objectHasProperty(userDef, 'issuer') ? userDef.issuer : true;
// Update the password
const newPasswordHashed = await Utils.hashPasswordBcrypt(config.get('admin.password'));
createUser.id = userDef.id;

MODIFY
test/api/context/ContextDefinition.ts
test/api/context/ContextDefinition.ts
@@ -65,28 +65,31 @@ export default class ContextDefinition {
static readonly USER_CONTEXTS: any = {
DEFAULT_ADMIN: {
- role: 'A', status: 'A', assignedToSite: true, withTags: true
+ role: 'A', status: 'A', assignedToSite: true, withTags: true, issuer: true
},
ADMIN_UNASSIGNED: {
- role: 'A', status: 'A', assignedToSite: false, withTags: true
+ role: 'A', status: 'A', assignedToSite: false, withTags: true, issuer: true
},
BASIC_USER: {
- role: 'B', status: 'A', assignedToSite: true, withTags: true
+ role: 'B', status: 'A', assignedToSite: true, withTags: true, issuer: true
},
BASIC_USER_UNASSIGNED: {
- role: 'B', status: 'A', assignedToSite: false, withTags: true
+ role: 'B', status: 'A', assignedToSite: false, withTags: true, issuer: true
},
BASIC_USER_PENDING: {
- role: 'B', status: 'P', assignedToSite: true, withTags: true
+ role: 'B', status: 'P', assignedToSite: true, withTags: true, issuer: true
},
BASIC_USER_LOCKED: {
- role: 'B', status: 'L', assignedToSite: true, withTags: true
+ role: 'B', status: 'L', assignedToSite: true, withTags: true, issuer: true
},
BASIC_USER_NO_TAGS: {
- role: 'B', status: 'A', assignedToSite: true, withTags: false
+ role: 'B', status: 'A', assignedToSite: true, withTags: false, issuer: true
},
DEMO_USER: {
- role: 'D', status: 'A', assignedToSite: true, withTags: true
+ role: 'D', status: 'A', assignedToSite: true, withTags: true, issuer: true
+ },
+ EXTERNAL_USER: {
+ role: 'B', status: 'A', assignedToSite: false, withTags: true, issuer: false
},
};
@@ -338,11 +341,15 @@ export default class ContextDefinition {
componentSettings: {
organization: {},
smartCharging:
- { content:
- { type: SmartChargingSettingsType.SAP_SMART_CHARGING, sapSmartCharging:
- { optimizerUrl: '',
+ {
+ content:
+ {
+ type: SmartChargingSettingsType.SAP_SMART_CHARGING, sapSmartCharging:
+ {
+ optimizerUrl: '',
user: '',
- password: '' }
+ password: ''
+ }
}
},
}
@@ -360,6 +367,7 @@ export default class ContextDefinition {
phone: '66666666666',
mobile: '66666666666',
plateID: '666-FB-69',
+ issuer: ContextDefinition.USER_CONTEXTS.DEFAULT_ADMIN.issuer,
role: ContextDefinition.USER_CONTEXTS.DEFAULT_ADMIN.role,
status: ContextDefinition.USER_CONTEXTS.DEFAULT_ADMIN.status,
assignedToSite: ContextDefinition.USER_CONTEXTS.DEFAULT_ADMIN.assignedToSite,
@@ -377,6 +385,7 @@ export default class ContextDefinition {
phone: '66666666666',
mobile: '66666666666',
plateID: '666-FB-69',
+ issuer: ContextDefinition.USER_CONTEXTS.ADMIN_UNASSIGNED.issuer,
role: ContextDefinition.USER_CONTEXTS.ADMIN_UNASSIGNED.role,
status: ContextDefinition.USER_CONTEXTS.ADMIN_UNASSIGNED.status,
assignedToSite: ContextDefinition.USER_CONTEXTS.ADMIN_UNASSIGNED.assignedToSite,
@@ -395,6 +404,7 @@ export default class ContextDefinition {
phone: '66666666666',
mobile: '66666666666',
plateID: '666-FB-69',
+ issuer: ContextDefinition.USER_CONTEXTS.BASIC_USER.issuer,
role: ContextDefinition.USER_CONTEXTS.BASIC_USER.role,
status: ContextDefinition.USER_CONTEXTS.BASIC_USER.status,
assignedToSite: ContextDefinition.USER_CONTEXTS.BASIC_USER.assignedToSite,
@@ -413,6 +423,7 @@ export default class ContextDefinition {
phone: '66666666666',
mobile: '66666666666',
plateID: '666-FB-69',
+ issuer: ContextDefinition.USER_CONTEXTS.DEMO_USER.issuer,
role: ContextDefinition.USER_CONTEXTS.DEMO_USER.role,
status: ContextDefinition.USER_CONTEXTS.DEMO_USER.status,
assignedToSite: ContextDefinition.USER_CONTEXTS.DEMO_USER.assignedToSite,
@@ -431,6 +442,7 @@ export default class ContextDefinition {
phone: '66666666666',
mobile: '66666666666',
plateID: '666-FB-69',
+ issuer: ContextDefinition.USER_CONTEXTS.BASIC_USER_UNASSIGNED.issuer,
role: ContextDefinition.USER_CONTEXTS.BASIC_USER_UNASSIGNED.role,
status: ContextDefinition.USER_CONTEXTS.BASIC_USER_UNASSIGNED.status,
assignedToSite: ContextDefinition.USER_CONTEXTS.BASIC_USER_UNASSIGNED.assignedToSite,
@@ -449,6 +461,7 @@ export default class ContextDefinition {
phone: '66666666666',
mobile: '66666666666',
plateID: '666-FB-69',
+ issuer: ContextDefinition.USER_CONTEXTS.BASIC_USER_PENDING.issuer,
role: ContextDefinition.USER_CONTEXTS.BASIC_USER_PENDING.role,
status: ContextDefinition.USER_CONTEXTS.BASIC_USER_PENDING.status,
assignedToSite: ContextDefinition.USER_CONTEXTS.BASIC_USER_PENDING.assignedToSite,
@@ -467,6 +480,7 @@ export default class ContextDefinition {
phone: '66666666666',
mobile: '66666666666',
plateID: '666-FB-69',
+ issuer: ContextDefinition.USER_CONTEXTS.BASIC_USER_LOCKED.issuer,
role: ContextDefinition.USER_CONTEXTS.BASIC_USER_LOCKED.role,
status: ContextDefinition.USER_CONTEXTS.BASIC_USER_LOCKED.status,
assignedToSite: ContextDefinition.USER_CONTEXTS.BASIC_USER_LOCKED.assignedToSite,
@@ -485,6 +499,7 @@ export default class ContextDefinition {
phone: '66666666666',
mobile: '66666666666',
plateID: '666-FB-69',
+ issuer: ContextDefinition.USER_CONTEXTS.BASIC_USER_NO_TAGS.issuer,
role: ContextDefinition.USER_CONTEXTS.BASIC_USER_NO_TAGS.role,
status: ContextDefinition.USER_CONTEXTS.BASIC_USER_NO_TAGS.status,
assignedToSite: ContextDefinition.USER_CONTEXTS.BASIC_USER_NO_TAGS.assignedToSite,
@@ -494,6 +509,25 @@ export default class ContextDefinition {
issuer: false,
active: true
}] : null)
+ },
+ { // External User
+ id: '5ce249a1a39ae1c056c456ae',
+ name: 'External',
+ firstName: 'User',
+ locale: 'en-US',
+ phone: '66666666666',
+ mobile: '66666666666',
+ plateID: '666-FB-69',
+ issuer: ContextDefinition.USER_CONTEXTS.EXTERNAL_USER.issuer,
+ role: ContextDefinition.USER_CONTEXTS.EXTERNAL_USER.role,
+ status: ContextDefinition.USER_CONTEXTS.EXTERNAL_USER.status,
+ assignedToSite: ContextDefinition.USER_CONTEXTS.EXTERNAL_USER.assignedToSite,
+ emailPrefix: 'b-external-',
+ tags: (ContextDefinition.USER_CONTEXTS.EXTERNAL_USER.withTags ? [{
+ id: 'A220311',
+ issuer: false,
+ active: true
+ }] : null)
}
];

remove dummy indexes