Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,9 @@ internal class FeatureManagementConstants
public const string ETag = "ETag";
public const string FeatureFlagId = "FeatureFlagId";
public const string FeatureFlagReference = "FeatureFlagReference";
public const string Status = "Status";
public const string AlwaysOnFilter = "AlwaysOn";
public const string Conditional = "Conditional";
public const string Disabled = "Disabled";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ public Task<IEnumerable<KeyValuePair<string, string>>> ProcessKeyValue(Configura

if (featureFlag.Enabled)
{
keyValues.Add(new KeyValuePair<string, string>($"{featureFlagPath}:{FeatureManagementConstants.Status}", FeatureManagementConstants.Conditional));

//if (featureFlag.Conditions?.ClientFilters == null)
if (featureFlag.Conditions?.ClientFilters == null || !featureFlag.Conditions.ClientFilters.Any()) // workaround since we are not yet setting client filters to null
{
//
// Always on
keyValues.Add(new KeyValuePair<string, string>(featureFlagPath, true.ToString()));
keyValues.Add(new KeyValuePair<string, string>($"{featureFlagPath}:{FeatureManagementConstants.EnabledFor}:{0}:{FeatureManagementConstants.Name}", FeatureManagementConstants.AlwaysOnFilter));
}
else
{
Expand Down Expand Up @@ -80,7 +80,7 @@ public Task<IEnumerable<KeyValuePair<string, string>>> ProcessKeyValue(Configura
}
else
{
keyValues.Add(new KeyValuePair<string, string>($"{FeatureManagementConstants.SectionName}:{featureFlag.Id}", false.ToString()));
keyValues.Add(new KeyValuePair<string, string>($"{featureFlagPath}:{FeatureManagementConstants.Status}", FeatureManagementConstants.Disabled));
}

if (featureFlag.Variants != null)
Expand Down
28 changes: 22 additions & 6 deletions tests/Tests.AzureAppConfiguration/FeatureManagementTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,6 @@ public class FeatureManagementTests
""enabled"": true,
""conditions"": {
""client_filters"": [
{
""name"": ""AlwaysOn""
}
]
},
""variants"": [
Expand Down Expand Up @@ -278,9 +275,6 @@ public class FeatureManagementTests
""enabled"": true,
""conditions"": {
""client_filters"": [
{
""name"": ""AlwaysOn""
}
]
},
""telemetry"": {
Expand Down Expand Up @@ -1289,6 +1283,7 @@ public void WithVariants()
})
.Build();

Assert.Equal("AlwaysOn", config["FeatureManagement:VariantsFeature:EnabledFor:0:Name"]);
Assert.Equal("Big", config["FeatureManagement:VariantsFeature:Variants:0:Name"]);
Assert.Equal("600px", config["FeatureManagement:VariantsFeature:Variants:0:ConfigurationValue"]);
Assert.Equal("Small", config["FeatureManagement:VariantsFeature:Variants:1:Name"]);
Expand Down Expand Up @@ -1316,6 +1311,27 @@ public void WithVariants()
Assert.Equal("13992821", config["FeatureManagement:VariantsFeature:Allocation:Seed"]);
}

[Fact]
public void WithStatus()
{
var mockResponse = new Mock<Response>();
var mockClient = new Mock<ConfigurationClient>(MockBehavior.Strict);

mockClient.Setup(c => c.GetConfigurationSettingsAsync(It.IsAny<SettingSelector>(), It.IsAny<CancellationToken>()))
.Returns(new MockAsyncPageable(_featureFlagCollection));

var config = new ConfigurationBuilder()
.AddAzureAppConfiguration(options =>
{
options.ClientManager = TestHelpers.CreateMockedConfigurationClientManager(mockClient.Object);
options.UseFeatureFlags();
})
.Build();

Assert.Equal("Disabled", config["FeatureManagement:App1_Feature2:Status"]);
Assert.Equal("Conditional", config["FeatureManagement:Feature1:Status"]);
}

[Fact]
public void WithTelemetry()
{
Expand Down