18 Commits

Author SHA1 Message Date
Natlinux 62a31d449b Merge pull request 'fix README' (#29) from feature/test into develop
Reviewed-on: Natlinux/DotNetAngular#29
2026-06-10 22:25:16 +00:00
Natlinux 66a360c63f fix README 2026-06-11 00:24:17 +02:00
Natlinux 42a45aeead Merge pull request 'update README' (#28) from feature/test into develop
Reviewed-on: Natlinux/DotNetAngular#28
2026-06-10 22:17:56 +00:00
Natlinux e482f40f8e update README 2026-06-11 00:17:16 +02:00
Natlinux fb10524ccc Merge pull request 'implement angular testing' (#27) from feature/tests into develop
Reviewed-on: Natlinux/DotNetAngular#27
2026-06-10 22:05:06 +00:00
Natlinux 391fa7ed99 implement angular testing 2026-06-11 00:04:16 +02:00
Natlinux c108ebd1e0 Merge pull request 'dotnet unit tests' (#26) from feature/tests into develop
Reviewed-on: Natlinux/DotNetAngular#26
2026-06-10 21:37:33 +00:00
Natlinux 5794991b30 dotnet unit tests 2026-06-10 23:37:08 +02:00
Natlinux 8c5b90a961 Merge pull request 'update Angular to latest Version' (#25) from feature/update into develop
Reviewed-on: Natlinux/DotNetAngular#25
2026-06-10 21:21:46 +00:00
Natlinux 5781c245e3 update Angular to latest Version 2026-06-10 23:21:29 +02:00
Natlinux f48dd0240f Merge pull request 'update nuget package to latest versions' (#24) from feature/update into develop
Reviewed-on: Natlinux/DotNetAngular#24
2026-06-10 20:37:25 +00:00
Natlinux 9fa7ebbc26 update nuget package to latest versions 2026-06-10 22:36:59 +02:00
Natlinux 8a57d43b20 Merge pull request 'clean up' (#23) from feature/update into develop
Reviewed-on: Natlinux/DotNetAngular#23
2026-06-10 20:05:51 +00:00
Natlinux ecbd7bc575 Merge branch 'develop' into feature/update 2026-06-10 20:05:40 +00:00
Natlinux e9b4a2bdc2 clean up 2026-06-10 22:05:11 +02:00
Natlinux d4a0deacdb Merge pull request 'update gitignore and README.md' (#22) from feature/update into develop
Reviewed-on: Natlinux/DotNetAngular#22
2026-06-10 20:04:51 +00:00
Natlinux 8f4c0f68b0 update gitignore and README.md
fix dark
remove ng-bootstrap
2026-06-10 22:03:14 +02:00
Natlinux 38d39c818e Merge pull request 'Merge pull request 'Merge pull request 'Merge pull request 'develop' (#14) from develop into main' (#15) from main into develop' (#20) from develop into main' (#21) from main into develop
Reviewed-on: Natlinux/DotNetAngular#21
2026-05-09 17:59:44 +00:00
64 changed files with 3329 additions and 2254 deletions
+478 -1
View File
@@ -1,5 +1,482 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET
project.lock.json
project.fragment.lock.json
artifacts/
# Tye
.tye/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
*.vbp
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
*.dsw
*.dsp
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# Visual Studio History (VSHistory) files
.vshistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
# VS Code files for those working on multiple tools
.vscode
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp
# JetBrains Rider
*.sln.iml
##
## Visual studio for Mac
##
# globs
Makefile.in
*.userprefs
*.usertasks
config.make
config.status
aclocal.m4
install-sh
autom4te.cache/
*.tar.gz
tarballs/
test-results/
# Mac bundle stuff
*.dmg
*.app
# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows shortcuts
*.lnk
# Rider Idea
bin/
obj/
/packages/
riderModule.iml
/_ReSharper.Caches/
# Production settings (contains secrets)
src/API/appsettings.Production.json
# JetBrains Rider IDE (user-specific)
.idea/
*.drawio
*.drawio.bkp
src/ClientApp/.angular/
src/ClientApp/dist/
src/ClientApp/coverage/
-13
View File
@@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DeviceTable">
<option name="columnSorters">
<list>
<ColumnSorterState>
<option name="column" value="Name" />
<option name="order" value="ASCENDING" />
</ColumnSorterState>
</list>
</option>
</component>
</project>
-4
View File
@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>
-10
View File
@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders>
<Path>src/ClientApp</Path>
</attachedFolders>
<explicitIncludes />
<explicitExcludes />
</component>
</project>
@@ -1,21 +0,0 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="HtmlUnknownTag" enabled="true" level="WARNING" enabled_by_default="true">
<option name="myValues">
<value>
<list size="7">
<item index="0" class="java.lang.String" itemvalue="nobr" />
<item index="1" class="java.lang.String" itemvalue="noembed" />
<item index="2" class="java.lang.String" itemvalue="comment" />
<item index="3" class="java.lang.String" itemvalue="noscript" />
<item index="4" class="java.lang.String" itemvalue="embed" />
<item index="5" class="java.lang.String" itemvalue="script" />
<item index="6" class="java.lang.String" itemvalue="ngb-toast" />
</list>
</value>
</option>
<option name="myCustomValuesEnabled" value="true" />
</inspection_tool>
</profile>
</component>
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RiderProjectSettingsUpdater">
<option name="singleClickDiffPreview" value="1" />
<option name="unhandledExceptionsIgnoreList" value="1" />
<option name="vcsConfiguration" value="3" />
</component>
</project>
File diff suppressed because one or more lines are too long
@@ -1,4 +0,0 @@
<changelist name="Uncommitted_changes_before_Update_at_09_03_26,_12_36_[Changes]" date="1773056200358" recycled="false" toDelete="true">
<option name="PATH" value="$PROJECT_DIR$/.idea/.idea.DotNetAngular/.idea/shelf/Uncommitted_changes_before_Update_at_09_03_26,_12_36_[Changes]/shelved.patch" />
<option name="DESCRIPTION" value="Uncommitted changes before Update at 09.03.26, 12:36 [Changes]" />
</changelist>
-6
View File
@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
-25
View File
@@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectTasksOptions">
<TaskOptions isEnabled="false">
<option name="arguments" value="$FileName$:$FileNameWithoutExtension$.css" />
<option name="checkSyntaxErrors" value="true" />
<option name="description" />
<option name="exitCodeBehavior" value="ERROR" />
<option name="fileExtension" value="scss" />
<option name="immediateSync" value="true" />
<option name="name" value="SCSS" />
<option name="output" value="$FileNameWithoutExtension$.css:$FileNameWithoutExtension$.css.map" />
<option name="outputFilters">
<array />
</option>
<option name="outputFromStdout" value="false" />
<option name="program" value="sass" />
<option name="runOnExternalChanges" value="true" />
<option name="scopeName" value="All Places" />
<option name="trackOnlyRoot" value="true" />
<option name="workingDir" value="$FileDir$" />
<envs />
</TaskOptions>
</component>
</project>
-406
View File
@@ -1,406 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoGeneratedRunConfigurationManager">
<projectFile profileName="Angular_dev">src/API/API.csproj</projectFile>
<projectFile profileName="Angular_test">src/API/API.csproj</projectFile>
<projectFile profileName="swagger_dev">src/API/API.csproj</projectFile>
<projectFile profileName="swagger_test">src/API/API.csproj</projectFile>
<projectFile>tests/Application.FunctionalTest/Application.FunctionalTest.csproj</projectFile>
<projectFile>tests/Application.UnitTest/Application.UnitTest.csproj</projectFile>
</component>
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="CMakeProjectFlavorService">
<option name="flavorId" value="CMakePlainProjectFlavor" />
</component>
<component name="CMakeSettings">
<configurations />
</component>
<component name="ChangeListManager">
<list default="true" id="1ac72a4a-52ad-4e70-9b15-c330b1ed3e7a" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/src/ClientApp/src/app/infrastructure/utilities/reset-password-validator.spec.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/.idea.DotNetAngular/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.DotNetAngular/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ClientApp/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/src/ClientApp/package-lock.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ClientApp/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/src/ClientApp/package.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ClientApp/src/app/app.component.spec.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/ClientApp/src/app/app.component.spec.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ClientApp/src/app/infrastructure/services/auth-service.spec.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/ClientApp/src/app/infrastructure/services/auth-service.spec.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ClientApp/src/app/infrastructure/services/dark-mode.service.spec.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/ClientApp/src/app/infrastructure/services/dark-mode.service.spec.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ClientApp/src/app/infrastructure/services/loading.service.spec.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/ClientApp/src/app/infrastructure/services/loading.service.spec.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ClientApp/src/app/infrastructure/services/reset-password.service.spec.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/ClientApp/src/app/infrastructure/services/reset-password.service.spec.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ClientApp/src/app/infrastructure/services/toast.service.spec.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/ClientApp/src/app/infrastructure/services/toast.service.spec.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ClientApp/src/app/infrastructure/services/user-store.service.spec.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/ClientApp/src/app/infrastructure/services/user-store.service.spec.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ClientApp/src/app/infrastructure/services/user.service.spec.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/ClientApp/src/app/infrastructure/services/user.service.spec.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ClientApp/src/app/infrastructure/utilities/password-validator.spec.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/ClientApp/src/app/infrastructure/utilities/password-validator.spec.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ClientApp/src/app/infrastructure/utilities/validate-form.spec.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/ClientApp/src/app/infrastructure/utilities/validate-form.spec.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/authentication/forget-password-popup/forget-password-popup.component.spec.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/authentication/forget-password-popup/forget-password-popup.component.spec.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/authentication/login/login.component.spec.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/authentication/login/login.component.spec.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/authentication/register/register.component.spec.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/authentication/register/register.component.spec.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/authentication/reset-password/reset-password.component.spec.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/authentication/reset-password/reset-password.component.spec.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/components/admin-dashboard/admin-dashboard.component.spec.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/components/admin-dashboard/admin-dashboard.component.spec.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/components/footer/footer.component.spec.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/components/footer/footer.component.spec.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/components/header/header.component.spec.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/components/header/header.component.spec.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/components/user-dashboard/user-dashboard.component.spec.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/components/user-dashboard/user-dashboard.component.spec.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/components/user-table/user-table.component.spec.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/components/user-table/user-table.component.spec.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/guards/admin.guard.spec.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/guards/admin.guard.spec.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/guards/authentication.guard.spec.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/guards/authentication.guard.spec.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/guards/guest.guard.spec.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/guards/guest.guard.spec.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/interceptors/token.interceptor.spec.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/ClientApp/src/app/presentation/interceptors/token.interceptor.spec.ts" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="DpaMonitoringSettings">
<option name="firstShow" value="false" />
</component>
<component name="EmbeddingIndexingInfo">
<option name="cachedIndexableFilesCount" value="1" />
<option name="fileBasedEmbeddingIndicesEnabled" value="true" />
</component>
<component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$" value="develop" />
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="HighlightingSettingsPerFile">
<setting file="file://$PROJECT_DIR$/dotnet-tools.json" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/src/ClientApp/package-lock.json" root0="SKIP_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/src/ClientApp/package.json" root0="FORCE_HIGHLIGHTING" />
</component>
<component name="McpProjectServerCommands">
<commands />
<urls />
</component>
<component name="MetaFilesCheckinStateConfiguration" checkMetaFiles="true" />
<component name="ProblemsViewState">
<option name="selectedTabId" value="CurrentFile" />
</component>
<component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 5
}</component>
<component name="ProjectId" id="397il1Wg7dxV8OktssHRVxsknl5" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
".NET Launch Settings Profile.API: Angular_dev.executor": "Run",
"RunOnceActivity.MCP Project settings loaded": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
"RunOnceActivity.cidr.known.project.marker": "true",
"RunOnceActivity.git.unshallow": "true",
"RunOnceActivity.readMode.enableVisualFormatting": "true",
"RunOnceActivity.typescript.service.memoryLimit.init": "true",
"cidr.known.project.marker": "true",
"codeWithMe.voiceChat.enabledByDefault": "false",
"com.intellij.ml.llm.matterhorn.ej.ui.settings.DefaultModelSelectionForGA.v1": "true",
"git-widget-placeholder": "feature/tests",
"git.auto.fetch.suggestion.counter": "1",
"junie.onboarding.icon.badge.shown": "true",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"settings.editor.selected.configurable": "vcs.Git",
"to.speed.mode.migration.done": "true",
"ts.external.directory.path": "/home/natlinux/RiderProjects/DotNetAngular/src/ClientApp/node_modules/typescript/lib",
"vue.rearranger.settings.migration": "true"
}
}]]></component>
<component name="RecapUselessUpdatesCounter">
<option name="suspendCountdown" value="0" />
</component>
<component name="RunManager" selected=".NET Launch Settings Profile.API: Angular_dev">
<configuration name="Application.FunctionalTest" type="DotNetProject" factoryName=".NET Project">
<option name="EXE_PATH" value="" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="" />
<option name="PASS_PARENT_ENVS" value="1" />
<option name="ENV_FILE_PATHS" value="" />
<option name="REDIRECT_INPUT_PATH" value="" />
<option name="MIXED_MODE_DEBUG" value="0" />
<option name="USE_MONO" value="0" />
<option name="RUNTIME_ARGUMENTS" value="" />
<option name="AUTO_ATTACH_CHILDREN" value="0" />
<option name="PROJECT_PATH" value="$PROJECT_DIR$/tests/Application.FunctionalTest/Application.FunctionalTest.csproj" />
<option name="PROJECT_EXE_PATH_TRACKING" value="1" />
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
<option name="PROJECT_KIND" value="DotNetCore" />
<option name="PROJECT_TFM" value="" />
<method v="2">
<option name="Build" />
</method>
</configuration>
<configuration name="Application.UnitTest" type="DotNetProject" factoryName=".NET Project">
<option name="EXE_PATH" value="" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="" />
<option name="PASS_PARENT_ENVS" value="1" />
<option name="ENV_FILE_PATHS" value="" />
<option name="REDIRECT_INPUT_PATH" value="" />
<option name="MIXED_MODE_DEBUG" value="0" />
<option name="USE_MONO" value="0" />
<option name="RUNTIME_ARGUMENTS" value="" />
<option name="AUTO_ATTACH_CHILDREN" value="0" />
<option name="PROJECT_PATH" value="$PROJECT_DIR$/tests/Application.UnitTest/Application.UnitTest.csproj" />
<option name="PROJECT_EXE_PATH_TRACKING" value="1" />
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
<option name="PROJECT_KIND" value="DotNetCore" />
<option name="PROJECT_TFM" value="" />
<method v="2">
<option name="Build" />
</method>
</configuration>
<configuration name="API: Angular_dev" type="LaunchSettings" factoryName=".NET Launch Settings Profile">
<option name="LAUNCH_PROFILE_PROJECT_FILE_PATH" value="$PROJECT_DIR$/src/API/API.csproj" />
<option name="LAUNCH_PROFILE_TFM" value="net9.0" />
<option name="LAUNCH_PROFILE_NAME" value="Angular_dev" />
<option name="USE_MONO" value="0" />
<option name="RUNTIME_ARGUMENTS" value="" />
<option name="GENERATE_APPLICATIONHOST_CONFIG" value="1" />
<option name="SHOW_IIS_EXPRESS_OUTPUT" value="0" />
<option name="SEND_DEBUG_REQUEST" value="1" />
<option name="ADDITIONAL_IIS_EXPRESS_ARGUMENTS" value="" />
<option name="AUTO_ATTACH_CHILDREN" value="0" />
<option name="MIXED_MODE_DEBUG" value="0" />
<method v="2">
<option name="Build" />
</method>
</configuration>
<configuration name="API: Angular_test" type="LaunchSettings" factoryName=".NET Launch Settings Profile">
<option name="LAUNCH_PROFILE_PROJECT_FILE_PATH" value="$PROJECT_DIR$/src/API/API.csproj" />
<option name="LAUNCH_PROFILE_TFM" value="net9.0" />
<option name="LAUNCH_PROFILE_NAME" value="Angular_test" />
<option name="USE_MONO" value="0" />
<option name="RUNTIME_ARGUMENTS" value="" />
<option name="GENERATE_APPLICATIONHOST_CONFIG" value="1" />
<option name="SHOW_IIS_EXPRESS_OUTPUT" value="0" />
<option name="SEND_DEBUG_REQUEST" value="1" />
<option name="ADDITIONAL_IIS_EXPRESS_ARGUMENTS" value="" />
<option name="AUTO_ATTACH_CHILDREN" value="0" />
<option name="MIXED_MODE_DEBUG" value="0" />
<method v="2">
<option name="Build" />
</method>
</configuration>
<configuration name="API: swagger_dev" type="LaunchSettings" factoryName=".NET Launch Settings Profile">
<option name="LAUNCH_PROFILE_PROJECT_FILE_PATH" value="$PROJECT_DIR$/src/API/API.csproj" />
<option name="LAUNCH_PROFILE_TFM" value="net9.0" />
<option name="LAUNCH_PROFILE_NAME" value="swagger_dev" />
<option name="USE_MONO" value="0" />
<option name="RUNTIME_ARGUMENTS" value="" />
<option name="GENERATE_APPLICATIONHOST_CONFIG" value="1" />
<option name="SHOW_IIS_EXPRESS_OUTPUT" value="0" />
<option name="SEND_DEBUG_REQUEST" value="1" />
<option name="ADDITIONAL_IIS_EXPRESS_ARGUMENTS" value="" />
<option name="AUTO_ATTACH_CHILDREN" value="0" />
<option name="MIXED_MODE_DEBUG" value="0" />
<method v="2">
<option name="Build" />
</method>
</configuration>
<configuration name="API: swagger_test" type="LaunchSettings" factoryName=".NET Launch Settings Profile">
<option name="LAUNCH_PROFILE_PROJECT_FILE_PATH" value="$PROJECT_DIR$/src/API/API.csproj" />
<option name="LAUNCH_PROFILE_TFM" value="net9.0" />
<option name="LAUNCH_PROFILE_NAME" value="swagger_test" />
<option name="USE_MONO" value="0" />
<option name="RUNTIME_ARGUMENTS" value="" />
<option name="GENERATE_APPLICATIONHOST_CONFIG" value="1" />
<option name="SHOW_IIS_EXPRESS_OUTPUT" value="0" />
<option name="SEND_DEBUG_REQUEST" value="1" />
<option name="ADDITIONAL_IIS_EXPRESS_ARGUMENTS" value="" />
<option name="AUTO_ATTACH_CHILDREN" value="0" />
<option name="MIXED_MODE_DEBUG" value="0" />
<method v="2">
<option name="Build" />
</method>
</configuration>
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="1ac72a4a-52ad-4e70-9b15-c330b1ed3e7a" name="Changes" comment="" />
<created>1770053658274</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1770053658274</updated>
<workItem from="1770053661221" duration="454000" />
<workItem from="1770054571766" duration="757000" />
<workItem from="1770057423308" duration="546000" />
<workItem from="1770057982196" duration="640000" />
<workItem from="1770062612983" duration="466000" />
<workItem from="1770204235235" duration="1487000" />
<workItem from="1770294298887" duration="1216000" />
<workItem from="1770295524085" duration="8729000" />
<workItem from="1770308954185" duration="9016000" />
<workItem from="1770369615769" duration="3456000" />
<workItem from="1770373101221" duration="2750000" />
<workItem from="1770377559983" duration="818000" />
<workItem from="1770379380312" duration="1252000" />
<workItem from="1770382791102" duration="1343000" />
<workItem from="1771239672703" duration="359000" />
<workItem from="1771331713319" duration="2451000" />
<workItem from="1771503996420" duration="1283000" />
<workItem from="1772664092787" duration="54000" />
<workItem from="1772664174287" duration="646000" />
<workItem from="1773053172796" duration="1432000" />
<workItem from="1773597121547" duration="689000" />
<workItem from="1773599776473" duration="3799000" />
<workItem from="1773605341198" duration="3147000" />
<workItem from="1773678089390" duration="1025000" />
<workItem from="1777730558210" duration="1422000" />
<workItem from="1778341026510" duration="1284000" />
<workItem from="1778343547356" duration="1390000" />
</task>
<task id="LOCAL-00001" summary="updating template">
<option name="closed" value="true" />
<created>1770055164655</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1770055164655</updated>
</task>
<task id="LOCAL-00002" summary="update to angular 20">
<option name="closed" value="true" />
<created>1770057870215</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1770057870215</updated>
</task>
<task id="LOCAL-00003" summary="login.component, register.component">
<option name="closed" value="true" />
<created>1770306489835</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1770306489835</updated>
</task>
<task id="LOCAL-00004" summary="update to dotnet 10">
<option name="closed" value="true" />
<created>1770318472632</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1770318472632</updated>
</task>
<task id="LOCAL-00005" summary="update nuget packages to new versions">
<option name="closed" value="true" />
<created>1771506336945</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1771506336945</updated>
</task>
<task id="LOCAL-00006" summary="update NuGet Package to new Version">
<option name="closed" value="true" />
<created>1773597809588</created>
<option name="number" value="00006" />
<option name="presentableId" value="LOCAL-00006" />
<option name="project" value="LOCAL" />
<updated>1773597809588</updated>
</task>
<task id="LOCAL-00007" summary="update Angular core to new version">
<option name="closed" value="true" />
<created>1773598259701</created>
<option name="number" value="00007" />
<option name="presentableId" value="LOCAL-00007" />
<option name="project" value="LOCAL" />
<updated>1773598259701</updated>
</task>
<task id="LOCAL-00008" summary="fix dropdown">
<option name="closed" value="true" />
<created>1773601314558</created>
<option name="number" value="00008" />
<option name="presentableId" value="LOCAL-00008" />
<option name="project" value="LOCAL" />
<updated>1773601314558</updated>
</task>
<task id="LOCAL-00009" summary="update angular and fix warnings">
<option name="closed" value="true" />
<created>1777739314669</created>
<option name="number" value="00009" />
<option name="presentableId" value="LOCAL-00009" />
<option name="project" value="LOCAL" />
<updated>1777739314669</updated>
</task>
<option name="localTasksCounter" value="10" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="UnityCheckinConfiguration" checkUnsavedScenes="true" />
<component name="UnityProjectConfiguration" hasMinimizedUI="false" />
<component name="Vcs.Log.Tabs.Properties">
<option name="RECENT_FILTERS">
<map>
<entry key="Branch">
<value>
<list>
<RecentGroup>
<option name="FILTER_VALUES">
<option value="feature/dotnet" />
</option>
</RecentGroup>
</list>
</value>
</entry>
</map>
</option>
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
</component>
<component name="VcsManagerConfiguration">
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
<MESSAGE value="updating template" />
<MESSAGE value="update to angular 20" />
<MESSAGE value="login.component, register.component" />
<MESSAGE value="update to dotnet 10" />
<MESSAGE value="update nuget packages to new versions" />
<MESSAGE value="update NuGet Package to new Version" />
<MESSAGE value="update Angular core to new version" />
<MESSAGE value="fix dropdown" />
<MESSAGE value="update nuget packages to new version" />
<MESSAGE value="update angular and fix warnings" />
<option name="LAST_COMMIT_MESSAGE" value="update angular and fix warnings" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<breakpoint enabled="true" type="DotNet_Exception_Breakpoints">
<properties exception="System.OperationCanceledException" breakIfHandledByOtherCode="false" displayValue="System.OperationCanceledException" />
<option name="timeStamp" value="1" />
</breakpoint>
<breakpoint enabled="true" type="DotNet_Exception_Breakpoints">
<properties exception="System.Threading.Tasks.TaskCanceledException" breakIfHandledByOtherCode="false" displayValue="System.Threading.Tasks.TaskCanceledException" />
<option name="timeStamp" value="2" />
</breakpoint>
<breakpoint enabled="true" type="DotNet_Exception_Breakpoints">
<properties exception="System.Threading.ThreadAbortException" breakIfHandledByOtherCode="false" displayValue="System.Threading.ThreadAbortException" />
<option name="timeStamp" value="3" />
</breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
<component name="XSLT-Support.FileAssociations.UIState">
<expand />
<select />
</component>
</project>
+209 -65
View File
@@ -1,88 +1,232 @@
# .NET + Angular Application Template
# DotNetAngular
This project is a full-stack web application Template combining **ASP.NET Core** for the backend and **Angular** for the frontend.
Full-Stack Webanwendung mit **ASP.NET Core (.NET 10)** und **Angular 21**, basierend auf **Clean Architecture** mit **PostgreSQL** als Datenbank.
## 🛠️ Technologies Used
---
- **Backend:** ASP.NET Core (.NET 10)
- **Frontend:** Angular
- **API Documentation:** Swagger (Swashbuckle)
## Architektur
## 🔐 Authentication (Register & Login)
```
src/
├── API # ASP.NET Core Web API (Controller, Middleware, Swagger)
├── Application # Anwendungslogik (Services, DTOs, Validatoren)
├── Domain # Entitäten, Repository-Interfaces, Value Objects
└── Infrastructure # EF Core DbContext, Repositories, Migrations
tests/
├── Application.UnitTest # xUnit-Unit-Tests
└── Application.FunctionalTest # xUnit-Funktionstests
```
The template includes a preconfigured user registration and authentication flow, designed as a solid baseline for production-ready applications.
### Patterns
- **Clean Architecture** mit 4 Schichten (API → Application → Domain ← Infrastructure)
- **Repository & Unit of Work** Pattern
- **Result Pattern** für explizite Erfolgs-/Fehlerrückgaben (keine Exceptions für Flow-Control)
- **FluentValidation** für Request-Validierung
- **JWT-Authentifizierung** mit Refresh-Token
- **Role-Based Access Control** (SuperAdmin, Admin, User)
- **Register:**
Creation of new user accounts via a dedicated API endpoint with server-side validation and secure password hashing.
---
- **Login:**
Token-based authentication using JWT (JSON Web Token). Upon successful authentication, a token is issued for authorized API access.
## Technologien
- **Authorization:**
Protected backend endpoints and frontend routes are secured using role- or policy-based access control.
| Bereich | Technologie | Version |
|---|---|---|
| **Backend** | ASP.NET Core | .NET 10 |
| **ORM** | Entity Framework Core | 10.0.7 |
| **Datenbank** | PostgreSQL (Npgsql) | 10.0.1 |
| **Auth** | JWT Bearer (System.IdentityModel.Tokens.Jwt) | 8.18.0 |
| **Validierung** | FluentValidation | 12.1.1 |
| **E-Mail** | MailKit / MimeKit | 4.16.0 |
| **API-Dokumentation** | Swagger (Swashbuckle) | 10.1.7 |
| **Frontend** | Angular (Standalone Components) | 21.2 |
| **UI-Framework** | Bootstrap + Bootstrap Icons | 5.3.8 / 1.13.1 |
| **JWT Frontend** | @auth0/angular-jwt | 5.2.0 |
| **Tests Backend** | xUnit v3 | 3.2.2 |
| **Tests Frontend** | Karma + Jasmine | 6.4 / 5.2 |
The authentication architecture is secure, extensible, and aligned with enterprise best practices.
---
## 🚀 Getting Started
## Features
### Prerequisites
- **Registrierung & Login** mit JWT-Token (Access + Refresh Token)
- **Passwort-Reset** per E-Mail (MailKit, HTML-Template)
- **Rollensystem**: SuperAdmin, Admin, User
- **Benutzerverwaltung**: CRUD, Rollenzuweisung/-entzug
- **Paginierte Benutzerliste**
- **Dark Mode**
- **Toast-Benachrichtigungen**
- **Route-Guards** (Authenticated, Admin, Guest)
- **Token-Interceptor** mit automatischem Refresh bei 401
---
## Voraussetzungen
- [.NET 10 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/10.0)
- [Node.js (LTS)](https://nodejs.org/)
- [Angular CLI ](https://angular.dev/)
- [Node.js (LTS)](https://nodejs.org/) (≥18)
- [Angular CLI](https://angular.dev/tools/cli)
- PostgreSQL (lokal oder per Docker)
- Ein Chrome/Chromium für Headless-Tests
### 🔧 Setup Instructions
---
1. **Install Angular dependencies**
⚠️ **Before starting the application for the first time**, run the following command in the `ClientApp` directory:
```bash
cd src/ClientApp
npm install
```
2. **Run the application**
Go back to the API folder and start the backend server:
```bash
cd src/API
dotnet run --launch-profile angular_dev
```
3. **Access the app**
- Angular frontend: [http://localhost:44492](http://localhost:44492)
- Swagger UI (API docs): [http://localhost:5184/swagger](http://localhost:5184/swagger)
## Setup
---
### 1. Repository klonen
## 🧪 Running Angular Tests
```bash
git clone <repo-url>
cd DotNetAngular
```
Angular frontend tests are set up using Karma + Jasmine. All test files follow the `.spec.ts` naming convention and are located alongside their respective components and services in `src/ClientApp/src/`.
### 2. Angular-Abhängigkeiten installieren
### Quick Start
```bash
cd src/ClientApp
npm install
cd ../..
```
```bash
cd src/ClientApp
npm test
```
### 3. Datenbank konfigurieren
### Headless/CI und Coverage
Die Verbindungsdaten werden über **User Secrets** gesetzt:
```bash
cd src/ClientApp
npm run test:coverage
```
The coverage report is generated under `src/ClientApp/coverage/` (HTML-Report in `index.html`).
```bash
cd src/API
dotnet user-secrets set "PostgreSqlSettings:Password" "<dein-passwort>"
dotnet user-secrets set "PostgreSqlSettings:Host" "localhost"
dotnet user-secrets set "EmailSettings:From" "deine-email@gmail.com"
dotnet user-secrets set "EmailSettings:Password" "<app-passwort>"
```
```bash
cd src/ClientApp
npm run test:ci
```
Note: For headless tests, a Chrome/Chromium runtime must be present on the machine.
> Standard-Datenbank: `template_db`, Standard-User: `natlinux` (aus `appsettings.json`).
### 4. Datenbank erstellen
```bash
dotnet ef database update
```
> `dotnet-ef` ist als lokales Tool in `dotnet-tools.json` definiert.
### 5. Anwendung starten
**Mit Angular-Dev-Proxy (empfohlen):**
```bash
cd src/API
dotnet run --launch-profile Angular_dev
```
- Angular Frontend: [http://localhost:44492](http://localhost:44492)
- API (direkt): [http://localhost:5184](http://localhost:5184) / [https://localhost:7091](https://localhost:7091)
**Nur API mit Swagger:**
```bash
dotnet run --launch-profile swagger_dev
```
- Swagger UI: [https://localhost:7091/swagger](https://localhost:7091/swagger)
---
## Tests
**Status:** 76 .NET-Tests + 132 Angular-Tests — alle grün.
### Backend (xUnit)
```bash
# Alle Tests
dotnet test
# Nur Unit-Tests
dotnet test tests/Application.UnitTest
# Nur Funktionstests
dotnet test tests/Application.FunctionalTest
```
Getestete Komponenten: `Result`/`PagedResult` (Edge Cases), `JwtService` (Token-Generierung, Refresh-Validierung), `EmailService` (SMTP-Interaktion), `AuthenticationService`.
### Frontend (Karma + Jasmine)
```bash
cd src/ClientApp
# Interaktiv (Browser)
npm test
# Headless CI
npm run test:ci
# Mit Coverage
npm run test:coverage
# Report: src/ClientApp/coverage/index.html
```
```bash
# Headless (benötigt Chromium-Pfad)
CHROME_BIN=/usr/bin/chromium npx ng test --no-watch --browsers=ChromeHeadless
```
Getestete Komponenten: `tokenInterceptor` (401-Refresh-Flow), `HeaderComponent` (Logout/Rolle/Username), `authService` (HTTP-Login/Register/Renew), `DarkModeService` (localStorage-Persistenz), `ToastComponent` (Auto-Dismiss), `PopupModalComponent` (Inputs/Outputs), `ForgetPasswordPopupComponent` (Close/Error/Success).
---
## NPM-Skripte (Frontend)
| Befehl | Beschreibung |
|---|---|
| `npm start` | `ng serve --port 44492` |
| `npm run build` | Produktions-Build |
| `npm test` | Tests (Watch-Modus) |
| `npm run test:ci` | Headless CI-Tests |
| `npm run test:coverage` | Tests mit Coverage |
| `npm run watch` | Dev-Build mit Watch |
---
## API-Endpunkte
Basis: `http://localhost:5184/api` (Dev) / `https://localhost:7091/api`
### Auth (`/api/auth`)
| Methode | Pfad | Auth | Beschreibung |
|---|---|---|---|
| POST | `/register` | - | Benutzer registrieren |
| POST | `/login` | - | Login (gibt JWT + Refresh-Token) |
| POST | `/refresh-token` | - | Access-Token erneuern |
| POST | `/send-reset-email/{email}` | - | Passwort-Reset-Mail senden |
| POST | `/reset-password` | - | Passwort zurücksetzen |
### User (`/api/user`)
| Methode | Pfad | Auth | Beschreibung |
|---|---|---|---|
| GET | `/` | Admin/SuperAdmin | Paginierte Benutzerliste |
| GET | `/{id}` | Authenticated | Benutzer per ID |
| PUT | `/` | Authenticated | Benutzer aktualisieren |
| DELETE | `/{id}` | Authenticated | Benutzer löschen (außer sich selbst) |
| POST | `/assign-role` | SuperAdmin | Rolle zuweisen |
| DELETE | `/revoke-role` | SuperAdmin | Rolle entziehen |
---
## Standard-Rollen
| Rolle | ID | Berechtigungen |
|---|---|---|
| SuperAdmin | 1 | Vollzugriff, Rollenverwaltung |
| Admin | 2 | Benutzerliste, Dashboard |
| User | 3 | Eigenes Dashboard, Profil bearbeiten |
Seed-Daten: SuperAdmin (ID 1) und Admin (ID 2) werden automatisch angelegt.
---
## Hinweise
- Der JWT-Secret-Key in `appsettings.json` ist ein Platzhalter und sollte in Produktion überschrieben werden (z.B. über User Secrets, Umgebungsvariablen oder `appsettings.Production.json`).
- E-Mail-Versand verwendet Gmail SMTP es wird ein [App-Passwort](https://support.google.com/accounts/answer/185833) benötigt.
+5 -5
View File
@@ -11,11 +11,11 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.7" />
<PackageReference Include="Microsoft.AspNetCore.SpaProxy" Version="10.0.7" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="10.1.7" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="10.1.7" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="10.1.7" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.9" />
<PackageReference Include="Microsoft.AspNetCore.SpaProxy" Version="10.0.9" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="10.2.1" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="10.2.1" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="10.2.1" />
</ItemGroup>
<ItemGroup>
+6 -6
View File
@@ -13,12 +13,12 @@
<ItemGroup>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="12.1.1" />
<PackageReference Include="MailKit" Version="4.16.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.7" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.7" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="10.0.7" />
<PackageReference Include="MimeKit" Version="4.16.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.18.0" />
<PackageReference Include="MailKit" Version="4.17.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.9" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.9" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="10.0.9" />
<PackageReference Include="MimeKit" Version="4.17.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.19.1" />
</ItemGroup>
</Project>
-42
View File
@@ -1,42 +0,0 @@
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
# Compiled output
/dist
/tmp
/out-tsc
/bazel-out
# Node
/node_modules
npm-debug.log
yarn-error.log
# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*
# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings
# System files
.DS_Store
Thumbs.db
-4
View File
@@ -1,4 +0,0 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
"recommendations": ["angular.ng-template"]
}
-20
View File
@@ -1,20 +0,0 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "ng serve",
"type": "chrome",
"request": "launch",
"preLaunchTask": "npm: start",
"url": "http://localhost:4200/"
},
{
"name": "ng test",
"type": "chrome",
"request": "launch",
"preLaunchTask": "npm: test",
"url": "http://localhost:9876/debug.html"
}
]
}
-42
View File
@@ -1,42 +0,0 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "start",
"isBackground": true,
"problemMatcher": {
"owner": "typescript",
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "(.*?)"
},
"endsPattern": {
"regexp": "bundle generation complete"
}
}
}
},
{
"type": "npm",
"script": "test",
"isBackground": true,
"problemMatcher": {
"owner": "typescript",
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "(.*?)"
},
"endsPattern": {
"regexp": "bundle generation complete"
}
}
}
}
]
}
-27
View File
@@ -1,27 +0,0 @@
# ClientApp
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 18.2.5.
## Development server
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files.
## Code scaffolding
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
## Build
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
## Running unit tests
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Running end-to-end tests
Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
+1681 -1215
View File
File diff suppressed because it is too large Load Diff
+15 -15
View File
@@ -12,17 +12,16 @@
},
"private": true,
"dependencies": {
"@angular/animations": "^21.2.4",
"@angular/common": "^21.2.4",
"@angular/compiler": "^21.2.4",
"@angular/core": "^21.2.4",
"@angular/forms": "^21.2.4",
"@angular/localize": "^21.2.4",
"@angular/platform-browser": "^21.2.4",
"@angular/platform-browser-dynamic": "^21.2.4",
"@angular/router": "^21.2.4",
"@angular/animations": "^22.0.1",
"@angular/common": "^22.0.1",
"@angular/compiler": "^22.0.1",
"@angular/core": "^22.0.1",
"@angular/forms": "^22.0.1",
"@angular/localize": "^22.0.1",
"@angular/platform-browser": "^22.0.1",
"@angular/platform-browser-dynamic": "^22.0.1",
"@angular/router": "^22.0.1",
"@auth0/angular-jwt": "^5.2.0",
"@ng-bootstrap/ng-bootstrap": "^20.0.0",
"bootstrap": "^5.3.8",
"bootstrap-icons": "^1.13.1",
"rxjs": "~7.8.0",
@@ -30,10 +29,11 @@
"zone.js": "~0.15.0"
},
"devDependencies": {
"@angular/build": "^21.2.2",
"@angular/cli": "^21.2.2",
"@angular/compiler-cli": "^21.2.4",
"@angular/build": "^22.0.0",
"@angular/cli": "^22.0.0",
"@angular/compiler-cli": "^22.0.1",
"@types/jasmine": "~5.1.0",
"istanbul-lib-instrument": "^6.0.3",
"jasmine-core": "~5.2.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
@@ -42,6 +42,6 @@
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"puppeteer": "^24.43.0",
"typescript": "~5.9.3"
"typescript": "~6.0.3"
}
}
}
+2 -1
View File
@@ -1,4 +1,4 @@
import {Component, inject} from '@angular/core';
import {Component, inject, ChangeDetectionStrategy} from '@angular/core';
import { RouterOutlet } from '@angular/router';
import {FooterComponent} from "./presentation/components/footer/footer.component";
import {ToastComponent} from "./presentation/shared/toast/toast.component";
@@ -10,6 +10,7 @@ import {DarkModeService} from "./infrastructure/services/dark-mode.service";
imports: [RouterOutlet, FooterComponent, ToastComponent, HeaderComponent],
templateUrl: './app.component.html',
standalone: true,
changeDetection: ChangeDetectionStrategy.Eager,
styleUrl: './app.component.scss'
})
export class AppComponent {
+2 -2
View File
@@ -4,10 +4,10 @@ import { provideRouter } from '@angular/router';
import { routes } from './app.routes';
import {provideHttpClient, withFetch, withInterceptors} from "@angular/common/http";
import {tokenInterceptor} from "./presentation/interceptors/token.interceptor";
import {provideClientHydration, withEventReplay} from "@angular/platform-browser";
import {provideClientHydration, withEventReplay, withNoIncrementalHydration} from "@angular/platform-browser";
export const appConfig: ApplicationConfig = {
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes),
provideHttpClient(withFetch(), withInterceptors([tokenInterceptor
])), provideClientHydration(withEventReplay())]
])), provideClientHydration(withEventReplay(), withNoIncrementalHydration())]
};
@@ -1,16 +1,27 @@
import {TestBed} from '@angular/core/testing';
import {provideHttpClient} from '@angular/common/http';
import {provideHttpClient, withXhr} from '@angular/common/http';
import {HttpTestingController, provideHttpClientTesting} from '@angular/common/http/testing';
import {AuthService} from './auth-service';
import {environment} from '../../../environments/environment.development';
describe('AuthService', () => {
let service: AuthService;
let httpTesting: HttpTestingController;
beforeEach(() => {
localStorage.clear();
TestBed.configureTestingModule({
providers: [provideHttpClient()]
providers: [
provideHttpClient(withXhr()),
provideHttpClientTesting(),
]
});
service = TestBed.inject(AuthService);
httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
httpTesting.verify();
});
it('should be created', () => {
@@ -42,4 +53,42 @@ describe('AuthService', () => {
service.signOut();
expect(service.isLoggedIn()).toBeFalse();
});
it('should POST to auth/login on login', () => {
const credentials = {email: 'test@example.com', password: 'password123'};
service.login(credentials).subscribe();
const req = httpTesting.expectOne(`${environment.baseUrl}auth/login`);
expect(req.request.method).toBe('POST');
expect(req.request.body).toEqual(credentials);
req.flush({value: {token: {accessToken: 'access', refreshToken: 'refresh'}}});
});
it('should POST to auth/register on register', () => {
const request = {username: 'newuser', email: 'new@example.com', password: 'StrongP@ss1'};
service.register(request).subscribe();
const req = httpTesting.expectOne(`${environment.baseUrl}auth/register`);
expect(req.request.method).toBe('POST');
expect(req.request.body).toEqual(request);
req.flush({value: 'User registered successfully'});
});
it('should POST to auth/refresh-token on renewToken', () => {
const refreshRequest = {userId: 1, refreshToken: 'refresh-token'};
service.renewToken(refreshRequest).subscribe();
const req = httpTesting.expectOne(`${environment.baseUrl}auth/refresh-token`);
expect(req.request.method).toBe('POST');
expect(req.request.body).toEqual(refreshRequest);
req.flush({value: {accessToken: 'new-access', refreshToken: 'new-refresh'}});
});
it('should return null for decodedToken when no token', () => {
localStorage.removeItem('token');
expect(service.decodedToken()).toBeNull();
});
});
@@ -37,7 +37,8 @@ export class AuthService implements IAuthService {
signOut() {
if (this.isBrowser) {
localStorage.clear();
localStorage.removeItem('token');
localStorage.removeItem('auth/refresh-token');
this.router.navigate(['/login']).catch(error => {
console.error('Navigation error:', error);
});
@@ -1,27 +1,66 @@
import {TestBed} from '@angular/core/testing';
import {PLATFORM_ID} from '@angular/core';
import {DarkModeService} from './dark-mode.service';
describe('DarkModeService', () => {
let service: DarkModeService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(DarkModeService);
localStorage.clear();
});
it('should be created', () => {
TestBed.configureTestingModule({});
const service = TestBed.inject(DarkModeService);
expect(service).toBeTruthy();
});
it('should toggle from null to dark', () => {
TestBed.configureTestingModule({});
const service = TestBed.inject(DarkModeService);
service.darkModeSignal.set(null);
service.updateDarkMode();
expect(service.darkModeSignal()).toBe('dark');
});
it('should toggle from dark to null', () => {
TestBed.configureTestingModule({});
const service = TestBed.inject(DarkModeService);
service.darkModeSignal.set('dark');
service.updateDarkMode();
expect(service.darkModeSignal()).toBeNull();
});
it('should start with null when localStorage is empty', () => {
TestBed.configureTestingModule({});
const service = TestBed.inject(DarkModeService);
expect(localStorage.getItem('darkModeSignal')).toBeNull();
expect(service.darkModeSignal()).toBeNull();
});
it('should read initial value from localStorage', () => {
localStorage.setItem('darkModeSignal', '"dark"');
TestBed.configureTestingModule({});
const service = TestBed.inject(DarkModeService);
TestBed.flushEffects();
expect(service.darkModeSignal()).toBe('dark');
});
it('should persist to localStorage when value changes', () => {
TestBed.configureTestingModule({});
const service = TestBed.inject(DarkModeService);
service.darkModeSignal.set('dark');
TestBed.flushEffects();
expect(localStorage.getItem('darkModeSignal')).toBe('"dark"');
service.darkModeSignal.set(null);
TestBed.flushEffects();
expect(localStorage.getItem('darkModeSignal')).toBe('null');
});
it('should do nothing in non-browser platform', () => {
TestBed.configureTestingModule({
providers: [{provide: PLATFORM_ID, useValue: 'server'}]
});
const serverService = TestBed.inject(DarkModeService);
serverService.updateDarkMode();
expect(serverService.darkModeSignal()).toBe('dark');
});
});
@@ -1,5 +1,5 @@
import {TestBed} from '@angular/core/testing';
import {provideHttpClient} from '@angular/common/http';
import {provideHttpClient, withXhr} from '@angular/common/http';
import {HttpTestingController, provideHttpClientTesting} from '@angular/common/http/testing';
import {ResetPasswordService} from './reset-password.service';
import {environment} from '../../../environments/environment.development';
@@ -11,7 +11,7 @@ describe('ResetPasswordService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [
provideHttpClient(),
provideHttpClient(withXhr()),
provideHttpClientTesting(),
]
});
@@ -8,7 +8,9 @@ export class ToastService {
toasts: Toast[] = [];
show(message: string, options: Partial<Toast> = {}) {
this.toasts.push({message, ...options});
const toast: Toast = {message, ...options};
this.toasts.push(toast);
setTimeout(() => this.remove(toast), toast.delay || 5000);
}
remove(toast: Toast) {
@@ -1,5 +1,5 @@
import {TestBed} from '@angular/core/testing';
import {provideHttpClient} from '@angular/common/http';
import {provideHttpClient, withXhr} from '@angular/common/http';
import {HttpTestingController, provideHttpClientTesting} from '@angular/common/http/testing';
import {UserService} from './user.service';
import {environment} from '../../../environments/environment.development';
@@ -11,7 +11,7 @@ describe('UserService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [
provideHttpClient(),
provideHttpClient(withXhr()),
provideHttpClientTesting(),
]
});
@@ -21,6 +21,6 @@
<span class="visually-hidden" role="status">Loading...</span>
}
Send</button>
<button type="button" class="btn btn-light" (click)="activeModal.close()">Close</button>
<button type="button" class="btn btn-light" (click)="close.emit()">Close</button>
</div>
</div>
@@ -1,6 +1,5 @@
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {ForgetPasswordPopupComponent} from './forget-password-popup.component';
import {NgbActiveModal} from '@ng-bootstrap/ng-bootstrap';
import {ResetPasswordService} from '../../../infrastructure/services/reset-password.service';
import {ToastService} from '../../../infrastructure/services/toast.service';
import {LoadingService} from '../../../infrastructure/services/loading.service';
@@ -11,19 +10,16 @@ describe('ForgetPasswordPopupComponent', () => {
let fixture: ComponentFixture<ForgetPasswordPopupComponent>;
let resetService: jasmine.SpyObj<ResetPasswordService>;
let toastService: jasmine.SpyObj<ToastService>;
let activeModal: jasmine.SpyObj<NgbActiveModal>;
beforeEach(async () => {
resetService = jasmine.createSpyObj('ResetPasswordService', ['sendResetPasswordLink']);
toastService = jasmine.createSpyObj('ToastService', ['show']);
activeModal = jasmine.createSpyObj('NgbActiveModal', ['close']);
await TestBed.configureTestingModule({
imports: [ForgetPasswordPopupComponent],
providers: [
{provide: ResetPasswordService, useValue: resetService},
{provide: ToastService, useValue: toastService},
{provide: NgbActiveModal, useValue: activeModal},
LoadingService,
]
}).compileComponents();
@@ -71,4 +67,51 @@ describe('ForgetPasswordPopupComponent', () => {
expect(toastService.show).toHaveBeenCalledWith('User not found', jasmine.any(Object));
});
it('should emit close event on successful send', () => {
const closeSpy = jasmine.createSpy();
component.close.subscribe(closeSpy);
resetService.sendResetPasswordLink.and.returnValue(of({value: 'Email sent'}));
component.resetPasswordEmail = 'test@example.com';
component.isValidEmail = true;
component.confirmToSend();
expect(closeSpy).toHaveBeenCalled();
});
it('should show success toast on successful send', () => {
resetService.sendResetPasswordLink.and.returnValue(of({value: 'Email sent'}));
component.resetPasswordEmail = 'test@example.com';
component.isValidEmail = true;
component.confirmToSend();
expect(toastService.show).toHaveBeenCalledWith('Email sent', jasmine.objectContaining({
classname: 'bg-success text-light'
}));
});
it('should clear email on successful send', () => {
resetService.sendResetPasswordLink.and.returnValue(of({value: 'Email sent'}));
component.resetPasswordEmail = 'test@example.com';
component.isValidEmail = true;
component.confirmToSend();
expect(component.resetPasswordEmail).toBe('');
});
it('should clear email on error', () => {
resetService.sendResetPasswordLink.and.returnValue(throwError(() => ({
error: {error: {message: 'Error'}}
})));
component.resetPasswordEmail = 'test@example.com';
component.isValidEmail = true;
component.confirmToSend();
expect(component.resetPasswordEmail).toBe('');
});
});
@@ -1,6 +1,5 @@
import {Component, inject} from '@angular/core';
import {Component, EventEmitter, inject, Output, ChangeDetectionStrategy} from '@angular/core';
import {FormsModule} from "@angular/forms";
import {NgbActiveModal} from "@ng-bootstrap/ng-bootstrap";
import {ResetPasswordService} from "../../../infrastructure/services/reset-password.service";
import {ToastService} from "../../../infrastructure/services/toast.service";
import {LoadingService} from "../../../infrastructure/services/loading.service";
@@ -11,19 +10,19 @@ import {LoadingService} from "../../../infrastructure/services/loading.service";
FormsModule
],
templateUrl: './forget-password-popup.component.html',
changeDetection: ChangeDetectionStrategy.Eager,
styleUrl: './forget-password-popup.component.scss'
})
export class ForgetPasswordPopupComponent {
public resetPasswordEmail!: string;
public isValidEmail!: boolean;
activeModal = inject(NgbActiveModal);
@Output() close = new EventEmitter<void>();
resetService = inject(ResetPasswordService);
toastService = inject(ToastService);
loadingService = inject(LoadingService);
constructor() { }
checkValidEmail(event: string) {
const value = event;
const emailPattern = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,3}$/;
@@ -45,7 +44,7 @@ export class ForgetPasswordPopupComponent {
delay: 3000
});
this.resetPasswordEmail = "";
this.activeModal.close();
this.close.emit();
},
error: (err) => {
this.loadingService.hide();
@@ -10,13 +10,16 @@
<div class="input-group">
<span class="input-group-text"><i class="bi bi-envelope-fill"></i></span>
<input [class.error]="loginForm.controls['email'].dirty && loginForm.hasError('required' , 'email')"
autocomplete="email" class="form-control" formControlName="email" id="email"
placeholder="E-Mail"
type="email">
autocomplete="email" class="form-control" formControlName="email" id="email"
placeholder="E-Mail"
type="email">
</div>
@if (loginForm.controls['email'].dirty && loginForm.hasError('pattern' , 'email')) {
<small
class="text-danger">*invalid E-Mail</small>
@if (loginForm.controls['email'].touched && loginForm.controls['email'].errors) {
@if (loginForm.controls['email'].errors['required']) {
<small class="text-danger">*Email is required</small>
} @else if (loginForm.controls['email'].errors['pattern']) {
<small class="text-danger">*invalid E-Mail</small>
}
}
<!-- Password -->
<div class="input-group mt-5">
@@ -28,15 +31,24 @@
placeholder="Password">
<span (click)="hideShowPassword()" class="input-group-text"><i class="bi {{eyeIcon}}"></i></span>
</div>
@if (loginForm.controls['password'].dirty && loginForm.hasError('required' , 'password')) {
<small
class="text-danger">*Password is required</small>
@if (loginForm.controls['password'].touched && loginForm.controls['password'].errors) {
@if (loginForm.controls['password'].errors['required']) {
<small class="text-danger">*Password is required</small>
}
}
<!-- Redirect links -->
<p class="m-1"><a (click)="openPopup()" class="fw-bold text-body" style="cursor: pointer;"><u>Forgot Password?</u></a></p>
@if (showForgotPasswordPopup) {
<div class="modal-backdrop fade show" style="z-index: 1050;"></div>
<div class="modal fade show d-block" tabindex="-1" style="z-index: 1055;">
<div class="modal-dialog modal-dialog-centered">
<app-forget-password-popup (close)="closePopup()"></app-forget-password-popup>
</div>
</div>
}
<div class="d-flex justify-content-center">
<button (click)="onLogin()" [disabled]="loginForm.invalid || loadingService.loading()" class="btn btn-lg btn-light"
type="submit">
type="submit">
@if (loadingService.loading()) {
<span class="spinner-border spinner-border-sm" aria-hidden="true"></span>
<span class="visually-hidden" role="status">Loading...</span>
@@ -45,30 +57,31 @@
</button>
</div>
<p class="text-center text-black-50 mt-5 mb-0">You don´t have an account? <a [routerLink]="['/register']"
class="fw-bold text-body"><u>Sign
up here!</u></a></p>
class="fw-bold text-body"><u>Sign
up here!</u></a></p>
</form>
</div>
<!-- other Sign in -->
<!-- <div class="text-center py-3">-->
<!-- <p class="text-center">or Sign in with</p>-->
<!-- <a class="px-2" href="https://www.google.com" target="_blank"><img-->
<!-- alt=""-->
<!-- height="40"-->
<!-- ngSrc="https://www.freepnglogos.com/uploads/google-logo-png/google-logo-png-suite-everything-you-need-know-about-google-newest-0.png"-->
<!-- width="40"/></a>-->
<!-- <a class="px-2" href="https://www.github.com" target="_blank"><img-->
<!-- alt="" height="40"-->
<!-- ngSrc="https://www.freepnglogos.com/uploads/512x512-logo-png/512x512-logo-github-icon-35.png"-->
<!-- width="40"/></a>-->
<!-- <a class="px-2" href="https://www.facebook.com" target="_blank"><img-->
<!-- alt=""-->
<!-- height="40"-->
<!-- ngSrc="https://www.freepnglogos.com/uploads/facebook-logo-icon/facebook-logo-icon-facebook-icon-png-images-icons-and-png-backgrounds-1.png"-->
<!-- width="40"/></a>-->
<!-- </div>-->
<!-- <div class="text-center py-3">-->
<!-- <p class="text-center">or Sign in with</p>-->
<!-- <a class="px-2" href="https://www.google.com" target="_blank"><img-->
<!-- alt=""-->
<!-- height="40"-->
<!-- ngSrc="https://www.freepnglogos.com/uploads/google-logo-png/google-logo-png-suite-everything-you-need-know-about-google-newest-0.png"-->
<!-- width="40"/></a>-->
<!-- <a class="px-2" href="https://www.github.com" target="_blank"><img-->
<!-- alt="" height="40"-->
<!-- ngSrc="https://www.freepnglogos.com/uploads/512x512-logo-png/512x512-logo-github-icon-35.png"-->
<!-- width="40"/></a>-->
<!-- <a class="px-2" href="https://www.facebook.com" target="_blank"><img-->
<!-- alt=""-->
<!-- height="40"-->
<!-- ngSrc="https://www.freepnglogos.com/uploads/facebook-logo-icon/facebook-logo-icon-facebook-icon-png-images-icons-and-png-backgrounds-1.png"-->
<!-- width="40"/></a>-->
<!-- </div>-->
</div>
</div>
</div>
</div>
</div>
@@ -5,7 +5,6 @@ import {ToastService} from '../../../infrastructure/services/toast.service';
import {UserStoreService} from '../../../infrastructure/services/user-store.service';
import {LoadingService} from '../../../infrastructure/services/loading.service';
import {ActivatedRoute, Router} from '@angular/router';
import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
import {of, throwError} from 'rxjs';
describe('LoginComponent', () => {
@@ -19,7 +18,6 @@ describe('LoginComponent', () => {
authService = jasmine.createSpyObj('AuthService', ['login', 'storeToken', 'storeRefreshToken', 'decodedToken']);
router = jasmine.createSpyObj('Router', ['navigate']);
toastService = jasmine.createSpyObj('ToastService', ['show']);
const modalService = jasmine.createSpyObj('NgbModal', ['open']);
await TestBed.configureTestingModule({
imports: [LoginComponent],
@@ -27,7 +25,6 @@ describe('LoginComponent', () => {
{provide: AuthService, useValue: authService},
{provide: Router, useValue: router},
{provide: ToastService, useValue: toastService},
{provide: NgbModal, useValue: modalService},
{provide: ActivatedRoute, useValue: {snapshot: {data: {}}, firstChild: null}},
UserStoreService,
LoadingService,
@@ -1,11 +1,10 @@
import {Component, inject} from '@angular/core';
import {Component, inject, ChangeDetectionStrategy} from '@angular/core';
import {FormBuilder, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms";
import {Router, RouterLink} from "@angular/router";
import ValidateForm from "../../../infrastructure/utilities/validate-form";
import {AuthService} from "../../../infrastructure/services/auth-service";
import {ToastService} from "../../../infrastructure/services/toast.service";
import {UserStoreService} from "../../../infrastructure/services/user-store.service";
import {NgbModal} from "@ng-bootstrap/ng-bootstrap";
import {ForgetPasswordPopupComponent} from "../forget-password-popup/forget-password-popup.component";
import {LoadingService} from "../../../infrastructure/services/loading.service";
import {Title} from "@angular/platform-browser";
@@ -14,10 +13,12 @@ import {Title} from "@angular/platform-browser";
selector: 'app-login',
imports: [
ReactiveFormsModule,
RouterLink
RouterLink,
ForgetPasswordPopupComponent
],
templateUrl: './login.component.html',
standalone: true,
changeDetection: ChangeDetectionStrategy.Eager,
styleUrl: './login.component.scss'
})
export class LoginComponent {
@@ -26,13 +27,13 @@ export class LoginComponent {
type: string = "password";
isText: boolean = true;
eyeIcon: string = "bi-eye-slash"
showForgotPasswordPopup = false;
loadingService = inject(LoadingService);
authenticateService = inject(AuthService)
toastService = inject(ToastService);
userStore = inject(UserStoreService);
private router = inject(Router)
modalService = inject(NgbModal)
title = inject(Title)
constructor(private formBuilder: FormBuilder) {
@@ -49,7 +50,11 @@ export class LoginComponent {
}
openPopup() {
this.modalService.open(ForgetPasswordPopupComponent, {centered: true ,backdrop: 'static' });
this.showForgotPasswordPopup = true;
}
closePopup() {
this.showForgotPasswordPopup = false;
}
onLogin() {
@@ -17,20 +17,14 @@
</div>
<div>
@if (registerForm.controls['username'].touched && registerForm.controls['username'].errors) {
@if (registerForm.controls['username'].errors['minlength']) {
<small class="text-danger">
*Username must be at least 3 characters long
</small>
}
@if (registerForm.controls['username'].errors['maxlength']) {
<small class="text-danger">
*Username could contain max 20 characters long
</small>
}
@if (registerForm.controls['username'].errors['pattern']) {
<small class="text-danger">
*Username could contain only letters, numbers and underscore
</small>
@if (registerForm.controls['username'].errors['required']) {
<small class="text-danger">*Username is required</small>
} @else if (registerForm.controls['username'].errors['minlength']) {
<small class="text-danger">*Username must be at least 3 characters long</small>
} @else if (registerForm.controls['username'].errors['maxlength']) {
<small class="text-danger">*Username could contain max 20 characters long</small>
} @else if (registerForm.controls['username'].errors['pattern']) {
<small class="text-danger">*Username could contain only letters, numbers and underscore</small>
}
}
</div>
@@ -43,9 +37,12 @@
name="email" placeholder="E-Mail"
type="email">
</div>
@if (registerForm.controls['email'].dirty && registerForm.hasError('pattern' , 'email')) {
<small
class="text-danger">*invalid E-Mail</small>
@if (registerForm.controls['email'].touched && registerForm.controls['email'].errors) {
@if (registerForm.controls['email'].errors['required']) {
<small class="text-danger">*Email is required</small>
} @else if (registerForm.controls['email'].errors['pattern']) {
<small class="text-danger">*invalid E-Mail</small>
}
}
<!-- Password -->
@@ -60,64 +57,52 @@
</div>
<div>
@if (registerForm.controls['password'].touched && registerForm.controls['password'].errors) {
@if (registerForm.controls['password'].errors['minlength']) {
<small class="text-danger">
*Password must be at least 10 characters long
</small>
}
@if (registerForm.controls['password'].errors['uppercase']) {
<small class="text-danger">
*Password must contain at least one uppercase letter
</small>
}
@if (registerForm.controls['password'].errors['lowercase']) {
<small class="text-danger">
*Password must contain at least one lowercase letter
</small>
}
@if (registerForm.controls['password'].errors['number']) {
<small class="text-danger">
*Password must contain at least one number
</small>
}
@if (registerForm.controls['password'].errors['special']) {
<small class="text-danger">
*Password must contain at least one special character
</small>
@if (registerForm.controls['password'].errors['required']) {
<small class="text-danger">*Password is required</small>
} @else if (registerForm.controls['password'].errors['minlength']) {
<small class="text-danger">*Password must be at least 10 characters long</small>
} @else if (registerForm.controls['password'].errors['uppercase']) {
<small class="text-danger">*Password must contain at least one uppercase letter</small>
} @else if (registerForm.controls['password'].errors['lowercase']) {
<small class="text-danger">*Password must contain at least one lowercase letter</small>
} @else if (registerForm.controls['password'].errors['number']) {
<small class="text-danger">*Password must contain at least one number</small>
} @else if (registerForm.controls['password'].errors['special']) {
<small class="text-danger">*Password must contain at least one special character</small>
}
}
</div>
<!-- Checkbox Terms -->
<!-- <div class="form-check d-flex justify-content-center mt-5">-->
<!-- <input class="checkbox form-check-input me-2" formControlName="terms" id="terms" type="checkbox">-->
<!-- <label class="form-check-label" for="terms">-->
<!-- I agree to the <a [routerLink]="['/terms-of-service']" class="text-body"><u>Terms of service</u></a>-->
<!-- </label>-->
<!-- </div>-->
<!-- <div class="text-center">-->
<!-- @if (registerForm.controls['terms'].untouched && registerForm.controls['terms'].invalid) {-->
<!-- <small-->
<!-- class="text-danger">-->
<!-- *You must agree to the terms-->
<!-- </small>-->
<!-- }-->
<!-- </div>-->
<!-- <div class="form-check d-flex justify-content-center mt-5">-->
<!-- <input class="checkbox form-check-input me-2" formControlName="terms" id="terms" type="checkbox">-->
<!-- <label class="form-check-label" for="terms">-->
<!-- I agree to the <a [routerLink]="['/terms-of-service']" class="text-body"><u>Terms of service</u></a>-->
<!-- </label>-->
<!-- </div>-->
<!-- <div class="text-center">-->
<!-- @if (registerForm.controls['terms'].untouched && registerForm.controls['terms'].invalid) {-->
<!-- <small-->
<!-- class="text-danger">-->
<!-- *You must agree to the terms-->
<!-- </small>-->
<!-- }-->
<!-- </div>-->
<!-- Button -->
<div class="d-flex justify-content-center">
<button (click)="onSignUp()" [disabled]="registerForm.invalid || loadingService.loading()" class="btn btn-lg btn-light mt-5"
type="submit">
@if (loadingService.loading()) {
<span class="spinner-border spinner-border-sm" aria-hidden="true"></span>
<span class="visually-hidden" role="status">Loading...</span>
}
Sign up
type="submit">
@if (loadingService.loading()) {
<span class="spinner-border spinner-border-sm" aria-hidden="true"></span>
<span class="visually-hidden" role="status">Loading...</span>
}
Sign up
</button>
</div>
<p class="text-center text-black-50 mt-5 mb-0">Have already an account? <a [routerLink]="['/login']"
class="fw-bold text-body"><u>Sign
in here!</u></a></p>
class="fw-bold text-body"><u>Sign
in here!</u></a></p>
</form>
</div>
</div>
@@ -125,4 +110,3 @@
</div>
</div>
</div>
@@ -1,4 +1,4 @@
import {Component, inject} from '@angular/core';
import {Component, inject, ChangeDetectionStrategy} from '@angular/core';
import {Router, RouterLink} from "@angular/router";
import {FormBuilder, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms";
@@ -17,6 +17,7 @@ import {Title} from "@angular/platform-browser";
],
templateUrl: './register.component.html',
standalone: true,
changeDetection: ChangeDetectionStrategy.Eager,
styleUrl: './register.component.scss'
})
export class RegisterComponent {
@@ -1,4 +1,4 @@
import {Component, inject, OnInit} from '@angular/core';
import {Component, inject, OnInit, ChangeDetectionStrategy} from '@angular/core';
import {FormBuilder, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms";
import {ResetPasswordService} from "../../../infrastructure/services/reset-password.service";
import {ActivatedRoute, Router} from "@angular/router";
@@ -15,6 +15,7 @@ import {PasswordValidator} from "../../../infrastructure/utilities/password-vali
ReactiveFormsModule
],
templateUrl: './reset-password.component.html',
changeDetection: ChangeDetectionStrategy.Eager,
styleUrl: './reset-password.component.scss'
})
export class ResetPasswordComponent implements OnInit {
@@ -1,4 +1,4 @@
import { Component } from '@angular/core';
import { Component, ChangeDetectionStrategy } from '@angular/core';
import {RouterLink} from "@angular/router";
@Component({
@@ -8,6 +8,7 @@ import {RouterLink} from "@angular/router";
],
templateUrl: './admin-dashboard.component.html',
styleUrl: './admin-dashboard.component.scss',
changeDetection: ChangeDetectionStrategy.Eager,
standalone: true
})
export class AdminDashboardComponent {
@@ -1,4 +1,4 @@
import {Component} from '@angular/core';
import {Component, ChangeDetectionStrategy} from '@angular/core';
import {RouterLink} from "@angular/router";
import {appVersion} from "../../../../environments/version";
@@ -7,6 +7,7 @@ import {appVersion} from "../../../../environments/version";
imports: [RouterLink],
templateUrl: './footer.component.html',
standalone: true,
changeDetection: ChangeDetectionStrategy.Eager,
styleUrl: './footer.component.scss'
})
export class FooterComponent {
@@ -1,32 +1,68 @@
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {HeaderComponent} from './header.component';
import {AuthService} from '../../../infrastructure/services/auth-service';
import {UserStoreService} from '../../../infrastructure/services/user-store.service';
import {ActivatedRoute} from '@angular/router';
describe('HeaderComponent', () => {
let component: HeaderComponent;
let fixture: ComponentFixture<HeaderComponent>;
let authService: jasmine.SpyObj<AuthService>;
beforeEach(async () => {
const authSpy = jasmine.createSpyObj('AuthService', [
'getUsernameFromToken', 'getRoleFromToken', 'getEmailFromToken', 'getUserIdFromToken',
'isLoggedIn', 'getToken', 'signOut', 'decodedToken'
authService = jasmine.createSpyObj('AuthService', [
'getUsernameFromToken', 'getRoleFromToken', 'getEmailFromToken',
'getUserIdFromToken', 'isLoggedIn', 'getToken', 'signOut', 'decodedToken'
]);
authService.getUsernameFromToken.and.returnValue('default-user');
authService.getRoleFromToken.and.returnValue('User');
await TestBed.configureTestingModule({
imports: [HeaderComponent],
providers: [
{provide: AuthService, useValue: authSpy},
{provide: ActivatedRoute, useValue: {snapshot: {data: {}}, firstChild: null}},
{provide: AuthService, useValue: authService},
{
provide: ActivatedRoute,
useValue: {snapshot: {data: {}}, firstChild: null}
},
UserStoreService,
]
}).compileComponents();
fixture = TestBed.createComponent(HeaderComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
fixture.detectChanges();
expect(component).toBeTruthy();
});
it('should load username from store or token fallback', () => {
const userStore = TestBed.inject(UserStoreService);
userStore.setUsernameForStore('store-user');
fixture.detectChanges();
expect(component.username).toBe('store-user');
});
it('should fall back to token username when store is empty', () => {
authService.getUsernameFromToken.and.returnValue('token-user');
fixture.detectChanges();
expect(component.username).toBe('token-user');
});
it('should load role from store or token fallback', () => {
authService.getRoleFromToken.and.returnValue('Admin');
fixture.detectChanges();
expect(component.role).toBe('Admin');
});
it('should call signOut on logout', () => {
fixture.detectChanges();
component.logOut();
expect(authService.signOut).toHaveBeenCalled();
});
});
@@ -1,4 +1,4 @@
import {Component, inject, OnInit} from '@angular/core';
import {Component, inject, OnInit, ChangeDetectionStrategy} from '@angular/core';
import {DarkModeService} from '../../../infrastructure/services/dark-mode.service';
import {FormsModule} from "@angular/forms";
import {ActivatedRoute, NavigationEnd, Router, RouterLink} from "@angular/router";
@@ -14,6 +14,7 @@ import {filter} from "rxjs/operators";
],
templateUrl: './header.component.html',
standalone: true,
changeDetection: ChangeDetectionStrategy.Eager,
styleUrl: './header.component.scss'
})
export class HeaderComponent implements OnInit {
@@ -1,9 +1,10 @@
import { Component } from '@angular/core';
import { Component, ChangeDetectionStrategy } from '@angular/core';
@Component({
selector: 'app-startpage',
imports: [],
templateUrl: './startpage.component.html',
changeDetection: ChangeDetectionStrategy.Eager,
styleUrl: './startpage.component.scss',
})
export class StartpageComponent {
@@ -1,9 +1,10 @@
import { Component } from '@angular/core';
import { Component, ChangeDetectionStrategy } from '@angular/core';
@Component({
selector: 'app-unauthorized',
imports: [],
templateUrl: './unauthorized.component.html',
changeDetection: ChangeDetectionStrategy.Eager,
styleUrl: './unauthorized.component.scss',
})
export class UnauthorizedComponent {
@@ -1,4 +1,4 @@
import {Component, inject} from '@angular/core';
import {Component, inject, ChangeDetectionStrategy} from '@angular/core';
import {Title} from "@angular/platform-browser";
import {UserStoreService} from "../../../infrastructure/services/user-store.service";
import {AuthService} from "../../../infrastructure/services/auth-service";
@@ -7,6 +7,7 @@ import {AuthService} from "../../../infrastructure/services/auth-service";
selector: 'app-user-dashboard',
imports: [],
templateUrl: './user-dashboard.component.html',
changeDetection: ChangeDetectionStrategy.Eager,
styleUrl: './user-dashboard.component.scss',
})
export class UserDashboardComponent {
@@ -1,4 +1,4 @@
import {Component, inject} from '@angular/core';
import {Component, inject, ChangeDetectionStrategy} from '@angular/core';
import {User} from "../../../domain/entities/user";
import {UserService} from "../../../infrastructure/services/user.service";
import {ToastService} from "../../../infrastructure/services/toast.service";
@@ -15,6 +15,7 @@ import {DatePipe, NgClass} from "@angular/common";
],
templateUrl: './user-table.component.html',
styleUrl: './user-table.component.scss',
changeDetection: ChangeDetectionStrategy.Eager,
standalone: true
})
export class UserTableComponent {
@@ -1,23 +1,35 @@
import {TestBed} from '@angular/core/testing';
import {HttpClient, HttpInterceptorFn, provideHttpClient, withInterceptors} from '@angular/common/http';
import {fakeAsync, TestBed, tick} from '@angular/core/testing';
import {HttpClient, HttpInterceptorFn, provideHttpClient, withInterceptors, withXhr} from '@angular/common/http';
import {HttpTestingController, provideHttpClientTesting} from '@angular/common/http/testing';
import {tokenInterceptor} from './token.interceptor';
import {AuthService} from '../../infrastructure/services/auth-service';
import {ToastService} from '../../infrastructure/services/toast.service';
import {Router} from '@angular/router';
import {of, throwError} from 'rxjs';
describe('tokenInterceptor', () => {
let authService: jasmine.SpyObj<AuthService>;
let toastService: jasmine.SpyObj<ToastService>;
let router: jasmine.SpyObj<Router>;
let httpClient: HttpClient;
let httpTesting: HttpTestingController;
beforeEach(() => {
authService = jasmine.createSpyObj('AuthService', ['getToken', 'getRefreshToken', 'getUserIdFromToken',
'storeToken', 'storeRefreshToken', 'signOut', 'renewToken']);
authService = jasmine.createSpyObj('AuthService', [
'getToken', 'getRefreshToken', 'getUserIdFromToken',
'storeToken', 'storeRefreshToken', 'signOut', 'renewToken'
]);
toastService = jasmine.createSpyObj('ToastService', ['show']);
router = jasmine.createSpyObj('Router', ['navigate']);
router.navigate.and.returnValue(Promise.resolve(true));
TestBed.configureTestingModule({
providers: [
provideHttpClient(withInterceptors([tokenInterceptor])),
provideHttpClient(withXhr(), withInterceptors([tokenInterceptor])),
provideHttpClientTesting(),
{provide: AuthService, useValue: authService},
{provide: ToastService, useValue: toastService},
{provide: Router, useValue: router},
]
});
httpClient = TestBed.inject(HttpClient);
@@ -47,4 +59,61 @@ describe('tokenInterceptor', () => {
expect(req.request.headers.has('Authorization')).toBeFalse();
req.flush({});
});
it('should retry with new token on 401 and refresh succeeds', () => {
authService.getToken.and.returnValues('expired-token', 'new-access-token');
authService.getRefreshToken.and.returnValue('valid-refresh');
authService.getUserIdFromToken.and.returnValue(1);
authService.renewToken.and.returnValue(of({
value: {accessToken: 'new-access-token', refreshToken: 'new-refresh-token'}
}));
const results: any[] = [];
httpClient.get('/api/data').subscribe({next: r => results.push(r)});
const req1 = httpTesting.expectOne('/api/data');
req1.flush('Unauthorized', {status: 401, statusText: 'Unauthorized'});
const req2 = httpTesting.expectOne('/api/data');
expect(req2.request.headers.get('Authorization')).toBe('Bearer new-access-token');
req2.flush({data: 'success'});
expect(results).toEqual([{data: 'success'}]);
expect(authService.storeToken).toHaveBeenCalledWith('new-access-token');
expect(authService.storeRefreshToken).toHaveBeenCalledWith('new-refresh-token');
});
it('should sign out and redirect on 401 when refresh fails', fakeAsync(() => {
authService.getToken.and.returnValue('expired-token');
authService.getRefreshToken.and.returnValue('expired-refresh');
authService.getUserIdFromToken.and.returnValue(1);
authService.renewToken.and.returnValue(throwError(() => ({
error: {error: {message: 'Token expired'}}
})));
httpClient.get('/api/data').subscribe({error: () => {}});
const req = httpTesting.expectOne('/api/data');
req.flush('Unauthorized', {status: 401, statusText: 'Unauthorized'});
tick();
expect(authService.signOut).toHaveBeenCalled();
expect(router.navigate).toHaveBeenCalledWith(['login']);
expect(toastService.show).toHaveBeenCalledWith('Token expired', jasmine.objectContaining({
classname: 'bg-warning text-light'
}));
}));
it('should pass through non-401 errors', () => {
authService.getToken.and.returnValue('some-token');
const errors: any[] = [];
httpClient.get('/api/test').subscribe({error: e => errors.push(e)});
const req = httpTesting.expectOne('/api/test');
req.flush('Forbidden', {status: 403, statusText: 'Forbidden'});
expect(errors.length).toBe(1);
expect(errors[0].status).toBe(403);
});
});
@@ -1,6 +1,5 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PopupModalComponent } from './popup-modal.component';
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {PopupModalComponent} from './popup-modal.component';
describe('PopupModalComponent', () => {
let component: PopupModalComponent;
@@ -9,8 +8,7 @@ describe('PopupModalComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [PopupModalComponent]
})
.compileComponents();
}).compileComponents();
fixture = TestBed.createComponent(PopupModalComponent);
component = fixture.componentInstance;
@@ -20,4 +18,29 @@ describe('PopupModalComponent', () => {
it('should create', () => {
expect(component).toBeTruthy();
});
it('should have default headerClass', () => {
expect(component.headerClass).toBe('bg-light');
});
it('should bind title input', () => {
component.title = 'Warning';
fixture.detectChanges();
const titleEl: HTMLElement = fixture.nativeElement.querySelector('.modal-title');
expect(titleEl.textContent).toContain('Warning');
});
it('should bind body input', () => {
component.body = 'Are you sure?';
fixture.detectChanges();
const bodyEl: HTMLElement = fixture.nativeElement.querySelector('.modal-body p');
expect(bodyEl.textContent).toContain('Are you sure?');
});
it('should emit confirm on onConfirm', () => {
const spy = jasmine.createSpy();
component.confirm.subscribe(spy);
component.onConfirm();
expect(spy).toHaveBeenCalled();
});
});
@@ -1,4 +1,4 @@
import {Component, EventEmitter, Input, Output} from '@angular/core';
import {Component, EventEmitter, Input, Output, ChangeDetectionStrategy} from '@angular/core';
import {NgClass} from "@angular/common";
@Component({
@@ -8,6 +8,7 @@ import {NgClass} from "@angular/common";
],
templateUrl: './popup-modal.component.html',
styleUrl: './popup-modal.component.scss',
changeDetection: ChangeDetectionStrategy.Eager,
standalone: true
})
export class PopupModalComponent {
@@ -1,9 +1,8 @@
@for (toast of toastService.toasts; track toast) {
<ngb-toast
(hidden)="toastService.remove(toast)"
[autohide]="true"
[class]="toast.classname"
[delay]="toast.delay || 5000">
{{ toast.message }}
</ngb-toast>
<div class="toast show" [class]="toast.classname" role="alert">
<div class="toast-body d-flex justify-content-between align-items-center gap-2">
{{ toast.message }}
<button type="button" class="btn-close btn-close-white flex-shrink-0" (click)="toastService.remove(toast)"></button>
</div>
</div>
}
@@ -1,4 +1,4 @@
ngb-toast {
.toast {
position: fixed;
top: 20px;
right: -100%; // Start außerhalb des Bildschirms
@@ -1,17 +1,18 @@
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {ToastComponent} from './toast.component';
import {ToastService} from '../../../infrastructure/services/toast.service';
describe('ToastComponent', () => {
let component: ToastComponent;
let fixture: ComponentFixture<ToastComponent>;
let toastService: ToastService;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ToastComponent]
})
.compileComponents();
}).compileComponents();
toastService = TestBed.inject(ToastService);
fixture = TestBed.createComponent(ToastComponent);
component = fixture.componentInstance;
fixture.detectChanges();
@@ -20,4 +21,45 @@ describe('ToastComponent', () => {
it('should create', () => {
expect(component).toBeTruthy();
});
it('should render toasts from service', () => {
toastService.show('Hello World', {classname: 'bg-info'});
fixture.detectChanges();
const toastEl = fixture.nativeElement.querySelector('.toast');
expect(toastEl).toBeTruthy();
expect(toastEl.textContent).toContain('Hello World');
expect(toastEl.classList).toContain('bg-info');
});
it('should render multiple toasts', () => {
toastService.show('First');
toastService.show('Second');
fixture.detectChanges();
const toastEls = fixture.nativeElement.querySelectorAll('.toast');
expect(toastEls.length).toBe(2);
});
it('should remove toast on close button click', () => {
toastService.show('Dismiss me');
fixture.detectChanges();
const closeBtn = fixture.nativeElement.querySelector('.btn-close');
closeBtn.click();
fixture.detectChanges();
const toastEls = fixture.nativeElement.querySelectorAll('.toast');
expect(toastEls.length).toBe(0);
});
it('should stop rendering after toast is removed', () => {
toastService.show('Temporary');
toastService.show('Persistent');
toastService.remove(toastService.toasts[0]);
fixture.detectChanges();
const toastEls = fixture.nativeElement.querySelectorAll('.toast');
expect(toastEls.length).toBe(1);
});
});
@@ -1,15 +1,13 @@
import {Component, inject} from '@angular/core';
import {Component, inject, ChangeDetectionStrategy} from '@angular/core';
import {ToastService} from "../../../infrastructure/services/toast.service";
import {NgbToast} from "@ng-bootstrap/ng-bootstrap";
@Component({
selector: 'app-toast',
imports: [
NgbToast
],
imports: [],
templateUrl: './toast.component.html',
standalone: true,
changeDetection: ChangeDetectionStrategy.Eager,
styleUrls: ['./toast.component.scss']
})
export class ToastComponent {
+9 -1
View File
@@ -11,5 +11,13 @@
],
"include": [
"src/**/*.d.ts"
]
],
"angularCompilerOptions": {
"extendedDiagnostics": {
"checks": {
"nullishCoalescingNotNullable": "suppress",
"optionalChainNotNullable": "suppress"
}
}
}
}
+9 -1
View File
@@ -11,5 +11,13 @@
"include": [
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
],
"angularCompilerOptions": {
"extendedDiagnostics": {
"checks": {
"nullishCoalescingNotNullable": "suppress",
"optionalChainNotNullable": "suppress"
}
}
}
}
+8 -8
View File
@@ -12,20 +12,20 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.3.9" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Core" Version="2.3.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.7">
<PackageReference Include="Microsoft.AspNetCore" Version="2.3.11" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Core" Version="2.3.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.7">
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.7" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.9" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.2" />
</ItemGroup>
<ItemGroup>
@@ -8,11 +8,11 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="10.0.0">
<PackageReference Include="coverlet.collector" Version="10.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.6.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@@ -8,11 +8,11 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="10.0.0">
<PackageReference Include="coverlet.collector" Version="10.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.6.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@@ -0,0 +1,64 @@
using Application.Common.Results;
namespace Application.UnitTest.Common.Results;
public class ResultTests
{
[Fact]
public void Success_ShouldReturnResultWithIsSuccessTrue()
{
var result = Result.Success();
Assert.True(result.IsSuccess);
Assert.False(result.IsFailure);
Assert.Equal(ErrorTypeConstant.None, result.Error.Code);
}
[Fact]
public void Success_WithValue_ShouldReturnResultWithValue()
{
var result = Result.Success("test-value");
Assert.True(result.IsSuccess);
Assert.Equal("test-value", result.Value);
}
[Fact]
public void Failure_ShouldReturnResultWithIsFailureTrue()
{
var error = new Error("TestError", "Something went wrong");
var result = Result.Failure(error);
Assert.True(result.IsFailure);
Assert.False(result.IsSuccess);
Assert.Equal("TestError", result.Error.Code);
Assert.Equal("Something went wrong", result.Error.Message);
}
[Fact]
public void Failure_WithValueType_ShouldReturnTypedResult()
{
var error = new Error("NotFound", "Item not found");
var result = Result.Failure<string>(error);
Assert.True(result.IsFailure);
Assert.Throws<InvalidOperationException>(() => result.Value);
}
[Fact]
public void Constructor_ShouldThrow_WhenSuccessWithError()
{
var error = new Error("SomeError", "message");
Assert.Throws<InvalidOperationException>(() => new ResultTestCase(true, error));
}
[Fact]
public void Constructor_ShouldThrow_WhenFailureWithNoError()
{
var noneError = new Error("None", string.Empty);
Assert.Throws<InvalidOperationException>(() => new ResultTestCase(false, noneError));
}
}
public class ResultTestCase : Result
{
public ResultTestCase(bool isSuccess, Error error) : base(isSuccess, error)
{
}
}
@@ -0,0 +1,110 @@
using Application.DTOs;
namespace Application.UnitTest.DTOs;
public class PagedResultTests
{
[Fact]
public void TotalPages_ShouldCalculateCorrectly_WhenExactDivision()
{
var paged = new PagedResult<string>
{
Items = ["a", "b", "c", "d", "e"],
TotalCount = 5,
PageNumber = 1,
PageSize = 5
};
Assert.Equal(1, paged.TotalPages);
}
[Fact]
public void TotalPages_ShouldRoundUp_WhenNotExactDivision()
{
var paged = new PagedResult<string>
{
Items = ["a", "b", "c"],
TotalCount = 10,
PageNumber = 1,
PageSize = 3
};
Assert.Equal(4, paged.TotalPages);
}
[Fact]
public void TotalPages_ShouldBeZero_WhenTotalCountIsZero()
{
var paged = new PagedResult<string>
{
Items = [],
TotalCount = 0,
PageNumber = 1,
PageSize = 10
};
Assert.Equal(0, paged.TotalPages);
}
[Fact]
public void HasPreviousPage_ShouldBeFalse_WhenOnFirstPage()
{
var paged = new PagedResult<string>
{
Items = [],
TotalCount = 20,
PageNumber = 1,
PageSize = 10
};
Assert.False(paged.HasPreviousPage);
}
[Fact]
public void HasPreviousPage_ShouldBeTrue_WhenPastFirstPage()
{
var paged = new PagedResult<string>
{
Items = [],
TotalCount = 20,
PageNumber = 2,
PageSize = 10
};
Assert.True(paged.HasPreviousPage);
}
[Fact]
public void HasNext_ShouldBeFalse_WhenOnLastPage()
{
var paged = new PagedResult<string>
{
Items = [],
TotalCount = 20,
PageNumber = 2,
PageSize = 10
};
Assert.False(paged.HasNext);
}
[Fact]
public void HasNext_ShouldBeTrue_WhenMorePagesExist()
{
var paged = new PagedResult<string>
{
Items = [],
TotalCount = 20,
PageNumber = 1,
PageSize = 10
};
Assert.True(paged.HasNext);
}
[Fact]
public void HasNext_ShouldBeFalse_WhenOnlyOnePage()
{
var paged = new PagedResult<string>
{
Items = [],
TotalCount = 3,
PageNumber = 1,
PageSize = 10
};
Assert.False(paged.HasNext);
}
}
@@ -134,6 +134,28 @@ public class AuthenticationServiceTests
Assert.Equal(AuthError.UserNotFound, result.Error);
}
[Fact]
public async Task LoginAsync_ShouldReturnFailure_WhenPasswordIsWrong()
{
var password = "ValidP@ss1!";
var user = new User
{
Id = 1,
Username = "testuser",
Email = "test@example.com",
Password = new PasswordHasher<User>().HashPassword(
new User { Username = "testuser", Email = "test@example.com", Password = password },
password)
};
var request = new LoginRequest(user.Email, "WrongPassword1!");
_userRepository.GetUserByEmailAsync(request.Email).Returns(user);
var result = await _sut.LoginAsync(request);
Assert.True(result.IsFailure);
Assert.Equal(AuthError.InvalidPassword, result.Error);
}
[Fact]
public async Task RefreshTokensAsync_ShouldReturnSuccess_WhenRefreshTokenIsValid()
{
@@ -0,0 +1,60 @@
using Application.Models;
using Application.Services;
using MailKit.Net.Smtp;
using Microsoft.Extensions.Configuration;
using MimeKit;
using NSubstitute;
namespace Application.UnitTest.Services;
public class EmailServiceTests
{
private readonly IConfiguration _configuration = Substitute.For<IConfiguration>();
private readonly ISmtpClient _smtpClient = Substitute.For<ISmtpClient>();
private readonly EmailService _sut;
public EmailServiceTests()
{
_configuration["EmailSettings:From"].Returns("sender@gmail.com");
_configuration["EmailSettings:SmtpServer"].Returns("smtp.gmail.com");
_configuration["EmailSettings:Password"].Returns("app-password");
_sut = new EmailService(_configuration, () => _smtpClient);
}
[Fact]
public void SendEmailAsync_ShouldConnectAndAuthenticate()
{
var request = new EmailRequest("recipient@example.com", "Test Subject", "<p>Hello</p>");
_sut.SendEmailAsync(request);
_smtpClient.Received(1).Connect("smtp.gmail.com", 465, true);
_smtpClient.Received(1).Authenticate("sender@gmail.com", "app-password");
_smtpClient.Received(1).Send(Arg.Any<MimeMessage>());
_smtpClient.Received(1).Disconnect(true);
}
[Fact]
public void SendEmailAsync_ShouldSendMessageWithCorrectDetails()
{
var request = new EmailRequest("recipient@example.com", "Welcome!", "<h1>Hi</h1>");
_sut.SendEmailAsync(request);
_smtpClient.Received(1).Send(Arg.Is<MimeMessage>(msg =>
msg.To.Mailboxes.Any(m => m.Address == "recipient@example.com") &&
msg.Subject == "Welcome!"));
}
[Fact]
public void SendEmailAsync_ShouldDisposeClient_AfterSending()
{
var request = new EmailRequest("recipient@example.com", "Subject", "Body");
_sut.SendEmailAsync(request);
_smtpClient.Received(1).Disconnect(true);
_smtpClient.Received(1).Dispose();
}
}
@@ -0,0 +1,170 @@
using System.IdentityModel.Tokens.Jwt;
using Application.Services;
using Domain.Entities;
using Domain.Interface;
using Microsoft.Extensions.Configuration;
using NSubstitute;
namespace Application.UnitTest.Services;
public class JwtServiceTests
{
private readonly IConfiguration _configuration = Substitute.For<IConfiguration>();
private readonly IUserRepository _userRepository = Substitute.For<IUserRepository>();
private readonly IUnitOfWork _unitOfWork = Substitute.For<IUnitOfWork>();
private readonly JwtService _sut;
public JwtServiceTests()
{
var section = Substitute.For<IConfigurationSection>();
section.Value.Returns("veryveryveryveryveryveryverysecretkey");
_configuration.GetSection("Jwt:Key").Returns(section);
_configuration["Jwt:Key"].Returns("veryveryveryveryveryveryverysecretkey");
_configuration["Jwt:Issuer"].Returns("https://localhost:7091");
_configuration["Jwt:Audience"].Returns("http://localhost:5184");
_sut = new JwtService(_configuration, _userRepository, _unitOfWork);
}
[Fact]
public async Task GenerateTokenAsync_ShouldReturnToken_WhenUserIsValid()
{
var user = new User
{
Id = 1,
Username = "testuser",
Email = "test@example.com",
Password = "hash"
};
_userRepository.GetUserRolesByEmailAsync(user.Email)
.Returns(["User"]);
var token = await _sut.GenerateTokenAsync(user);
Assert.NotNull(token);
Assert.NotEmpty(token);
var handler = new JwtSecurityTokenHandler();
var jwtToken = handler.ReadJwtToken(token);
Assert.Equal("https://localhost:7091", jwtToken.Issuer);
Assert.Contains(jwtToken.Claims, c => c.Type == "email" && c.Value == user.Email);
Assert.Contains(jwtToken.Claims, c => c.Type == "UserId" && c.Value == "1");
Assert.Contains(jwtToken.Claims, c => c.Type == "username" && c.Value == user.Username);
Assert.Contains(jwtToken.Claims, c => c.Type == "role" && c.Value == "User");
}
[Fact]
public async Task GenerateTokenAsync_ShouldIncludeAllRoles()
{
var user = new User
{
Id = 2,
Username = "adminuser",
Email = "admin@example.com",
Password = "hash"
};
_userRepository.GetUserRolesByEmailAsync(user.Email)
.Returns(["Admin", "User"]);
var token = await _sut.GenerateTokenAsync(user);
var handler = new JwtSecurityTokenHandler();
var jwtToken = handler.ReadJwtToken(token);
var roleClaims = jwtToken.Claims.Where(c => c.Type == "role").Select(c => c.Value).ToList();
Assert.Contains("Admin", roleClaims);
Assert.Contains("User", roleClaims);
}
[Fact]
public async Task GenerateAndSaveRefreshTokenAsync_ShouldUpdateUserAndCommit()
{
var user = new User
{
Id = 1,
Username = "testuser",
Email = "test@example.com",
Password = "hash"
};
var refreshToken = await _sut.GenerateAndSaveRefreshTokenAsync(user);
Assert.NotNull(refreshToken);
Assert.NotEmpty(refreshToken);
Assert.Equal(refreshToken, user.RefreshToken);
Assert.NotNull(user.RefreshTokenExpiryTime);
Assert.True(user.RefreshTokenExpiryTime > DateTime.UtcNow);
_userRepository.Received(1).Update(user);
await _unitOfWork.Received(1).CommitAsync();
}
[Fact]
public async Task ValidateRefreshTokenAsync_ShouldReturnNull_WhenUserNotFound()
{
_userRepository.GetUserByIdAsync(99).Returns((User?)null);
var result = await _sut.ValidateRefreshTokenAsync(99, "some-token");
Assert.Null(result);
}
[Fact]
public async Task ValidateRefreshTokenAsync_ShouldReturnNull_WhenTokenMismatch()
{
var user = new User
{
Id = 1,
Username = "testuser",
Email = "test@example.com",
Password = "hash",
RefreshToken = "stored-token",
RefreshTokenExpiryTime = DateTime.UtcNow.AddDays(1)
};
_userRepository.GetUserByIdAsync(1).Returns(user);
var result = await _sut.ValidateRefreshTokenAsync(1, "wrong-token");
Assert.Null(result);
}
[Fact]
public async Task ValidateRefreshTokenAsync_ShouldReturnNull_WhenTokenExpired()
{
var user = new User
{
Id = 1,
Username = "testuser",
Email = "test@example.com",
Password = "hash",
RefreshToken = "expired-token",
RefreshTokenExpiryTime = DateTime.UtcNow.AddDays(-1)
};
_userRepository.GetUserByIdAsync(1).Returns(user);
var result = await _sut.ValidateRefreshTokenAsync(1, "expired-token");
Assert.Null(result);
}
[Fact]
public async Task ValidateRefreshTokenAsync_ShouldReturnUser_WhenTokenValid()
{
var user = new User
{
Id = 1,
Username = "testuser",
Email = "test@example.com",
Password = "hash",
RefreshToken = "valid-token",
RefreshTokenExpiryTime = DateTime.UtcNow.AddDays(1)
};
_userRepository.GetUserByIdAsync(1).Returns(user);
var result = await _sut.ValidateRefreshTokenAsync(1, "valid-token");
Assert.NotNull(result);
Assert.Equal(1, result.Id);
}
}