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

Merge spint/#10 into sprint/#11 #273

Merged
merged 20 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
bdb88f7
refactor: update connection string storage model
hoeyi Jun 9, 2024
d7bba60
build: add ozym identity bundle app and fix sql permission error
hoeyi Jun 11, 2024
af6c8fa
build: update referenced packages to latest versions
hoeyi Jun 11, 2024
4a122bc
fix: fix error caused by connection string pattern
hoeyi Jun 15, 2024
b5c082a
build: add installation scripts and documentation
hoeyi Jun 17, 2024
55ecb8b
docs: update description of metadata service registration method
hoeyi Jun 19, 2024
558e0b8
refactor(Blazor): revise startup code for Blazor for simplicity
hoeyi Jun 19, 2024
d290672
refactor(Blazor): remove hard-coded set of app urls
hoeyi Jun 19, 2024
0c0dcc9
build: remove command line set of environment variables in Dockerfiles
hoeyi Jun 20, 2024
0ee7835
build: remove unsupported launch profiles for Web/Api projects
hoeyi Jun 20, 2024
7dd6929
build: move docker files to dedicated directory
hoeyi Jun 20, 2024
2bd9da5
build: add elements to docker compose launch settings
hoeyi Jun 20, 2024
819b1df
repo: move scripts into dedicated directory
hoeyi Jun 20, 2024
5dc46f8
build: update migration scripts to handle file location change
hoeyi Jun 20, 2024
6f9a7ee
repo: add back auto-generated launchSettings.json
hoeyi Jun 20, 2024
fba08dd
build: combine code coverage scripts into single file
hoeyi Jun 20, 2024
7581bbe
repo: merge branch <build/refator-scripts>
hoeyi Aug 2, 2024
74de5c9
repo: prep identity system for cenrtalized management (#266)
hoeyi Aug 31, 2024
8a7168a
feat(Blazor): implement role-based authorization (#270)
hoeyi Sep 8, 2024
c1c01cb
repo: sync README changes to dev branch (#271)
hoeyi Sep 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -379,4 +379,5 @@ FodyWeavers.xsd
/Ozym.EntityModel/*bundle

# Ingore commit message text
.commit
.commit
*.env
23 changes: 0 additions & 23 deletions Add-Migration-OzymIdentity.bat

This file was deleted.

23 changes: 0 additions & 23 deletions Add-Migration-OzymWorks.bat

This file was deleted.

15 changes: 0 additions & 15 deletions Bundle-Migration-OzymWorks.bat

This file was deleted.

15 changes: 0 additions & 15 deletions Generate-CodeCoverageReport.bat

This file was deleted.

8 changes: 4 additions & 4 deletions Ozym.API.Test/Ozym.API.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="MSTest.TestAdapter" Version="3.4.3" />
<PackageReference Include="MSTest.TestFramework" Version="3.4.3" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
8 changes: 5 additions & 3 deletions Ozym.API/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ COPY . .
WORKDIR /src/Ozym.API

# Build the web api project.
RUN dotnet build "Ozym.API.csproj" -c Release -o /app/build
ARG CONFIGURATION
RUN dotnet build "Ozym.API.csproj" -c $CONFIGURATION -o /app/build

FROM build AS publish
RUN dotnet publish "Ozym.API.csproj" -c Release -o /app/publish /p:UseAppHost=false --property WarningLevel=1
ARG CONFIGURATION
RUN dotnet publish "Ozym.API.csproj" -c $CONFIGURATION -o /app/publish /p:UseAppHost=false --property WarningLevel=1

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Ozym.API.dll", "--environment=Development"]
ENTRYPOINT ["dotnet", "Ozym.API.dll"]
9 changes: 4 additions & 5 deletions Ozym.API/Ozym.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Asp.Versioning.Mvc" Version="8.0.0" />
<PackageReference Include="AutoMapper.Extensions.ExpressionMapping" Version="6.0.4" />
<PackageReference Include="Asp.Versioning.Mvc" Version="8.1.0" />
<PackageReference Include="Ichosys.Extensions.Configuration" Version="3.0.0.5070" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Serilog.Formatting.Compact" Version="2.0.0" />
<PackageReference Include="Serilog.Formatting.Compact" Version="3.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
</ItemGroup>

<ItemGroup>
Expand Down
70 changes: 34 additions & 36 deletions Ozym.API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using System;
using Asp.Versioning;
using System.Runtime.InteropServices;
using Microsoft.Extensions.Logging;

namespace Ozym.Api
{
Expand All @@ -20,14 +21,20 @@ public class Program
{
public static void Main(string[] args)
{

var builder = WebApplication.CreateBuilder(args);

var logger = ConvertFromSerilogILogger(logger: BuildLogger());
AppDomain.CurrentDomain.UnhandledException += (sender, eventArgs) =>
{
logger?.Log(
logLevel: LogLevel.Critical,
message: "Unhandled exception encountered.\n{Exception}",
eventArgs.ExceptionObject as Exception);
Console.WriteLine("Application terminating: {0}", eventArgs.IsTerminating);

// If Windows OS, secure appsetings.json is supported.
bool isWindowsOS = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
var config = BuildConfiguration(
logger, builder.Environment.EnvironmentName, configureSecureJson: isWindowsOS);
};

var config = BuildConfiguration(logger, builder.Environment.EnvironmentName);

// Add services to DI container
builder.Services.AddSingleton(implementationInstance: logger);
Expand Down Expand Up @@ -87,48 +94,39 @@ public static void Main(string[] args)
/// </summary>
/// <param name="logger">The <see cref="ILogger"/> to use.</param>
/// <param name="environment"></param>
/// <param name="configureSecureJson"></param>
/// <returns>An <see cref="IConfiguration"/>.</returns>
private static IConfigurationRoot BuildConfiguration(
ILogger logger,
string environment,
bool configureSecureJson = true)
string environment)
{
if (string.IsNullOrEmpty(environment))
throw new ArgumentNullException(paramName: nameof(environment));

IConfigurationRoot config;
if (configureSecureJson)
{
config = new ConfigurationBuilder()
.AddSecureJsonWritable(
path: $"appsettings.api.{environment}.json",
logger: logger,
IConfigurationRoot config = new ConfigurationBuilder()
.AddEnvironmentVariables()
.AddJsonWritable(
path: $"appsettings.{environment}.json",
optional: false,
reloadOnChange: true)
.AddUserSecrets<Program>()
.Build();

string rsaKeyAddress = "_file:RsaKeyContainer";
if (config[rsaKeyAddress] is null)
{
config[rsaKeyAddress] = $"E1EB57FA-8D2C-41CF-912A-DDBC39534A39";
config.Commit();
}

config["ConnectionStrings:OzymWorks"] = config["ConnectionStrings:OzymWorks"];
config["ConnectionStrings:OzymIdentity"] = config["ConnectionStrings:OzymIdentity"];
config.Commit();
}
else
{
config = new ConfigurationBuilder()
.AddJsonWritable(
path: $"appsettings.api.{environment}.json",
optional: false,
reloadOnChange: true)
.Build();
}
string connectionStringPattern = config["ConnectionStrings:__pattern__"] ??
throw new InvalidOperationException(
"Configuration key 'ConnectionStrings:__pattern__' is undefined.");

string dockerDatabaseService = config["DOCKER_DATABASE_SERVICE"]
?? throw new InvalidOperationException(
"Configuration key 'DOCKER_DATABASE_SERVICE' is undefined.");

config["ConnectionStrings:OzymWorks"] = string.Format(
connectionStringPattern,
dockerDatabaseService,
"OzymWorks",
"OzymAppUser",
config["OZYM_APP_PASSWORD"]);

config.Commit();
config.Reload();

return config;
}
Expand Down
14 changes: 3 additions & 11 deletions Ozym.API/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
{
"profiles": {
"Ozym.Api": {
"Ozym.API": {
"commandName": "Project",
"launchUrl": "swagger",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Docker": {
"commandName": "Docker",
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"environmentVariables": {
"ASPNETCORE_URLS": "https://+:443;http://+:80"
},
"publishAllPorts": true,
"useSSL": true
"applicationUrl": "https://localhost:50702;http://localhost:50703"
}
}
}
14 changes: 14 additions & 0 deletions Ozym.API/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"ConnectionStrings": {
"__pattern__": "Server={0};Database={1};User Id={2};Password='{3}';TrustServerCertificate=true",
"OzymWorks": "{set in program startup}",
"OzymIdentity": "{set in program startup}"
},
"DATABASE_PROVIDER": "SQL_SERVER"
}
9 changes: 0 additions & 9 deletions Ozym.API/appsettings.api.Development.json

This file was deleted.

9 changes: 0 additions & 9 deletions Ozym.API/appsettings.api.json

This file was deleted.

14 changes: 14 additions & 0 deletions Ozym.API/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"ConnectionStrings": {
"__pattern__": "Server={0};Database={1};User Id={2};Password='{3}';TrustServerCertificate=true",
"OzymWorks": "{set in program startup}",
"OzymIdentity": "{set in program startup}"
},
"DATABASE_PROVIDER": "SQL_SERVER"
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ namespace Ozym.Test.EntityModelService
/// <typeparam name="T"></typeparam>
public interface IModelCollectionServiceTest<T>
{
/// <summary>
/// Verifies the unit of work for generating the default <typeparamref name="T"/> model.
/// </summary>
/// <returns></returns>
Task GetDefault_Yields_Model_Instance();

/// <summary>
/// Verifies the unit of work for checking a model exists using a key value.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ namespace Ozym.Test.EntityModelService
public abstract partial class ModelCollectionServiceTest<T> : IModelCollectionServiceTest<T>
where T : class, new()
{
/// <inheritdoc/>
[TestMethod]
public virtual async Task GetDefault_Yields_Model_Instance()
{
var model = await GetModelService().GetDefaultAsync();

Assert.IsInstanceOfType(model, typeof(T));
}

/// <inheritdoc/>
[TestMethod]
public virtual void ModelExists_KeyIsPresent_Returns_True()
Expand Down
10 changes: 5 additions & 5 deletions Ozym.DAL.Test/Ozym.DAL.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.0">
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.6">
<TreatAsUsed>true</TreatAsUsed>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1">
<PackageReference Include="MSTest.TestAdapter" Version="3.4.3">
<TreatAsUsed>true</TreatAsUsed>
</PackageReference>
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="MSTest.TestFramework" Version="3.4.3" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
6 changes: 4 additions & 2 deletions Ozym.DAL/DataTransfer/Common/SecurityDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ public bool HasPerpetualPrice
Name = nameof(SecurityDto_SR.CurrentySymbol_Name),
Description = nameof(SecurityDto_SR.CurrentSymbol_Description),
ResourceType = typeof(SecurityDto_SR))]
#pragma warning disable CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
public string? CurrentSymbol { get; set; }
#pragma warning restore CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
}

[Noun(
Expand All @@ -169,8 +171,8 @@ public class SecurityDto : SecurityDtoBase

public SecurityDto()
{
Attributes = new HashSet<SecurityAttributeDto>();
Symbols = new HashSet<SecuritySymbolDto>();
Attributes = [];
Symbols = [];
}

public ICollection<SecurityAttributeDto> Attributes
Expand Down
Loading