Compare commits

..

No commits in common. 'master' and 'testTony' have entirely different histories.

@ -1,6 +1,6 @@
kind: pipeline kind: pipeline
type: docker type: docker
name: default name: CI
trigger: trigger:
event: event:
@ -10,6 +10,7 @@ steps:
- name: build - name: build
image: mcr.microsoft.com/dotnet/sdk:8.0 image: mcr.microsoft.com/dotnet/sdk:8.0
commands: commands:
- cd Verax_API_EF
- cd Verax_API_EF - cd Verax_API_EF
- dotnet restore Verax_API_EF.sln - dotnet restore Verax_API_EF.sln
- dotnet build Verax_API_EF.sln -c Release --no-restore - dotnet build Verax_API_EF.sln -c Release --no-restore
@ -18,6 +19,7 @@ steps:
- name: tests - name: tests
image: mcr.microsoft.com/dotnet/sdk:8.0 image: mcr.microsoft.com/dotnet/sdk:8.0
commands: commands:
- cd Verax_API_EF
- cd Verax_API_EF - cd Verax_API_EF
- dotnet restore Verax_API_EF.sln - dotnet restore Verax_API_EF.sln
- dotnet test Verax_API_EF.sln --no-restore - dotnet test Verax_API_EF.sln --no-restore
@ -32,9 +34,10 @@ steps:
from_secret: SECRET_SONAR_LOGIN # Secret de Drone from_secret: SECRET_SONAR_LOGIN # Secret de Drone
project_key: Verax_API_EF project_key: Verax_API_EF
commands: commands:
- cd Verax_API_EF/
- cd Verax_API_EF/ - cd Verax_API_EF/
- dotnet restore Verax_API_EF.sln - dotnet restore Verax_API_EF.sln
- dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions="Unit_Test_EF/**","API_Unit_Test/**","API_Tests_Console/**","Test_Console_EF/**","DbContextLib/Migrations/**","StubbedContextLib/**","API/Program.cs","DbContextLib/ApplicationDbContext.cs" /d:sonar.login=$${sonar_token} - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions="Unit_Test_EF/**","API_Unit_Test/**" /d:sonar.login=$${sonar_token}
- dotnet build Verax_API_EF.sln -c Release --no-restore - dotnet build Verax_API_EF.sln -c Release --no-restore
- dotnet test Verax_API_EF.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" - dotnet test Verax_API_EF.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage"
- reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport"
@ -47,32 +50,3 @@ steps:
- push - push
- pull_request - pull_request
depends_on: [build,tests] depends_on: [build,tests]
- name: docker-build-and-push
image: plugins/docker
settings:
dockerfile: Verax_API_EF/Dockerfile
context: Verax_API_EF
registry: hub.codefirst.iut.uca.fr
repo: hub.codefirst.iut.uca.fr/louis.laborie/sae_2a_api_ef
username:
from_secret: SECRET_REGISTRY_USERNAME
password:
from_secret: SECRET_REGISTRY_PASSWORD
when:
branch:
- master
- rebase
- name: deploy-container
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
environment:
IMAGENAME: hub.codefirst.iut.uca.fr/louis.laborie/sae_2a_api_ef:latest
CONTAINERNAME: verax-api
COMMAND: create
OVERWRITE: true
CODEFIRST_CLIENTDRONE_ENV_ASPNETCORE_HTTP_PORTS: 80
ADMINS: louislaborie,tonyfages
depends_on:
- docker-build-and-push

@ -1,76 +1,2 @@
<h1 align="center">Verax API EF</h1> # Verax_API_EF
<p align="center">
<img src="https://img.shields.io/badge/C%23-239120.svg?style=for-the-badge&logo=c-sharp&logoColor=white" alt="C#"/>
<img src="https://img.shields.io/badge/Entity%20Framework-512BD4.svg?style=for-the-badge&logo=entity-framework&logoColor=white" alt="Entity Framework"/>
<img src="https://img.shields.io/badge/.NET-512BD4.svg?style=for-the-badge&logo=.net&logoColor=white" alt=".NET"/>
<img src="https://img.shields.io/badge/SQL%20Server-E34F26.svg?style=for-the-badge&logo=microsoft-sql-server&logoColor=white" alt="SQL Server"/>
<img src="https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=Verax_API_EF&metric=alert_status&token=09154b15417d84a94e809d60f1d5bb01654b5501" alt="Coverage"/>
</p>
## Introduction
Bienvenue sur le projet `Verax_API_EF`, une API RESTful développée spécifiquement pour faciliter la communication entre le site web et l'application Android du projet [Verax](https://codefirst.iut.uca.fr/git/Verax/Verax). Cette interface est conçue pour gérer efficacement les articles, les formulaires, et les utilisateurs.
## Technologies
- **.NET 8**: Le framework utilisé pour développer l'application.
- **Entity Framework Core**: ORM utilisé pour l'accès et la gestion de la base de données.
- **SQL Server**: Système de gestion de base de données recommandé (modifiable selon vos préférences).
## Configuration requise
- .NET 8.
- Un IDE tel que Visual Studio, VS Code avec l'extension C#, ou JetBrains Rider pour le développement.
## Installation
1. **Cloner le projet** : Exécutez `git clone https://codefirst.iut.uca.fr/git/Verax/Verax_API_EF.git` pour cloner le dépôt dans votre espace de travail local.
2. Ouvrez le fichier `Verax_API_EF.sln` avec votre IDE.
3. Restaurez les packages nécessaires.
4. Lancez le projet depuis IDE.
## Utilisation
Après avoir lancé l'API, elle sera accessible via `http://localhost:5000` par défaut. Voici quelques exemples de requêtes que vous pouvez effectuer :
- **Obtenir des articles** : `GET /articles`
- **Ajouter un utilisateur** : `POST /user`
- **Mettre à jour un article** : `PUT /article/{id}`
- **Supprimer un formulaire** : `DELETE /formulaire/{id}`
## Problèmes pouvant être rencontrés
### Migration
- Lors de la création de la base de données, l'API s'appuie sur une migration incluse dans le projet `DbContextLib`. Si cette migration est absente, l'API ne fonctionnera pas correctement car la base de données sera vide, entraînant ainsi l'absence de données retournées. En cas de non présence de cette migration, vous devrez décommenter les lignes dans le fichier `LibraryContext.cs` du projet `DbContextLib` (aux alentours de la ligne 60), puis exécuter les commandes suivantes :
```bash
dotnet ef migrations add mrg1 --project DbContextLib --context LibraryContext
```
PS: N'oubliez pas de supprimer l'ancienne base de données dans le projet API et de recommenter les lignes dans le fichier `LibraryContext.cs`
### Tests Console API
- Pour exécuter les tests console de l'API, assurez-vous au préalable que l'API est en cours d'exécution sur votre machine. Il est également crucial de vérifier que le port utilisé par l'application correspond à celui spécifié dans les configurations des tests. Cette vérification garantit que les tests peuvent interagir correctement avec l'API et fournir des résultats fiables.
## Equipe de développement
<p align="center" >
<a href="https://codefirst.iut.uca.fr/git/louis.laborie" style="margin-right: 20px;">
<img src="img/Louis.png" width="50" height="50" title="Louis Laborie" alt="Louis Laborie"/>
</a>
<a href="https://codefirst.iut.uca.fr/git/tony.fages" style="margin-right: 20px;">
<img src="img/Tony.png" width="50" height="50" title="Tony Fages" alt="Tony Fages"/>
</a>
<p>

@ -0,0 +1,507 @@
# ---> macOS
# 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
# ---> VisualStudio
## 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 Core
project.lock.json
project.fragment.lock.json
artifacts/
# 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 6 technical files
*.ncb
*.aps
# 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
# ---> JetBrains
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# AWS User-specific
.idea/**/aws.xml
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# SonarLint plugin
.idea/sonarlint/
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

