Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FSSDK-9538] chore Cherry-pick & prep for 3.11.4 release #364

Merged
merged 21 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
8 changes: 4 additions & 4 deletions .github/workflows/csharp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Continuous Integration

on:
push:
branches: [ release-3.11.3 ]
branches: [ release-3.11.4 ]
pull_request:
branches: [ release-3.11.3 ]
branches: [ release-3.11.4 ]

jobs:
lintCodebase:
Expand Down Expand Up @@ -101,15 +101,15 @@ jobs:
integration_tests:
name: Run Integration Tests
needs: [ netFrameworksAndUnitTest, netStandard16, netStandard20 ]
uses: optimizely/csharp-sdk/.github/workflows/integration_test.yml@cb1c68ba0847f04ea54384c9b4500502c00681e6
uses: optimizely/csharp-sdk/.github/workflows/integration_test.yml@mike/pick-prep-3.11.4
secrets:
CI_USER_TOKEN: ${{ secrets.CI_USER_TOKEN }}
TRAVIS_COM_TOKEN: ${{ secrets.TRAVIS_COM_TOKEN }}

fullstack_production_suite:
name: Run Performance Tests
needs: [ netFrameworksAndUnitTest, netStandard16, netStandard20 ]
uses: optimizely/csharp-sdk/.github/workflows/integration_test.yml@cb1c68ba0847f04ea54384c9b4500502c00681e6
uses: optimizely/csharp-sdk/.github/workflows/integration_test.yml@mike/pick-prep-3.11.4
with:
FULLSTACK_TEST_REPO: ProdTesting
secrets:
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.CI_USER_TOKEN }}
EVENT_TYPE: ${{ github.event_name }}
GITHUB_CONTEXT: ${{ toJson(github) }}
REPO_SLUG: optimizely/fullstack-sdk-compatibility-suite@b45d804ce7670090341fcbae91f5daa39b03aa94
# REPO_SLUG: ${{ github.repository }}
PULL_REQUEST_SLUG: ${{ github.repository }}
UPSTREAM_REPO: ${{ github.repository }}
PULL_REQUEST_SHA: ${{ github.event.pull_request.head.sha }}
Expand All @@ -52,4 +52,6 @@ jobs:
HOME: 'home/runner'
run: |
echo "$GITHUB_CONTEXT"
home/runner/travisci-tools/trigger-script-with-status-update.sh
# Adding the FSC branch that does not include tests for ODP (before-odp)
# Remember to also disable the ODP_SERVER and ATS_API features in app-dot
home/runner/travisci-tools/trigger-script-with-status-update.sh before-odp
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Optimizely C# SDK Changelog

## 3.11.4
July 26, 2023

