test console connect to API
continuous-integration/drone/push Build is passing Details

master
Tony Fages 1 year ago
parent c2a5d84d9a
commit 434deead41

@ -12,11 +12,6 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="454eaf08-7244-4002-811f-5409ccfe6a2a" name="Changes" comment=""> <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$/.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/Controllers/ArticleController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/API/Controllers/ArticleController.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/API/Controllers/FormulaireController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/API/Controllers/FormulaireController.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/API/Controllers/UserController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/API/Controllers/UserController.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/API/Entity_FrameWork.Article.db" beforeDir="false" afterPath="$PROJECT_DIR$/API/Entity_FrameWork.Article.db" afterDir="false" />
<change beforePath="$PROJECT_DIR$/API/Program.cs" beforeDir="false" afterPath="$PROJECT_DIR$/API/Program.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/API/log.txt" beforeDir="false" afterPath="$PROJECT_DIR$/API/log.txt" 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_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" /> <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" />
@ -137,7 +132,7 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1712063297753</updated> <updated>1712063297753</updated>
<workItem from="1712063301685" duration="548000" /> <workItem from="1712063301685" duration="548000" />
<workItem from="1712498505089" duration="2249000" /> <workItem from="1712498505089" duration="6987000" />
</task> </task>
<servers /> <servers />
</component> </component>

