Skip to content

Commit

Permalink
VIH-9570 New audio recording filename for HRS (#613)
Browse files Browse the repository at this point in the history
* Change url for testing

* Add launch darkly service

* Update client

* Install launch darkly into test projects

* Logging to debug ld issue

* Use feature toggles stub

* Remove unneeded changes

* Bumping chart version

* Use passed in service id, case number and hearing ref id

* code coverage issues

* Rename

* add logging

* More logging

* Inject url into pod to fix feature flagging not working in pr environment

* Rename

* Strip out special characters

* Fix sonar cloud warnings

* Remove logging

* Remove Services from coverage exclusions

* Revert yaml changes after testing

---------

Co-authored-by: hmcts-ado-cnp <174565+hmcts-ado-cnp[bot]@users.noreply.github.com>
  • Loading branch information
oliver-scott and hmcts-ado-cnp authored Oct 27, 2023
1 parent ba503ac commit 13f5887
Show file tree
Hide file tree
Showing 33 changed files with 417 additions and 44 deletions.
2 changes: 1 addition & 1 deletion VideoApi/Testing.Common/Testing.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="Moq" Version="4.14.1" />
<PackageReference Include="NBuilder" Version="6.1.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.56.0.67649">
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.12.0.78982">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion VideoApi/VideoApi.Common/VideoApi.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.50.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.56.0.67649">
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.12.0.78982">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
6 changes: 3 additions & 3 deletions VideoApi/VideoApi.Common/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
},
"SonarAnalyzer.CSharp": {
"type": "Direct",
"requested": "[8.56.0.67649, )",
"resolved": "8.56.0.67649",
"contentHash": "u5klyn4PBAOe38/CoPbxGjuMqJQ5K0M7SA17H2DHgHyQ+neSU+abneRGjSQSVD76kbYXzG7E1/KQwTuj+nnMZw=="
"requested": "[9.12.0.78982, )",
"resolved": "9.12.0.78982",
"contentHash": "QxhfMFCNeZWP3gP/R8QM3MuDWm+Esj8Lt3oD61tid5TPuqsaKJtwMZNZWE2FOqqGuKlu3805o8MlkTWBL75skA=="
},
"System.IdentityModel.Tokens.Jwt": {
"type": "Direct",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public BookNewConferenceRequest()
{
Endpoints = new List<AddEndpointRequest>();
}


public string CaseTypeServiceId { get; set; }
public Guid HearingRefId { get; set; }
public string CaseType { get; set; }
public DateTime ScheduledDateTime { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion VideoApi/VideoApi.Contract/VideoApi.Contract.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.56.0.67649">
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.12.0.78982">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion VideoApi/VideoApi.DAL/VideoApi.DAL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="RandomStringCreator" Version="2.0.0" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.56.0.67649">
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.12.0.78982">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
59 changes: 56 additions & 3 deletions VideoApi/VideoApi.DAL/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@
},
"SonarAnalyzer.CSharp": {
"type": "Direct",
"requested": "[8.56.0.67649, )",
"resolved": "8.56.0.67649",
"contentHash": "u5klyn4PBAOe38/CoPbxGjuMqJQ5K0M7SA17H2DHgHyQ+neSU+abneRGjSQSVD76kbYXzG7E1/KQwTuj+nnMZw=="
"requested": "[9.12.0.78982, )",
"resolved": "9.12.0.78982",
"contentHash": "QxhfMFCNeZWP3gP/R8QM3MuDWm+Esj8Lt3oD61tid5TPuqsaKJtwMZNZWE2FOqqGuKlu3805o8MlkTWBL75skA=="
},
"Z.EntityFramework.Plus.EFCore": {
"type": "Direct",
Expand Down Expand Up @@ -153,6 +153,58 @@
"resolved": "2.8.26",
"contentHash": "OiKusGL20vby4uDEswj2IgkdchC1yQ6rwbIkZDVBPIR6al2b7n3pC91elBul9q33KaBgRKhbZH3+2Ur4fnWx2A=="
},
"LaunchDarkly.Cache": {
"type": "Transitive",
"resolved": "1.0.2",
"contentHash": "0bEnUVFVeW1TTDXb/bW6kS3FLQTLeGtw7Xh8yt6WNO56utVmtgcrMLvcnF6yeTn+N4FXrKfW09KkLNmK8YYQvw=="
},
"LaunchDarkly.CommonSdk": {
"type": "Transitive",
"resolved": "6.0.1",
"contentHash": "VznCYcyVawa93/hIv9i8mIGSskvMJ4rN9fkwkRU5GDnFlE69UFf2whQ5N3OrLmh4Or5dxJ0k7mnQEIxBf+eosw==",
"dependencies": {
"System.Collections.Immutable": "1.7.1"
}
},
"LaunchDarkly.EventSource": {
"type": "Transitive",
"resolved": "5.0.1",
"contentHash": "DN44Ry5M4lyrjiF7LEu0Ijco7Wm8R7mJopN+giYsYjkQlszsXdFvm3POoehIDAOtL1HHl5bZvF9k9xK034u3IA==",
"dependencies": {
"LaunchDarkly.Logging": "[1.0.1, 3.0.0)"
}
},
"LaunchDarkly.InternalSdk": {
"type": "Transitive",
"resolved": "3.1.2",
"contentHash": "wag5BzohWxzrAQN6eH6PPevfHcTBSnsbdDF6EBMeaAxcTL6hRB8T/QU7AwfUIp941KzS9fQusFo9OJLm+ZQ6BA==",
"dependencies": {
"LaunchDarkly.CommonSdk": "6.0.1",
"LaunchDarkly.Logging": "[2.0.0, 3.0.0)",
"System.Collections.Immutable": "1.7.1"
}
},
"LaunchDarkly.Logging": {
"type": "Transitive",
"resolved": "2.0.0",
"contentHash": "lsLKNqAZ7HIlkdTIrf4FetfRA1SUDE3WlaZQn79aSVkLjYWEhUhkDDK7hORGh4JoA3V2gXN+cIvJQax2uR/ijA==",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "6.0.0"
}
},
"LaunchDarkly.ServerSdk": {
"type": "Transitive",
"resolved": "7.1.0",
"contentHash": "k/ATty36RoXogJ286AJJ2KIXBnaLP1oh18yH0iW/ODnlAWXYpBa4iC/PwjJpeQRCG0n/V+brlMLnO2oco/yoOg==",
"dependencies": {
"LaunchDarkly.Cache": "1.0.2",
"LaunchDarkly.CommonSdk": "6.0.1",
"LaunchDarkly.EventSource": "5.0.1",
"LaunchDarkly.InternalSdk": "3.1.2",
"LaunchDarkly.Logging": "2.0.0",
"System.Collections.Immutable": "1.7.1"
}
},
"Microsoft.ApplicationInsights": {
"type": "Transitive",
"resolved": "2.21.0",
Expand Down Expand Up @@ -1878,6 +1930,7 @@
"type": "Project",
"dependencies": {
"Azure.Storage.Blobs": "[12.14.1, )",
"LaunchDarkly.ServerSdk": "[7.1.0, )",
"Microsoft.AspNetCore.Mvc.Abstractions": "[2.2.0, )",
"Microsoft.Extensions.Configuration": "[7.0.0, )",
"Polly": "[7.2.0, )",
Expand Down
2 changes: 1 addition & 1 deletion VideoApi/VideoApi.Domain/VideoApi.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ItemGroup>
<PackageReference Include="Enums.NET" Version="4.0.0" />
<PackageReference Include="RandomStringCreator" Version="2.0.0" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.56.0.67649">
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.12.0.78982">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion VideoApi/VideoApi.Events/VideoApi.Events.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.56.0.67649">
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.12.0.78982">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
1 change: 1 addition & 0 deletions VideoApi/VideoApi.IntegrationTests/Hooks/ConfigHooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ private static void RegisterStubs(IServiceCollection services)
services.AddScoped<IAudioPlatformService, AudioPlatformServiceStub>();
services.AddScoped<IConsultationService, ConsultationServiceStub>();
services.AddScoped<IVirtualRoomService, VirtualRoomServiceStub>();
services.AddSingleton<IFeatureToggles, FeatureTogglesStub>();
}

private static void RegisterAzuriteStorageService(TestContext context, IServiceCollection services)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Storage.Blobs" Version="12.14.1" />
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -16,7 +16,7 @@
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.11" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.56.0.67649">
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.12.0.78982">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
65 changes: 59 additions & 6 deletions VideoApi/VideoApi.IntegrationTests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
},
"coverlet.msbuild": {
"type": "Direct",
"requested": "[3.2.0, )",
"resolved": "3.2.0",
"contentHash": "lu/eJJpqJb4qy3BGPtDD/LI5RSOwXYYyRErTyaG0OTP69llzVK3FEe74hBQx0JtLUTLEVBfERV4uGYcE1Br2sg=="
"requested": "[6.0.0, )",
"resolved": "6.0.0",
"contentHash": "cUKI50VSVBqDQDFIdBnjN0Jk5JYhjtD0geP2BZZv71/ZrKORJXcLRswFsojI+cHdV+rFUL2XDJEpuhK3x1YqLA=="
},
"FluentAssertions": {
"type": "Direct",
Expand Down Expand Up @@ -68,9 +68,9 @@
},
"SonarAnalyzer.CSharp": {
"type": "Direct",
"requested": "[8.56.0.67649, )",
"resolved": "8.56.0.67649",
"contentHash": "u5klyn4PBAOe38/CoPbxGjuMqJQ5K0M7SA17H2DHgHyQ+neSU+abneRGjSQSVD76kbYXzG7E1/KQwTuj+nnMZw=="
"requested": "[9.12.0.78982, )",
"resolved": "9.12.0.78982",
"contentHash": "QxhfMFCNeZWP3gP/R8QM3MuDWm+Esj8Lt3oD61tid5TPuqsaKJtwMZNZWE2FOqqGuKlu3805o8MlkTWBL75skA=="
},
"VH.AcceptanceTests.Common": {
"type": "Direct",
Expand Down Expand Up @@ -241,6 +241,58 @@
"resolved": "1.11.46",
"contentHash": "dLMn4EVfJBHWmWK4Uh0XGD76FPLHI0qr2Tm0s1m/xmgiHb1JUb9zB8AzO8HtrkBBlMN6JfCUBYddhqC0hZNR+g=="
},
"LaunchDarkly.Cache": {
"type": "Transitive",
"resolved": "1.0.2",
"contentHash": "0bEnUVFVeW1TTDXb/bW6kS3FLQTLeGtw7Xh8yt6WNO56utVmtgcrMLvcnF6yeTn+N4FXrKfW09KkLNmK8YYQvw=="
},
"LaunchDarkly.CommonSdk": {
"type": "Transitive",
"resolved": "6.0.1",
"contentHash": "VznCYcyVawa93/hIv9i8mIGSskvMJ4rN9fkwkRU5GDnFlE69UFf2whQ5N3OrLmh4Or5dxJ0k7mnQEIxBf+eosw==",
"dependencies": {
"System.Collections.Immutable": "1.7.1"
}
},
"LaunchDarkly.EventSource": {
"type": "Transitive",
"resolved": "5.0.1",
"contentHash": "DN44Ry5M4lyrjiF7LEu0Ijco7Wm8R7mJopN+giYsYjkQlszsXdFvm3POoehIDAOtL1HHl5bZvF9k9xK034u3IA==",
"dependencies": {
"LaunchDarkly.Logging": "[1.0.1, 3.0.0)"
}
},
"LaunchDarkly.InternalSdk": {
"type": "Transitive",
"resolved": "3.1.2",
"contentHash": "wag5BzohWxzrAQN6eH6PPevfHcTBSnsbdDF6EBMeaAxcTL6hRB8T/QU7AwfUIp941KzS9fQusFo9OJLm+ZQ6BA==",
"dependencies": {
"LaunchDarkly.CommonSdk": "6.0.1",
"LaunchDarkly.Logging": "[2.0.0, 3.0.0)",
"System.Collections.Immutable": "1.7.1"
}
},
"LaunchDarkly.Logging": {
"type": "Transitive",
"resolved": "2.0.0",
"contentHash": "lsLKNqAZ7HIlkdTIrf4FetfRA1SUDE3WlaZQn79aSVkLjYWEhUhkDDK7hORGh4JoA3V2gXN+cIvJQax2uR/ijA==",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "6.0.0"
}
},
"LaunchDarkly.ServerSdk": {
"type": "Transitive",
"resolved": "7.1.0",
"contentHash": "k/ATty36RoXogJ286AJJ2KIXBnaLP1oh18yH0iW/ODnlAWXYpBa4iC/PwjJpeQRCG0n/V+brlMLnO2oco/yoOg==",
"dependencies": {
"LaunchDarkly.Cache": "1.0.2",
"LaunchDarkly.CommonSdk": "6.0.1",
"LaunchDarkly.EventSource": "5.0.1",
"LaunchDarkly.InternalSdk": "3.1.2",
"LaunchDarkly.Logging": "2.0.0",
"System.Collections.Immutable": "1.7.1"
}
},
"MicroElements.Swashbuckle.FluentValidation": {
"type": "Transitive",
"resolved": "5.7.0",
Expand Down Expand Up @@ -2824,6 +2876,7 @@
"type": "Project",
"dependencies": {
"Azure.Storage.Blobs": "[12.14.1, )",
"LaunchDarkly.ServerSdk": "[7.1.0, )",
"Microsoft.AspNetCore.Mvc.Abstractions": "[2.2.0, )",
"Microsoft.Extensions.Configuration": "[7.0.0, )",
"Polly": "[7.2.0, )",
Expand Down
15 changes: 14 additions & 1 deletion VideoApi/VideoApi.Services/AudioPlatformService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
Expand All @@ -29,8 +30,20 @@ public AudioPlatformService(IEnumerable<IWowzaHttpClient> wowzaClients, WowzaCon
_logger = logger;
ApplicationName = configuration.ApplicationName;
}

public string GetAudioIngestUrl(string hearingId) => $"{_configuration.StreamingEndpoint}{ApplicationName}/{hearingId}";

public string GetAudioIngestUrl(string serviceId, string caseNumber, string hearingId)
{
const string regex = "[^a-zA-Z0-9]";
const RegexOptions regexOptions = RegexOptions.None;
var timeout = TimeSpan.FromMilliseconds(500);

var sanitisedServiceId = Regex.Replace(serviceId, regex, "", regexOptions, timeout);
var sanitisedCaseNumber = Regex.Replace(caseNumber, regex, "", regexOptions, timeout);

return $"{_configuration.StreamingEndpoint}{ApplicationName}/{sanitisedServiceId}-{sanitisedCaseNumber}-{hearingId}";
}

public string ApplicationName { get; }

Expand Down
5 changes: 5 additions & 0 deletions VideoApi/VideoApi.Services/AudioPlatformServiceStub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ public string GetAudioIngestUrl(string hearingId)
{
return $"https://localhost.streaming.mediaServices.windows.net/{hearingId}";
}

public string GetAudioIngestUrl(string serviceId, string caseNumber, string hearingId)
{
return $"https://localhost.streaming.mediaServices.windows.net/{serviceId}-{caseNumber}-{hearingId}";
}

public string ApplicationName { get; }
}
Expand Down
5 changes: 5 additions & 0 deletions VideoApi/VideoApi.Services/Contracts/IAudioPlatformService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public interface IAudioPlatformService
/// </summary>
public string GetAudioIngestUrl(string hearingId);

/// <summary>
/// Builds the URI pointing to the location the wowza application that Kinly will stream the audio to
/// </summary>
public string GetAudioIngestUrl(string serviceId, string caseNumber, string hearingId);

/// <summary>
/// Wowza recorder application name
/// </summary>
Expand Down
41 changes: 41 additions & 0 deletions VideoApi/VideoApi.Services/FeatureToggles.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using System.Diagnostics.CodeAnalysis;
using LaunchDarkly.Logging;
using LaunchDarkly.Sdk;
using LaunchDarkly.Sdk.Server;
using LaunchDarkly.Sdk.Server.Interfaces;

namespace VideoApi.Services
{
public interface IFeatureToggles
{
public bool HrsIntegrationEnabled();
}

[ExcludeFromCodeCoverage]
public class FeatureToggles : IFeatureToggles
{
private readonly ILdClient _ldClient;
private readonly Context _context;
private const string LdUser = "vh-video-api";
private const string HrsIntegrationEnabledToggleKey = "hrs-integration";

public FeatureToggles(string sdkKey, string environmentName)
{
var config = Configuration.Builder(sdkKey)
.Logging(Components.Logging(Logs.ToWriter(Console.Out)).Level(LogLevel.Warn)).Build();
_context = Context.Builder(LdUser).Name(environmentName).Build();
_ldClient = new LdClient(config);
}

public bool HrsIntegrationEnabled()
{
if (!_ldClient.Initialized)
{
throw new InvalidOperationException("LaunchDarkly client not initialized");
}

return _ldClient.BoolVariation(HrsIntegrationEnabledToggleKey, _context);
}
}
}
12 changes: 12 additions & 0 deletions VideoApi/VideoApi.Services/FeatureTogglesStub.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace VideoApi.Services
{
public class FeatureTogglesStub : IFeatureToggles
{
public bool HrsIntegration { get; set; } = false;

public bool HrsIntegrationEnabled()
{
return HrsIntegration;
}
}
}
3 changes: 2 additions & 1 deletion VideoApi/VideoApi.Services/VideoApi.Services.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@

<ItemGroup>
<PackageReference Include="Azure.Storage.Blobs" Version="12.14.1" />
<PackageReference Include="LaunchDarkly.ServerSdk" Version="7.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Polly" Version="7.2.0" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.56.0.67649">
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.12.0.78982">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Loading

0 comments on commit 13f5887

Please sign in to comment.