Additional changes for incorrect credentials
MODIFY
src/integration/asset/iothink/IothinkAssetIntegration.ts
src/integration/asset/iothink/IothinkAssetIntegration.ts
@@ -146,7 +146,8 @@ export default class IothinkAssetIntegration extends AssetIntegration<AssetSetti
private async connect(): Promise<string> {
// Get token from cache
- let token = AssetTokenCache.getInstanceForTenant(this.tenant).getToken(this.connection.id);
+ const key = this.connection.id + this.connection.iothinkConnection.user + this.connection.iothinkConnection.password;
+ let token = AssetTokenCache.getInstanceForTenant(this.tenant).getToken(key);
if (!token) {
this.checkConnectionIsProvided();
// Get a fresh token (if not found or expired)

MODIFY
src/integration/asset/wit/WitAssetIntegration.ts
src/integration/asset/wit/WitAssetIntegration.ts
@@ -103,7 +103,8 @@ export default class WitAssetIntegration extends AssetIntegration<AssetSetting>
}
private async connect(): Promise<string> {
- let token = AssetTokenCache.getInstanceForTenant(this.tenant).getToken(this.connection.id);
+ const key = this.connection.id + this.connection.witConnection.user + this.connection.witConnection.password;
+ let token = AssetTokenCache.getInstanceForTenant(this.tenant).getToken(key);
if (!token) {
// Check if connection is initialized
this.checkConnectionIsProvided();

MODIFY
test/api/AssetTest.ts
test/api/AssetTest.ts
@@ -311,7 +311,7 @@ describe('Asset', function() {
testData.userService.assetApi,
Factory.asset.build({
siteAreaID: testData.newSiteArea.id,
- assetType: 'PR'
+ assetType: 'PR',
})
);
testData.createdAssets.push(testData.newAsset);
@@ -376,6 +376,7 @@ describe('Asset', function() {
it('should not be able to retrieve latest consumption with incorrect credentials', async function() {
if (!testData.pending) {
+ // Change entity
const settingID = '0123456789abcdef';
const url = config.get('assetConnectors.ioThink.url');
const user = 'WrongUser';

Additional changes for incorrect credentials