@ -1,85 +0,0 @@
Private property of Exodus: 16477@macbook-pro-de-fages.home
jetbrains.exodus.io.LockingManager.lock(LockingManager.kt:88)
jetbrains.exodus.io.LockingManager.lock(LockingManager.kt:39)
jetbrains.exodus.io.FileDataWriter.lock(FileDataWriter.kt:70)
jetbrains.exodus.log.Log.tryLock(Log.kt:804)
jetbrains.exodus.log.Log.<init>(Log.kt:117)
jetbrains.exodus.env.Environments.newLogInstance(Environments.kt:117)
jetbrains.exodus.env.Environments.newLogInstance(Environments.kt:81)
jetbrains.exodus.env.Environments.newLogInstance(Environments.kt:77)
jetbrains.exodus.env.Environments$newInstance$4.invoke(Environments.kt:46)
jetbrains.exodus.env.Environments$newInstance$4.invoke(Environments.kt:46)
jetbrains.exodus.env.Environments.prepare(Environments.kt:120)
jetbrains.exodus.env.Environments.newInstance(Environments.kt:46)
kotlinx.dnq.store.container.EntityStoreHelperKt.createTransientEntityStore(EntityStoreHelper.kt:40)
kotlinx.dnq.store.container.EntityStoreHelperKt.createTransientEntityStore(EntityStoreHelper.kt:31)
kotlinx.dnq.store.container.EntityStoreHelperKt.createTransientEntityStore$default(EntityStoreHelper.kt:30)
com.github.copilot.chat.session.persistence.xodus.XdChatSessionPersistenceService.initStore(XdChatSessionPersistenceService.kt:115)
com.github.copilot.chat.session.persistence.xodus.XdChatSessionPersistenceService.<init>(XdChatSessionPersistenceService.kt:22)
com.github.copilot.chat.session.persistence.xodus.XdChatSessionPersistenceService.<init>(XdChatSessionPersistenceService.kt:15)
com.github.copilot.chat.session.persistence.ChatSessionPersistenceServiceKt.ChatSessionPersistenceService(ChatSessionPersistenceService.kt:43)
com.github.copilot.chat.session.persistence.ChatSessionPersistenceServiceKt.chatSessionsPersistenceService(ChatSessionPersistenceService.kt:53)
com.github.copilot.chat.session.ChatSessionManager.<init>(ChatSessionManager.kt:45)
com.github.copilot.chat.session.ChatSessionManager.<init>(ChatSessionManager.kt:25)
com.github.copilot.chat.window.CopilotChatToolWindow.onCopilotReady(CopilotChatToolWindow.kt:133)
com.github.copilot.chat.window.CopilotChatToolWindow.access$onCopilotReady(CopilotChatToolWindow.kt:40)
com.github.copilot.chat.window.CopilotChatToolWindow$initCopilotStatusListener$1.invoke(CopilotChatToolWindow.kt:118)
com.github.copilot.chat.window.CopilotChatToolWindow$initCopilotStatusListener$1.invoke(CopilotChatToolWindow.kt:115)
com.github.copilot.status.CopilotAuthStatusKt.subscribeToCopilotAuthStatus(CopilotAuthStatus.kt:27)
com.github.copilot.chat.window.CopilotChatToolWindow.initCopilotStatusListener(CopilotChatToolWindow.kt:115)
com.github.copilot.chat.window.CopilotChatToolWindow.<init>(CopilotChatToolWindow.kt:59)
com.github.copilot.chat.window.CopilotChatToolWindow.<init>(CopilotChatToolWindow.kt:40)
com.github.copilot.chat.window.CopilotChatToolWindowFactory.init(CopilotChatToolWindowFactory.kt:18)
com.intellij.openapi.wm.impl.ToolWindowManagerImpl.registerToolWindow$intellij_platform_ide_impl(ToolWindowManagerImpl.kt:1123)
com.intellij.toolWindow.ToolWindowSetInitializerKt.registerToolWindows(ToolWindowSetInitializer.kt:223)
com.intellij.toolWindow.ToolWindowSetInitializerKt.access$registerToolWindows(ToolWindowSetInitializer.kt:1)
com.intellij.toolWindow.ToolWindowSetInitializer$createAndLayoutToolWindows$entries$1$1.invokeSuspend(ToolWindowSetInitializer.kt:141)
com.intellij.toolWindow.ToolWindowSetInitializer$createAndLayoutToolWindows$entries$1$1.invoke(ToolWindowSetInitializer.kt)
com.intellij.toolWindow.ToolWindowSetInitializer$createAndLayoutToolWindows$entries$1$1.invoke(ToolWindowSetInitializer.kt)
kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:78)
kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:167)
kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
com.intellij.platform.diagnostic.telemetry.impl.TracerKt.span(tracer.kt:53)
com.intellij.platform.diagnostic.telemetry.impl.TracerKt.span$default(tracer.kt:49)
com.intellij.toolWindow.ToolWindowSetInitializer$createAndLayoutToolWindows$entries$1.invokeSuspend(ToolWindowSetInitializer.kt:138)
kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:194)
com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:843)
com.intellij.openapi.application.impl.ApplicationImpl$4.run(ApplicationImpl.java:463)
com.intellij.openapi.application.impl.RwLockHolder.runWithEnabledImplicitRead(RwLockHolder.kt:75)
com.intellij.openapi.application.impl.RwLockHolder.runWithImplicitRead(RwLockHolder.kt:67)
com.intellij.openapi.application.impl.ApplicationImpl.runWithImplicitRead(ApplicationImpl.java:1436)
com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:82)
com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:124)
com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:44)
java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:792)
java.desktop/java.awt.EventQueue$3.run(EventQueue.java:739)
java.desktop/java.awt.EventQueue$3.run(EventQueue.java:733)
java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:761)
com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:695)
com.intellij.ide.IdeEventQueue._dispatchEvent$lambda$12(IdeEventQueue.kt:589)
com.intellij.openapi.application.impl.RwLockHolder.runWithoutImplicitRead(RwLockHolder.kt:44)
com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:589)
com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:72)
com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:355)
com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:354)
com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:793)
com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:354)
com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:349)
com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:1014)
com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:106)
com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:1014)
com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$7(IdeEventQueue.kt:349)
com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:848)
com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:391)
java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RiderProjectSettingsUpdater">
<option name="vcsConfiguration" value="2" />
</component>
</project>

@ -2,5 +2,6 @@
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" /> <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component> </component>
</project> </project>

@ -1,143 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoGeneratedRunConfigurationManager">
<projectFile profileName="http">API/API.csproj</projectFile>
<projectFile profileName="https">API/API.csproj</projectFile>
<projectFile>API_Tests_Console/API_Tests_Console.csproj</projectFile>
<projectFile>Test_Console_EF/Test_Console_EF.csproj</projectFile>
</component>
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="454eaf08-7244-4002-811f-5409ccfe6a2a" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/.idea.Verax_API_EF/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.Verax_API_EF/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/API/log.txt" beforeDir="false" afterPath="$PROJECT_DIR$/API/log.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/API_Tests_Console/Tests_Console_Connect_API.cs" beforeDir="false" afterPath="$PROJECT_DIR$/API_Tests_Console/Tests_Console_Connect_API.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/API_Tests_Console/Tests_Console_Connect_Localhost.cs" beforeDir="false" afterPath="$PROJECT_DIR$/API_Tests_Console/Tests_Console_Connect_Localhost.cs" 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="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
</component>
<component name="MetaFilesCheckinStateConfiguration" checkMetaFiles="true" />
<component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 0
}</component>
<component name="ProjectId" id="2eXuZ2IMoPdjqkvkhUH8MxoFt4X" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
".NET Launch Settings Profile.API: http.executor": "Run",
".NET Project.API_Tests_Console.executor": "Run",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"git-widget-placeholder": "master",
"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",
"vue.rearranger.settings.migration": "true"
},
"keyToStringList": {
"rider.external.source.directories": [
"/Users/tonyfages/Library/Application Support/JetBrains/Rider2023.3/resharper-host/DecompilerCache",
"/Users/tonyfages/Library/Application Support/JetBrains/Rider2023.3/resharper-host/SourcesCache",
"/Users/tonyfages/.local/share/Symbols/src"
]
}
}]]></component>
<component name="RunManager" selected=".NET Project.API_Tests_Console">
<configuration name="API_Tests_Console" 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="USE_EXTERNAL_CONSOLE" value="0" />
<option name="USE_MONO" value="0" />
<option name="RUNTIME_ARGUMENTS" value="" />
<option name="PROJECT_PATH" value="$PROJECT_DIR$/API_Tests_Console/API_Tests_Console.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="Test_Console_EF" 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="USE_EXTERNAL_CONSOLE" value="0" />
<option name="USE_MONO" value="0" />
<option name="RUNTIME_ARGUMENTS" value="" />
<option name="PROJECT_PATH" value="$PROJECT_DIR$/Test_Console_EF/Test_Console_EF.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: http" type="LaunchSettings" factoryName=".NET Launch Settings Profile">
<option name="LAUNCH_PROFILE_PROJECT_FILE_PATH" value="$PROJECT_DIR$/API/API.csproj" />
<option name="LAUNCH_PROFILE_TFM" value="net8.0" />
<option name="LAUNCH_PROFILE_NAME" value="http" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />
<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="" />
<method v="2">
<option name="Build" />
</method>
</configuration>
<configuration name="API: https" type="LaunchSettings" factoryName=".NET Launch Settings Profile">
<option name="LAUNCH_PROFILE_PROJECT_FILE_PATH" value="$PROJECT_DIR$/API/API.csproj" />
<option name="LAUNCH_PROFILE_TFM" value="net8.0" />
<option name="LAUNCH_PROFILE_NAME" value="https" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />
<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="" />
<method v="2">
<option name="Build" />
</method>
</configuration>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="454eaf08-7244-4002-811f-5409ccfe6a2a" name="Changes" comment="" />
<created>1712063297753</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1712063297753</updated>
<workItem from="1712063301685" duration="548000" />
<workItem from="1712498505089" duration="6987000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="UnityCheckinConfiguration" checkUnsavedScenes="true" />
</project>

File diff suppressed because it is too large Load Diff

