Feature/migrate to minimal api (#662)

* migrate from classic controller to minimal api

* fix all PublicApi integration test

* update all nuget package add forget project

* fix pay now

* Adapt readme use in memory database

* undo AuthenticateEndpoint to use EndpointBaseAsync

* Update README.md

Co-authored-by: Steve Smith <steve@kentsmiths.com>

Co-authored-by: Steve Smith <steve@kentsmiths.com>
This commit is contained in:
Cédric Michel
2022-01-21 16:13:31 +01:00
committed by GitHub
parent 02b509711b
commit 1e13733d3d
63 changed files with 842 additions and 630 deletions

View File

@@ -0,0 +1,36 @@
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.eShopWeb;
using Microsoft.eShopWeb.ApplicationCore.Constants;
using Microsoft.eShopWeb.PublicApi.AuthEndpoints;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace PublicApiIntegrationTests.AuthEndpoints
{
[TestClass]
public class AuthenticateEndpoint
{
[TestMethod]
[DataRow("demouser@microsoft.com", AuthorizationConstants.DEFAULT_PASSWORD, true)]
[DataRow("demouser@microsoft.com", "badpassword", false)]
[DataRow("baduser@microsoft.com", "badpassword", false)]
public async Task ReturnsExpectedResultGivenCredentials(string testUsername, string testPassword, bool expectedResult)
{
var request = new AuthenticateRequest()
{
Username = testUsername,
Password = testPassword
};
var jsonContent = new StringContent(JsonSerializer.Serialize(request), Encoding.UTF8, "application/json");
var response = await ProgramTest.NewClient.PostAsync("api/authenticate", jsonContent);
response.EnsureSuccessStatusCode();
var stringResponse = await response.Content.ReadAsStringAsync();
var model = stringResponse.FromJson<AuthenticateResponse>();
Assert.AreEqual(expectedResult, model.Result);
}
}
}