Skip to content

VIH-11197 Remove Vodafone toggle and Kinly supplier #2348

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

Merged
merged 10 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from 9 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
2 changes: 1 addition & 1 deletion VideoWeb/VideoWeb.Common/Enums/Supplier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace VideoWeb.Common.Enums
{
public enum Supplier
{
Kinly = 1,
// Kinly = 1,
Vodafone = 2
}
}
9 changes: 1 addition & 8 deletions VideoWeb/VideoWeb.Common/FeatureToggles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace VideoWeb.Common;

public interface IFeatureToggles
{
public bool Vodafone();
bool AppInsightsProfilingEnabled();
}

Expand All @@ -17,7 +16,6 @@ public class FeatureToggles : IFeatureToggles
private readonly LdClient _ldClient;
private readonly Context _context;
private const string LdUser = "vh-video-web";
private const string VodafoneToggleKey = "vodafone";
private const string ProfilingKey = "enable-profiling";

public FeatureToggles(string sdkKey, string environmentName)
Expand All @@ -27,12 +25,7 @@ public FeatureToggles(string sdkKey, string environmentName)
_context = Context.Builder(LdUser).Name(environmentName).Build();
_ldClient = new LdClient(config);
}

public bool Vodafone()
{
return GetBoolValueWithKey(VodafoneToggleKey);
}


public bool AppInsightsProfilingEnabled()
{
return GetBoolValueWithKey(ProfilingKey);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ public interface IHashGenerator
string GenerateSelfTestTokenHash(string expiresOnUtc, string data);
}

