Skip to content

Commit

Permalink
Add AWS configuration in ConfigHandler (#1948)
Browse files Browse the repository at this point in the history
  • Loading branch information
delager authored and kbeaugrand committed Jun 22, 2023
1 parent b7833f1 commit 4c2f89b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/AzureIoTHub.Portal.Domain/ConfigHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,8 @@ public abstract class ConfigHandler
public abstract string MySQLConnectionString { get; }

public abstract string DbProvider { get; }
public abstract string AWSAccess { get; }
public abstract string AWSAccessSecret { get; }
public abstract string AWSRegion { get; }
}
}
4 changes: 4 additions & 0 deletions src/AzureIoTHub.Portal.Infrastructure/ConfigHandlerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,9 @@ internal abstract class ConfigHandlerBase : ConfigHandler
internal const string IdeasUrlKey = "Ideas:Url";
internal const string IdeasAuthenticationHeaderKey = "Ideas:Authentication:Header";
internal const string IdeasAuthenticationTokenKey = "Ideas:Authentication:Token";

internal const string AWSAccessKey = "AWS:Access";
internal const string AWSAccessSecretKey = "AWS:AccessSecret";
internal const string AWSRegionKey = "AWS:Region";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ internal DevelopmentConfigHandler(IConfiguration config)

public override string MySQLConnectionString => this.config[MySQLConnectionStringKey]!;

public override string DbProvider => this.config.GetValue(DbProviderKey, DbProviders.PostgreSQL)!;
public override string DbProvider => this.config.GetValue(DbProviderKey, DbProviders.PostgreSQL);

public override string AWSAccess => this.config[AWSAccessKey];
public override string AWSAccessSecret => this.config[AWSAccessSecretKey];
public override string AWSRegion => this.config[AWSRegionKey];
}
}
10 changes: 7 additions & 3 deletions src/AzureIoTHub.Portal.Infrastructure/ProductionConfigHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,12 @@ internal ProductionConfigHandler(IConfiguration config)
public override string LoRaKeyManagementApiVersion => this.config[LoRaKeyManagementApiVersionKey]!;

public override bool IdeasEnabled => this.config.GetValue(IdeasEnabledKey, false);
public override string IdeasUrl => this.config.GetValue(IdeasUrlKey, string.Empty)!;
public override string IdeasAuthenticationHeader => this.config.GetValue(IdeasAuthenticationHeaderKey, "Ocp-Apim-Subscription-Key")!;
public override string IdeasAuthenticationToken => this.config.GetValue(IdeasAuthenticationTokenKey, string.Empty)!;
public override string IdeasUrl => this.config.GetValue(IdeasUrlKey, string.Empty);
public override string IdeasAuthenticationHeader => this.config.GetValue(IdeasAuthenticationHeaderKey, "Ocp-Apim-Subscription-Key");
public override string IdeasAuthenticationToken => this.config.GetValue(IdeasAuthenticationTokenKey, string.Empty);

public override string AWSAccess => this.config[AWSAccessKey];
public override string AWSAccessSecret => this.config[AWSAccessSecretKey];
public override string AWSRegion => this.config[AWSRegionKey];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ private DevelopmentConfigHandler CreateDevelopmentConfigHandler()
[TestCase(ConfigHandlerBase.StorageAccountConnectionStringKey, nameof(ConfigHandlerBase.StorageAccountConnectionString))]
[TestCase(ConfigHandlerBase.PostgreSQLConnectionStringKey, nameof(ConfigHandlerBase.PostgreSQLConnectionString))]
[TestCase(ConfigHandlerBase.MySQLConnectionStringKey, nameof(ConfigHandlerBase.MySQLConnectionString))]
[TestCase(ConfigHandlerBase.AWSAccessKey, nameof(ConfigHandlerBase.AWSAccess))]
[TestCase(ConfigHandlerBase.AWSAccessSecretKey, nameof(ConfigHandlerBase.AWSAccessSecret))]
[TestCase(ConfigHandlerBase.AWSRegionKey, nameof(ConfigHandlerBase.AWSRegion))]
public void SettingsShouldGetValueFromAppSettings(string configKey, string configPropertyName)
{
// Arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ public void SecretsShouldGetValueFromConnectionStrings(string configKey, string
[TestCase(ConfigHandlerBase.OIDCApiClientIdKey, nameof(ConfigHandlerBase.OIDCApiClientId))]
[TestCase(ConfigHandlerBase.LoRaKeyManagementUrlKey, nameof(ConfigHandlerBase.LoRaKeyManagementUrl))]
[TestCase(ConfigHandlerBase.LoRaKeyManagementApiVersionKey, nameof(ConfigHandlerBase.LoRaKeyManagementApiVersion))]
[TestCase(ConfigHandlerBase.AWSAccessKey, nameof(ConfigHandlerBase.AWSAccess))]
[TestCase(ConfigHandlerBase.AWSAccessSecretKey, nameof(ConfigHandlerBase.AWSAccessSecret))]
[TestCase(ConfigHandlerBase.AWSRegionKey, nameof(ConfigHandlerBase.AWSRegion))]
public void SettingsShouldGetValueFromAppSettings(string configKey, string configPropertyName)
{
// Arrange
Expand Down

0 comments on commit 4c2f89b

Please sign in to comment.