Skip to content

Commit a28d729

Browse files
authored
Merge pull request #144 from Flagsmith/revert-141-fix!/exception-on-startup-for-server-side-key
Revert "fix!: throw exception on startup when using local evaluation without server key"
2 parents 00aafa2 + b712d4c commit a28d729

3 files changed

Lines changed: 9 additions & 27 deletions

File tree

Flagsmith.Client.Test/Fixtures.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Flagsmith.FlagsmithClientTest
88
{
99
internal class Fixtures
1010
{
11-
public static string ApiKey => "ser.test_key";
11+
public static string ApiKey => "test_key";
1212
public static string ApiUrl => "http://test_url/";
1313
public static AnalyticsProcessorTest GetAnalyticalProcessorTest() => new(new HttpClient(), ApiKey, ApiUrl);
1414
public static JObject JsonObject = JObject.Parse(@"{

Flagsmith.Client.Test/FlagsmithTest.cs

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
@@ -523,24 +523,6 @@ public void TestCannotCreateFlagsmithClientInRemoteEvaluationWithoutAPIKey()
523523
Assert.Equal("ValueError: environmentKey is required", exception.Message);
524524
}
525525

526-
[Fact]
527-
public void TestCannotCreateFlagsmithClientInLocalEvaluationWithoutServerAPIKey()
528-
{
529-
// When
530-
Action createFlagsmith = () => new FlagsmithClient(
531-
environmentKey: "foobar",
532-
enableClientSideEvaluation: true
533-
);
534-
535-
// Then
536-
var exception = Assert.Throws<Exception>(() => createFlagsmith());
537-
Assert.Equal
538-
(
539-
"ValueError: In order to use local evaluation, please generate a server key in the environment settings page.",
540-
exception.Message
541-
);
542-
}
543-
544526
[Fact]
545527
/// <summary>
546528
/// Test that analytics data is consistent with concurrent calls to get flags.
@@ -572,7 +554,7 @@ public async Task TestAnalyticsDataConsistencyWithConcurrentCallsToGetFlags()
572554
featuresDictionary.TryAdd($"Feature_{i}", 0);
573555
}
574556

575-
// When
557+
// When
576558
var tasks = new Task[numberOfThreads];
577559

578560
// Create numberOfThreads threads.
@@ -584,13 +566,13 @@ public async Task TestAnalyticsDataConsistencyWithConcurrentCallsToGetFlags()
584566
// Prepare an array of feature names of length callsPerThread.
585567
for (int j = 0; j < callsPerThread; j++)
586568
{
587-
// The feature names are randomly selected from the featuresDictionary and added to the
588-
// list of features, which represents the features that have been evaluated.
569+
// The feature names are randomly selected from the featuresDictionary and added to the
570+
// list of features, which represents the features that have been evaluated.
589571
string featureName = $"Feature_{new Random().Next(1, featuresDictionary.Count + 1)}";
590572
features[j] = featureName;
591573

592574
// The relevant key in the featuresDictionary is incremented to simulate an evaluation
593-
// to track for that feature.
575+
// to track for that feature.
594576
featuresDictionary[featureName]++;
595577
}
596578

Flagsmith.FlagsmithClient/FlagsmithClient.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ public FlagsmithClient(
150150
{
151151
if (!EnvironmentKey!.StartsWith("ser."))
152152
{
153-
throw new Exception(
154-
"ValueError: In order to use local evaluation, please generate a server key in the environment settings page."
153+
Console.WriteLine(
154+
"In order to use local evaluation, please generate a server key in the environment settings page."
155155
);
156156
}
157157

@@ -399,4 +399,4 @@ private IFlags GetIdentityFlagsFromDocument(string identifier, List<ITrait>? tra
399399

400400
~FlagsmithClient() => _pollingManager?.StopPoll();
401401
}
402-
}
402+
}

0 commit comments

Comments
 (0)