public class HashGenerator : IHashGenerator
public class VodafoneHashGenerator : IHashGenerator
{
private readonly KinlyConfiguration _kinlyConfiguration;
private readonly VodafoneConfiguration _vodafoneConfiguration;

public HashGenerator(KinlyConfiguration kinlyConfiguration)
public VodafoneHashGenerator(VodafoneConfiguration vodafoneConfiguration)
{
_kinlyConfiguration = kinlyConfiguration;
_vodafoneConfiguration = vodafoneConfiguration;
}

public string GenerateSelfTestTokenHash(string expiresOnUtc, string data)
{
var asciiEncoding = new ASCIIEncoding();
var stringToHash = $"{expiresOnUtc}{data}";

var keyBytes = asciiEncoding.GetBytes(_kinlyConfiguration.SelfTestApiSecret);
var keyBytes = asciiEncoding.GetBytes(_vodafoneConfiguration.SelfTestApiSecret);
var messageBytes = asciiEncoding.GetBytes(stringToHash);

using (var hmac = new HMACSHA256(keyBytes))
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using VideoWeb.Common.Enums;
using VideoWeb.Common.Security.HashGen;
using VideoWeb.Common.Security.Tokens.Base;
using VideoWeb.Common.Security.Tokens.Kinly;
using VideoWeb.Common.Security.Tokens.Vodafone;

namespace VideoWeb.Common
Expand All @@ -27,15 +26,13 @@ public ISupplierPlatformService Create(Supplier supplier)
private IJwtTokenProvider GetJwtTokenProvider(Supplier supplier) =>
supplier switch
{
Supplier.Kinly => serviceProvider.GetService<IKinlyJwtTokenProvider>(),
Supplier.Vodafone => serviceProvider.GetService<IVodafoneJwtTokenProvider>(),
_ => throw new InvalidOperationException($"Unsupported supplier {supplier}")
};

private SupplierConfiguration GetSupplierConfiguration(Supplier supplier) =>
private VodafoneConfiguration GetSupplierConfiguration(Supplier supplier) =>
supplier switch
{
Supplier.Kinly => serviceProvider.GetRequiredService<IOptions<KinlyConfiguration>>().Value,
Supplier.Vodafone => serviceProvider.GetRequiredService<IOptions<VodafoneConfiguration>>().Value,
_ => throw new InvalidOperationException($"Unsupported supplier {supplier}")
};
Expand Down
4 changes: 2 additions & 2 deletions VideoWeb/VideoWeb.Common/VideoWeb.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<OutputType>Library</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BookingsApi.Client" Version="3.1.10" />
<PackageReference Include="BookingsApi.Client" Version="3.1.12-pr-0933-0009" />
<PackageReference Include="LaunchDarkly.ServerSdk" Version="8.5.0" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.22.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />
Expand All @@ -16,7 +16,7 @@
</PackageReference>
<PackageReference Include="StackExchange.Redis" Version="2.8.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.5.2" />
<PackageReference Include="VideoApi.Client" Version="3.1.10" />
<PackageReference Include="VideoApi.Client" Version="3.1.15-pr-0708-0007" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions VideoWeb/VideoWeb.Contract/VideoWeb.Contract.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BookingsApi.Client" Version="3.1.10" />
<PackageReference Include="BookingsApi.Client" Version="3.1.12-pr-0933-0009" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.32.0.97167">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="VideoApi.Client" Version="3.1.10" />
<PackageReference Include="VideoApi.Client" Version="3.1.15-pr-0708-0007" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VideoWeb.Common\VideoWeb.Common.csproj" />
Expand Down
26 changes: 0 additions & 26 deletions VideoWeb/VideoWeb.UnitTests/Builders/GenerateTemporaryTokens.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using VideoWeb.Common;
using VideoWeb.Common.Enums;
using VideoWeb.Common.Security.HashGen;
using VideoWeb.Common.Security.Tokens.Kinly;
using VideoWeb.Common.Security.Tokens.Vodafone;

namespace VideoWeb.UnitTests.Common
Expand All @@ -19,38 +18,14 @@ public class SupplierPlatformServiceFactoryTests
public void SetUp()
{
_serviceProvider = new Mock<IServiceProvider>();
var kinlyJwtTokenProvider = new Mock<IKinlyJwtTokenProvider>();
var vodafoneJwtTokenProvider = new Mock<IVodafoneJwtTokenProvider>();
var kinlyConfig = new KinlyConfiguration();
var vodafoneConfig = new VodafoneConfiguration();
var kinlyConfigOptions = new Mock<IOptions<KinlyConfiguration>>();
var vodafoneConfigOptions = new Mock<IOptions<VodafoneConfiguration>>();
kinlyConfigOptions.Setup(m => m.Value).Returns(kinlyConfig);
vodafoneConfigOptions.Setup(m => m.Value).Returns(vodafoneConfig);
_serviceProvider.Setup(x => x.GetService(typeof(IKinlyJwtTokenProvider))).Returns(kinlyJwtTokenProvider.Object);
_serviceProvider.Setup(x => x.GetService(typeof(IVodafoneJwtTokenProvider))).Returns(vodafoneJwtTokenProvider.Object);
_serviceProvider.Setup(x => x.GetService(typeof(IOptions<KinlyConfiguration>))).Returns(kinlyConfigOptions.Object);
_serviceProvider.Setup(x => x.GetService(typeof(IOptions<VodafoneConfiguration>))).Returns(vodafoneConfigOptions.Object);
}

[Test]
public void Should_create_supplier_platform_service_for_kinly()
{
// Arrange
var sut = new SupplierPlatformServiceFactory(_serviceProvider.Object);

// Act
var service = sut.Create(Supplier.Kinly);

// Assert
service.Should().BeOfType<SupplierPlatformService>();
service.Should().NotBeNull();
var tokenProvider = service.GetTokenProvider();
var supplierConfiguration = service.GetSupplierConfiguration();
tokenProvider.Should().BeAssignableTo<IKinlyJwtTokenProvider>();
supplierConfiguration.Should().BeAssignableTo<KinlyConfiguration>();
}

[Test]
public void Should_create_supplier_platform_service_for_vodafone()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public class SupplierPlatformServiceTests
public void SetUp()
{
_jwtTokenProvider = new Mock<IJwtTokenProvider>();
_supplierConfiguration = new KinlyConfiguration
_supplierConfiguration = new VodafoneConfiguration
{
HeartbeatUrlBase = "kinly-heartbeat-url-base"
HeartbeatUrlBase = "vodafone-heartbeat-url-base"
};

_sut = new SupplierPlatformService(_jwtTokenProvider.Object, _supplierConfiguration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,64 +23,29 @@ public class GetClientConfigurationSettingsTests
public void Setup()
{
_mocker = AutoMock.GetLoose();
_mocker.Mock<IFeatureToggles>()
.Setup(x => x.Vodafone())
.Returns(true);
}

[Test]
public void Should_return_response_with_settings_with_vodafone_enabled()
public void Should_return_response_with_settings()
{
// Arrange
var kinlyConfiguration = new KinlyConfiguration
{
JoinByPhoneFromDate = "2021-02-09"
};
var vodafoneConfiguration = new VodafoneConfiguration
{
JoinByPhoneFromDate = "2022-02-09"
};
var supplierConfigurations = new List<SupplierConfiguration>
{
kinlyConfiguration,
vodafoneConfiguration
};
var configSettingsController = SetUpController(supplierConfigurations);
_mocker.Mock<IFeatureToggles>()
.Setup(x => x.Vodafone())
.Returns(true);

// Act
var response = configSettingsController.GetClientConfigurationSettings();

// Assert
AssertResponse(response, supplierConfigurations);
}

[Test]
public void Should_return_response_with_settings_with_vodafone_disabled()
{
// Arrange
var kinlyConfiguration = new KinlyConfiguration
{
JoinByPhoneFromDate = "2021-02-09"
};
var supplierConfigurations = new List<SupplierConfiguration>
{
kinlyConfiguration
};
var configSettingsController = SetUpController(supplierConfigurations);
_mocker.Mock<IFeatureToggles>()
.Setup(x => x.Vodafone())
.Returns(false);

// Act
var response = configSettingsController.GetClientConfigurationSettings();

// Assert
AssertResponse(response, supplierConfigurations);
}

[Test]
public void should_return_bad_request_when_config_is_missing()
{
Expand All @@ -97,20 +62,14 @@ public void should_return_bad_request_when_config_is_missing()
{
VideoApiUrl = "https://vh-video-api/"
};

var kinlyConfiguration = new KinlyConfiguration
{
JoinByPhoneFromDate = "2021-02-09"
};


var vodafoneConfiguration = new VodafoneConfiguration
{
JoinByPhoneFromDate = "2022-02-09"
};

var supplierConfigurations = new List<SupplierConfiguration>
{
kinlyConfiguration,
vodafoneConfiguration
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class HeartbeatConfigurationControllerTests
private HeartbeatConfigurationController _sut;
private int _expiresInMinutes = 2;
private string _heartbeatUrlBase = "url";
private IOptions<KinlyConfiguration> _kinlyConfiguration;
private IOptions<VodafoneConfiguration> _vodafoneConfiguration;
private Mock<IJwtTokenProvider> _tokenProviderMock;
private Conference _conference;

Expand All @@ -33,7 +33,7 @@ public void Setup()
{
_mocker = AutoMock.GetLoose();

_kinlyConfiguration = Options.Create(new KinlyConfiguration()
_vodafoneConfiguration = Options.Create(new VodafoneConfiguration()
{
ExpiresInMinutes = _expiresInMinutes,
HeartbeatUrlBase = _heartbeatUrlBase
Expand All @@ -42,20 +42,20 @@ public void Setup()
_conference = new Conference
{
Id = Guid.NewGuid(),
Supplier = Supplier.Kinly
Supplier = Supplier.Vodafone
};

var kinlyPlatformServiceMock = new Mock<ISupplierPlatformService>();
kinlyPlatformServiceMock
var vodafonePlatformServiceMock = new Mock<ISupplierPlatformService>();
vodafonePlatformServiceMock
.Setup(x => x.GetSupplierConfiguration())
.Returns(_kinlyConfiguration.Value);
kinlyPlatformServiceMock
.Returns(_vodafoneConfiguration.Value);
vodafonePlatformServiceMock
.Setup(x => x.GetTokenProvider())
.Returns(_tokenProviderMock.Object);

_mocker.Mock<ISupplierPlatformServiceFactory>()
.Setup(x => x.Create(Supplier.Kinly))
.Returns(kinlyPlatformServiceMock.Object);
.Setup(x => x.Create(Supplier.Vodafone))
.Returns(vodafonePlatformServiceMock.Object);

_mocker.Mock<IConferenceService>()
.Setup(x => x.GetConference(It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void Setup()
hashGenerator.Setup(h => h.GenerateSelfTestTokenHash(It.IsAny<string>(), It.IsAny<string>())).Returns(token);
JwtTokenProvider.Setup(v => v.GenerateToken(It.IsAny<string>(), It.IsAny<int>())).Returns(token);

TokenController = new VideoWeb.Controllers.TokenController(hashGenerator.Object, new KinlyConfiguration() { HashExpiresInMinutes = 30, ExpiresInMinutes = 20 });
TokenController = new VideoWeb.Controllers.TokenController(hashGenerator.Object, new VodafoneConfiguration() { HashExpiresInMinutes = 30, ExpiresInMinutes = 20 });
}
}
}
Loading
Loading