@ -2204,3 +2204,181 @@ info: 04/07/2024 16:34:29.341 RelationalEventId.CommandExecuted[20101] (Microsof
FROM "FormSet" AS "f" FROM "FormSet" AS "f"
WHERE "f"."Id" = @__id_0 WHERE "f"."Id" = @__id_0
LIMIT 1 LIMIT 1
info: 04/07/2024 18:26:44.352 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 18:26:44.356 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 18:26:44.363 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 18:26:44.371 RelationalEventId.MigrationsNotApplied[20405] (Microsoft.EntityFrameworkCore.Migrations)
No migrations were applied. The database is already up to date.
info: 04/07/2024 18:28:16.315 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 18:28:16.320 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 18:28:16.326 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 18:28:16.335 RelationalEventId.MigrationsNotApplied[20405] (Microsoft.EntityFrameworkCore.Migrations)
No migrations were applied. The database is already up to date.
info: 04/07/2024 18:30:50.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: 04/07/2024 18:31:42.064 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 18:31:42.068 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 18:31:42.075 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 18:31:42.083 RelationalEventId.MigrationsNotApplied[20405] (Microsoft.EntityFrameworkCore.Migrations)
No migrations were applied. The database is already up to date.
info: 04/07/2024 18:31:49.090 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 18:31:49.094 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 18:31:49.102 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 18:31:49.111 RelationalEventId.MigrationsNotApplied[20405] (Microsoft.EntityFrameworkCore.Migrations)
No migrations were applied. The database is already up to date.
info: 04/07/2024 18:35:21.368 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 18:35:21.372 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 18:35:21.379 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 18:35:21.387 RelationalEventId.MigrationsNotApplied[20405] (Microsoft.EntityFrameworkCore.Migrations)
No migrations were applied. The database is already up to date.
warn: 04/07/2024 18:35:57.005 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 18:35:57.060 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: 04/07/2024 18:36:03.927 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 18:37:52.364 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 18:37:52.368 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 18:37:52.375 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 18:37:52.383 RelationalEventId.MigrationsNotApplied[20405] (Microsoft.EntityFrameworkCore.Migrations)
No migrations were applied. The database is already up to date.
info: 04/07/2024 18:38:20.030 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 18:38:20.078 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 18:38:31.707 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 18:38:31.710 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 18:38:31.730 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (1ms) [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 18:38:31.737 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 18:38:31.753 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 18:38:31.756 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 18:38:31.756 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 18:38:31.756 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 18:38:31.764 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 18:38:31.765 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 18:38:31.774 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 18:38:31.776 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 18:38:31.792 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 18:38:31.795 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 18:38:31.801 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"

@ -7,54 +7,161 @@ using Entities;
using Model; using Model;
public class Tests_Console_Connect_API 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"; // Cette section permet de tester d'API déployée sur le serveur codefirst de l'IUT
static readonly HttpClient client = new HttpClient(); static readonly HttpClient client = new HttpClient();
static string email = "verax@verax.com";
static string password = "P@ssw0rd1";
public static async Task Main2(string[] args) public static async Task Main2(string[] args)
{ {
await TestUser(); //await RegisterUser("verax@verax.com", "P@ssw0rd1");
await TestFormulaire();
await TestArticle(); // 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);
} }
private static async Task TestFormulaire()
static async Task TestArticle(string tokenAPI)
{ {
await TestFormulaireGetAll(); await TestArticleGetId(tokenAPI);
await TestFormulaireGetId(); //await TestArticleCreate(tokenAPI);
//await TestFormulaireCreate(); await TestArticleGetAll(tokenAPI);
//await TestFormulaireDelete(); //await TestArticleDelete(tokenAPI);
//await TestFormulaireUpdate(); //await TestArticleUpdate(tokenAPI);
} }
private static async Task TestUser()
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)
{ {
await TestUserGetAll(); Console.WriteLine($"Error parsing JSON response: {e.Message}");
await TestUserGetId(); return null;
//await TestUserCreate(); }
//await TestUserDelete();
//await TestUserUpdate();
await TestGetAllArticleUser();
await TestGetArticleByUser();
//await TestCreateArticleUser();
//await TestDeleteArticleUser();
//await TestUpdateArticleUser();
} }
static async Task TestArticle()
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
{ {
await TestArticleGetId(); var response = await client.PostAsync("https://codefirst.iut.uca.fr/containers/Verax-verax-api/register", data);
//await TestArticleCreate(); var responseBody = await response.Content.ReadAsStringAsync();
await TestArticleGetAll();
//await TestArticleDelete(); if (response.IsSuccessStatusCode)
//await TestArticleUpdate(); {
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() static async Task TestArticleGetAll(string tokenAPI)
{ {
try try
{ {
@ -70,7 +177,7 @@ public class Tests_Console_Connect_API
} }
} }
static async Task TestArticleGetId() static async Task TestArticleGetId(string tokenAPI)
{ {
try try
{ {
@ -86,7 +193,7 @@ public class Tests_Console_Connect_API
} }
} }
static async Task TestArticleCreate() static async Task TestArticleCreate(string tokenAPI)
{ {
try try
{ {
@ -112,7 +219,7 @@ public class Tests_Console_Connect_API
} }
} }
static async Task TestArticleDelete() static async Task TestArticleDelete(string tokenAPI)
{ {
try try
{ {
@ -128,7 +235,7 @@ public class Tests_Console_Connect_API
} }
} }
static async Task TestArticleUpdate() static async Task TestArticleUpdate(string tokenAPI)
{ {
try try
{ {
@ -154,7 +261,7 @@ public class Tests_Console_Connect_API
} }
} }
static async Task TestFormulaireGetAll() static async Task TestFormulaireGetAll(string tokenAPI)
{ {
try try
{ {
@ -170,7 +277,7 @@ public class Tests_Console_Connect_API
} }
} }
static async Task TestFormulaireGetId() static async Task TestFormulaireGetId(string tokenAPI)
{ {
try try
{ {
@ -186,7 +293,7 @@ public class Tests_Console_Connect_API
} }
} }
static async Task TestFormulaireCreate() static async Task TestFormulaireCreate(string tokenAPI)
{ {
try try
{ {
@ -211,7 +318,7 @@ public class Tests_Console_Connect_API
} }
} }
static async Task TestFormulaireDelete() static async Task TestFormulaireDelete(string tokenAPI)
{ {
try try
{ {
@ -227,7 +334,7 @@ public class Tests_Console_Connect_API
} }
} }
static async Task TestFormulaireUpdate() static async Task TestFormulaireUpdate(string tokenAPI)
{ {
try try
{ {
@ -252,7 +359,7 @@ public class Tests_Console_Connect_API
} }
} }
static async Task TestUserGetAll() static async Task TestUserGetAll(string tokenAPI)
{ {
try try
{ {
@ -268,7 +375,7 @@ public class Tests_Console_Connect_API
} }
} }
static async Task TestUserGetId() static async Task TestUserGetId(string tokenAPI)
{ {
try try
{ {
@ -284,7 +391,7 @@ public class Tests_Console_Connect_API
} }
} }
static async Task TestUserCreate() static async Task TestUserCreate(string tokenAPI)
{ {
try try
{ {
@ -311,7 +418,7 @@ public class Tests_Console_Connect_API
} }
} }
static async Task TestUserDelete() static async Task TestUserDelete(string tokenAPI)
{ {
try try
{ {
@ -327,7 +434,7 @@ public class Tests_Console_Connect_API
} }
} }
static async Task TestUserUpdate() static async Task TestUserUpdate(string tokenAPI)
{ {
try try
{ {
@ -354,7 +461,7 @@ public class Tests_Console_Connect_API
} }
} }
static async Task TestGetAllArticleUser() static async Task TestGetAllArticleUser(string tokenAPI)
{ {
try try
{ {
@ -370,7 +477,7 @@ public class Tests_Console_Connect_API
} }
} }
static async Task TestGetArticleByUser() static async Task TestGetArticleByUser(string tokenAPI)
{ {
try try
{ {
@ -386,7 +493,7 @@ public class Tests_Console_Connect_API
} }
} }
static async Task TestCreateArticleUser() static async Task TestCreateArticleUser(string tokenAPI)
{ {
try try
{ {
@ -409,7 +516,7 @@ public class Tests_Console_Connect_API
} }
} }
static async Task TestDeleteArticleUser() static async Task TestDeleteArticleUser(string tokenAPI)
{ {
try try
{ {
@ -425,7 +532,7 @@ public class Tests_Console_Connect_API
} }
} }
static async Task TestUpdateArticleUser() static async Task TestUpdateArticleUser(string tokenAPI)
{ {
try try
{ {

@ -8,53 +8,64 @@ using Entities;
using Model; using Model;
class Tests_Console_Connect_Localhost class Tests_Console_Connect_Localhost
{static readonly HttpClient client = new HttpClient(); {
static string tokenAPI = static readonly HttpClient client = new HttpClient();
"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 string email = "verax@verax.com";
static string password = "P@ssw0rd1";
static async Task Main(string[] args) static async Task Main(string[] args)
{ {
//await TestUser(); //Commenter lignes apres premier execution
//await TestFormulaire(); await RegisterUser(email, password);
//await TestArticle();
await Tests_Console_Connect_API.Main2(args);
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() private static async Task TestFormulaire(string tokenAPI)
{ {
await TestFormulaireGetAll(); await TestFormulaireGetAll(tokenAPI);
await TestFormulaireGetId(); await TestFormulaireGetId(tokenAPI);
//await TestFormulaireCreate(); //await TestFormulaireCreate(tokenAPI);
//await TestFormulaireDelete(); //await TestFormulaireDelete(tokenAPI);
//await TestFormulaireUpdate(); //await TestFormulaireUpdate(tokenAPI);
} }
private static async Task TestUser() private static async Task TestUser(string tokenAPI)
{ {
await TestUserGetAll(); await TestUserGetAll(tokenAPI);
await TestUserGetId(); await TestUserGetId(tokenAPI);
//await TestUserCreate(); //await TestUserCreate(tokenAPI);
//await TestUserDelete(); //await TestUserDelete(tokenAPI);
//await TestUserUpdate(); //await TestUserUpdate(tokenAPI);
await TestGetAllArticleUser(); await TestGetAllArticleUser(tokenAPI);
await TestGetArticleByUser(); await TestGetArticleByUser(tokenAPI);
//await TestCreateArticleUser(); //await TestCreateArticleUser(tokenAPI);
//await TestDeleteArticleUser(); //await TestDeleteArticleUser(tokenAPI);
//await TestUpdateArticleUser(); //await TestUpdateArticleUser(tokenAPI);
} }
static async Task TestArticle() static async Task TestArticle(string tokenAPI)
{ {
await TestArticleGetId(); await TestArticleGetId(tokenAPI);
//await TestArticleCreate(); //await TestArticleCreate(tokenAPI);
await TestArticleGetAll(); await TestArticleGetAll(tokenAPI);
//await TestArticleDelete(); //await TestArticleDelete(tokenAPI);
// await TestArticleUpdate(); //await TestArticleUpdate(tokenAPI);
} }
static async Task TestArticleGetAll() static async Task TestArticleGetAll(string tokenAPI)
{ {
try try
{ {
@ -70,7 +81,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestArticleGetId() static async Task TestArticleGetId(string tokenAPI)
{ {
try try
{ {
@ -86,7 +97,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestArticleCreate() static async Task TestArticleCreate(string tokenAPI)
{ {
try try
{ {
@ -98,6 +109,7 @@ 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);
@ -111,7 +123,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestArticleDelete() static async Task TestArticleDelete(string tokenAPI)
{ {
try try
{ {
@ -127,7 +139,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestArticleUpdate() static async Task TestArticleUpdate(string tokenAPI)
{ {
try try
{ {
@ -153,7 +165,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestFormulaireGetAll() static async Task TestFormulaireGetAll(string tokenAPI)
{ {
try try
{ {
@ -169,7 +181,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestFormulaireGetId() static async Task TestFormulaireGetId(string tokenAPI)
{ {
try try
{ {
@ -185,7 +197,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestFormulaireCreate() static async Task TestFormulaireCreate(string tokenAPI)
{ {
try try
{ {
@ -210,7 +222,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestFormulaireDelete() static async Task TestFormulaireDelete(string tokenAPI)
{ {
try try
{ {
@ -226,7 +238,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestFormulaireUpdate() static async Task TestFormulaireUpdate(string tokenAPI)
{ {
try try
{ {
@ -251,7 +263,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestUserGetAll() static async Task TestUserGetAll(string tokenAPI)
{ {
try try
{ {
@ -267,7 +279,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestUserGetId() static async Task TestUserGetId(string tokenAPI)
{ {
try try
{ {
@ -283,7 +295,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestUserCreate() static async Task TestUserCreate(string tokenAPI)
{ {
try try
{ {
@ -310,7 +322,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestUserDelete() static async Task TestUserDelete(string tokenAPI)
{ {
try try
{ {
@ -326,7 +338,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestUserUpdate() static async Task TestUserUpdate(string tokenAPI)
{ {
try try
{ {
@ -353,7 +365,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestGetAllArticleUser() static async Task TestGetAllArticleUser(string tokenAPI)
{ {
try try
{ {
@ -369,7 +381,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestGetArticleByUser() static async Task TestGetArticleByUser(string tokenAPI)
{ {
try try
{ {
@ -385,7 +397,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestCreateArticleUser() static async Task TestCreateArticleUser(string tokenAPI)
{ {
try try
{ {
@ -408,7 +420,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestDeleteArticleUser() static async Task TestDeleteArticleUser(string tokenAPI)
{ {
try try
{ {
@ -424,7 +436,7 @@ class Tests_Console_Connect_Localhost
} }
} }
static async Task TestUpdateArticleUser() static async Task TestUpdateArticleUser(string tokenAPI)
{ {
try try
{ {
@ -449,4 +461,98 @@ 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;
}
}
} }
Loading…
Cancel
Save