### Bug Fix
- Fix Last-Modified date & time format for If-Modified-Since ([#361](https://github.com/optimizely/csharp-sdk/pull/361)).

## 3.11.3
July 18, 2023

Expand Down
6 changes: 3 additions & 3 deletions OptimizelySDK.DemoApp/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.11.3.0")]
[assembly: AssemblyFileVersion("3.11.3.0")]
[assembly: AssemblyInformationalVersion("3.11.3")] // Used by Nuget.
[assembly: AssemblyVersion("3.11.4.0")]
[assembly: AssemblyFileVersion("3.11.4.0")]
[assembly: AssemblyInformationalVersion("3.11.4")] // Used by Nuget.

6 changes: 3 additions & 3 deletions OptimizelySDK.Net35/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.11.3.0")]
[assembly: AssemblyFileVersion("3.11.3.0")]
[assembly: AssemblyInformationalVersion("3.11.3")] // Used by Nuget.
[assembly: AssemblyVersion("3.11.4.0")]
[assembly: AssemblyFileVersion("3.11.4.0")]
[assembly: AssemblyInformationalVersion("3.11.4")] // Used by Nuget.
6 changes: 3 additions & 3 deletions OptimizelySDK.Net40/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.11.3.0")]
[assembly: AssemblyFileVersion("3.11.3.0")]
[assembly: AssemblyInformationalVersion("3.11.3")] // Used by Nuget.
[assembly: AssemblyVersion("3.11.4.0")]
[assembly: AssemblyFileVersion("3.11.4.0")]
[assembly: AssemblyInformationalVersion("3.11.4")] // Used by Nuget.
6 changes: 3 additions & 3 deletions OptimizelySDK.NetStandard16/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.11.3.0")]
[assembly: AssemblyFileVersion("3.11.3.0")]
[assembly: AssemblyInformationalVersion("3.11.3")] // Used by Nuget.
[assembly: AssemblyVersion("3.11.4.0")]
[assembly: AssemblyFileVersion("3.11.4.0")]
[assembly: AssemblyInformationalVersion("3.11.4")] // Used by Nuget.
6 changes: 3 additions & 3 deletions OptimizelySDK.NetStandard20/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.11.3.0")]
[assembly: AssemblyFileVersion("3.11.3.0")]
[assembly: AssemblyInformationalVersion("3.11.3")] // Used by Nuget.
[assembly: AssemblyVersion("3.11.4.0")]
[assembly: AssemblyFileVersion("3.11.4.0")]
[assembly: AssemblyInformationalVersion("3.11.4")] // Used by Nuget.
79 changes: 42 additions & 37 deletions OptimizelySDK.Tests/ConfigTest/HttpProjectConfigManagerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@
using OptimizelySDK.Tests.Utils;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;

namespace OptimizelySDK.Tests.DatafileManagement_Tests
Expand All @@ -39,6 +37,11 @@ public class HttpProjectConfigManagerTest
private Mock<TestNotificationCallbacks> NotificationCallbackMock =
new Mock<TestNotificationCallbacks>();

private const string ExpectedRfc1123DateTime = "Thu, 03 Nov 2022 16:00:00 GMT";

private readonly DateTime _pastLastModified =
new DateTimeOffset(new DateTime(2022, 11, 3, 16, 0, 0, DateTimeKind.Utc)).UtcDateTime;

[SetUp]
public void Setup()
{
Expand All @@ -54,7 +57,7 @@ public void Setup()
public void TestHttpConfigManagerRetrieveProjectConfigByURL()
{
var t = MockSendAsync(TestData.Datafile);
HttpProjectConfigManager httpManager = new HttpProjectConfigManager.Builder()
var httpManager = new HttpProjectConfigManager.Builder()
.WithUrl("https://cdn.optimizely.com/datafiles/QBw9gFM8oTn7ogY9ANCC1z.json")
.WithLogger(LoggerMock.Object)
.WithPollingInterval(TimeSpan.FromMilliseconds(1000))
Expand All @@ -67,7 +70,7 @@ public void TestHttpConfigManagerRetrieveProjectConfigByURL()
t.Wait(1000);

HttpClientMock.Verify(_ => _.SendAsync(
It.Is<System.Net.Http.HttpRequestMessage>(requestMessage =>
It.Is<HttpRequestMessage>(requestMessage =>
requestMessage.RequestUri.ToString() ==
"https://cdn.optimizely.com/datafiles/QBw9gFM8oTn7ogY9ANCC1z.json"
)));
Expand All @@ -77,9 +80,9 @@ public void TestHttpConfigManagerRetrieveProjectConfigByURL()
[Test]
public void TestHttpConfigManagerWithInvalidStatus()
{
var t = MockSendAsync(statusCode: HttpStatusCode.Forbidden);
MockSendAsync(statusCode: HttpStatusCode.Forbidden);

HttpProjectConfigManager httpManager = new HttpProjectConfigManager.Builder()
var httpManager = new HttpProjectConfigManager.Builder()
.WithUrl("https://cdn.optimizely.com/datafiles/QBw9gFM8oTn7ogY9ANCC1z.json")
.WithLogger(LoggerMock.Object)
.WithPollingInterval(TimeSpan.FromMilliseconds(1000))
Expand All @@ -102,24 +105,29 @@ public void TestSettingIfModifiedSinceInRequestHeader()
statusCode: HttpStatusCode.NotModified,
responseContentHeaders: new Dictionary<string, string>
{
{
"Last-Modified", new DateTime(2050, 10, 10).ToString("R")
},
{ "Last-Modified", _pastLastModified.ToString("r") },
}
);

var httpManager = new HttpProjectConfigManager.Builder()
.WithDatafile(string.Empty)
.WithSdkKey("QBw9gFM8oTn7ogY9ANCC1z")
.WithLogger(LoggerMock.Object)
.WithPollingInterval(TimeSpan.FromMilliseconds(1000))
.WithBlockingTimeoutPeriod(TimeSpan.FromMilliseconds(2000))
.WithStartByDefault()
.Build(defer: true);
httpManager.LastModifiedSince = new DateTime(2020, 4, 4).ToString("R");
httpManager.LastModifiedSince = _pastLastModified.ToString("r");
t.Wait(3000);

HttpClientMock.Verify(_ => _.SendAsync(
It.Is<HttpRequestMessage>(requestMessage =>
requestMessage.Headers.IfModifiedSince.HasValue &&
requestMessage.Headers.IfModifiedSince.Value.UtcDateTime.ToString("r") ==
ExpectedRfc1123DateTime
)), Times.Once);
LoggerMock.Verify(
_ => _.Log(LogLevel.DEBUG, "Set If-Modified-Since in request header."),
_ => _.Log(LogLevel.DEBUG,
$"Set If-Modified-Since in request header: {ExpectedRfc1123DateTime}"),
Times.AtLeastOnce);

httpManager.Dispose();
Expand All @@ -129,24 +137,24 @@ public void TestSettingIfModifiedSinceInRequestHeader()
public void TestSettingLastModifiedFromResponseHeader()
{
MockSendAsync(
datafile: TestData.Datafile,
statusCode: HttpStatusCode.OK,
responseContentHeaders: new Dictionary<string, string>
{
{
"Last-Modified", new DateTime(2050, 10, 10).ToString("R")
},
{ "Last-Modified", _pastLastModified.ToString("r") },
}
);
var httpManager = new HttpProjectConfigManager.Builder()
.WithUrl("https://cdn.optimizely.com/datafiles/QBw9gFM8oTn7ogY9ANCC1z.json")
.WithSdkKey("QBw9gFM8oTn7ogY9ANCC1z")
.WithLogger(LoggerMock.Object)
.WithPollingInterval(TimeSpan.FromMilliseconds(1000))
.WithBlockingTimeoutPeriod(TimeSpan.FromMilliseconds(500))
.WithStartByDefault()
.Build();

LoggerMock.Verify(
_ => _.Log(LogLevel.DEBUG, "Set LastModifiedSince from response header."),
_ => _.Log(LogLevel.DEBUG,
$"Set LastModifiedSince from response header: {ExpectedRfc1123DateTime}"),
Times.AtLeastOnce);

httpManager.Dispose();
Expand All @@ -157,16 +165,15 @@ public void TestHttpClientHandler()
{
var httpConfigHandler = HttpProjectConfigManager.HttpClient.GetHttpClientHandler();
Assert.IsTrue(httpConfigHandler.AutomaticDecompression ==
(System.Net.DecompressionMethods.Deflate |
System.Net.DecompressionMethods.GZip));
(DecompressionMethods.Deflate | DecompressionMethods.GZip));
}

[Test]
public void TestHttpConfigManagerRetrieveProjectConfigGivenEmptyFormatUseDefaultFormat()
{
var t = MockSendAsync(TestData.Datafile);

HttpProjectConfigManager httpManager = new HttpProjectConfigManager.Builder()
var httpManager = new HttpProjectConfigManager.Builder()
.WithSdkKey("QBw9gFM8oTn7ogY9ANCC1z")
.WithFormat("")
.WithLogger(LoggerMock.Object)
Expand All @@ -179,7 +186,7 @@ public void TestHttpConfigManagerRetrieveProjectConfigGivenEmptyFormatUseDefault
// Time is given here to avoid hanging-up in any worst case.
t.Wait(1000);
HttpClientMock.Verify(_ => _.SendAsync(
It.Is<System.Net.Http.HttpRequestMessage>(requestMessage =>
It.Is<HttpRequestMessage>(requestMessage =>
requestMessage.RequestUri.ToString() ==
"https://cdn.optimizely.com/datafiles/QBw9gFM8oTn7ogY9ANCC1z.json"
)));
Expand All @@ -191,7 +198,7 @@ public void TestHttpConfigManagerRetrieveProjectConfigBySDKKey()
{
var t = MockSendAsync(TestData.Datafile);

HttpProjectConfigManager httpManager = new HttpProjectConfigManager.Builder()
var httpManager = new HttpProjectConfigManager.Builder()
.WithSdkKey("QBw9gFM8oTn7ogY9ANCC1z")
.WithLogger(LoggerMock.Object)
.WithPollingInterval(TimeSpan.FromMilliseconds(1000))
Expand All @@ -201,7 +208,7 @@ public void TestHttpConfigManagerRetrieveProjectConfigBySDKKey()

t.Wait(1000);
HttpClientMock.Verify(_ => _.SendAsync(
It.Is<System.Net.Http.HttpRequestMessage>(requestMessage =>
It.Is<HttpRequestMessage>(requestMessage =>
requestMessage.RequestUri.ToString() ==
"https://cdn.optimizely.com/datafiles/QBw9gFM8oTn7ogY9ANCC1z.json"
)));
Expand All @@ -214,8 +221,7 @@ public void TestHttpConfigManagerRetrieveProjectConfigByFormat()
{
var t = MockSendAsync(TestData.Datafile);

HttpProjectConfigManager httpManager = new HttpProjectConfigManager.Builder()
.WithSdkKey("10192104166")
var httpManager = new HttpProjectConfigManager.Builder().WithSdkKey("10192104166")
.WithFormat("https://cdn.optimizely.com/json/{0}.json")
.WithLogger(LoggerMock.Object)
.WithPollingInterval(TimeSpan.FromMilliseconds(1000))
Expand All @@ -225,7 +231,7 @@ public void TestHttpConfigManagerRetrieveProjectConfigByFormat()

t.Wait(1000);
HttpClientMock.Verify(_ => _.SendAsync(
It.Is<System.Net.Http.HttpRequestMessage>(requestMessage =>
It.Is<HttpRequestMessage>(requestMessage =>
requestMessage.RequestUri.ToString() ==
"https://cdn.optimizely.com/json/10192104166.json"
)));
Expand All @@ -242,8 +248,7 @@ public void TestHttpProjectConfigManagerDoesntRaiseExceptionForDefaultErrorHandl
{
var t = MockSendAsync(TestData.Datafile);

HttpProjectConfigManager httpManager = new HttpProjectConfigManager.Builder()
.WithSdkKey("10192104166")
var httpManager = new HttpProjectConfigManager.Builder().WithSdkKey("10192104166")
.WithFormat("https://cdn.optimizely.com/json/{0}.json")
.WithLogger(LoggerMock.Object)
.WithPollingInterval(TimeSpan.FromMilliseconds(1000))
Expand All @@ -253,7 +258,7 @@ public void TestHttpProjectConfigManagerDoesntRaiseExceptionForDefaultErrorHandl

t.Wait(1000);
HttpClientMock.Verify(_ => _.SendAsync(
It.Is<System.Net.Http.HttpRequestMessage>(requestMessage =>
It.Is<HttpRequestMessage>(requestMessage =>
requestMessage.RequestUri.ToString() ==
"https://cdn.optimizely.com/json/10192104166.json"
)));
Expand All @@ -272,7 +277,7 @@ public void TestOnReadyPromiseResolvedImmediatelyWhenDatafileIsProvided()
var t = MockSendAsync(TestData.SimpleABExperimentsDatafile,
TimeSpan.FromMilliseconds(100));

HttpProjectConfigManager httpManager = new HttpProjectConfigManager.Builder()
var httpManager = new HttpProjectConfigManager.Builder()
// Revision - 15
.WithSdkKey("10192104166")
.WithDatafile(TestData.Datafile)
Expand Down Expand Up @@ -302,7 +307,7 @@ public void TestOnReadyPromiseWaitsForProjectConfigRetrievalWhenDatafileIsNotPro
var t = MockSendAsync(TestData.SimpleABExperimentsDatafile,
TimeSpan.FromMilliseconds(1000));

HttpProjectConfigManager httpManager = new HttpProjectConfigManager.Builder()
var httpManager = new HttpProjectConfigManager.Builder()
.WithSdkKey("QBw9gFM8oTn7ogY9ANCC1z")
.WithLogger(LoggerMock.Object)
.WithPollingInterval(TimeSpan.FromSeconds(2))
Expand Down Expand Up @@ -350,7 +355,7 @@ public void TestHttpConfigManagerDoesNotWaitForTheConfigWhenDeferIsTrue()
[Test]
public void TestHttpConfigManagerSendConfigUpdateNotificationWhenProjectConfigGetsUpdated()
{
var t = MockSendAsync(TestData.Datafile);
MockSendAsync(TestData.Datafile);

var httpManager = new HttpProjectConfigManager.Builder()
.WithSdkKey("QBw9gFM8oTn7ogY9ANCC1z")
Expand All @@ -373,7 +378,7 @@ public void TestHttpConfigManagerSendConfigUpdateNotificationWhenProjectConfigGe
[Test]
public void TestHttpConfigManagerDoesNotSendConfigUpdateNotificationWhenDatafileIsProvided()
{
var t = MockSendAsync(TestData.Datafile, TimeSpan.FromMilliseconds(100));
MockSendAsync(TestData.Datafile, TimeSpan.FromMilliseconds(100));

var httpManager = new HttpProjectConfigManager.Builder()
.WithSdkKey("QBw9gFM8oTn7ogY9ANCC1z")
Expand Down Expand Up @@ -533,7 +538,7 @@ public void TestAuthUrlWhenTokenProvided()
t.Wait(2000);

HttpClientMock.Verify(_ => _.SendAsync(
It.Is<System.Net.Http.HttpRequestMessage>(requestMessage =>
It.Is<HttpRequestMessage>(requestMessage =>
requestMessage.RequestUri.ToString() ==
"https://config.optimizely.com/datafiles/auth/QBw9gFM8oTn7ogY9ANCC1z.json"
)));
Expand All @@ -554,7 +559,7 @@ public void TestDefaultUrlWhenTokenNotProvided()
// it's to wait if SendAsync is not triggered.
t.Wait(2000);
HttpClientMock.Verify(_ => _.SendAsync(
It.Is<System.Net.Http.HttpRequestMessage>(requestMessage =>
It.Is<HttpRequestMessage>(requestMessage =>
requestMessage.RequestUri.ToString() ==
"https://cdn.optimizely.com/datafiles/QBw9gFM8oTn7ogY9ANCC1z.json"
)));
Expand All @@ -577,7 +582,7 @@ public void TestAuthenticationHeaderWhenTokenProvided()
t.Wait(2000);

HttpClientMock.Verify(_ => _.SendAsync(
It.Is<System.Net.Http.HttpRequestMessage>(requestMessage =>
It.Is<HttpRequestMessage>(requestMessage =>
requestMessage.Headers.Authorization.ToString() == "Bearer datafile1"
)));
httpManager.Dispose();
Expand All @@ -597,7 +602,7 @@ public void TestFormatUrlHigherPriorityThanDefaultUrl()
// it's to wait if SendAsync is not triggered.
t.Wait(2000);
HttpClientMock.Verify(_ => _.SendAsync(
It.Is<System.Net.Http.HttpRequestMessage>(requestMessage =>
It.Is<HttpRequestMessage>(requestMessage =>
requestMessage.RequestUri.ToString() ==
"http://customformat/QBw9gFM8oTn7ogY9ANCC1z.json"
)));
Expand Down
6 changes: 3 additions & 3 deletions OptimizelySDK.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.11.3.0")]
[assembly: AssemblyFileVersion("3.11.3.0")]
[assembly: AssemblyInformationalVersion("3.11.3")] // Used by Nuget.
[assembly: AssemblyVersion("3.11.4.0")]
[assembly: AssemblyFileVersion("3.11.4.0")]
[assembly: AssemblyInformationalVersion("3.11.4")] // Used by Nuget.
Loading
Loading