diff --git a/Verax_API_EF/.idea/.idea.Verax_API_EF/.idea/copilot/chatSessions/00000000000.xd b/Verax_API_EF/.idea/.idea.Verax_API_EF/.idea/copilot/chatSessions/00000000000.xd index acce52c..5590542 100644 Binary files a/Verax_API_EF/.idea/.idea.Verax_API_EF/.idea/copilot/chatSessions/00000000000.xd and b/Verax_API_EF/.idea/.idea.Verax_API_EF/.idea/copilot/chatSessions/00000000000.xd differ diff --git a/Verax_API_EF/.idea/.idea.Verax_API_EF/.idea/workspace.xml b/Verax_API_EF/.idea/.idea.Verax_API_EF/.idea/workspace.xml index ab16e6f..74856e6 100644 --- a/Verax_API_EF/.idea/.idea.Verax_API_EF/.idea/workspace.xml +++ b/Verax_API_EF/.idea/.idea.Verax_API_EF/.idea/workspace.xml @@ -11,12 +11,15 @@ - - - + + + + + - + + diff --git a/Verax_API_EF/API/Controllers/ArticleController.cs b/Verax_API_EF/API/Controllers/ArticleController.cs index 77caa98..c62a6cd 100644 --- a/Verax_API_EF/API/Controllers/ArticleController.cs +++ b/Verax_API_EF/API/Controllers/ArticleController.cs @@ -1,11 +1,13 @@ using API_Mapping; using API_Services; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Model; namespace API.Controllers { + [Authorize] [Route("api/[controller]")] [ApiController] public class ArticleController : ControllerBase diff --git a/Verax_API_EF/API/Controllers/FormulaireController.cs b/Verax_API_EF/API/Controllers/FormulaireController.cs index fcf25aa..d24c303 100644 --- a/Verax_API_EF/API/Controllers/FormulaireController.cs +++ b/Verax_API_EF/API/Controllers/FormulaireController.cs @@ -5,9 +5,11 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; using API_Mapping; +using Microsoft.AspNetCore.Authorization; namespace API.Controllers { + [Authorize] [Route("api/[controller]")] [ApiController] public class FormulaireController : ControllerBase diff --git a/Verax_API_EF/API/Controllers/UserController.cs b/Verax_API_EF/API/Controllers/UserController.cs index 0f305cd..fea31c5 100644 --- a/Verax_API_EF/API/Controllers/UserController.cs +++ b/Verax_API_EF/API/Controllers/UserController.cs @@ -4,10 +4,12 @@ using API_Services; using Model; using API_Mapping; using Entities; +using Microsoft.AspNetCore.Authorization; namespace API.Controllers { + [Authorize] [Route("api/[controller]")] [ApiController] public class UserController : ControllerBase diff --git a/Verax_API_EF/API/Entity_FrameWork.Article.db b/Verax_API_EF/API/Entity_FrameWork.Article.db index b1ed424..9fbff3b 100644 Binary files a/Verax_API_EF/API/Entity_FrameWork.Article.db and b/Verax_API_EF/API/Entity_FrameWork.Article.db differ diff --git a/Verax_API_EF/API/Program.cs b/Verax_API_EF/API/Program.cs index d7f9f3e..5aee76a 100644 --- a/Verax_API_EF/API/Program.cs +++ b/Verax_API_EF/API/Program.cs @@ -86,6 +86,7 @@ app.UseSwagger(); app.UseSwaggerUI(); app.UseHttpsRedirection(); +app.UseAuthentication(); app.UseAuthorization(); app.MapControllers(); diff --git a/Verax_API_EF/API/log.txt b/Verax_API_EF/API/log.txt index 62c888f..b865ca6 100644 --- a/Verax_API_EF/API/log.txt +++ b/Verax_API_EF/API/log.txt @@ -1811,3 +1811,396 @@ info: 04/07/2024 16:11:26.514 RelationalEventId.CommandExecuted[20101] (Microsof 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: 04/07/2024 16:18:06.986 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: 04/07/2024 16:18:06.990 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: 04/07/2024 16:18:06.997 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30'] + SELECT "MigrationId", "ProductVersion" + FROM "__EFMigrationsHistory" + ORDER BY "MigrationId"; +info: 04/07/2024 16:18:07.006 RelationalEventId.MigrationsNotApplied[20405] (Microsoft.EntityFrameworkCore.Migrations) + No migrations were applied. The database is already up to date. +info: 04/07/2024 16:18:13.066 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: 04/07/2024 16:19:31.182 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: 04/07/2024 16:19:33.699 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: 04/07/2024 16:19:35.033 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: 04/07/2024 16:19:53.180 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: 04/07/2024 16:23:05.168 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: 04/07/2024 16:23:05.172 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: 04/07/2024 16:23:05.178 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30'] + SELECT "MigrationId", "ProductVersion" + FROM "__EFMigrationsHistory" + ORDER BY "MigrationId"; +info: 04/07/2024 16:23:05.186 RelationalEventId.MigrationsNotApplied[20405] (Microsoft.EntityFrameworkCore.Migrations) + No migrations were applied. The database is already up to date. +info: 04/07/2024 16:23:10.313 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: 04/07/2024 16:24:36.209 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: 04/07/2024 16:24:36.213 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: 04/07/2024 16:24:36.219 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30'] + SELECT "MigrationId", "ProductVersion" + FROM "__EFMigrationsHistory" + ORDER BY "MigrationId"; +info: 04/07/2024 16:24:36.228 RelationalEventId.MigrationsNotApplied[20405] (Microsoft.EntityFrameworkCore.Migrations) + No migrations were applied. The database is already up to date. +info: 04/07/2024 16:26:07.617 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: 04/07/2024 16:31:00.483 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: 04/07/2024 16:32:40.093 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (2ms) [Parameters=[@__p_0='?' (DbType = Int64)], CommandType='Text', CommandTimeout='30'] + SELECT "a"."Id", "a"."Author", "a"."DatePublished", "a"."Description", "a"."LectureTime", "a"."Title" + FROM "ArticleSet" AS "a" + WHERE "a"."Id" = @__p_0 + LIMIT 1 +info: 04/07/2024 16:32:40.185 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (3ms) [Parameters=[@p0='?' (Size = 4), @p1='?' (Size = 4), @p2='?' (Size = 4), @p3='?' (DbType = Int32), @p4='?' (Size = 4)], CommandType='Text', CommandTimeout='30'] + INSERT INTO "ArticleSet" ("Author", "DatePublished", "Description", "LectureTime", "Title") + VALUES (@p0, @p1, @p2, @p3, @p4) + RETURNING "Id"; +info: 04/07/2024 16:32:40.202 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: 04/07/2024 16:32:44.333 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: 04/07/2024 16:32:55.135 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__p_0='?' (DbType = Int64)], CommandType='Text', CommandTimeout='30'] + SELECT "a"."Id", "a"."Author", "a"."DatePublished", "a"."Description", "a"."LectureTime", "a"."Title" + FROM "ArticleSet" AS "a" + WHERE "a"."Id" = @__p_0 + LIMIT 1 +info: 04/07/2024 16:32:55.146 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: 04/07/2024 16:32:55.160 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__id_0='?' (DbType = Int64)], CommandType='Text', CommandTimeout='30'] + SELECT "a"."Id", "a"."Author", "a"."DatePublished", "a"."Description", "a"."LectureTime", "a"."Title" + FROM "ArticleSet" AS "a" + WHERE "a"."Id" = @__id_0 + LIMIT 1 +info: 04/07/2024 16:32:55.166 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@p0='?' (DbType = Int64)], CommandType='Text', CommandTimeout='30'] + DELETE FROM "ArticleSet" + WHERE "Id" = @p0 + RETURNING 1; +info: 04/07/2024 16:33:02.778 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" +warn: 04/07/2024 16:33:35.873 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: 04/07/2024 16:33:35.877 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__p_0='?' (DbType = Int32)], CommandType='Text', CommandTimeout='30'] + SELECT "u"."Pseudo", "u"."Mail", "u"."Mdp", "u"."Nom", "u"."Prenom", "u"."Role" + FROM "UserSet" AS "u" + LIMIT -1 OFFSET @__p_0 +info: 04/07/2024 16:33:35.901 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__pseudo_0='?' (Size = 3)], CommandType='Text', CommandTimeout='30'] + SELECT "u"."Pseudo", "u"."Mail", "u"."Mdp", "u"."Nom", "u"."Prenom", "u"."Role" + FROM "UserSet" AS "u" + WHERE "u"."Pseudo" = @__pseudo_0 + LIMIT 1 +info: 04/07/2024 16:33:35.910 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30'] + SELECT "a"."ArticleEntityId", "a"."UserEntityPseudo" + FROM "ArticleUserSet" AS "a" +info: 04/07/2024 16:33:35.926 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__articleUser_UserEntityPseudo_0='?' (Size = 6)], CommandType='Text', CommandTimeout='30'] + SELECT "u"."Pseudo", "u"."Mail", "u"."Mdp", "u"."Nom", "u"."Prenom", "u"."Role" + FROM "UserSet" AS "u" + WHERE "u"."Pseudo" = @__articleUser_UserEntityPseudo_0 + LIMIT 1 +info: 04/07/2024 16:33:35.929 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__articleUser_UserEntityPseudo_0='?' (Size = 4)], CommandType='Text', CommandTimeout='30'] + SELECT "u"."Pseudo", "u"."Mail", "u"."Mdp", "u"."Nom", "u"."Prenom", "u"."Role" + FROM "UserSet" AS "u" + WHERE "u"."Pseudo" = @__articleUser_UserEntityPseudo_0 + LIMIT 1 +info: 04/07/2024 16:33:35.930 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__articleUser_UserEntityPseudo_0='?' (Size = 4)], CommandType='Text', CommandTimeout='30'] + SELECT "u"."Pseudo", "u"."Mail", "u"."Mdp", "u"."Nom", "u"."Prenom", "u"."Role" + FROM "UserSet" AS "u" + WHERE "u"."Pseudo" = @__articleUser_UserEntityPseudo_0 + LIMIT 1 +info: 04/07/2024 16:33:35.930 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__articleUser_UserEntityPseudo_0='?' (Size = 3)], CommandType='Text', CommandTimeout='30'] + SELECT "u"."Pseudo", "u"."Mail", "u"."Mdp", "u"."Nom", "u"."Prenom", "u"."Role" + FROM "UserSet" AS "u" + WHERE "u"."Pseudo" = @__articleUser_UserEntityPseudo_0 + LIMIT 1 +info: 04/07/2024 16:33:35.939 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__pseudo_0='?' (Size = 3)], CommandType='Text', CommandTimeout='30'] + SELECT "a"."ArticleEntityId", "a"."UserEntityPseudo" + FROM "ArticleUserSet" AS "a" + WHERE "a"."UserEntityPseudo" = @__pseudo_0 +info: 04/07/2024 16:33:35.941 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__article_ArticleEntityId_0='?' (DbType = Int64)], CommandType='Text', CommandTimeout='30'] + SELECT "a"."Id", "a"."Author", "a"."DatePublished", "a"."Description", "a"."LectureTime", "a"."Title" + FROM "ArticleSet" AS "a" + WHERE "a"."Id" = @__article_ArticleEntityId_0 + LIMIT 1 +warn: 04/07/2024 16:33:35.949 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: 04/07/2024 16:33:35.951 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [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: 04/07/2024 16:33:35.966 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__id_0='?' (DbType = Int64)], CommandType='Text', CommandTimeout='30'] + SELECT "f"."Id", "f"."DatePublication", "f"."Link", "f"."Theme", "f"."UserEntityPseudo" + FROM "FormSet" AS "f" + WHERE "f"."Id" = @__id_0 + LIMIT 1 +info: 04/07/2024 16:33:35.969 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__p_0='?' (DbType = Int64)], CommandType='Text', CommandTimeout='30'] + SELECT "a"."Id", "a"."Author", "a"."DatePublished", "a"."Description", "a"."LectureTime", "a"."Title" + FROM "ArticleSet" AS "a" + WHERE "a"."Id" = @__p_0 + LIMIT 1 +info: 04/07/2024 16:33:35.974 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: 04/07/2024 16:33:51.891 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [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: 04/07/2024 16:33:51.901 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__id_0='?' (DbType = Int64)], CommandType='Text', CommandTimeout='30'] + SELECT "f"."Id", "f"."DatePublication", "f"."Link", "f"."Theme", "f"."UserEntityPseudo" + FROM "FormSet" AS "f" + WHERE "f"."Id" = @__id_0 + LIMIT 1 +info: 04/07/2024 16:34:01.016 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__p_0='?' (DbType = Int32)], CommandType='Text', CommandTimeout='30'] + SELECT "u"."Pseudo", "u"."Mail", "u"."Mdp", "u"."Nom", "u"."Prenom", "u"."Role" + FROM "UserSet" AS "u" + LIMIT -1 OFFSET @__p_0 +info: 04/07/2024 16:34:01.025 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__pseudo_0='?' (Size = 3)], CommandType='Text', CommandTimeout='30'] + SELECT "u"."Pseudo", "u"."Mail", "u"."Mdp", "u"."Nom", "u"."Prenom", "u"."Role" + FROM "UserSet" AS "u" + WHERE "u"."Pseudo" = @__pseudo_0 + LIMIT 1 +info: 04/07/2024 16:34:01.028 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30'] + SELECT "a"."ArticleEntityId", "a"."UserEntityPseudo" + FROM "ArticleUserSet" AS "a" +info: 04/07/2024 16:34:01.029 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__articleUser_UserEntityPseudo_0='?' (Size = 6)], CommandType='Text', CommandTimeout='30'] + SELECT "u"."Pseudo", "u"."Mail", "u"."Mdp", "u"."Nom", "u"."Prenom", "u"."Role" + FROM "UserSet" AS "u" + WHERE "u"."Pseudo" = @__articleUser_UserEntityPseudo_0 + LIMIT 1 +info: 04/07/2024 16:34:01.029 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__articleUser_UserEntityPseudo_0='?' (Size = 4)], CommandType='Text', CommandTimeout='30'] + SELECT "u"."Pseudo", "u"."Mail", "u"."Mdp", "u"."Nom", "u"."Prenom", "u"."Role" + FROM "UserSet" AS "u" + WHERE "u"."Pseudo" = @__articleUser_UserEntityPseudo_0 + LIMIT 1 +info: 04/07/2024 16:34:01.029 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__articleUser_UserEntityPseudo_0='?' (Size = 4)], CommandType='Text', CommandTimeout='30'] + SELECT "u"."Pseudo", "u"."Mail", "u"."Mdp", "u"."Nom", "u"."Prenom", "u"."Role" + FROM "UserSet" AS "u" + WHERE "u"."Pseudo" = @__articleUser_UserEntityPseudo_0 + LIMIT 1 +info: 04/07/2024 16:34:01.029 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__articleUser_UserEntityPseudo_0='?' (Size = 3)], CommandType='Text', CommandTimeout='30'] + SELECT "u"."Pseudo", "u"."Mail", "u"."Mdp", "u"."Nom", "u"."Prenom", "u"."Role" + FROM "UserSet" AS "u" + WHERE "u"."Pseudo" = @__articleUser_UserEntityPseudo_0 + LIMIT 1 +info: 04/07/2024 16:34:01.032 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__pseudo_0='?' (Size = 3)], CommandType='Text', CommandTimeout='30'] + SELECT "a"."ArticleEntityId", "a"."UserEntityPseudo" + FROM "ArticleUserSet" AS "a" + WHERE "a"."UserEntityPseudo" = @__pseudo_0 +info: 04/07/2024 16:34:01.033 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__article_ArticleEntityId_0='?' (DbType = Int64)], CommandType='Text', CommandTimeout='30'] + SELECT "a"."Id", "a"."Author", "a"."DatePublished", "a"."Description", "a"."LectureTime", "a"."Title" + FROM "ArticleSet" AS "a" + WHERE "a"."Id" = @__article_ArticleEntityId_0 + LIMIT 1 +info: 04/07/2024 16:34:07.857 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__p_0='?' (DbType = Int32)], CommandType='Text', CommandTimeout='30'] + SELECT "u"."Pseudo", "u"."Mail", "u"."Mdp", "u"."Nom", "u"."Prenom", "u"."Role" + FROM "UserSet" AS "u" + LIMIT -1 OFFSET @__p_0 +info: 04/07/2024 16:34:07.866 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__pseudo_0='?' (Size = 3)], CommandType='Text', CommandTimeout='30'] + SELECT "u"."Pseudo", "u"."Mail", "u"."Mdp", "u"."Nom", "u"."Prenom", "u"."Role" + FROM "UserSet" AS "u" + WHERE "u"."Pseudo" = @__pseudo_0 + LIMIT 1 +info: 04/07/2024 16:34:07.868 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30'] + SELECT "a"."ArticleEntityId", "a"."UserEntityPseudo" + FROM "ArticleUserSet" AS "a" +info: 04/07/2024 16:34:07.869 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__articleUser_UserEntityPseudo_0='?' (Size = 6)], CommandType='Text', CommandTimeout='30'] + SELECT "u"."Pseudo", "u"."Mail", "u"."Mdp", "u"."Nom", "u"."Prenom", "u"."Role" + FROM "UserSet" AS "u" + WHERE "u"."Pseudo" = @__articleUser_UserEntityPseudo_0 + LIMIT 1 +info: 04/07/2024 16:34:07.870 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__articleUser_UserEntityPseudo_0='?' (Size = 4)], CommandType='Text', CommandTimeout='30'] + SELECT "u"."Pseudo", "u"."Mail", "u"."Mdp", "u"."Nom", "u"."Prenom", "u"."Role" + FROM "UserSet" AS "u" + WHERE "u"."Pseudo" = @__articleUser_UserEntityPseudo_0 + LIMIT 1 +info: 04/07/2024 16:34:07.870 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__articleUser_UserEntityPseudo_0='?' (Size = 4)], CommandType='Text', CommandTimeout='30'] + SELECT "u"."Pseudo", "u"."Mail", "u"."Mdp", "u"."Nom", "u"."Prenom", "u"."Role" + FROM "UserSet" AS "u" + WHERE "u"."Pseudo" = @__articleUser_UserEntityPseudo_0 + LIMIT 1 +info: 04/07/2024 16:34:07.871 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__articleUser_UserEntityPseudo_0='?' (Size = 3)], CommandType='Text', CommandTimeout='30'] + SELECT "u"."Pseudo", "u"."Mail", "u"."Mdp", "u"."Nom", "u"."Prenom", "u"."Role" + FROM "UserSet" AS "u" + WHERE "u"."Pseudo" = @__articleUser_UserEntityPseudo_0 + LIMIT 1 +info: 04/07/2024 16:34:07.874 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__pseudo_0='?' (Size = 3)], CommandType='Text', CommandTimeout='30'] + SELECT "a"."ArticleEntityId", "a"."UserEntityPseudo" + FROM "ArticleUserSet" AS "a" + WHERE "a"."UserEntityPseudo" = @__pseudo_0 +info: 04/07/2024 16:34:07.874 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__article_ArticleEntityId_0='?' (DbType = Int64)], CommandType='Text', CommandTimeout='30'] + SELECT "a"."Id", "a"."Author", "a"."DatePublished", "a"."Description", "a"."LectureTime", "a"."Title" + FROM "ArticleSet" AS "a" + WHERE "a"."Id" = @__article_ArticleEntityId_0 + LIMIT 1 +info: 04/07/2024 16:34:07.878 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__p_0='?' (DbType = Int64)], CommandType='Text', CommandTimeout='30'] + SELECT "a"."Id", "a"."Author", "a"."DatePublished", "a"."Description", "a"."LectureTime", "a"."Title" + FROM "ArticleSet" AS "a" + WHERE "a"."Id" = @__p_0 + LIMIT 1 +info: 04/07/2024 16:34:07.882 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: 04/07/2024 16:34:17.889 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__p_0='?' (DbType = Int32)], CommandType='Text', CommandTimeout='30'] + SELECT "u"."Pseudo", "u"."Mail", "u"."Mdp", "u"."Nom", "u"."Prenom", "u"."Role" + FROM "UserSet" AS "u" + LIMIT -1 OFFSET @__p_0 +info: 04/07/2024 16:34:17.900 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__pseudo_0='?' (Size = 3)], CommandType='Text', CommandTimeout='30'] + SELECT "u"."Pseudo", "u"."Mail", "u"."Mdp", "u"."Nom", "u"."Prenom", "u"."Role" + FROM "UserSet" AS "u" + WHERE "u"."Pseudo" = @__pseudo_0 + LIMIT 1 +info: 04/07/2024 16:34:17.902 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30'] + SELECT "a"."ArticleEntityId", "a"."UserEntityPseudo" + FROM "ArticleUserSet" AS "a" +info: 04/07/2024 16:34:17.903 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__articleUser_UserEntityPseudo_0='?' (Size = 6)], CommandType='Text', CommandTimeout='30'] + SELECT "u"."Pseudo", "u"."Mail", "u"."Mdp", "u"."Nom", "u"."Prenom", "u"."Role" + FROM "UserSet" AS "u" + WHERE "u"."Pseudo" = @__articleUser_UserEntityPseudo_0 + LIMIT 1 +info: 04/07/2024 16:34:17.903 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__articleUser_UserEntityPseudo_0='?' (Size = 4)], CommandType='Text', CommandTimeout='30'] + SELECT "u"."Pseudo", "u"."Mail", "u"."Mdp", "u"."Nom", "u"."Prenom", "u"."Role" + FROM "UserSet" AS "u" + WHERE "u"."Pseudo" = @__articleUser_UserEntityPseudo_0 + LIMIT 1 +info: 04/07/2024 16:34:17.903 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__articleUser_UserEntityPseudo_0='?' (Size = 4)], CommandType='Text', CommandTimeout='30'] + SELECT "u"."Pseudo", "u"."Mail", "u"."Mdp", "u"."Nom", "u"."Prenom", "u"."Role" + FROM "UserSet" AS "u" + WHERE "u"."Pseudo" = @__articleUser_UserEntityPseudo_0 + LIMIT 1 +info: 04/07/2024 16:34:17.903 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__articleUser_UserEntityPseudo_0='?' (Size = 3)], CommandType='Text', CommandTimeout='30'] + SELECT "u"."Pseudo", "u"."Mail", "u"."Mdp", "u"."Nom", "u"."Prenom", "u"."Role" + FROM "UserSet" AS "u" + WHERE "u"."Pseudo" = @__articleUser_UserEntityPseudo_0 + LIMIT 1 +info: 04/07/2024 16:34:17.905 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__pseudo_0='?' (Size = 3)], CommandType='Text', CommandTimeout='30'] + SELECT "a"."ArticleEntityId", "a"."UserEntityPseudo" + FROM "ArticleUserSet" AS "a" + WHERE "a"."UserEntityPseudo" = @__pseudo_0 +info: 04/07/2024 16:34:17.905 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__article_ArticleEntityId_0='?' (DbType = Int64)], CommandType='Text', CommandTimeout='30'] + SELECT "a"."Id", "a"."Author", "a"."DatePublished", "a"."Description", "a"."LectureTime", "a"."Title" + FROM "ArticleSet" AS "a" + WHERE "a"."Id" = @__article_ArticleEntityId_0 + LIMIT 1 +info: 04/07/2024 16:34:17.908 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [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: 04/07/2024 16:34:17.911 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__id_0='?' (DbType = Int64)], CommandType='Text', CommandTimeout='30'] + SELECT "f"."Id", "f"."DatePublication", "f"."Link", "f"."Theme", "f"."UserEntityPseudo" + FROM "FormSet" AS "f" + WHERE "f"."Id" = @__id_0 + LIMIT 1 +info: 04/07/2024 16:34:17.913 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__p_0='?' (DbType = Int64)], CommandType='Text', CommandTimeout='30'] + SELECT "a"."Id", "a"."Author", "a"."DatePublished", "a"."Description", "a"."LectureTime", "a"."Title" + FROM "ArticleSet" AS "a" + WHERE "a"."Id" = @__p_0 + LIMIT 1 +info: 04/07/2024 16:34:17.917 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: 04/07/2024 16:34:29.331 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [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: 04/07/2024 16:34:29.341 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command) + Executed DbCommand (0ms) [Parameters=[@__id_0='?' (DbType = Int64)], CommandType='Text', CommandTimeout='30'] + SELECT "f"."Id", "f"."DatePublication", "f"."Link", "f"."Theme", "f"."UserEntityPseudo" + FROM "FormSet" AS "f" + WHERE "f"."Id" = @__id_0 + LIMIT 1 diff --git a/Verax_API_EF/API_Tests_Console/Tests_Console_Connect_API.cs b/Verax_API_EF/API_Tests_Console/Tests_Console_Connect_API.cs index 311bfcd..d7becbf 100644 --- a/Verax_API_EF/API_Tests_Console/Tests_Console_Connect_API.cs +++ b/Verax_API_EF/API_Tests_Console/Tests_Console_Connect_API.cs @@ -1,3 +1,5 @@ +using System.Net.Http.Headers; + namespace API_Tests_Console; using System.Text; using System.Text.Json; @@ -7,15 +9,15 @@ public class Tests_Console_Connect_API { // See https://aka.ms/new-console-template for more information - + static string tokenAPI = + "CfDJ8BzHcEhs6r9BlTUBqjgLGaNf6WAMKOugl8uuuypKPb1asjgUip-391in3rJXoNOFAM9pEtczqk3OQrTw0-GpQWq5_IWjXwoEAnoWMXVdKnyNXutqU07I_py4cVgGEkx3WVirYMAIY2LtXTMBkfqcirhauvr_GwWpnumMWthDz5cIFl-EBEVOHf5bL7DRk0EZrG97HT8gpk9HQ__YxD2pQ8g7p0BFMs5FGaZeLQEC0bD07ttOtnxwaNlo4R0e6VVInAdRuXipNDEAESd8AIUtUwbv1x-KCMqdJ8_6dKSsip2iOerCBBDI8xgFN99GETT_tGQI05yNCLsxNpzEzH3H-EC8C7KUIw0h72CdeGC8ZSnnbxzNIpMMgDP9vdrlVxcYAqQwJGNOj5i_c2bMtoT6AAWaALLkhueJhX6F7_darIr6_lervAdQS2RBhIrhpPnlwef6S3xoSLBYq5PNYAg_17EECnLISWwkX_kZCfSHtxMsiAjr_rhsXkE5Ku_J5TQooATrSZk_fD5p3dUS87ijl9MrR1M3pRuI30oe3o-tiSnvoY6GQUcw3ES3CpoPWA_Z_3gtkPTcmdpJC8Hu_Vpx16U8y25R5iIMHLV_cz_rx79yRjikq9L_wSCkaC4cCo_sWQ1uesQjkCkX4Jn2Q-5Sxm4Piq7Yj5Fu3FvDPqXUoG4xGxhV8wnMMiM3kpmp69nrpA"; static readonly HttpClient client = new HttpClient(); - - static async Task Main2(string[] args) + public static async Task Main2(string[] args) { - //await TestUser(); - //await TestFormulaire(); + await TestUser(); + await TestFormulaire(); await TestArticle(); } @@ -23,9 +25,9 @@ public class Tests_Console_Connect_API { await TestFormulaireGetAll(); await TestFormulaireGetId(); - await TestFormulaireCreate(); - await TestFormulaireDelete(); - await TestFormulaireUpdate(); + //await TestFormulaireCreate(); + //await TestFormulaireDelete(); + //await TestFormulaireUpdate(); } private static async Task TestUser() @@ -39,7 +41,7 @@ public class Tests_Console_Connect_API await TestGetArticleByUser(); //await TestCreateArticleUser(); //await TestDeleteArticleUser(); - await TestUpdateArticleUser(); + //await TestUpdateArticleUser(); } @@ -56,6 +58,7 @@ public class Tests_Console_Connect_API { 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(); @@ -71,6 +74,7 @@ public class Tests_Console_Connect_API { 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(); @@ -94,6 +98,7 @@ public class Tests_Console_Connect_API 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); @@ -111,6 +116,7 @@ public class Tests_Console_Connect_API { 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(); @@ -134,6 +140,7 @@ public class Tests_Console_Connect_API 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); @@ -151,6 +158,7 @@ public class Tests_Console_Connect_API { 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(); @@ -166,6 +174,7 @@ public class Tests_Console_Connect_API { 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(); @@ -188,6 +197,7 @@ public class Tests_Console_Connect_API 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); @@ -205,6 +215,7 @@ public class Tests_Console_Connect_API { 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(); @@ -227,6 +238,7 @@ public class Tests_Console_Connect_API 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); @@ -244,6 +256,7 @@ public class Tests_Console_Connect_API { 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(); @@ -259,6 +272,7 @@ public class Tests_Console_Connect_API { 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(); @@ -283,6 +297,7 @@ public class Tests_Console_Connect_API 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); @@ -300,6 +315,7 @@ public class Tests_Console_Connect_API { 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(); @@ -324,6 +340,7 @@ public class Tests_Console_Connect_API 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); @@ -341,6 +358,7 @@ public class Tests_Console_Connect_API { 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(); @@ -356,6 +374,7 @@ public class Tests_Console_Connect_API { 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(); @@ -376,6 +395,7 @@ public class Tests_Console_Connect_API 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); @@ -393,6 +413,7 @@ public class Tests_Console_Connect_API { 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(); @@ -413,6 +434,7 @@ public class Tests_Console_Connect_API 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"); diff --git a/Verax_API_EF/API_Tests_Console/Tests_Console_Connect_Localhost.cs b/Verax_API_EF/API_Tests_Console/Tests_Console_Connect_Localhost.cs index d88869c..8e3d956 100644 --- a/Verax_API_EF/API_Tests_Console/Tests_Console_Connect_Localhost.cs +++ b/Verax_API_EF/API_Tests_Console/Tests_Console_Connect_Localhost.cs @@ -1,28 +1,33 @@ // See https://aka.ms/new-console-template for more information +using System.Net.Http.Headers; using System.Text; using System.Text.Json; +using API_Tests_Console; using Entities; using Model; class Tests_Console_Connect_Localhost {static readonly HttpClient client = new HttpClient(); - + static string tokenAPI = + "CfDJ8BzHcEhs6r9BlTUBqjgLGaNf6WAMKOugl8uuuypKPb1asjgUip-391in3rJXoNOFAM9pEtczqk3OQrTw0-GpQWq5_IWjXwoEAnoWMXVdKnyNXutqU07I_py4cVgGEkx3WVirYMAIY2LtXTMBkfqcirhauvr_GwWpnumMWthDz5cIFl-EBEVOHf5bL7DRk0EZrG97HT8gpk9HQ__YxD2pQ8g7p0BFMs5FGaZeLQEC0bD07ttOtnxwaNlo4R0e6VVInAdRuXipNDEAESd8AIUtUwbv1x-KCMqdJ8_6dKSsip2iOerCBBDI8xgFN99GETT_tGQI05yNCLsxNpzEzH3H-EC8C7KUIw0h72CdeGC8ZSnnbxzNIpMMgDP9vdrlVxcYAqQwJGNOj5i_c2bMtoT6AAWaALLkhueJhX6F7_darIr6_lervAdQS2RBhIrhpPnlwef6S3xoSLBYq5PNYAg_17EECnLISWwkX_kZCfSHtxMsiAjr_rhsXkE5Ku_J5TQooATrSZk_fD5p3dUS87ijl9MrR1M3pRuI30oe3o-tiSnvoY6GQUcw3ES3CpoPWA_Z_3gtkPTcmdpJC8Hu_Vpx16U8y25R5iIMHLV_cz_rx79yRjikq9L_wSCkaC4cCo_sWQ1uesQjkCkX4Jn2Q-5Sxm4Piq7Yj5Fu3FvDPqXUoG4xGxhV8wnMMiM3kpmp69nrpA"; + static async Task Main(string[] args) { //await TestUser(); //await TestFormulaire(); - await TestArticle(); + //await TestArticle(); + await Tests_Console_Connect_API.Main2(args); } private static async Task TestFormulaire() { await TestFormulaireGetAll(); await TestFormulaireGetId(); - await TestFormulaireCreate(); - await TestFormulaireDelete(); - await TestFormulaireUpdate(); + //await TestFormulaireCreate(); + //await TestFormulaireDelete(); + //await TestFormulaireUpdate(); } private static async Task TestUser() @@ -36,7 +41,7 @@ class Tests_Console_Connect_Localhost await TestGetArticleByUser(); //await TestCreateArticleUser(); //await TestDeleteArticleUser(); - await TestUpdateArticleUser(); + //await TestUpdateArticleUser(); } @@ -45,7 +50,7 @@ class Tests_Console_Connect_Localhost await TestArticleGetId(); //await TestArticleCreate(); await TestArticleGetAll(); - // await TestArticleDelete(); + //await TestArticleDelete(); // await TestArticleUpdate(); } @@ -53,6 +58,7 @@ class Tests_Console_Connect_Localhost { try { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI); var response = await client.GetAsync("http://localhost:5052/articles"); response.EnsureSuccessStatusCode(); var responseBody = await response.Content.ReadAsStringAsync(); @@ -68,6 +74,7 @@ class Tests_Console_Connect_Localhost { try { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI); var response = await client.GetAsync("http://localhost:5052/article/1"); response.EnsureSuccessStatusCode(); var responseBody = await response.Content.ReadAsStringAsync(); @@ -108,6 +115,7 @@ class Tests_Console_Connect_Localhost { try { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI); var response = await client.DeleteAsync("http://localhost:5052/article/1"); response.EnsureSuccessStatusCode(); var responseBody = await response.Content.ReadAsStringAsync(); @@ -131,6 +139,7 @@ class Tests_Console_Connect_Localhost 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("http://localhost:5052/article/1", data); @@ -148,6 +157,7 @@ class Tests_Console_Connect_Localhost { try { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI); var response = await client.GetAsync("http://localhost:5052/formulaires"); response.EnsureSuccessStatusCode(); var responseBody = await response.Content.ReadAsStringAsync(); @@ -163,6 +173,7 @@ class Tests_Console_Connect_Localhost { try { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI); var response = await client.GetAsync("http://localhost:5052/formulaire/2"); response.EnsureSuccessStatusCode(); var responseBody = await response.Content.ReadAsStringAsync(); @@ -185,6 +196,7 @@ class Tests_Console_Connect_Localhost 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("http://localhost:5052/formulaire", data); @@ -202,6 +214,7 @@ class Tests_Console_Connect_Localhost { try { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI); var response = await client.DeleteAsync("http://localhost:5052/formulaire/5"); response.EnsureSuccessStatusCode(); var responseBody = await response.Content.ReadAsStringAsync(); @@ -224,6 +237,7 @@ class Tests_Console_Connect_Localhost 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("http://localhost:5052/formulaire/4", data); @@ -241,6 +255,7 @@ class Tests_Console_Connect_Localhost { try { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI); var response = await client.GetAsync("http://localhost:5052/users"); response.EnsureSuccessStatusCode(); var responseBody = await response.Content.ReadAsStringAsync(); @@ -256,6 +271,7 @@ class Tests_Console_Connect_Localhost { try { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI); var response = await client.GetAsync("http://localhost:5052/user/Sha"); response.EnsureSuccessStatusCode(); var responseBody = await response.Content.ReadAsStringAsync(); @@ -280,6 +296,7 @@ class Tests_Console_Connect_Localhost 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("http://localhost:5052/user", data); @@ -297,6 +314,7 @@ class Tests_Console_Connect_Localhost { try { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI); var response = await client.DeleteAsync("http://localhost:5052/user/J"); response.EnsureSuccessStatusCode(); var responseBody = await response.Content.ReadAsStringAsync(); @@ -321,6 +339,7 @@ class Tests_Console_Connect_Localhost 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("http://localhost:5052/user/Sha", data); @@ -338,6 +357,7 @@ class Tests_Console_Connect_Localhost { try { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI); var response = await client.GetAsync("http://localhost:5052/user/article/users"); response.EnsureSuccessStatusCode(); var responseBody = await response.Content.ReadAsStringAsync(); @@ -353,6 +373,7 @@ class Tests_Console_Connect_Localhost { try { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI); var response = await client.GetAsync("http://localhost:5052/user/Sha/articles"); response.EnsureSuccessStatusCode(); var responseBody = await response.Content.ReadAsStringAsync(); @@ -373,6 +394,7 @@ class Tests_Console_Connect_Localhost 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("http://localhost:5052/user/article", data); @@ -390,6 +412,7 @@ class Tests_Console_Connect_Localhost { try { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenAPI); var response = await client.DeleteAsync("http://localhost:5052/user/Sha/3"); response.EnsureSuccessStatusCode(); var responseBody = await response.Content.ReadAsStringAsync(); @@ -410,6 +433,7 @@ class Tests_Console_Connect_Localhost 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");