Skip to content

Commit

Permalink
* Bug fixes to ApiClient and BearerTokenClient to support security mi…
Browse files Browse the repository at this point in the history
…croservice

* Add ServiceBricks.Xunit.Debug project
  • Loading branch information
Danny Logsdon committed May 5, 2024
1 parent b60234b commit 8ea1daa
Show file tree
Hide file tree
Showing 16 changed files with 114 additions and 24 deletions.
6 changes: 6 additions & 0 deletions ServiceBricksV1.sln
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceBricks.Storage.Azure
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceBricks.Storage.AzureDataTables.Debug", "src\V1\ServiceBricks.Storage.AzureDataTables.Debug\ServiceBricks.Storage.AzureDataTables.Debug.csproj", "{2A9F4A46-06B7-4645-B91E-AEEB8536B985}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceBricks.Xunit.Debug", "src\V1\ServiceBricks.Xunit.Debug\ServiceBricks.Xunit.Debug.csproj", "{E8CFF68F-4B25-49CF-A4FF-59F846254239}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -155,6 +157,10 @@ Global
{2A9F4A46-06B7-4645-B91E-AEEB8536B985}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A9F4A46-06B7-4645-B91E-AEEB8536B985}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A9F4A46-06B7-4645-B91E-AEEB8536B985}.Release|Any CPU.Build.0 = Release|Any CPU
{E8CFF68F-4B25-49CF-A4FF-59F846254239}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E8CFF68F-4B25-49CF-A4FF-59F846254239}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E8CFF68F-4B25-49CF-A4FF-59F846254239}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E8CFF68F-4B25-49CF-A4FF-59F846254239}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion src/V1/ServiceBricks.Debug/ServiceBricks.Debug.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>1.0.4</Version>
<Version>1.0.5</Version>
<Description>ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more.</Description>
<AssemblyTitle>ServiceBricks</AssemblyTitle>
<Authors>holomodular</Authors>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>1.0.4</Version>
<Version>1.0.5</Version>
<Description>ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more.</Description>
<AssemblyTitle>ServiceBricks.ServiceBus.Azure</AssemblyTitle>
<Authors>holomodular</Authors>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>1.0.4</Version>
<Version>1.0.5</Version>
<Description>ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more.</Description>
<AssemblyTitle>ServiceBricks.ServiceBus.Azure</AssemblyTitle>
<Authors>holomodular</Authors>
Expand Down Expand Up @@ -29,7 +29,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="ServiceBricks" Version="1.0.4" />
<PackageReference Include="ServiceBricks" Version="1.0.5" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>1.0.4</Version>
<Version>1.0.5</Version>
<Description>ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more.</Description>
<AssemblyTitle>ServiceBricks.Storage.AzureDataTables</AssemblyTitle>
<Authors>holomodular</Authors>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>1.0.4</Version>
<Version>1.0.5</Version>
<Description>ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more.</Description>
<AssemblyTitle>ServiceBricks.Storage.AzureDataTables</AssemblyTitle>
<Authors>holomodular</Authors>
Expand Down Expand Up @@ -30,7 +30,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="ServiceBricks" Version="1.0.4" />
<PackageReference Include="ServiceBricks" Version="1.0.5" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>1.0.4</Version>
<Version>1.0.5</Version>
<Description>ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more.</Description>
<AssemblyTitle>ServiceBricks.Storage.EntityFrameworkCore</AssemblyTitle>
<Authors>holomodular</Authors>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>1.0.4</Version>
<Version>1.0.5</Version>
<Description>ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more.</Description>
<AssemblyTitle>ServiceBricks.Storage.EntityFrameworkCore</AssemblyTitle>
<Authors>holomodular</Authors>
Expand Down Expand Up @@ -30,7 +30,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="ServiceBricks" Version="1.0.4" />
<PackageReference Include="ServiceBricks" Version="1.0.5" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>1.0.4</Version>
<Version>1.0.5</Version>
<Description>ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more.</Description>
<AssemblyTitle>ServiceBricks.Storage.MongoDb</AssemblyTitle>
<Authors>holomodular</Authors>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>1.0.4</Version>
<Version>1.0.5</Version>
<Description>ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more.</Description>
<AssemblyTitle>ServiceBricks.Storage.MongoDb</AssemblyTitle>
<Authors>holomodular</Authors>
Expand Down Expand Up @@ -30,7 +30,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="ServiceBricks" Version="1.0.4" />
<PackageReference Include="ServiceBricks" Version="1.0.5" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
Expand Down
88 changes: 88 additions & 0 deletions src/V1/ServiceBricks.Xunit.Debug/ServiceBricks.Xunit.Debug.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>1.0.5</Version>
<Description>ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more.</Description>
<AssemblyTitle>ServiceBricks.Xunit</AssemblyTitle>
<Authors>holomodular</Authors>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<Nullable>disable</Nullable>
<Copyright>Copyright © 2023 HoloModular LLC. All Rights Reserved. Visit http://HoloModular.com to learn more.</Copyright>
<PackageProjectUrl>http://ServiceBricks.com</PackageProjectUrl>
<PackageIcon>logo.png</PackageIcon>
<PackageTags>service;bricks;</PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>ServiceBricks.Xunit.snk</AssemblyOriginatorKeyFile>
<PackageReadmeFile>readme.md</PackageReadmeFile>
<ImplicitUsings>enable</ImplicitUsings>
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/holomodular/ServiceBricks</RepositoryUrl>
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\ServiceBricks.Xunit\ApiClientReturnResponseTest.cs" Link="ApiClientReturnResponseTest.cs" />
<Compile Include="..\ServiceBricks.Xunit\ApiClientTest.cs" Link="ApiClientTest.cs" />
<Compile Include="..\ServiceBricks.Xunit\ApiControllerTest.cs" Link="ApiControllerTest.cs" />
<Compile Include="..\ServiceBricks.Xunit\Constants.cs" Link="Constants.cs" />
<Compile Include="..\ServiceBricks.Xunit\ISystemManager.cs" Link="ISystemManager.cs" />
<Compile Include="..\ServiceBricks.Xunit\ITestManager.cs" Link="ITestManager.cs" />
<Compile Include="..\ServiceBricks.Xunit\MappingTest.cs" Link="MappingTest.cs" />
<Compile Include="..\ServiceBricks.Xunit\ServiceBricksStartup.cs" Link="ServiceBricksStartup.cs" />
<Compile Include="..\ServiceBricks.Xunit\ServiceBrickTestModule.cs" Link="ServiceBrickTestModule.cs" />
<Compile Include="..\ServiceBricks.Xunit\SystemManager.cs" Link="SystemManager.cs" />
<Compile Include="..\ServiceBricks.Xunit\TestManager.cs" Link="TestManager.cs" />
<Compile Include="..\ServiceBricks.Xunit\TestStartup.cs" Link="TestStartup.cs" />
<Compile Include="..\ServiceBricks.Xunit\Usings.cs" Link="Usings.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ServiceBricks.Debug\ServiceBricks.Debug.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.26" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="7.0.15" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>


