Skip to content

Commit 11745a4

Browse files
authored
Feat: Added DatafileAccessToken in ClientConfigHandler to read from App.config (#237)
1 parent c18f2d7 commit 11745a4

File tree

6 files changed

+18
-3
lines changed

6 files changed

+18
-3
lines changed

OptimizelySDK.Tests/App.config

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
format="https://cdn.optimizely.com/data/{0}.json"
1818
pollingInterval="2000"
1919
blockingTimeOutPeriod="10000"
20+
datafileAccessToken="testingtoken123"
2021
autoUpdate="true"
2122
defaultStart="true">
2223
</HttpProjectConfig>

OptimizelySDK.Tests/ClientConfigHandlerTest.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019, Optimizely
2+
* Copyright 2019-2020, Optimizely
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -38,6 +38,7 @@ public void TestHTTPAppConfigSection()
3838
Assert.AreEqual(httpSetting.PollingInterval, 2000);
3939
Assert.AreEqual(httpSetting.SDKKey, "43214321");
4040
Assert.AreEqual(httpSetting.Url, "www.testurl.com");
41+
Assert.AreEqual(httpSetting.DatafileAccessToken, "testingtoken123");
4142
}
4243

4344
[Test]

OptimizelySDK.Tests/OptimizelyFactoryTest.cs

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public void TestOptimizelyInstanceUsingConfigFile()
5353
Url = "www.testurl.com",
5454
LastModified = "",
5555
AutoUpdate = true,
56+
DatafileAccessToken = "testingtoken123",
5657
BlockingTimeout = TimeSpan.FromSeconds(10),
5758
PollingInterval = TimeSpan.FromSeconds(2)
5859
};

OptimizelySDK/ClientConfigHandler.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019, Optimizely
2+
* Copyright 2019-2020, Optimizely
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -61,6 +61,12 @@ public bool DefaultStart
6161
{
6262
get { return (bool)base["defaultStart"]; }
6363
}
64+
65+
[ConfigurationProperty("datafileAccessToken")]
66+
public string DatafileAccessToken
67+
{
68+
get { return (string)base["datafileAccessToken"]; }
69+
}
6470
}
6571

6672
public class BatchEventProcessorElement : ConfigurationElement

OptimizelySDK/OptimizelyFactory.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019, Optimizely
2+
* Copyright 2019-2020, Optimizely
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use file except in compliance with the License.
@@ -83,6 +83,7 @@ public static Optimizely NewDefaultInstance()
8383
.WithFormat(httpProjectConfigElement.Format)
8484
.WithPollingInterval(TimeSpan.FromMilliseconds(httpProjectConfigElement.PollingInterval))
8585
.WithBlockingTimeoutPeriod(TimeSpan.FromMilliseconds(httpProjectConfigElement.BlockingTimeOutPeriod))
86+
.WithAccessToken(httpProjectConfigElement.DatafileAccessToken)
8687
.WithLogger(logger)
8788
.WithErrorHandler(errorHandler)
8889
.WithNotificationCenter(notificationCenter)

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ User can provide variables using following procedure:
110110
format="https://cdn.optimizely.com/data/{0}.json"
111111
pollingInterval="2000"
112112
blockingTimeOutPeriod="10000"
113+
datafileAccessToken="testingtoken123"
113114
autoUpdate="true"
114115
defaultStart="true">
115116
</HttpProjectConfig>
@@ -205,6 +206,10 @@ This option enables user to provide a custom URL format to fetch the datafile.
205206

206207
This option is used to specify whether to start the config manager on initialization or not. If no value is provided, by default it is true and will start polling datafile from remote immediately.
207208

209+
##### Datafile access token
210+
211+
This option is used to provide token for datafile belonging to a secure environment.
212+
208213
## Development
209214

210215
### Unit tests

0 commit comments

Comments
 (0)