Skip to content

Commit

Permalink
Test: openapi http test flow
Browse files Browse the repository at this point in the history
  • Loading branch information
shps951023 committed Jun 9, 2024
1 parent 2731714 commit e96f614
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 4 deletions.
8 changes: 7 additions & 1 deletion tests/IdentityAPIEndpoints/IdentityAPIEndpoints.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.34928.147
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityAPIEndpoints", "IdentityAPIEndpoints\IdentityAPIEndpoints.csproj", "{28162644-8BC8-4E5E-8B23-74C0FD97EBDE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityAPIEndpoints", "IdentityAPIEndpoints\IdentityAPIEndpoints.csproj", "{28162644-8BC8-4E5E-8B23-74C0FD97EBDE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MiniAuth.IdentityAuth", "..\..\src\MiniAuth.IdentityAuth\MiniAuth.IdentityAuth.csproj", "{E44732DA-574E-4E0D-BD43-B0E3C1383A7C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -15,6 +17,10 @@ Global
{28162644-8BC8-4E5E-8B23-74C0FD97EBDE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{28162644-8BC8-4E5E-8B23-74C0FD97EBDE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{28162644-8BC8-4E5E-8B23-74C0FD97EBDE}.Release|Any CPU.Build.0 = Release|Any CPU
{E44732DA-574E-4E0D-BD43-B0E3C1383A7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E44732DA-574E-4E0D-BD43-B0E3C1383A7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E44732DA-574E-4E0D-BD43-B0E3C1383A7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E44732DA-574E-4E0D-BD43-B0E3C1383A7C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.6.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\MiniAuth.IdentityAuth\MiniAuth.IdentityAuth.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@basepath = http://localhost:5135

### Access RequireAuthorization api
GET {{basepath}}/

### Register a new user
POST {{basepath}}/account/register
Content-Type: application/json

{
"username": "example@example.com",
"password": "ExamplePassword123456!",
"email": "example@example.com"
}

### Login and retrieve tokens and set accesstoken variable
POST {{basepath}}/account/login
Content-Type: application/json

{
"email": "example@example.com",
"password": "ExamplePassword123456!"
}

### {
# "tokenType": "Bearer",
# "accessToken": "CfDJ8JQ6UejBIoRIkUpEJR_892d-zbl9LEcgWQiW6uF55wQzMaIo9tELg3ATO_91h3I6CFxA4uC6yNJGx2o3Mk3iSVzPF6iTZetbunzE-Yxf40apjpXEZkc_dEYMQfnpDIq8XJFclh8uWLTLk7Jq7Ne1Rg7LNK-Uh5vzqgP5bS609Viu8dV29kgtK1RfIU2N_7o4lw1X-YoX38jwyc-ArodRrJRkcMsEs0ts2L1pIRKQH8NO3x-fcmQLGJrcutKg9OBTlscx6r-WCc_bJMjGdDQgXrZEYu-XSPbgc4FAB3C3NAZFEqqwXW1NLIb_3Xa3CYqrsX2veomIXNgq3YoomZ0rMdm94gC7Z1R8LjMAWecPU9p2UB1IFIbvLMRLpmgIVHQjTaHKS42-uA0NB5TdJxaF0Gc90czUmd8PG9l5yEPgDPiQLztkk5vBm0y_HR5cgUDQdEwSQt8Av0gsmbME9atzkxeFFFTVezB52YR_SsMzbx5q_lJE-ux6SDdmykzbSwjg4ecJRPd6_G_MNMt72Pc-gTIHZC56zqyrUt_6N3RdsQTSt5_6dl42IGRMO6j6JRrk9BRpWykWLylDcLfNyfGx1QV7cyqbKIPNbOLFT2VKsA_Svz79Gb37VyiaNEppMjO2UI6CWj1DxazYWNMERiQ0Tfj1Q7HIJkFINC9fIbNPI2SjqNurAxCTIAfBqzf0Nox8hl1bcZN7OSun8-u7nhbqdg0",
# "expiresIn": 3600,
# "refreshToken": "CfDJ8JQ6UejBIoRIkUpEJR_892dg_5gvwNBXBMYLYQj05RIc14gg_31KrsnOjceSSvrowYNz_kXZ2g8jdWl91ctdU3A3yy5krWnD_p-sJAUNF_OT6NTsZrhnajn7bLOtjgGQ3tbaFYq5_qEGYFXkDk9N3leqQQnyXwoa7sfIVijq_-BjK1kcg9EoyUmlQQ17ysdtw4S5AFQ8b-K8CrVCIDuUYopb5cviYcXBMBkoGz2EkY2og67F1yEFpuMbTox8POmTcbbDK7nCFUPZQVI-0k7dKhBo9AojS9ez4HjZDWINBcruqvVXQwhBI5GYWSwsg0C03sm2dCnqmGIslS88E3kQUfkHcSKDPu-Y-9As7oE1xYszvy31DEr3H0ul7slHEsa5VxpYo_GRpbGBKzLFKgPrUG2jEF_JdUcNZiGZcuwRNIgF3QFNZxu6ZeMjS6U1WIbAaiuFPN9V-rPeERy3Q6ilAc5Oi-nA8j1FpuyOLxS62BUSywLVj7tCA7DL7y8DN2iAPoEiDavzdG4dbtU6opkB7btxp19hBfWPyvNzWtVCSVgF4SomxXHtNhaR6w9CeY7ZNYC_mWqAjckSkkDgsct2Vn6_od6SnQgLiDxwzv8DuEgT-N0ZsusbPGRSrRLrLcAkbKyP3iVRo1lp7gmNgi6t3lpOnXMhu_9cx1ZnYLsXwUgEBQYyid9XTsEAoTgyC001tSYJ194vEsaItkxdB5OlCBQ"
# }
### GET {{basepath}}/ with header token authroization
GET {{basepath}}/
Authorization : Bearer CfDJ8JQ6UejBIoRIkUpEJR_892d-zbl9LEcgWQiW6uF55wQzMaIo9tELg3ATO_91h3I6CFxA4uC6yNJGx2o3Mk3iSVzPF6iTZetbunzE-Yxf40apjpXEZkc_dEYMQfnpDIq8XJFclh8uWLTLk7Jq7Ne1Rg7LNK-Uh5vzqgP5bS609Viu8dV29kgtK1RfIU2N_7o4lw1X-YoX38jwyc-ArodRrJRkcMsEs0ts2L1pIRKQH8NO3x-fcmQLGJrcutKg9OBTlscx6r-WCc_bJMjGdDQgXrZEYu-XSPbgc4FAB3C3NAZFEqqwXW1NLIb_3Xa3CYqrsX2veomIXNgq3YoomZ0rMdm94gC7Z1R8LjMAWecPU9p2UB1IFIbvLMRLpmgIVHQjTaHKS42-uA0NB5TdJxaF0Gc90czUmd8PG9l5yEPgDPiQLztkk5vBm0y_HR5cgUDQdEwSQt8Av0gsmbME9atzkxeFFFTVezB52YR_SsMzbx5q_lJE-ux6SDdmykzbSwjg4ecJRPd6_G_MNMt72Pc-gTIHZC56zqyrUt_6N3RdsQTSt5_6dl42IGRMO6j6JRrk9BRpWykWLylDcLfNyfGx1QV7cyqbKIPNbOLFT2VKsA_Svz79Gb37VyiaNEppMjO2UI6CWj1DxazYWNMERiQ0Tfj1Q7HIJkFINC9fIbNPI2SjqNurAxCTIAfBqzf0Nox8hl1bcZN7OSun8-u7nhbqdg0

11 changes: 8 additions & 3 deletions tests/IdentityAPIEndpoints/IdentityAPIEndpoints/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class Program
{
public static void Main(string[] args)
{
// http://localhost:5135/swagger/index.html
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddAuthorization();
Expand All @@ -22,13 +23,17 @@ public static void Main(string[] args)
builder.Services.AddSwaggerGen();
using (var scope = builder.Services.BuildServiceProvider().CreateScope())
{
var db = scope.ServiceProvider.GetRequiredService<IdentityDbContext>();
db.Database.Migrate();
var ctx = scope.ServiceProvider.GetRequiredService<IdentityDbContext>();
if (ctx.Database.EnsureCreated())
{

}
}


var app = builder.Build();
app.MapGet("/", () => "Hello World!");
app.MapGet("/", () => "Hello World!").RequireAuthorization()
;
app.MapGroup("/account").MapIdentityApi<IdentityUser>();

if (app.Environment.IsDevelopment())
Expand Down

0 comments on commit e96f614

Please sign in to comment.