@ -1,559 +0,0 @@
using System.Net.Http.Headers;
namespace API_Tests_Console;
using System.Text;
using System.Text.Json;
using Entities;
using Model;
public class Tests_Console_Connect_API
{
// Cette section permet de tester d'API déployée sur le serveur codefirst de l'IUT
static readonly HttpClient client = new HttpClient();
static string email = "verax@verax.com";
static string password = "P@ssw0rd1";
public static async Task Main2(string[] args)
{
//await RegisterUser("verax@verax.com", "P@ssw0rd1");
// Ne pas commenter cette ligne
string tokenAPI = await LoginAndGetToken(email, password);
//await TestUser(tokenAPI);
//await TestFormulaire(tokenAPI);
await TestArticle(tokenAPI);
}
private static async Task TestFormulaire(string tokenAPI)
{
await TestFormulaireGetAll(tokenAPI);
await TestFormulaireGetId(tokenAPI);
//await TestFormulaireCreate(tokenAPI);
//await TestFormulaireDelete(tokenAPI);
//await TestFormulaireUpdate(tokenAPI);
}
private static async Task TestUser(string tokenAPI)
{
await TestUserGetAll(tokenAPI);
await TestUserGetId(tokenAPI);
await TestUserCreate(tokenAPI);
//await TestUserDelete(tokenAPI);
//await TestUserUpdate(tokenAPI);
await TestGetAllArticleUser(tokenAPI);
await TestGetArticleByUser(tokenAPI);
//await TestCreateArticleUser(tokenAPI);
//await TestDeleteArticleUser(tokenAPI);
//await TestUpdateArticleUser(tokenAPI);
}
static async Task TestArticle(string tokenAPI)
{
await TestArticleGetId(tokenAPI);
//await TestArticleCreate(tokenAPI);
await TestArticleGetAll(tokenAPI);
//await TestArticleDelete(tokenAPI);
//await TestArticleUpdate(tokenAPI);
}
public static async Task<string> LoginAndGetToken(string Email, string Password)
{
var credentials = new
{
email = Email,
password = Password
};
var json = JsonSerializer.Serialize(credentials);
var data = new StringContent(json, Encoding.UTF8, "application/json");
try
{
var response = await client.PostAsync("https://codefirst.iut.uca.fr/containers/Verax-verax-api/login", data);
var responseBody = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode)
{
using (JsonDocument doc = JsonDocument.Parse(responseBody))
{
if (doc.RootElement.TryGetProperty("accessToken", out JsonElement tokenElement)) // Change "token" to the actual property name
{
string token = tokenElement.GetString();
Console.WriteLine("Token retrieved");
return token;
}
else
{
Console.WriteLine("Token not found in the response.");
return null;
}
}
}
else
{
Console.WriteLine($"Login failed: {response.StatusCode}");
Console.WriteLine(responseBody);
return null;
}
}
catch (HttpRequestException e)
{
Console.WriteLine($"HttpRequestException: {e.Message}");
return null;
}
catch (JsonException e)
{
Console.WriteLine($"Error parsing JSON response: {e.Message}");
return null;
}
}
public static async Task<string> RegisterUser(string email, string password)
{
var newUser = new
{
email = email,
password = password
};
var json = JsonSerializer.Serialize(newUser);
var data = new StringContent(json, Encoding.UTF8, "application/json");
try
{
var response = await client.PostAsync("https://codefirst.iut.uca.fr/containers/Verax-verax-api/register", data);
var responseBody = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode)
{
Console.WriteLine("Registration successful");
Console.WriteLine(responseBody);
return responseBody;
}
else
{
Console.WriteLine($"Registration failed: {response.StatusCode}");
Console.WriteLine(responseBody);
return null;
}
}
catch (HttpRequestException e)
{
Console.WriteLine($"HttpRequestException: {e.Message}");
return null;
}
catch (Exception e)
{
Console.WriteLine($"General Exception: {e.Message}");
return null;
}
}
static async Task TestArticleGetAll(string tokenAPI)
{
try
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var response = await client.GetAsync("https://codefirst.iut.uca.fr/containers/Verax-verax-api/articles");
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
static async Task TestArticleGetId(string tokenAPI)
{
try
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var response = await client.GetAsync("https://codefirst.iut.uca.fr/containers/Verax-verax-api/article/1");
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
static async Task TestArticleCreate(string tokenAPI)
{
try
{
var article = new Article()
{
Title = "Test",
Description = "Test",
Author = "Test",
DatePublished = "Test",
LectureTime = 0
};
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var json = JsonSerializer.Serialize(article);
var data = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://codefirst.iut.uca.fr/containers/Verax-verax-api/article", data);
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
static async Task TestArticleDelete(string tokenAPI)
{
try
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var response = await client.DeleteAsync("https://codefirst.iut.uca.fr/containers/Verax-verax-api/article/1");
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
static async Task TestArticleUpdate(string tokenAPI)
{
try
{
var article = new Article()
{
Title = "Louis",
Description = "Je",
Author = "T'",
DatePublished = "aime",
LectureTime = 0
};
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var json = JsonSerializer.Serialize(article);
var data = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PutAsync("https://codefirst.iut.uca.fr/containers/Verax-verax-api/article/1", data);
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
static async Task TestFormulaireGetAll(string tokenAPI)
{
try
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var response = await client.GetAsync("https://codefirst.iut.uca.fr/containers/Verax-verax-api/formulaires");
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
static async Task TestFormulaireGetId(string tokenAPI)
{
try
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var response = await client.GetAsync("https://codefirst.iut.uca.fr/containers/Verax-verax-api/formulaire/1");
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
static async Task TestFormulaireCreate(string tokenAPI)
{
try
{
var formulaire = new Formulaire()
{
Theme = "Test",
Date = "Test",
Lien = "Test",
UserPseudo = "Sha"
};
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var json = JsonSerializer.Serialize(formulaire);
var data = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://codefirst.iut.uca.fr/containers/Verax-verax-api/formulaire", data);
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
static async Task TestFormulaireDelete(string tokenAPI)
{
try
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var response = await client.DeleteAsync("https://codefirst.iut.uca.fr/containers/Verax-verax-api/formulaire/5");
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
static async Task TestFormulaireUpdate(string tokenAPI)
{
try
{
var formulaire = new Formulaire()
{
Theme = "J'",
Date = "aime",
Lien = "Les",
UserPseudo = "Sha"
};
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var json = JsonSerializer.Serialize(formulaire);
var data = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PutAsync("https://codefirst.iut.uca.fr/containers/Verax-verax-api/", data);
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
static async Task TestUserGetAll(string tokenAPI)
{
try
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var response = await client.GetAsync("https://codefirst.iut.uca.fr/containers/Verax-verax-api/users");
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
static async Task TestUserGetId(string tokenAPI)
{
try
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var response = await client.GetAsync("https://codefirst.iut.uca.fr/containers/Verax-verax-api/user/Sha");
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
static async Task TestUserCreate(string tokenAPI)
{
try
{
var user = new User()
{
Pseudo = "J",
Nom = "'",
Prenom = "aime",
Mail = "les",
Mdp = "pieds",
Role = "Admin"
};
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var json = JsonSerializer.Serialize(user);
var data = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://codefirst.iut.uca.fr/containers/Verax-verax-api/user", data);
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
static async Task TestUserDelete(string tokenAPI)
{
try
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var response = await client.DeleteAsync("https://codefirst.iut.uca.fr/containers/Verax-verax-api/user/Sha");
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
static async Task TestUserUpdate(string tokenAPI)
{
try
{
var user = new User()
{
Pseudo = "Sha",
Nom = "J'",
Prenom = "aime",
Mail = "les",
Mdp = "pieds",
Role = "Admin"
};
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var json = JsonSerializer.Serialize(user);
var data = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PutAsync("https://codefirst.iut.uca.fr/containers/Verax-verax-api/user/Sha", data);
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
static async Task TestGetAllArticleUser(string tokenAPI)
{
try
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var response = await client.GetAsync("https://codefirst.iut.uca.fr/containers/Verax-verax-api/article/users");
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
static async Task TestGetArticleByUser(string tokenAPI)
{
try
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var response = await client.GetAsync("https://codefirst.iut.uca.fr/containers/Verax-verax-api/user/Sha/articles");
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
static async Task TestCreateArticleUser(string tokenAPI)
{
try
{
var articleUser = new ArticleUserEntity()
{
ArticleEntityId = 1,
UserEntityPseudo = "Sha"
};
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var json = JsonSerializer.Serialize(articleUser);
var data = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://codefirst.iut.uca.fr/containers/Verax-verax-api/user/article", data);
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
static async Task TestDeleteArticleUser(string tokenAPI)
{
try
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var response = await client.DeleteAsync("https://codefirst.iut.uca.fr/containers/Verax-verax-api/user/Sha/3");
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
static async Task TestUpdateArticleUser(string tokenAPI)
{
try
{
var articleUser = new ArticleUserEntity()
{
ArticleEntityId = 2,
UserEntityPseudo = "Sha"
};
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
long oldId = 3;
var json = JsonSerializer.Serialize(articleUser);
var data = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PutAsync($"https://codefirst.iut.uca.fr/containers/Verax-verax-api/user/Sha/{oldId}", data);
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}

@ -1,35 +0,0 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
EXPOSE 8080
EXPOSE 8081
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["API/API.csproj", "API/"]
COPY ["API_DbDataManager/API_DbDataManager.csproj", "API_DbDataManager/"]
COPY ["API_Services/API_Services.csproj", "API_Services/"]
COPY ["Entities/Entities.csproj", "Entities/"]
COPY ["Model/Model.csproj", "Model/"]
COPY ["DbContextLib/DbContextLib.csproj", "DbContextLib/"]
COPY ["StubbedContextLib/StubbedContextLib.csproj", "StubbedContextLib/"]
COPY ["API_Mapping/API_Mapping.csproj", "API_Mapping/"]
COPY ["API_Model/API_Model.csproj", "API_Model/"]
RUN dotnet restore "API/API.csproj"
COPY . .
WORKDIR "/src/API"
RUN dotnet build "API.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "API.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "API.dll"]

@ -1,9 +0,0 @@
using System.Text.Json.Serialization;
namespace Model;
[JsonConverter(typeof(JsonStringEnumConverter))]
public enum UserOrderCriteria
{
None, ByFirstName, ByLastName
}

@ -0,0 +1,2 @@
# Verax_API_EF

@ -1,70 +0,0 @@
using DbContextLib;
using Entities;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
namespace TestsUnitaires;
public class TestsArticleUserEntity
{
[Fact]
public void Add_Test()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<LibraryContext>()
.UseSqlite(connection)
.Options;
using (var context = new LibraryContext(options))
{
context.Database.EnsureCreated();
ArticleEntity a1 = new ArticleEntity { Title = "Breaking News Elisabeth 2 Died", Description = "The queen of England died today at the age of 95", DatePublished = "2022-02-06", LectureTime = 2, Author = "Tom Smith" };
ArticleEntity a2 = new ArticleEntity { Title = "The new iPhone 15", Description = "The new iPhone 15 is out and it's the best phone ever", DatePublished = "2022-02-06", LectureTime = 3, Author = "Tom Smith" };
ArticleEntity a3 = new ArticleEntity { Title = "M&M's new recipe", Description = "M&M's new recipe is out and it's the best chocolate ever", DatePublished = "2022-02-06", LectureTime = 1, Author = "M&M's Red" };
UserEntity u1 = new UserEntity
{
Pseudo = "Blizzard",
Prenom = "Louis",
Nom = "Laborie",
Mail = "he@gmail.com",
Mdp = "1234",
Role = "Admin"
};
ArticleUserEntity au1 = new ArticleUserEntity
{
UserEntityPseudo = "Blizzard",
ArticleEntityId = 1
};
ArticleUserEntity au2 = new ArticleUserEntity
{
UserEntityPseudo = "Blizzard",
ArticleEntityId = 2
};
ArticleUserEntity au3 = new ArticleUserEntity
{
UserEntityPseudo = "Blizzard",
ArticleEntityId = 3
};
context.ArticleSet.Add(a1);
context.ArticleSet.Add(a2);
context.ArticleSet.Add(a3);
context.UserSet.Add(u1);
context.ArticleUserSet.Add(au1);
context.ArticleUserSet.Add(au2);
context.ArticleUserSet.Add(au3);
context.SaveChanges();
Assert.Equal(3, context.ArticleSet.Count());
Assert.Equal(1, context.ArticleUserSet.First().ArticleEntityId);
connection.Close();
}
}
}

@ -1,200 +0,0 @@
using DbContextLib;
using Entities;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
namespace Tests;
public class TestsFormEntity
{
[Fact]
public void Add_Test()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<LibraryContext>()
.UseSqlite(connection)
.Options;
using (var context = new LibraryContext(options))
{
context.Database.EnsureCreated();
UserEntity u1 = new UserEntity
{
Pseudo = "Blizzard",
Prenom = "Louis",
Nom = "Laborie",
Mail = "he@gmail.com",
Mdp = "1234",
Role = "Admin"
};
FormEntity f1 = new FormEntity
{
Id = 1,
Theme = "theme",
DatePublication = "date",
Link = "link",
UserEntityPseudo = "Blizzard",
User = u1
};
FormEntity f2 = new FormEntity
{
Id = 2,
Theme = "theme",
DatePublication = "date",
Link = "link",
UserEntityPseudo = "Blizzard",
User = u1
};
FormEntity f3 = new FormEntity
{
Id = 3,
Theme = "theme",
DatePublication = "date",
Link = "link",
UserEntityPseudo = "Blizzard",
User = u1
};
context.UserSet.Add(u1);
context.FormSet.Add(f1);
context.FormSet.Add(f2);
context.FormSet.Add(f3);
context.SaveChanges();
Assert.Equal(3, context.FormSet.Count());
Assert.Equal("Blizzard", context.FormSet.First().UserEntityPseudo);
connection.Close();
}
}
[Fact]
public void Modify_Test()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<LibraryContext>()
.UseSqlite(connection)
.Options;
using (var context = new LibraryContext(options))
{
context.Database.EnsureCreated();
UserEntity u1 = new UserEntity
{
Pseudo = "Blizzard",
Prenom = "Louis",
Nom = "Laborie",
Mail = "he@gmail.com",
Mdp = "1234",
Role = "Admin"
};
FormEntity f1 = new FormEntity
{
Id = 1,
Theme = "theme",
DatePublication = "date",
Link = "link",
UserEntityPseudo = "Blizzard",
User = u1
};
FormEntity f2 = new FormEntity
{
Id = 2,
Theme = "theme2",
DatePublication = "date",
Link = "link",
UserEntityPseudo = "Blizzard",
User = u1
};
FormEntity f3 = new FormEntity
{
Id = 3,
Theme = "theme3",
DatePublication = "date",
Link = "link",
UserEntityPseudo = "Blizzard",
User = u1
};
context.UserSet.Add(u1);
context.FormSet.Add(f1);
context.FormSet.Add(f2);
context.FormSet.Add(f3);
context.SaveChanges();
var form = context.FormSet.First(f => f.Id == 1);
form.Theme = "Politique";
context.SaveChanges();
string formRemove = "theme";
string formNew = "Politique";
Assert.Equal(1, context.FormSet.Count(f => f.Theme == formNew));
Assert.Equal(0, context.FormSet.Count(f => f.Theme == formRemove));
connection.Close();
}
}
[Fact]
public void Remove_Test()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<LibraryContext>()
.UseSqlite(connection)
.Options;
using (var context = new LibraryContext(options))
{
context.Database.EnsureCreated();
UserEntity u1 = new UserEntity
{
Pseudo = "Blizzard",
Prenom = "Louis",
Nom = "Laborie",
Mail = "he@gmail.com",
Mdp = "1234",
Role = "Admin"
};
FormEntity f1 = new FormEntity
{
Id = 1,
Theme = "theme",
DatePublication = "date",
Link = "link",
UserEntityPseudo = "Blizzard",
User = u1
};
FormEntity f2 = new FormEntity
{
Id = 2,
Theme = "theme2",
DatePublication = "date",
Link = "link",
UserEntityPseudo = "Blizzard",
User = u1
};
FormEntity f3 = new FormEntity
{
Id = 3,
Theme = "theme3",
DatePublication = "date",
Link = "link",
UserEntityPseudo = "Blizzard",
User = u1
};
context.UserSet.Add(u1);
context.FormSet.Add(f1);
context.FormSet.Add(f2);
context.FormSet.Add(f3);
context.SaveChanges();
Assert.Equal(3, context.FormSet.Count());
var form = context.FormSet.First(f => f.Theme == "theme2");
context.Remove(form);
context.SaveChanges();
Assert.Equal(2, context.FormSet.Count());
Assert.Equal(0, context.FormSet.Count(f => f.Theme == "theme2"));
connection.Close();
}
}
}

@ -0,0 +1,15 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/.idea.Verax_API_EF.iml
/contentModel.xml
/projectSettingsUpdater.xml
/modules.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# GitHub Copilot persisted chat sessions
/copilot/chatSessions

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders>
<Path>../../Verax_API_EF</Path>
</attachedFolders>
<explicitIncludes />
<explicitExcludes />
</component>
</project>

@ -1,313 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoGeneratedRunConfigurationManager">
<projectFile profileName="http">API/API.csproj</projectFile>
<projectFile profileName="https">API/API.csproj</projectFile>
<projectFile>API_Tests_Console/API_Tests_Console.csproj</projectFile>
<projectFile>Test_Console_EF/Test_Console_EF.csproj</projectFile>
</component>
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="0b890b11-446c-405a-95d5-cd68743c4057" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/.idea.Verax_API_EF/.idea/.gitignore" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/.idea.Verax_API_EF/.idea/indexLayout.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/.idea.Verax_API_EF/.idea/vcs.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API/API.csproj" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API/API.http" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API/Controllers/ArticleController.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API/Controllers/FormulaireController.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API/Controllers/UserController.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API/Entity_FrameWork.Article.db" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API/Program.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API/Properties/launchSettings.json" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API/appsettings.Development.json" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API/appsettings.json" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API/log.txt" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_DbDataManager/API_DbDataManager.csproj" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_DbDataManager/DbManager.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_DbDataManager/DbManagerArticle.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_DbDataManager/DbManagerFormulaire.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_DbDataManager/DbManagerUser.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_DbDataManager/Extensions.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Mapping/API_Mapping.csproj" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Mapping/ArticleMapper.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Mapping/FormulaireMapping.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Mapping/UserMapping.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Model/API_Model.csproj" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Model/ArticleDTO.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Model/FormulaireDTO.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Model/UserDTO.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Services/API_Services.csproj" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Services/IArticleService.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Services/IDataManager.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Services/IFormulaireService.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Services/IUserService.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Tests_Console/API_Tests_Console.csproj" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Tests_Console/Tests_Console.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_UnitTest_Mapper/API_UnitTest_Mapper.csproj" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_UnitTest_Mapper/GlobalUsings.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Unit_Test/API_Unit_Test.csproj" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Unit_Test/ArticleControllerTests.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Unit_Test/ArticleDTOTests.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Unit_Test/ArticleMapperTests.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Unit_Test/DbManagerArticleTests.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Unit_Test/DbManagerFormulaireTests.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Unit_Test/DbManagerTests.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Unit_Test/DbManagerUserTests.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Unit_Test/ExtensionsTests.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Unit_Test/FormMapperTests.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Unit_Test/FormulaireControllerTests.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Unit_Test/FormulaireDTOTests.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Unit_Test/GlobalUsings.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Unit_Test/IArticleServiceTests.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Unit_Test/IFormServiceTests.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Unit_Test/IUserServiceTests.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Unit_Test/UserControllerTests.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Unit_Test/UserDTOTests.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/API_Unit_Test/UserMappingTests.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/DbContextLib/ApplicationDbContext.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/DbContextLib/DbContextLib.csproj" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/DbContextLib/LibraryContext.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/DbContextLib/Migrations/20240317095050_mrg1.Designer.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/DbContextLib/Migrations/20240317095050_mrg1.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/DbContextLib/Migrations/LibraryContextModelSnapshot.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Dockerfile" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Entities/ArticleEntity.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Entities/ArticleUserEntity.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Entities/Entities.csproj" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Entities/FormEntity.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Entities/UserEntity.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Model/Article.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Model/ArticleOrderCriteria.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Model/FormOrderCriteria.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Model/Formulaire.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Model/Model.csproj" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Model/User.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Model/UserOrderCriteria.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/StubbedContextLib/Class1.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/StubbedContextLib/StubbedContextLib.csproj" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Test_Console_EF/Entity_FrameWork.Article.db" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Test_Console_EF/Test_Console_EF.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Test_Console_EF/Test_Console_EF.csproj" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Test_Console_EF/log.txt" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Unit_Test_EF/TestsArticleEntity.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Unit_Test_EF/TestsArticleUserEntity.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Unit_Test_EF/TestsFormEntity.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Unit_Test_EF/TestsUserEntity.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Unit_Test_EF/Unit_Test_EF.csproj" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Verax_API_EF.sln" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Verax_API_EF/.idea/.idea.Verax_API_EF.dir/.idea/.gitignore" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Verax_API_EF/.idea/.idea.Verax_API_EF.dir/.idea/indexLayout.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Verax_API_EF/.idea/.idea.Verax_API_EF.dir/.idea/vcs.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Verax_API_EF/Program.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Verax_API_EF/Verax_API_EF.csproj" beforeDir="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="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/../.." />
</component>
<component name="MetaFilesCheckinStateConfiguration" checkMetaFiles="true" />
<component name="ProblemsViewState">
<option name="selectedTabId" value="Toolset" />
</component>
<component name="ProjectColorInfo">{
&quot;customColor&quot;: &quot;&quot;,
&quot;associatedIndex&quot;: 8
}</component>
<component name="ProjectId" id="2eENYNJJTgbOpfWw136RJzo5ItR" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
".NET Launch Settings Profile.API: docker.executor": "Run",
".NET Launch Settings Profile.API: http.executor": "Run",
".NET Launch Settings Profile.API: https.executor": "Run",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"git-widget-placeholder": "rebase",
"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",
"vue.rearranger.settings.migration": "true"
},
"keyToStringList": {
"rider.external.source.directories": [
"/Users/tonyfages/Library/Application Support/JetBrains/Rider2023.3/resharper-host/DecompilerCache",
"/Users/tonyfages/Library/Application Support/JetBrains/Rider2023.3/resharper-host/SourcesCache",
"/Users/tonyfages/.local/share/Symbols/src"
]
}
}]]></component>
<component name="RunManager" selected=".NET Launch Settings Profile.API: https">
<configuration name="API_Tests_Console" 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="USE_EXTERNAL_CONSOLE" value="0" />
<option name="USE_MONO" value="0" />
<option name="RUNTIME_ARGUMENTS" value="" />
<option name="PROJECT_PATH" value="$PROJECT_DIR$/API_Tests_Console/API_Tests_Console.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="Test_Console_EF" 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="USE_EXTERNAL_CONSOLE" value="0" />
<option name="USE_MONO" value="0" />
<option name="RUNTIME_ARGUMENTS" value="" />
<option name="PROJECT_PATH" value="$PROJECT_DIR$/Test_Console_EF/Test_Console_EF.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: Docker" type="LaunchSettings" factoryName=".NET Launch Settings Profile" temporary="true">
<option name="LAUNCH_PROFILE_PROJECT_FILE_PATH" value="$PROJECT_DIR$/API/API.csproj" />
<option name="LAUNCH_PROFILE_TFM" value="net8.0" />
<option name="LAUNCH_PROFILE_NAME" value="Docker" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />
<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="" />
<method v="2">
<option name="Build" />
</method>
</configuration>
<configuration name="API: docker" type="LaunchSettings" factoryName=".NET Launch Settings Profile" temporary="true">
<option name="LAUNCH_PROFILE_PROJECT_FILE_PATH" value="$PROJECT_DIR$/API/API.csproj" />
<option name="LAUNCH_PROFILE_TFM" value="net8.0" />
<option name="LAUNCH_PROFILE_NAME" value="docker" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />
<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="" />
<method v="2">
<option name="Build" />
</method>
</configuration>
<configuration name="API: http" type="LaunchSettings" factoryName=".NET Launch Settings Profile">
<option name="LAUNCH_PROFILE_PROJECT_FILE_PATH" value="$PROJECT_DIR$/API/API.csproj" />
<option name="LAUNCH_PROFILE_TFM" value="net8.0" />
<option name="LAUNCH_PROFILE_NAME" value="http" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />
<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="" />
<method v="2">
<option name="Build" />
</method>
</configuration>
<configuration name="API: https" type="LaunchSettings" factoryName=".NET Launch Settings Profile">
<option name="LAUNCH_PROFILE_PROJECT_FILE_PATH" value="$PROJECT_DIR$/API/API.csproj" />
<option name="LAUNCH_PROFILE_TFM" value="net8.0" />
<option name="LAUNCH_PROFILE_NAME" value="https" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />
<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="" />
<method v="2">
<option name="Build" />
</method>
</configuration>
<configuration name="../Dockerfile: Compose Deployment" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
<deployment type="dockerfile">
<settings>
<option name="imageTag" value="api" />
<option name="containerName" value="api" />
<option name="contextFolderPath" value="$PROJECT_DIR$" />
<option name="portBindings">
<list>
<DockerPortBindingImpl>
<option name="containerPort" value="8080" />
<option name="hostIp" value="127.0.0.1" />
<option name="hostPort" value="8080" />
</DockerPortBindingImpl>
</list>
</option>
<option name="sourceFilePath" value="../Dockerfile" />
</settings>
</deployment>
<EXTENSION ID="com.jetbrains.rider.docker.debug" isFastModeEnabled="true" isSslEnabled="false" />
<method v="2" />
</configuration>
<configuration default="true" type="docker-deploy" factoryName="dockerfile" temporary="true">
<deployment type="dockerfile" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue=".NET Launch Settings Profile.API: Docker" />
<item itemvalue=".NET Launch Settings Profile.API: docker" />
</list>
</recent_temporary>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="0b890b11-446c-405a-95d5-cd68743c4057" name="Changes" comment="" />
<created>1711465825676</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1711465825676</updated>
<workItem from="1711465828197" duration="234000" />
<workItem from="1711466068272" duration="848000" />
<workItem from="1711468488298" duration="751000" />
<workItem from="1712036968994" duration="2827000" />
</task>
<task id="LOCAL-00001" summary="Dockerfile">
<option name="closed" value="true" />
<created>1712038898812</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1712038898812</updated>
</task>
<option name="localTasksCounter" value="2" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="UnityCheckinConfiguration" checkUnsavedScenes="true" />
<component name="VcsManagerConfiguration">
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
<MESSAGE value="Dockerfile" />
<option name="LAST_COMMIT_MESSAGE" value="Dockerfile" />
</component>
</project>

@ -6,7 +6,6 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization> <InvariantGlobalization>true</InvariantGlobalization>
<StartWorkingDirectory>$(MSBuildProjectDirectory)</StartWorkingDirectory> <StartWorkingDirectory>$(MSBuildProjectDirectory)</StartWorkingDirectory>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -33,10 +32,4 @@
<ProjectReference Include="..\StubbedContextLib\StubbedContextLib.csproj" /> <ProjectReference Include="..\StubbedContextLib\StubbedContextLib.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Include="..\.dockerignore">
<Link>.dockerignore</Link>
</Content>
</ItemGroup>
</Project> </Project>

@ -1,13 +1,11 @@
using API_Mapping; using API_Mapping;
using API_Services; using API_Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Model; using Model;
namespace API.Controllers namespace API.Controllers
{ {
[Authorize]
[Route("api/[controller]")] [Route("api/[controller]")]
[ApiController] [ApiController]
public class ArticleController : ControllerBase public class ArticleController : ControllerBase

@ -5,11 +5,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using API_Mapping; using API_Mapping;
using Microsoft.AspNetCore.Authorization;
namespace API.Controllers namespace API.Controllers
{ {
[Authorize]
[Route("api/[controller]")] [Route("api/[controller]")]
[ApiController] [ApiController]
public class FormulaireController : ControllerBase public class FormulaireController : ControllerBase

@ -4,12 +4,10 @@ using API_Services;
using Model; using Model;
using API_Mapping; using API_Mapping;
using Entities; using Entities;
using Microsoft.AspNetCore.Authorization;
namespace API.Controllers namespace API.Controllers
{ {
[Authorize]
[Route("api/[controller]")] [Route("api/[controller]")]
[ApiController] [ApiController]
public class UserController : ControllerBase public class UserController : ControllerBase
@ -127,7 +125,7 @@ namespace API.Controllers
} }
} }
[HttpGet("/user/article/users")] [HttpGet("/articleUsers")]
public async Task<IActionResult> GetAllArticleUsers() public async Task<IActionResult> GetAllArticleUsers()
{ {
_logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(GetAllArticleUsers), ""); _logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(GetAllArticleUsers), "");
@ -147,7 +145,7 @@ namespace API.Controllers
} }
} }
[HttpGet("/user/{pseudo}/articles")] [HttpGet("/user/{pseudo}/article")]
public async Task<IActionResult> GetArticleUser(string pseudo) public async Task<IActionResult> GetArticleUser(string pseudo)
{ {
_logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(GetArticleUser), pseudo); _logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(GetArticleUser), pseudo);
@ -208,34 +206,18 @@ namespace API.Controllers
} }
} }
[HttpPut("/user/{pseudo}/{oldId}")] [HttpPut("/user/{pseudo}/article")]
public async Task<IActionResult> UpdateArticleUser(ArticleUserEntity articleUser, long oldId) public async Task<IActionResult> UpdateArticleUser(ArticleUserEntity articleUser)
{ {
_logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(UpdateArticleUser), articleUser); _logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(UpdateArticleUser), articleUser);
try try
{ {
var existingEntity = (await _dataManager.UserService.GetArticleUser(articleUser.UserEntityPseudo)).Select(a => a.ToDTO()); var result = (await _dataManager.UserService.UpdateArticleUser(articleUser));
if (!result)
if (existingEntity == null)
{
return NotFound($"ArticleUser {articleUser.UserEntityPseudo} does not exist");
}
var deleteResult = await _dataManager.UserService.DeleteArticleUser(articleUser.UserEntityPseudo, oldId);
if (!deleteResult)
{
return BadRequest($"Failed to delete ArticleUser {articleUser.UserEntityPseudo}");
}
var createResult = await _dataManager.UserService.CreateArticleUser(articleUser);
if (createResult == null)
{ {
return BadRequest($"Failed to create ArticleUser {articleUser.UserEntityPseudo}"); return BadRequest($"ArticleUser {articleUser.UserEntityPseudo} does not exist");
} }
return Ok(result);
return Ok(createResult);
} }
catch (Exception error) catch (Exception error)
{ {
@ -243,5 +225,7 @@ namespace API.Controllers
return BadRequest(error.Message); return BadRequest(error.Message);
} }
} }
} }
} }

@ -75,18 +75,13 @@ app.MapIdentityApi<IdentityUser>();
app.MapSwagger().RequireAuthorization(); app.MapSwagger().RequireAuthorization();
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.
/*
if (app.Environment.IsDevelopment()) if (app.Environment.IsDevelopment())
{ {
app.UseSwagger(); app.UseSwagger();
app.UseSwaggerUI(); app.UseSwaggerUI();
}*/ }
app.UseSwagger();
app.UseSwaggerUI();
app.UseHttpsRedirection(); app.UseHttpsRedirection();
app.UseAuthentication();
app.UseAuthorization(); app.UseAuthorization();
app.MapControllers(); app.MapControllers();

@ -0,0 +1,140 @@
info: 03/15/2024 16:59:22.173 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (6ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT COUNT(*) FROM "sqlite_master" WHERE "name" = '__EFMigrationsHistory' AND "type" = 'table';
info: 03/15/2024 16:59:22.176 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT COUNT(*) FROM "sqlite_master" WHERE "name" = '__EFMigrationsHistory' AND "type" = 'table';
info: 03/15/2024 16:59:22.182 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT "MigrationId", "ProductVersion"
FROM "__EFMigrationsHistory"
ORDER BY "MigrationId";
info: 03/15/2024 16:59:22.190 RelationalEventId.MigrationsNotApplied[20405] (Microsoft.EntityFrameworkCore.Migrations)
No migrations were applied. The database is already up to date.
info: 03/15/2024 16:59:30.063 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT "a"."Id", "a"."Author", "a"."DatePublished", "a"."Description", "a"."LectureTime", "a"."Title"
FROM "ArticleSet" AS "a"
info: 03/15/2024 17:08:29.557 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (6ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT COUNT(*) FROM "sqlite_master" WHERE "name" = '__EFMigrationsHistory' AND "type" = 'table';
info: 03/15/2024 17:08:29.561 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT COUNT(*) FROM "sqlite_master" WHERE "name" = '__EFMigrationsHistory' AND "type" = 'table';
info: 03/15/2024 17:08:29.567 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT "MigrationId", "ProductVersion"
FROM "__EFMigrationsHistory"
ORDER BY "MigrationId";
info: 03/15/2024 17:08:29.575 RelationalEventId.MigrationsNotApplied[20405] (Microsoft.EntityFrameworkCore.Migrations)
No migrations were applied. The database is already up to date.
info: 03/15/2024 17:08:33.305 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT "a"."Id", "a"."Author", "a"."DatePublished", "a"."Description", "a"."LectureTime", "a"."Title"
FROM "ArticleSet" AS "a"
info: 03/16/2024 13:47:23.492 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (6ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT COUNT(*) FROM "sqlite_master" WHERE "name" = '__EFMigrationsHistory' AND "type" = 'table';
info: 03/16/2024 13:47:23.496 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT COUNT(*) FROM "sqlite_master" WHERE "name" = '__EFMigrationsHistory' AND "type" = 'table';
info: 03/16/2024 13:47:23.503 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT "MigrationId", "ProductVersion"
FROM "__EFMigrationsHistory"
ORDER BY "MigrationId";
info: 03/16/2024 13:47:23.511 RelationalEventId.MigrationsNotApplied[20405] (Microsoft.EntityFrameworkCore.Migrations)
No migrations were applied. The database is already up to date.
info: 03/16/2024 13:49:15.334 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT "a"."Id", "a"."Author", "a"."DatePublished", "a"."Description", "a"."LectureTime", "a"."Title"
FROM "ArticleSet" AS "a"
info: 03/16/2024 13:50:41.465 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (5ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT COUNT(*) FROM "sqlite_master" WHERE "name" = '__EFMigrationsHistory' AND "type" = 'table';
info: 03/16/2024 13:50:41.469 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT COUNT(*) FROM "sqlite_master" WHERE "name" = '__EFMigrationsHistory' AND "type" = 'table';
info: 03/16/2024 13:50:41.475 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT "MigrationId", "ProductVersion"
FROM "__EFMigrationsHistory"
ORDER BY "MigrationId";
info: 03/16/2024 13:50:41.483 RelationalEventId.MigrationsNotApplied[20405] (Microsoft.EntityFrameworkCore.Migrations)
No migrations were applied. The database is already up to date.
info: 03/16/2024 13:53:25.287 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (6ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT COUNT(*) FROM "sqlite_master" WHERE "name" = '__EFMigrationsHistory' AND "type" = 'table';
info: 03/16/2024 13:53:25.291 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT COUNT(*) FROM "sqlite_master" WHERE "name" = '__EFMigrationsHistory' AND "type" = 'table';
info: 03/16/2024 13:53:25.298 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT "MigrationId", "ProductVersion"
FROM "__EFMigrationsHistory"
ORDER BY "MigrationId";
info: 03/16/2024 13:53:25.307 RelationalEventId.MigrationsNotApplied[20405] (Microsoft.EntityFrameworkCore.Migrations)
No migrations were applied. The database is already up to date.
warn: 03/16/2024 13:55:55.456 CoreEventId.RowLimitingOperationWithoutOrderByWarning[10102] (Microsoft.EntityFrameworkCore.Query)
The query uses a row limiting operator ('Skip'/'Take') without an 'OrderBy' operator. This may lead to unpredictable results. If the 'Distinct' operator is used after 'OrderBy', then make sure to use the 'OrderBy' operator after 'Distinct' as the ordering would otherwise get erased.
info: 03/16/2024 13:55:55.509 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (2ms) [Parameters=[@__p_0='?' (DbType = Int32)], CommandType='Text', CommandTimeout='30']
SELECT "f"."Id", "f"."DatePublication", "f"."Link", "f"."Theme", "f"."UserEntityPseudo"
FROM "FormSet" AS "f"
LIMIT -1 OFFSET @__p_0
info: 03/16/2024 13:58:19.293 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (6ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT COUNT(*) FROM "sqlite_master" WHERE "name" = '__EFMigrationsHistory' AND "type" = 'table';
info: 03/16/2024 13:58:19.297 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT COUNT(*) FROM "sqlite_master" WHERE "name" = '__EFMigrationsHistory' AND "type" = 'table';
info: 03/16/2024 13:58:19.304 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT "MigrationId", "ProductVersion"
FROM "__EFMigrationsHistory"
ORDER BY "MigrationId";
info: 03/16/2024 13:58:19.312 RelationalEventId.MigrationsNotApplied[20405] (Microsoft.EntityFrameworkCore.Migrations)
No migrations were applied. The database is already up to date.
info: 03/16/2024 13:59:32.285 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (6ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT COUNT(*) FROM "sqlite_master" WHERE "name" = '__EFMigrationsHistory' AND "type" = 'table';
info: 03/16/2024 13:59:32.289 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT COUNT(*) FROM "sqlite_master" WHERE "name" = '__EFMigrationsHistory' AND "type" = 'table';
info: 03/16/2024 13:59:32.296 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT "MigrationId", "ProductVersion"
FROM "__EFMigrationsHistory"
ORDER BY "MigrationId";
info: 03/16/2024 13:59:32.303 RelationalEventId.MigrationsNotApplied[20405] (Microsoft.EntityFrameworkCore.Migrations)
No migrations were applied. The database is already up to date.
info: 03/16/2024 14:00:53.457 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (5ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT COUNT(*) FROM "sqlite_master" WHERE "name" = '__EFMigrationsHistory' AND "type" = 'table';
info: 03/16/2024 14:00:53.462 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT COUNT(*) FROM "sqlite_master" WHERE "name" = '__EFMigrationsHistory' AND "type" = 'table';
info: 03/16/2024 14:00:53.468 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT "MigrationId", "ProductVersion"
FROM "__EFMigrationsHistory"
ORDER BY "MigrationId";
info: 03/16/2024 14:00:53.476 RelationalEventId.MigrationsNotApplied[20405] (Microsoft.EntityFrameworkCore.Migrations)
No migrations were applied. The database is already up to date.
info: 03/16/2024 14:01:22.357 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT "a"."Id", "a"."Author", "a"."DatePublished", "a"."Description", "a"."LectureTime", "a"."Title"
FROM "ArticleSet" AS "a"
info: 03/16/2024 14:02:47.267 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT "a"."Id", "a"."Author", "a"."DatePublished", "a"."Description", "a"."LectureTime", "a"."Title"
FROM "ArticleSet" AS "a"
info: 03/16/2024 14:03:10.579 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT "a"."Id", "a"."Author", "a"."DatePublished", "a"."Description", "a"."LectureTime", "a"."Title"
FROM "ArticleSet" AS "a"
info: 03/16/2024 14:03:15.675 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT "a"."Id", "a"."Author", "a"."DatePublished", "a"."Description", "a"."LectureTime", "a"."Title"
FROM "ArticleSet" AS "a"
ORDER BY "a"."Title"

@ -1,76 +1,60 @@
// See https://aka.ms/new-console-template for more information // See https://aka.ms/new-console-template for more information
using System.Net.Http.Headers;
using System.Text; using System.Text;
using System.Text.Json; using System.Text.Json;
using API_Tests_Console;
using Entities; using Entities;
using Model; using Model;
class Tests_Console_Connect_Localhost class Tests_Console
{ {
static readonly HttpClient client = new HttpClient(); static readonly HttpClient client = new HttpClient();
static string email = "verax@verax.com";
static string password = "P@ssw0rd1";
static async Task Main(string[] args) static async Task Main(string[] args)
{ {
//Commenter lignes apres premier execution //await TestUser();
await RegisterUser(email, password); await TestFormulaire();
//await TestArticle();
string tokenAPI = await LoginAndGetToken(email, password);
await TestUser(tokenAPI);
await TestFormulaire(tokenAPI);
await TestArticle(tokenAPI);
//Pour executer les tests de la console en communiquant avec l'API deployée sur codeFirst
//await Tests_Console_Connect_API.Main2(args);
} }
private static async Task TestFormulaire(string tokenAPI) private static async Task TestFormulaire()
{ {
await TestFormulaireGetAll(tokenAPI); await TestFormulaireGetAll();
await TestFormulaireGetId(tokenAPI); //await TestFormulaireGetId();
//await TestFormulaireCreate(tokenAPI); //await TestFormulaireCreate();
//await TestFormulaireDelete(tokenAPI); //await TestFormulaireDelete();
//await TestFormulaireUpdate(tokenAPI); //await TestFormulaireUpdate();
} }
private static async Task TestUser(string tokenAPI) private static async Task TestUser()
{ {
await TestUserGetAll(tokenAPI); //await TestUserGetAll();
await TestUserGetId(tokenAPI); //await TestUserGetId();
//await TestUserCreate(tokenAPI); //await TestUserCreate();
//await TestUserDelete(tokenAPI); //await TestUserDelete();
//await TestUserUpdate(tokenAPI); //await TestUserUpdate();
await TestGetAllArticleUser(tokenAPI); //await TestGetAllArticleUser();
await TestGetArticleByUser(tokenAPI); //await TestGetArticleByUser();
//await TestCreateArticleUser(tokenAPI); //await TestCreateArticleUser();
//await TestDeleteArticleUser(tokenAPI); //await TestDeleteArticleUser();
//await TestUpdateArticleUser(tokenAPI); //await TestUpdateArticleUser();
} }
static async Task TestArticle(string tokenAPI) static async Task TestArticle()
{ {
await TestArticleGetId(tokenAPI); await TestArticleGetId();
//await TestArticleCreate(tokenAPI); await TestArticleCreate();
await TestArticleGetAll(tokenAPI); await TestArticleGetAll();
//await TestArticleDelete(tokenAPI); await TestArticleDelete();
//await TestArticleUpdate(tokenAPI); await TestArticleUpdate();
} }
static async Task TestArticleGetAll(string tokenAPI) static async Task TestArticleGetAll()
{ {
try try
{ {
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI); var response = await client.GetAsync("http://localhost:5052/api/Article");
var response = await client.GetAsync("http://localhost:5052/articles");
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync(); var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody); Console.WriteLine(responseBody);
@ -81,11 +65,10 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestArticleGetId(string tokenAPI) static async Task TestArticleGetId()
{ {
try try
{ {
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var response = await client.GetAsync("http://localhost:5052/article/1"); var response = await client.GetAsync("http://localhost:5052/article/1");
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync(); var responseBody = await response.Content.ReadAsStringAsync();
@ -97,7 +80,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestArticleCreate(string tokenAPI) static async Task TestArticleCreate()
{ {
try try
{ {
@ -109,7 +92,6 @@ class Tests_Console_Connect_Localhost
DatePublished = "Test", DatePublished = "Test",
LectureTime = 0 LectureTime = 0
}; };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var json = JsonSerializer.Serialize(article); var json = JsonSerializer.Serialize(article);
var data = new StringContent(json, Encoding.UTF8, "application/json"); var data = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("http://localhost:5052/article", data); var response = await client.PostAsync("http://localhost:5052/article", data);
@ -123,12 +105,11 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestArticleDelete(string tokenAPI) static async Task TestArticleDelete()
{ {
try try
{ {
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI); var response = await client.DeleteAsync("http://localhost:5052/article/4");
var response = await client.DeleteAsync("http://localhost:5052/article/1");
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync(); var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody); Console.WriteLine(responseBody);
@ -139,7 +120,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestArticleUpdate(string tokenAPI) static async Task TestArticleUpdate()
{ {
try try
{ {
@ -151,7 +132,6 @@ class Tests_Console_Connect_Localhost
DatePublished = "aime", DatePublished = "aime",
LectureTime = 0 LectureTime = 0
}; };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var json = JsonSerializer.Serialize(article); var json = JsonSerializer.Serialize(article);
var data = new StringContent(json, Encoding.UTF8, "application/json"); var data = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PutAsync("http://localhost:5052/article/1", data); var response = await client.PutAsync("http://localhost:5052/article/1", data);
@ -165,11 +145,10 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestFormulaireGetAll(string tokenAPI) static async Task TestFormulaireGetAll()
{ {
try try
{ {
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var response = await client.GetAsync("http://localhost:5052/formulaires"); var response = await client.GetAsync("http://localhost:5052/formulaires");
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync(); var responseBody = await response.Content.ReadAsStringAsync();
@ -181,11 +160,10 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestFormulaireGetId(string tokenAPI) static async Task TestFormulaireGetId()
{ {
try try
{ {
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var response = await client.GetAsync("http://localhost:5052/formulaire/2"); var response = await client.GetAsync("http://localhost:5052/formulaire/2");
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync(); var responseBody = await response.Content.ReadAsStringAsync();
@ -197,7 +175,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestFormulaireCreate(string tokenAPI) static async Task TestFormulaireCreate()
{ {
try try
{ {
@ -208,7 +186,6 @@ class Tests_Console_Connect_Localhost
Lien = "Test", Lien = "Test",
UserPseudo = "Sha" UserPseudo = "Sha"
}; };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var json = JsonSerializer.Serialize(formulaire); var json = JsonSerializer.Serialize(formulaire);
var data = new StringContent(json, Encoding.UTF8, "application/json"); var data = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("http://localhost:5052/formulaire", data); var response = await client.PostAsync("http://localhost:5052/formulaire", data);
@ -222,11 +199,10 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestFormulaireDelete(string tokenAPI) static async Task TestFormulaireDelete()
{ {
try try
{ {
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var response = await client.DeleteAsync("http://localhost:5052/formulaire/5"); var response = await client.DeleteAsync("http://localhost:5052/formulaire/5");
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync(); var responseBody = await response.Content.ReadAsStringAsync();
@ -238,7 +214,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestFormulaireUpdate(string tokenAPI) static async Task TestFormulaireUpdate()
{ {
try try
{ {
@ -249,7 +225,6 @@ class Tests_Console_Connect_Localhost
Lien = "Les", Lien = "Les",
UserPseudo = "Sha" UserPseudo = "Sha"
}; };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var json = JsonSerializer.Serialize(formulaire); var json = JsonSerializer.Serialize(formulaire);
var data = new StringContent(json, Encoding.UTF8, "application/json"); var data = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PutAsync("http://localhost:5052/formulaire/4", data); var response = await client.PutAsync("http://localhost:5052/formulaire/4", data);
@ -263,11 +238,10 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestUserGetAll(string tokenAPI) static async Task TestUserGetAll()
{ {
try try
{ {
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var response = await client.GetAsync("http://localhost:5052/users"); var response = await client.GetAsync("http://localhost:5052/users");
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync(); var responseBody = await response.Content.ReadAsStringAsync();
@ -279,11 +253,10 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestUserGetId(string tokenAPI) static async Task TestUserGetId()
{ {
try try
{ {
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var response = await client.GetAsync("http://localhost:5052/user/Sha"); var response = await client.GetAsync("http://localhost:5052/user/Sha");
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync(); var responseBody = await response.Content.ReadAsStringAsync();
@ -295,7 +268,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestUserCreate(string tokenAPI) static async Task TestUserCreate()
{ {
try try
{ {
@ -308,7 +281,6 @@ class Tests_Console_Connect_Localhost
Mdp = "pieds", Mdp = "pieds",
Role = "Admin" Role = "Admin"
}; };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var json = JsonSerializer.Serialize(user); var json = JsonSerializer.Serialize(user);
var data = new StringContent(json, Encoding.UTF8, "application/json"); var data = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("http://localhost:5052/user", data); var response = await client.PostAsync("http://localhost:5052/user", data);
@ -322,11 +294,10 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestUserDelete(string tokenAPI) static async Task TestUserDelete()
{ {
try try
{ {
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var response = await client.DeleteAsync("http://localhost:5052/user/J"); var response = await client.DeleteAsync("http://localhost:5052/user/J");
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync(); var responseBody = await response.Content.ReadAsStringAsync();
@ -338,7 +309,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestUserUpdate(string tokenAPI) static async Task TestUserUpdate()
{ {
try try
{ {
@ -351,7 +322,6 @@ class Tests_Console_Connect_Localhost
Mdp = "pieds", Mdp = "pieds",
Role = "Admin" Role = "Admin"
}; };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var json = JsonSerializer.Serialize(user); var json = JsonSerializer.Serialize(user);
var data = new StringContent(json, Encoding.UTF8, "application/json"); var data = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PutAsync("http://localhost:5052/user/Sha", data); var response = await client.PutAsync("http://localhost:5052/user/Sha", data);
@ -365,12 +335,11 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestGetAllArticleUser(string tokenAPI) static async Task TestGetAllArticleUser()
{ {
try try
{ {
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI); var response = await client.GetAsync("http://localhost:5052/ArticleUsers");
var response = await client.GetAsync("http://localhost:5052/user/article/users");
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync(); var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody); Console.WriteLine(responseBody);
@ -381,12 +350,11 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestGetArticleByUser(string tokenAPI) static async Task TestGetArticleByUser()
{ {
try try
{ {
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI); var response = await client.GetAsync("http://localhost:5052/user/Sha/article");
var response = await client.GetAsync("http://localhost:5052/user/Sha/articles");
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync(); var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody); Console.WriteLine(responseBody);
@ -397,7 +365,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestCreateArticleUser(string tokenAPI) static async Task TestCreateArticleUser()
{ {
try try
{ {
@ -406,7 +374,6 @@ class Tests_Console_Connect_Localhost
ArticleEntityId = 1, ArticleEntityId = 1,
UserEntityPseudo = "Sha" UserEntityPseudo = "Sha"
}; };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
var json = JsonSerializer.Serialize(articleUser); var json = JsonSerializer.Serialize(articleUser);
var data = new StringContent(json, Encoding.UTF8, "application/json"); var data = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("http://localhost:5052/user/article", data); var response = await client.PostAsync("http://localhost:5052/user/article", data);
@ -420,12 +387,11 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestDeleteArticleUser(string tokenAPI) static async Task TestDeleteArticleUser()
{ {
try try
{ {
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI); var response = await client.DeleteAsync("http://localhost:5052/user/Sha/article");
var response = await client.DeleteAsync("http://localhost:5052/user/Sha/3");
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync(); var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody); Console.WriteLine(responseBody);
@ -436,20 +402,18 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestUpdateArticleUser(string tokenAPI) static async Task TestUpdateArticleUser()
{ {
try try
{ {
var articleUser = new ArticleUserEntity() var articleUser = new ArticleUserEntity()
{ {
ArticleEntityId = 2, ArticleEntityId = 1,
UserEntityPseudo = "Sha" UserEntityPseudo = "Sha"
}; };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI);
long oldId = 3;
var json = JsonSerializer.Serialize(articleUser); var json = JsonSerializer.Serialize(articleUser);
var data = new StringContent(json, Encoding.UTF8, "application/json"); var data = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PutAsync($"http://localhost:5052/user/Sha/{oldId}", data); var response = await client.PutAsync("http://localhost:5052/user/Sha/article", data);
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync(); var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody); Console.WriteLine(responseBody);
@ -460,99 +424,4 @@ class Tests_Console_Connect_Localhost
} }
} }
public static async Task<string> LoginAndGetToken(string Email, string Password)
{
var credentials = new
{
email = Email,
password = Password
};
var json = JsonSerializer.Serialize(credentials);
var data = new StringContent(json, Encoding.UTF8, "application/json");
try
{
var response = await client.PostAsync("http://localhost:5052/login", data);
var responseBody = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode)
{
using (JsonDocument doc = JsonDocument.Parse(responseBody))
{
if (doc.RootElement.TryGetProperty("accessToken", out JsonElement tokenElement)) // Change "token" to the actual property name
{
string token = tokenElement.GetString();
Console.WriteLine("Token retrieved");
return token;
}
else
{
Console.WriteLine("Token not found in the response.");
return null;
}
}
}
else
{
Console.WriteLine($"Login failed: {response.StatusCode}");
Console.WriteLine(responseBody);
return null;
}
}
catch (HttpRequestException e)
{
Console.WriteLine($"HttpRequestException: {e.Message}");
return null;
}
catch (JsonException e)
{
Console.WriteLine($"Error parsing JSON response: {e.Message}");
return null;
}
}
public static async Task<string> RegisterUser(string email, string password)
{
var newUser = new
{
email = email,
password = password
};
var json = JsonSerializer.Serialize(newUser);
var data = new StringContent(json, Encoding.UTF8, "application/json");
try
{
var response = await client.PostAsync("http://localhost:5052/register", data);
var responseBody = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode)
{
Console.WriteLine("Registration successful");
Console.WriteLine(responseBody);
return responseBody;
}
else
{
Console.WriteLine($"Registration failed: {response.StatusCode}");
Console.WriteLine(responseBody);
return null;
}
}
catch (HttpRequestException e)
{
Console.WriteLine($"HttpRequestException: {e.Message}");
return null;
}
catch (Exception e)
{
Console.WriteLine($"General Exception: {e.Message}");
return null;
}
}
} }

@ -1,11 +1,9 @@
using API_Mapping;
using API.Controllers; using API.Controllers;
using Entities; using Entities;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Model; using Model;
using Moq; using Moq;
using Web_API.Model;
namespace API_Unit_Test; namespace API_Unit_Test;
@ -94,48 +92,4 @@ public class UserControllerTests
Assert.IsType<BadRequestObjectResult>(result); Assert.IsType<BadRequestObjectResult>(result);
} }
[Fact]
public async Task CreateArticleUser_ReturnsOk_WithNewArticleUser()
{
// Arrange
var articleUser = new ArticleUserEntity { UserEntityPseudo = "User1", ArticleEntityId = 1 };
_mockDataManager.Setup(m => m.UserService.CreateArticleUser(articleUser)).ReturnsAsync(true);
// Act
var result = await _controller.CreateArticleUser(articleUser);
// Assert
Assert.IsType<OkObjectResult>(result);
}
[Fact]
public async Task UpdateArticleUser_ReturnsOk_WhenUpdated()
{
// Arrange
var articleUser = new ArticleUserEntity { UserEntityPseudo = "User1", ArticleEntityId = 2 };
_mockDataManager.Setup(m => m.UserService.DeleteArticleUser(It.IsAny<string>(), It.IsAny<long>())).ReturnsAsync(true);
_mockDataManager.Setup(m => m.UserService.CreateArticleUser(It.IsAny<ArticleUserEntity>())).ReturnsAsync(true);
// Act
var result = await _controller.UpdateArticleUser(articleUser, 1);
// Assert
Assert.IsType<OkObjectResult>(result);
}
[Fact]
public async Task DeleteArticleUser_ReturnsOk_WhenDeleted()
{
// Arrange
_mockDataManager.Setup(m => m.UserService.DeleteArticleUser(It.IsAny<string>(), It.IsAny<long>())).ReturnsAsync(true);
// Act
var result = await _controller.DeleteArticleUser("User1", 1);
// Assert
Assert.IsType<OkObjectResult>(result);
}
} }

@ -56,8 +56,6 @@ public class LibraryContext : DbContext
.HasOne(f => f.User) .HasOne(f => f.User)
.WithMany(u => u.Forms) .WithMany(u => u.Forms)
.HasForeignKey(f => f.UserEntityPseudo); .HasForeignKey(f => f.UserEntityPseudo);
// En cas de besoin, decomenter les lignes suivantes afin de faire la migration
/* /*
modelBuilder.Entity<ArticleEntity>().HasData( modelBuilder.Entity<ArticleEntity>().HasData(
new ArticleEntity new ArticleEntity
@ -147,7 +145,6 @@ public class LibraryContext : DbContext
new FormEntity new FormEntity
{ {
Id = 1, Id = 1,
Theme = "Form 1 Theme",
DatePublication = "Form 1 Description", DatePublication = "Form 1 Description",
Link = "hhtp://form1.com", Link = "hhtp://form1.com",
UserEntityPseudo = "Sha" UserEntityPseudo = "Sha"
@ -155,7 +152,6 @@ public class LibraryContext : DbContext
new FormEntity new FormEntity
{ {
Id = 2, Id = 2,
Theme = "Form 2 Theme",
DatePublication = "Form 2 Description", DatePublication = "Form 2 Description",
Link = "hhtp://form2.com", Link = "hhtp://form2.com",
UserEntityPseudo = "Sha" UserEntityPseudo = "Sha"
@ -163,13 +159,11 @@ public class LibraryContext : DbContext
new FormEntity new FormEntity
{ {
Id = 3, Id = 3,
Theme = "Form 3 Theme",
DatePublication = "Form 3 Description", DatePublication = "Form 3 Description",
Link = "hhtp://form3.com", Link = "hhtp://form3.com",
UserEntityPseudo = "Sha" UserEntityPseudo = "Sha"
} }
); );
*/ */
} }
} }

@ -10,14 +10,14 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace DbContextLib.Migrations namespace DbContextLib.Migrations
{ {
[DbContext(typeof(LibraryContext))] [DbContext(typeof(LibraryContext))]
[Migration("20240317095050_mrg1")] [Migration("20240312155559_mrg1")]
partial class mrg1 partial class mrg1
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.3"); modelBuilder.HasAnnotation("ProductVersion", "8.0.2");
modelBuilder.Entity("Entities.ArticleEntity", b => modelBuilder.Entity("Entities.ArticleEntity", b =>
{ {
@ -154,7 +154,7 @@ namespace DbContextLib.Migrations
Id = 1L, Id = 1L,
DatePublication = "Form 1 Description", DatePublication = "Form 1 Description",
Link = "hhtp://form1.com", Link = "hhtp://form1.com",
Theme = "Form 1 Theme", Theme = "",
UserEntityPseudo = "Sha" UserEntityPseudo = "Sha"
}, },
new new
@ -162,7 +162,7 @@ namespace DbContextLib.Migrations
Id = 2L, Id = 2L,
DatePublication = "Form 2 Description", DatePublication = "Form 2 Description",
Link = "hhtp://form2.com", Link = "hhtp://form2.com",
Theme = "Form 2 Theme", Theme = "",
UserEntityPseudo = "Sha" UserEntityPseudo = "Sha"
}, },
new new
@ -170,7 +170,7 @@ namespace DbContextLib.Migrations
Id = 3L, Id = 3L,
DatePublication = "Form 3 Description", DatePublication = "Form 3 Description",
Link = "hhtp://form3.com", Link = "hhtp://form3.com",
Theme = "Form 3 Theme", Theme = "",
UserEntityPseudo = "Sha" UserEntityPseudo = "Sha"
}); });
}); });

@ -130,9 +130,9 @@ namespace DbContextLib.Migrations
columns: new[] { "Id", "DatePublication", "Link", "Theme", "UserEntityPseudo" }, columns: new[] { "Id", "DatePublication", "Link", "Theme", "UserEntityPseudo" },
values: new object[,] values: new object[,]
{ {
{ 1L, "Form 1 Description", "hhtp://form1.com", "Form 1 Theme", "Sha" }, { 1L, "Form 1 Description", "hhtp://form1.com", "", "Sha" },
{ 2L, "Form 2 Description", "hhtp://form2.com", "Form 2 Theme", "Sha" }, { 2L, "Form 2 Description", "hhtp://form2.com", "", "Sha" },
{ 3L, "Form 3 Description", "hhtp://form3.com", "Form 3 Theme", "Sha" } { 3L, "Form 3 Description", "hhtp://form3.com", "", "Sha" }
}); });
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(

@ -14,7 +14,7 @@ namespace DbContextLib.Migrations
protected override void BuildModel(ModelBuilder modelBuilder) protected override void BuildModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.3"); modelBuilder.HasAnnotation("ProductVersion", "8.0.2");
modelBuilder.Entity("Entities.ArticleEntity", b => modelBuilder.Entity("Entities.ArticleEntity", b =>
{ {
@ -151,7 +151,7 @@ namespace DbContextLib.Migrations
Id = 1L, Id = 1L,
DatePublication = "Form 1 Description", DatePublication = "Form 1 Description",
Link = "hhtp://form1.com", Link = "hhtp://form1.com",
Theme = "Form 1 Theme", Theme = "",
UserEntityPseudo = "Sha" UserEntityPseudo = "Sha"
}, },
new new
@ -159,7 +159,7 @@ namespace DbContextLib.Migrations
Id = 2L, Id = 2L,
DatePublication = "Form 2 Description", DatePublication = "Form 2 Description",
Link = "hhtp://form2.com", Link = "hhtp://form2.com",
Theme = "Form 2 Theme", Theme = "",
UserEntityPseudo = "Sha" UserEntityPseudo = "Sha"
}, },
new new
@ -167,7 +167,7 @@ namespace DbContextLib.Migrations
Id = 3L, Id = 3L,
DatePublication = "Form 3 Description", DatePublication = "Form 3 Description",
Link = "hhtp://form3.com", Link = "hhtp://form3.com",
Theme = "Form 3 Theme", Theme = "",
UserEntityPseudo = "Sha" UserEntityPseudo = "Sha"
}); });
}); });

@ -1,8 +1,5 @@
using System.Text.Json.Serialization;
namespace Model; namespace Model;
[JsonConverter(typeof(JsonStringEnumConverter))]
public enum ArticleOrderCriteria public enum ArticleOrderCriteria
{ {
None, ByTitle, ByAuthor, ByLectureTime, ByDatePublished, ByDescription None, ByTitle, ByAuthor, ByLectureTime, ByDatePublished, ByDescription

@ -1,9 +1,5 @@
using System.Text.Json.Serialization;
namespace Model; namespace Model;
[JsonConverter(typeof(JsonStringEnumConverter))]
public enum FormOrderCriteria public enum FormOrderCriteria
{ {
None, ByTheme, ByDate, ByPseudo, ByLien None, ByTheme, ByDate, ByPseudo, ByLien

@ -0,0 +1,6 @@
namespace Model;
public enum UserOrderCriteria
{
None, ByFirstName, ByLastName
}

@ -10,7 +10,7 @@ public class StubbedContext : LibraryContext
{ {
base.OnModelCreating(modelBuilder); base.OnModelCreating(modelBuilder);
modelBuilder.Entity<ArticleEntity>().HasData( modelBuilder.Entity<ArticleEntity>().HasData(
new ArticleEntity new ArticleEntity
{ {
Id = 1, Id = 1,
@ -45,7 +45,7 @@ public class StubbedContext : LibraryContext
modelBuilder.Entity<UserEntity>().HasData( modelBuilder.Entity<UserEntity>().HasData(
new UserEntity new UserEntity
{ {
Nom = "Fages", Prenom = "Tony", Pseudo = "TonyF", Mail = "tony@gmail.com", Mdp = "1234", Role = "Admin" Nom = "Fages", Prenom = "Tony", Pseudo = "TonyF", Mail = "tony@gmail.com", Mdp = "1234", Role = "Admin"
}, },
new UserEntity new UserEntity
{ {
@ -55,14 +55,6 @@ public class StubbedContext : LibraryContext
new UserEntity new UserEntity
{ {
Nom = "M&M's", Prenom = "Red", Pseudo = "RedM", Mail = "M&M#mail.com", Mdp = "1234", Role = "Modérator" Nom = "M&M's", Prenom = "Red", Pseudo = "RedM", Mail = "M&M#mail.com", Mdp = "1234", Role = "Modérator"
},
new UserEntity
{
Nom = "Cascarra", Prenom = "Cascarra", Pseudo = "Sha", Mail = "ShaCasca@gmail.com", Mdp = "1234", Role = "Admin"
},
new UserEntity
{
Nom = "Sillard", Prenom = "Noa", Pseudo = "NoaSil", Mail = "", Mdp = "1234", Role = "Admin"
} }
); );
@ -70,12 +62,12 @@ public class StubbedContext : LibraryContext
new ArticleUserEntity new ArticleUserEntity
{ {
ArticleEntityId = 1, ArticleEntityId = 1,
UserEntityPseudo = "TonyF" UserEntityPseudo = "Sha"
}, },
new ArticleUserEntity new ArticleUserEntity
{ {
ArticleEntityId = 2, ArticleEntityId = 2,
UserEntityPseudo = "NoaSil" UserEntityPseudo = "Sha"
}, },
new ArticleUserEntity new ArticleUserEntity
{ {
@ -85,38 +77,11 @@ public class StubbedContext : LibraryContext
new ArticleUserEntity new ArticleUserEntity
{ {
ArticleEntityId = 3, ArticleEntityId = 3,
UserEntityPseudo = "RedM" UserEntityPseudo = "Sha"
}, },
new ArticleUserEntity new ArticleUserEntity
{ {
ArticleEntityId = 2, ArticleEntityId = 2,
UserEntityPseudo = "TomS"
}
);
modelBuilder.Entity<FormEntity>().HasData(
new FormEntity
{
Id = 1,
Theme = "Form 1 Theme",
DatePublication = "Form 1 Description",
Link = "hhtp://form1.com",
UserEntityPseudo = "Sha"
},
new FormEntity
{
Id = 2,
Theme = "Form 2 Theme",
DatePublication = "Form 2 Description",
Link = "hhtp://form2.com",
UserEntityPseudo = "Sha"
},
new FormEntity
{
Id = 3,
Theme = "Form 3 Theme",
DatePublication = "Form 3 Description",
Link = "hhtp://form3.com",
UserEntityPseudo = "Sha" UserEntityPseudo = "Sha"
} }
); );

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save