Skip to content

Commit

Permalink
Merge Hotfix from 2.7.1 (#1065)
Browse files Browse the repository at this point in the history
* Add configurable API version support for LoRaWAN Management function

* Make IDE0220 isssue as a warning

* Add unit test to LoRaKeyManagementApiVersion setting
  • Loading branch information
kbeaugrand authored Aug 11, 2022
1 parent c181b05 commit bb7ecb9
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ dotnet_diagnostic.IDE1003.severity=suggestion
dotnet_diagnostic.IDE1004.severity=suggestion
dotnet_diagnostic.IDE1007.severity=suggestion
dotnet_diagnostic.IDE1008.severity=suggestion
dotnet_diagnostic.IDE0220.severity=warning

# Enforce file header
dotnet_diagnostic.IDE0073.severity = error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ private DevelopmentConfigHandler CreateDevelopmentConfigHandler()
[TestCase(ConfigHandler.OIDCApiClientIdKey, nameof(ConfigHandler.OIDCApiClientId))]
[TestCase(ConfigHandler.LoRaKeyManagementUrlKey, nameof(ConfigHandler.LoRaKeyManagementUrl))]
[TestCase(ConfigHandler.LoRaKeyManagementCodeKey, nameof(ConfigHandler.LoRaKeyManagementCode))]
[TestCase(ConfigHandler.LoRaKeyManagementApiVersionKey, nameof(ConfigHandler.LoRaKeyManagementApiVersion))]
[TestCase(ConfigHandler.IoTHubConnectionStringKey, nameof(ConfigHandler.IoTHubConnectionString))]
[TestCase(ConfigHandler.DPSConnectionStringKey, nameof(ConfigHandler.DPSConnectionString))]
[TestCase(ConfigHandler.StorageAccountConnectionStringKey, nameof(ConfigHandler.StorageAccountConnectionString))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public void SecretsShouldGetValueFromConnectionStrings(string configKey, string
[TestCase(ConfigHandler.OIDCClientIdKey, nameof(ConfigHandler.OIDCClientId))]
[TestCase(ConfigHandler.OIDCApiClientIdKey, nameof(ConfigHandler.OIDCApiClientId))]
[TestCase(ConfigHandler.LoRaKeyManagementUrlKey, nameof(ConfigHandler.LoRaKeyManagementUrl))]
[TestCase(ConfigHandler.LoRaKeyManagementApiVersionKey, nameof(ConfigHandler.LoRaKeyManagementApiVersion))]
public void SettingsShouldGetValueFromAppSettings(string configKey, string configPropertyName)
{
// Arrange
Expand Down
3 changes: 3 additions & 0 deletions src/AzureIoTHub.Portal/Server/ConfigHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public abstract class ConfigHandler

internal const string LoRaKeyManagementUrlKey = "LoRaKeyManagement:Url";
internal const string LoRaKeyManagementCodeKey = "LoRaKeyManagement:Code";
internal const string LoRaKeyManagementApiVersionKey = "LoRaKeyManagement:ApiVersion";

internal const string MetricExporterRefreshIntervalKey = "Metrics:ExporterRefreshIntervalInSeconds";
internal const string MetricLoaderRefreshIntervalKey = "Metrics:LoaderRefreshIntervalInMinutes";
Expand Down Expand Up @@ -100,6 +101,8 @@ internal static ConfigHandler Create(IWebHostEnvironment env, IConfiguration con

internal abstract string LoRaKeyManagementCode { get; }

internal abstract string LoRaKeyManagementApiVersion { get; }

internal abstract string PortalName { get; }

internal abstract int MetricExporterRefreshIntervalInSeconds { get; }
Expand Down
2 changes: 2 additions & 0 deletions src/AzureIoTHub.Portal/Server/DevelopmentConfigHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ internal DevelopmentConfigHandler(IConfiguration config)

internal override string LoRaKeyManagementCode => this.config[LoRaKeyManagementCodeKey];

internal override string LoRaKeyManagementApiVersion => this.config[LoRaKeyManagementApiVersionKey];

internal override bool IdeasEnabled => this.config.GetValue(IdeasEnabledKey, false);
internal override string IdeasUrl => this.config.GetValue(IdeasUrlKey, string.Empty);
internal override string IdeasAuthenticationHeader => this.config.GetValue(IdeasAuthenticationHeaderKey, "Ocp-Apim-Subscription-Key");
Expand Down
2 changes: 2 additions & 0 deletions src/AzureIoTHub.Portal/Server/ProductionConfigHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ internal ProductionConfigHandler(IConfiguration config)

internal override string LoRaKeyManagementCode => this.config.GetConnectionString(LoRaKeyManagementCodeKey);

internal override string LoRaKeyManagementApiVersion => this.config[LoRaKeyManagementApiVersionKey];

internal override bool IdeasEnabled => this.config.GetValue(IdeasEnabledKey, false);
internal override string IdeasUrl => this.config.GetValue(IdeasUrlKey, string.Empty);
internal override string IdeasAuthenticationHeader => this.config.GetValue(IdeasAuthenticationHeaderKey, "Ocp-Apim-Subscription-Key");
Expand Down
2 changes: 1 addition & 1 deletion src/AzureIoTHub.Portal/Server/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void ConfigureServices(IServiceCollection services)
{
client.BaseAddress = new Uri(configuration.LoRaKeyManagementUrl);
client.DefaultRequestHeaders.Add("x-functions-key", configuration.LoRaKeyManagementCode);
client.DefaultRequestHeaders.Add("api-version", "2020-10-09");
client.DefaultRequestHeaders.Add("api-version", configuration.LoRaKeyManagementApiVersion ?? "2022-03-04");
})
.AddPolicyHandler(transientHttpErrorPolicy);

Expand Down

0 comments on commit bb7ecb9

Please sign in to comment.