Skip to content

Commit

Permalink
Several changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kylemiller-rum committed Feb 6, 2024
1 parent eb9c18e commit 4911272
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 17 deletions.
4 changes: 2 additions & 2 deletions RDSService/RDSService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<AssemblyVersion>1.0.0.2</AssemblyVersion>
<FileVersion>1.0.0.2</FileVersion>
<AssemblyVersion>1.0.0.3</AssemblyVersion>
<FileVersion>1.0.0.3</FileVersion>
<LangVersion>default</LangVersion>
</PropertyGroup>

Expand Down
6 changes: 3 additions & 3 deletions RDSServiceClient/RDSServiceClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<Description>Client for RDSService running on a remote RDS connection broker</Description>
<PackageProjectUrl>https://github.com/kyle079/RDSService</PackageProjectUrl>
<RepositoryUrl>https://github.com/kyle079/RDSService</RepositoryUrl>
<Version>1.0.5</Version>
<AssemblyVersion>1.0.5</AssemblyVersion>
<FileVersion>1.0.5</FileVersion>
<Version>1.0.6</Version>
<AssemblyVersion>1.0.6</AssemblyVersion>
<FileVersion>1.0.6</FileVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>

Expand Down
17 changes: 10 additions & 7 deletions RDSServiceClient/RdsSessionService.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Net.Http.Json;
using Microsoft.Extensions.Options;
using RDSServiceLibrary;
using RDSServiceLibrary.Interfaces;
using RDSServiceLibrary.Models;
using System.Text.Json;

namespace RDSServiceClient
{
Expand All @@ -16,16 +16,16 @@ public RdsSessionService(HttpClient httpClient)
}

public Task<string> GetActiveManagementServer(string? connectionBroker = null) =>
ProcessRequest<string>("GetActiveManagementServer");
ProcessRequest<string>("RDS/GetActiveManagementServer");

public Task<List<RdsSession>> GetSessions(string? connectionBroker = null) =>

Check warning on line 21 in RDSServiceClient/RdsSessionService.cs

View workflow job for this annotation

GitHub Actions / build

Nullability of reference types in return type of 'Task<List<RdsSession>> RdsSessionService.GetSessions(string? connectionBroker = null)' doesn't match implicitly implemented member 'Task<List<RdsSession>?> IRdsSessionService.GetSessions(string? connectionBroker = null)'.
ProcessRequest<List<RdsSession>>("GetSessions");
ProcessRequest<List<RdsSession>>("RDS/GetSessions");

public Task<bool> DisconnectSession(SessionInfo sessionInfo, string? connectionBroker = null) =>
ProcessPostRequest("DisconnectSession", sessionInfo);
ProcessPostRequest("RDS/DisconnectSession", sessionInfo);

public Task<bool> LogOffSession(SessionInfo sessionInfo, string? connectionBroker = null) =>
ProcessPostRequest("LogOffSession", sessionInfo);
ProcessPostRequest("RDS/LogOffSession", sessionInfo);

private async Task<T> ProcessRequest<T>(string url)
{
Expand All @@ -46,9 +46,12 @@ private static async Task HandleError(HttpResponseMessage response)
{
if (!response.IsSuccessStatusCode)
{
var result = await response.Content.ReadFromJsonAsync<RdsServiceException>();
var content = await response.Content.ReadAsStringAsync();
if (!content.TrimStart().StartsWith("{"))
throw new RdsServiceException($"An error occurred calling the RDS service, {response.StatusCode}, {response.Content.ReadAsStringAsync()}");
var result = JsonSerializer.Deserialize<RdsServiceException>(content);
if (result != null) throw result;
throw new RdsServiceException("An error occurred calling the RDS service");
throw new RdsServiceException($"An error occurred calling the RDS service, {response.StatusCode}, {response.Content.ReadAsStringAsync()}");
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions RDSServiceLibrary/Models/RdsSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ namespace RDSServiceLibrary.Models;

public class RdsSession
{
public RdsSession() { }

Check warning on line 8 in RDSServiceLibrary/Models/RdsSession.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'CollectionName' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 8 in RDSServiceLibrary/Models/RdsSession.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'DomainName' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 8 in RDSServiceLibrary/Models/RdsSession.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'UserName' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 8 in RDSServiceLibrary/Models/RdsSession.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HostServer' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 8 in RDSServiceLibrary/Models/RdsSession.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'UnifiedSessionId' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 8 in RDSServiceLibrary/Models/RdsSession.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'CollectionName' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 8 in RDSServiceLibrary/Models/RdsSession.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'DomainName' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 8 in RDSServiceLibrary/Models/RdsSession.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'UserName' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 8 in RDSServiceLibrary/Models/RdsSession.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HostServer' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

public RdsSession(PSObject psObject)
{
CollectionName = psObject.Properties["CollectionName"].Value.ToString() ?? string.Empty;
Expand Down
6 changes: 3 additions & 3 deletions RDSServiceLibrary/RDSServiceLibrary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<Nullable>enable</Nullable>
<LangVersion>default</LangVersion>
<TargetFramework>net7.0</TargetFramework>
<Version>1.0.3</Version>
<AssemblyVersion>1.0.3</AssemblyVersion>
<FileVersion>1.0.3</FileVersion>
<Version>1.0.6</Version>
<AssemblyVersion>1.0.6</AssemblyVersion>
<FileVersion>1.0.6</FileVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>

Expand Down
1 change: 1 addition & 0 deletions RDSServiceTester/RDSServiceTester.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\RDSServiceClient\RDSServiceClient.csproj" />
<ProjectReference Include="..\RDSService\RDSService.csproj" />
</ItemGroup>

Expand Down
26 changes: 26 additions & 0 deletions RDSServiceTester/RdsServiceClientTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Text.Json;
using RDSServiceClient;
using Xunit.Abstractions;

namespace RDSServiceTester;

public class RdsServiceClientTest
{
private readonly ITestOutputHelper _testOutputHelper;

private readonly RdsSessionService _rdsSessionService =
new(new HttpClient { BaseAddress = new Uri("http://rdscb01.royal.corp:5555") });

public RdsServiceClientTest(ITestOutputHelper testOutputHelper)
{
_testOutputHelper = testOutputHelper;
}

[Fact]
public async Task GetSessions_ReturnsResults()
{
var result = await _rdsSessionService.GetSessions("rdscb01.royal.corp");
_testOutputHelper.WriteLine(JsonSerializer.Serialize(result));
Assert.NotNull(result);
}
}
3 changes: 1 addition & 2 deletions RDSServiceTester/RdsServiceTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Text.Json;
using System.Text.Json;
using RDSService.Services;
using RDSServiceLibrary.Models;
using Xunit.Abstractions;

namespace RDSServiceTester;
Expand Down

0 comments on commit 4911272

Please sign in to comment.