</Project>
Binary file not shown.
4 changes: 2 additions & 2 deletions src/V1/ServiceBricks.Xunit/ServiceBricks.Xunit.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>1.0.4</Version>
<Version>1.0.5</Version>
<Description>ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more.</Description>
<AssemblyTitle>ServiceBricks.Xunit</AssemblyTitle>
<Authors>holomodular</Authors>
Expand Down Expand Up @@ -31,7 +31,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="ServiceBricks" Version="1.0.4" />
<PackageReference Include="ServiceBricks" Version="1.0.5" />
</ItemGroup>


Expand Down
10 changes: 4 additions & 6 deletions src/V1/ServiceBricks/Api/ApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ public virtual async Task<IResponseItem<TModel>> ExecuteAsync<TModel>(HttpReques
}
else
{
resp.AddMessage(ResponseMessage.CreateError(LocalizationResource.ERROR_REST_CLIENT));
_logger.LogWarning($"{result.StatusCode} {request.RequestUri}");
if (_apiConfig.ReturnResponseObject)
{
var content = await result.Content.ReadAsStringAsync();
Expand All @@ -99,17 +101,13 @@ public virtual async Task<IResponseItem<TModel>> ExecuteAsync<TModel>(HttpReques
{
resp.Item = JsonConvert.DeserializeObject<TModel>(content);
}
return resp;
}
else
{
resp.AddMessage(ResponseMessage.CreateError(LocalizationResource.ERROR_REST_CLIENT));
return resp;
}
return resp;
}
}
else
{
_logger.LogError("ApiClient SendAsync returned null");
resp.AddMessage(ResponseMessage.CreateError(LocalizationResource.ERROR_REST_CLIENT));
return resp;
}
Expand Down
2 changes: 0 additions & 2 deletions src/V1/ServiceBricks/Service/BearerTokenClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public virtual IResponseItem<AccessTokenResponse> GetAccessToken()
try
{
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, _bearerTokenCredentials.AuthorizationUrl);
request.Headers.Add(HEADER_CONTENTTYPE, CONTENTTYPE_APPLICATIONJSON);
string data = JsonConvert.SerializeObject(_bearerTokenCredentials.AccessTokenRequest);
request.Content = new StringContent(data, Encoding.UTF8, CONTENTTYPE_APPLICATIONJSON);
var result = base.Send(request);
Expand Down Expand Up @@ -124,7 +123,6 @@ public virtual async Task<IResponseItem<AccessTokenResponse>> GetAccessTokenAsyn
try
{
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, _bearerTokenCredentials.AuthorizationUrl);
request.Headers.Add(HEADER_CONTENTTYPE, CONTENTTYPE_APPLICATIONJSON);
string data = JsonConvert.SerializeObject(_bearerTokenCredentials.AccessTokenRequest);
request.Content = new StringContent(data, Encoding.UTF8, CONTENTTYPE_APPLICATIONJSON);
var result = await base.SendAsync(request);
Expand Down
2 changes: 1 addition & 1 deletion src/V1/ServiceBricks/ServiceBricks.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>1.0.4</Version>
<Version>1.0.5</Version>
<Description>ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more.</Description>
<AssemblyTitle>ServiceBricks</AssemblyTitle>
<Authors>holomodular</Authors>
Expand Down

0 comments on commit 8ea1daa

Please sign in to comment.