diff --git a/OutOfSchool/OutOfSchool.AuthServer.Tests/Services/GovCommunicationServiceTests.cs b/OutOfSchool/OutOfSchool.AuthServer.Tests/Services/GovCommunicationServiceTests.cs index 17f70076a..35b2f0fed 100644 --- a/OutOfSchool/OutOfSchool.AuthServer.Tests/Services/GovCommunicationServiceTests.cs +++ b/OutOfSchool/OutOfSchool.AuthServer.Tests/Services/GovCommunicationServiceTests.cs @@ -96,21 +96,20 @@ public async Task GetUserInfo_WithCorrectRequest_ReturnsOkResponse() { CertBase64 = "cert", }; - var certSetup = SetupSendAsync(handler, HttpMethod.Get, - new Uri(eUSignServiceUri, "api/v1/certificate").ToString()); - ReturnsHttpResponseAsync(certSetup, certResponse, HttpStatusCode.OK); + handler.SetupSendAsync(HttpMethod.Get, + new Uri(eUSignServiceUri, "api/v1/certificate").ToString()) + .ReturnsHttpResponseAsync(certResponse, HttpStatusCode.OK); var infoResponse = new EnvelopedUserInfoResponse { EncryptedUserInfo = "serialized_info", }; - var infoSetup = SetupSendAsync(handler, HttpMethod.Get, new Uri(idServerUri, "/userinfo").ToString(), true); - ReturnsHttpResponseAsync(infoSetup, infoResponse, HttpStatusCode.OK); + handler.SetupSendAsync(HttpMethod.Get, new Uri(idServerUri, "/userinfo").ToString(), true) + .ReturnsHttpResponseAsync(infoResponse, HttpStatusCode.OK); - var decryptSetup = - SetupSendAsync(handler, HttpMethod.Post, new Uri(eUSignServiceUri, "api/v1/decrypt").ToString()); - ReturnsHttpResponseAsync(decryptSetup, expected, HttpStatusCode.OK); + handler.SetupSendAsync(HttpMethod.Post, new Uri(eUSignServiceUri, "api/v1/decrypt").ToString()) + .ReturnsHttpResponseAsync(expected, HttpStatusCode.OK); // Act var userInfo = await communicationService.GetUserInfo(remoteUserId, remoteToken); @@ -125,9 +124,9 @@ public async Task GetUserInfo_WithEUSignCertError_ReturnsErrorResponse() // Arrange var remoteUserId = "123"; var remoteToken = "secret"; - var certSetup = SetupSendAsync(handler, HttpMethod.Get, - new Uri(eUSignServiceUri, "api/v1/certificate").ToString()); - ReturnsHttpResponseAsync(certSetup, null, HttpStatusCode.InternalServerError); + handler.SetupSendAsync(HttpMethod.Get, + new Uri(eUSignServiceUri, "api/v1/certificate").ToString()) + .ReturnsHttpResponseAsync(null, HttpStatusCode.InternalServerError); // Act var userInfo = await communicationService.GetUserInfo(remoteUserId, remoteToken); @@ -152,17 +151,17 @@ public async Task GetUserInfo_WithGovError_ReturnsErrorResponse() { CertBase64 = "cert", }; - var certSetup = SetupSendAsync(handler, HttpMethod.Get, - new Uri(eUSignServiceUri, "api/v1/certificate").ToString()); - ReturnsHttpResponseAsync(certSetup, certResponse, HttpStatusCode.OK); + handler.SetupSendAsync(HttpMethod.Get, + new Uri(eUSignServiceUri, "api/v1/certificate").ToString()) + .ReturnsHttpResponseAsync(certResponse, HttpStatusCode.OK); var errorResponse = new IdGovErrorResponse { Error = 1, }; - var infoSetup = SetupSendAsync(handler, HttpMethod.Get, new Uri(idServerUri, "/userinfo").ToString(), true); - ReturnsHttpResponseAsync(infoSetup, errorResponse, HttpStatusCode.Unauthorized); + handler.SetupSendAsync(HttpMethod.Get, new Uri(idServerUri, "/userinfo").ToString(), true) + .ReturnsHttpResponseAsync(errorResponse, HttpStatusCode.Unauthorized); // Act var userInfo = await communicationService.GetUserInfo(remoteUserId, remoteToken); @@ -190,21 +189,20 @@ public async Task GetUserInfo_WithEUSignDecryptError_ReturnsErrorResponse() { CertBase64 = "cert", }; - var certSetup = SetupSendAsync(handler, HttpMethod.Get, - new Uri(eUSignServiceUri, "api/v1/certificate").ToString()); - ReturnsHttpResponseAsync(certSetup, certResponse, HttpStatusCode.OK); + handler.SetupSendAsync(HttpMethod.Get, + new Uri(eUSignServiceUri, "api/v1/certificate").ToString()) + .ReturnsHttpResponseAsync(certResponse, HttpStatusCode.OK); var infoResponse = new EnvelopedUserInfoResponse { EncryptedUserInfo = "serialized_info", }; - var infoSetup = SetupSendAsync(handler, HttpMethod.Get, new Uri(idServerUri, "/userinfo").ToString(), true); - ReturnsHttpResponseAsync(infoSetup, infoResponse, HttpStatusCode.OK); + handler.SetupSendAsync(HttpMethod.Get, new Uri(idServerUri, "/userinfo").ToString(), true) + .ReturnsHttpResponseAsync(infoResponse, HttpStatusCode.OK); - var decryptSetup = - SetupSendAsync(handler, HttpMethod.Post, new Uri(eUSignServiceUri, "api/v1/decrypt").ToString()); - ReturnsHttpResponseAsync(decryptSetup, null, HttpStatusCode.InternalServerError); + handler.SetupSendAsync(HttpMethod.Post, new Uri(eUSignServiceUri, "api/v1/decrypt").ToString()) + .ReturnsHttpResponseAsync(null, HttpStatusCode.InternalServerError); // Act var userInfo = await communicationService.GetUserInfo(remoteUserId, remoteToken); diff --git a/OutOfSchool/OutOfSchool.BusinessLogic/OutOfSchool.BusinessLogic.csproj b/OutOfSchool/OutOfSchool.BusinessLogic/OutOfSchool.BusinessLogic.csproj index 2b36477e6..4a9a234c7 100644 --- a/OutOfSchool/OutOfSchool.BusinessLogic/OutOfSchool.BusinessLogic.csproj +++ b/OutOfSchool/OutOfSchool.BusinessLogic/OutOfSchool.BusinessLogic.csproj @@ -1,10 +1,7 @@  - net8.0 direct - - enable diff --git a/OutOfSchool/OutOfSchool.WebApi.Tests/Common/CommunicationServiceTest.cs b/OutOfSchool/OutOfSchool.WebApi.Tests/Common/CommunicationServiceTest.cs index 77fbd5c2d..2aef888c9 100644 --- a/OutOfSchool/OutOfSchool.WebApi.Tests/Common/CommunicationServiceTest.cs +++ b/OutOfSchool/OutOfSchool.WebApi.Tests/Common/CommunicationServiceTest.cs @@ -13,7 +13,6 @@ using OutOfSchool.Common.Config; using OutOfSchool.Common.Models; using OutOfSchool.Tests.Common; -using static OutOfSchool.Tests.Common.HttpClientTestHelper; namespace OutOfSchool.WebApi.Tests.Common; @@ -59,8 +58,8 @@ public async Task SendRequest_WithCorrectRequest_ReturnsOkResponse() Url = uri, }; var response = new TestResponse("OK"); - var setup = SetupSendAsync(handler, HttpMethod.Post, uri.ToString()); - ReturnsHttpResponseAsync(setup, response, HttpStatusCode.OK); + handler.SetupSendAsync(HttpMethod.Post, uri.ToString()) + .ReturnsHttpResponseAsync(response, HttpStatusCode.OK); // Act var result = await communicationService.SendRequest(request); @@ -72,8 +71,8 @@ public async Task SendRequest_WithCorrectRequest_ReturnsOkResponse() public async Task SendRequest_WithEmptyRequest_ReturnsErrorResponse() { // Arrange - var setup = SetupSendAsync(handler, HttpMethod.Get, uri.ToString()); - ReturnsHttpResponseAsync(setup, null, HttpStatusCode.OK); + handler.SetupSendAsync(HttpMethod.Get, uri.ToString()) + .ReturnsHttpResponseAsync(null, HttpStatusCode.OK); // Act var result = await communicationService.SendRequest(null); @@ -90,8 +89,8 @@ public async Task SendRequest_WithServerError_ReturnsErrorResponse() HttpMethodType = HttpMethodType.Get, Url = uri, }; - var setup = SetupSendAsync(handler, HttpMethod.Get, uri.ToString()); - ReturnsHttpResponseAsync(setup, null, HttpStatusCode.Unauthorized); + handler.SetupSendAsync(HttpMethod.Get, uri.ToString()) + .ReturnsHttpResponseAsync(null, HttpStatusCode.Unauthorized); // Act var result = await communicationService.SendRequest(request); @@ -108,8 +107,8 @@ public void SendRequest_WithServerErrorAndWrongHandler_ThrowsException() HttpMethodType = HttpMethodType.Get, Url = uri, }; - var setup = SetupSendAsync(handler, HttpMethod.Get, uri.ToString()); - ReturnsHttpResponseAsync(setup, null, HttpStatusCode.Unauthorized); + handler.SetupSendAsync(HttpMethod.Get, uri.ToString()) + .ReturnsHttpResponseAsync(null, HttpStatusCode.Unauthorized); // Act Assert.ThrowsAsync(() => @@ -125,8 +124,8 @@ public async Task SendRequest_WithServerErrorAndCustomHandler_ReturnsErrorRespon HttpMethodType = HttpMethodType.Get, Url = uri, }; - var setup = SetupSendAsync(handler, HttpMethod.Get, uri.ToString()); - ReturnsHttpResponseAsync(setup, null, HttpStatusCode.Unauthorized); + handler.SetupSendAsync(HttpMethod.Get, uri.ToString()) + .ReturnsHttpResponseAsync(null, HttpStatusCode.Unauthorized); // Act var result = await communicationService.SendRequest(request, new TestErrorHandler()); @@ -148,8 +147,8 @@ public async Task SendRequest_WithHttpException_ReturnsErrorResponse() Token = "secret", Url = uri, }; - var setup = SetupSendAsync(handler, HttpMethod.Get, uri.ToString()); - setup.Throws(new HttpRequestException(null, null, HttpStatusCode.InsufficientStorage)); + handler.SetupSendAsync(HttpMethod.Get, uri.ToString()) + .Throws(new HttpRequestException(null, null, HttpStatusCode.InsufficientStorage)); // Act var result = await communicationService.SendRequest(request);