Change tenant id to object Setting Storage
MODIFY
src/scheduler/tasks/MigrateSensitiveDataTask.ts
src/scheduler/tasks/MigrateSensitiveDataTask.ts
@@ -9,7 +9,7 @@ export default class MigrateSensitiveDataTask extends SchedulerTask {
public async processTenant(tenant: Tenant, config: TaskConfig): Promise<void> {
const keySettings = await SettingStorage.getCryptoSettings(tenant);
if (keySettings?.crypto.migrationToBeDone) {
- await Cypher.handleCryptoSettingsChange(tenant.id);
+ await Cypher.handleCryptoSettingsChange(tenant);
}
}
}

MODIFY
src/server/rest/v1/service/TenantService.ts
src/server/rest/v1/service/TenantService.ts
@@ -259,7 +259,7 @@ export default class TenantService {
try {
await TenantStorage.createTenantDB(filteredRequest.id);
// Create initial settings for tenant
- await TenantService.createInitialSettingsForTenant(filteredRequest.id);
+ await TenantService.createInitialSettingsForTenant(filteredRequest);
} finally {
// Release the database creation Lock
await LockingManager.release(createDatabaseLock);
@@ -389,7 +389,7 @@ export default class TenantService {
next();
}
- private static async updateSettingsWithComponents(tenant: Partial<Tenant>, req: Request): Promise<void> {
+ private static async updateSettingsWithComponents(tenant: Tenant, req: Request): Promise<void> {
// Create settings
for (const componentName in tenant.components) {
// Get the settings
@@ -418,13 +418,13 @@ export default class TenantService {
newSetting.createdOn = new Date();
newSetting.createdBy = { 'id': req.user.id };
// Save Setting
- await SettingStorage.saveSettings(tenant.id, newSetting);
+ await SettingStorage.saveSettings(tenant, newSetting);
} else {
currentSetting.content = newSettingContent;
currentSetting.lastChangedOn = new Date();
currentSetting.lastChangedBy = { 'id': req.user.id };
// Save Setting
- await SettingStorage.saveSettings(tenant.id, currentSetting);
+ await SettingStorage.saveSettings(tenant, currentSetting);
}
}
}

MODIFY
test/api/BillingStripeTestData.ts
test/api/BillingStripeTestData.ts
@@ -75,7 +75,7 @@ export default class StripeIntegrationTestData {
public async setBillingSystemValidCredentials(immediateBilling: boolean) : Promise<void> {
const billingSettings = this.getLocalSettings(immediateBilling);
await this.saveBillingSettings(billingSettings);
- billingSettings.stripe.secretKey = await Cypher.encrypt(this.getTenantID(), billingSettings.stripe.secretKey);
+ billingSettings.stripe.secretKey = await Cypher.encrypt(this.getTenant(), billingSettings.stripe.secretKey);
this.billingImpl = StripeBillingIntegration.getInstance(this.getTenant(), billingSettings);
assert(this.billingImpl, 'Billing implementation should not be null');
}

MODIFY
test/api/BillingTest.ts
test/api/BillingTest.ts
@@ -81,7 +81,7 @@ class TestData {
await this.saveBillingSettings(billingSettings);
const tenant = this.tenantContext?.getTenant();
assert(!!tenant, 'Tenant cannot be null');
- billingSettings.stripe.secretKey = await Cypher.encrypt(tenant.id, billingSettings.stripe.secretKey);
+ billingSettings.stripe.secretKey = await Cypher.encrypt(tenant, billingSettings.stripe.secretKey);
const billingImpl = StripeBillingIntegration.getInstance(tenant, billingSettings);
assert(billingImpl, 'Billing implementation should not be null');
return billingImpl;
@@ -91,7 +91,7 @@ class TestData {
const billingSettings = this.getLocalSettings(false);
const tenant = this.tenantContext?.getTenant();
assert(!!tenant, 'Tenant cannot be null');
- billingSettings.stripe.secretKey = await Cypher.encrypt(tenant.id, 'sk_test_' + 'invalid_credentials');
+ billingSettings.stripe.secretKey = await Cypher.encrypt(tenant, 'sk_test_' + 'invalid_credentials');
await this.saveBillingSettings(billingSettings);
const billingImpl = StripeBillingIntegration.getInstance(tenant, billingSettings);
assert(billingImpl, 'Billing implementation should not be null');

MODIFY
test/api/SmartChargingTest.ts
test/api/SmartChargingTest.ts
@@ -322,7 +322,7 @@ describe('Smart Charging Service', function() {
it('Should not connect to Smart Charging Provider with invalid URL', async () => {
const sapSmartChargingSettings = TestData.getSmartChargingSettings();
- sapSmartChargingSettings.password = await Cypher.encrypt(testData.tenantContext.getTenant().id, sapSmartChargingSettings.password);
+ sapSmartChargingSettings.password = await Cypher.encrypt(testData.tenantContext.getTenant(), sapSmartChargingSettings.password);
sapSmartChargingSettings.optimizerUrl = '';
await TestData.saveSmartChargingSettings(testData, sapSmartChargingSettings);
const response = await testData.userService.smartChargingApi.testConnection({});

Change tenant id to object Setting Storage