IdentityServer4TestServer icon indicating copy to clipboard operation
IdentityServer4TestServer copied to clipboard

How to do micro service integration test

Open jingliancui opened this issue 7 years ago • 2 comments

Hi @devdigital I am now contribute a web service which combine mvcclient and identity server. But I can't do test with two server. for example: Used httpclient sent request to the client, then client request token from idserver. My sample code reference this issue: https://github.com/IdentityServer/IdentityServer4/issues/2861 which use two customize WebApplicationFactory. The Author of identity server tell me that I can using your project to do that. But I don't know how to do this.Because your sample code in the readme show the client is not match my mvcclient project.

jingliancui avatar Dec 24 '18 05:12 jingliancui

It seem like that use this to solve it:

       using (var client = clientFactory
            .WithClientId(clientId)
            .WithClientSecret(clientSecret)
            .Create(server))
        {
            var response = await client.GetToken();
            Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode);
        }

I will try it later,now I use the latest version of asp.net core 2.2 and the newest idserver.It can not initial the factory (throw exception).Maybe I 'll create another new issue ,So close this first.

jingliancui avatar Dec 24 '18 05:12 jingliancui

It's seem like that after fix this issue to continue the micro services work: https://github.com/devdigital/IdentityServer4TestServer/issues/22

jingliancui avatar Dec 24 '18 06:12 jingliancui