locked
mock IdentityServer4,  AspNetCore integration tests RRS feed

  • Question

  • User-1760607715 posted

    Hi , I would like to mock IdentityServer4, when using  AspNetCore integration tests

    here is my code : 

    public class TestFixture : WebApplicationFactory, IDisposable

    {

    }

    public class QueryTest : IClassFixture

    {

    private readonly TestFixture _fixture;

    private readonly HttpClient _httpClient;

    public VoteQueryTest(TestFixture fixture)

    { _fixture = fixture; _httpClient = _fixture.CreateClient();

    }

    Tuesday, December 4, 2018 5:12 PM

All replies

  • User475983607 posted

    abonn.abonn.specs

    Hi , I would like to mock IdentityServer4, when using  AspNetCore integration tests

    here is my code : 

    public class TestFixture : WebApplicationFactory, IDisposable { } public class QueryTest : IClassFixture { private readonly TestFixture _fixture; private readonly HttpClient _httpClient; public VoteQueryTest(TestFixture fixture) { _fixture = fixture; _httpClient = _fixture.CreateClient(); }

    You want to test security attributes in ASP.NET Core? 

    https://davidpine.net/blog/asp-net-core-security-unit-testing/

    https://stackoverflow.com/questions/48562403/unit-testing-an-authorizeattribute-on-an-asp-net-core-mvc-api-controller

    What do you mean mock IdentityServer4?  What are you trying to test exactly?

    Tuesday, December 4, 2018 5:15 PM
  • User-1760607715 posted

    I use IdentityServer4 to authorize webapi core, so I would like to mock IdentityServer4 ==>  fake calls of IdentityServer4

    Friday, December 7, 2018 12:29 PM
  • User475983607 posted

    I use IdentityServer4 to authorize webapi core, so I would like to mock IdentityServer4 ==>  fake calls of IdentityServer4

     Identity server exchanges user credentials for a token.  It is up to the client to pass the token to a secured resource.  Generally the client caches the token. 

    What call are you trying to mock? 

    Friday, December 7, 2018 1:56 PM