public async Task DecryptTicket_SblBridgeResponseIsServiceUnavailable_ThrowsException() { // Arrange HttpResponseMessage httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.ServiceUnavailable, ReasonPhrase = "Service Unavailable" }; InitializeMocks(httpResponseMessage); HttpClient httpClient = new HttpClient(_handlerMock.Object); SblCookieDecryptionService target = new SblCookieDecryptionService(httpClient, _generalSettingsOptions.Object, _logger.Object); SblBridgeResponseException actual = null; // Act try { await target.DecryptTicket("random and irrelevant bytes"); } catch (SblBridgeResponseException e) { actual = e; } // Assert _handlerMock.VerifyAll(); Assert.NotNull(actual); Assert.Contains("ServiceUnavailable", actual.Message); }
public async Task DecryptTicket_SblBridgeResponseIsBadRequest_ReturnsNull() { // Arrange HttpResponseMessage httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.BadRequest, ReasonPhrase = "Service Unavailable" }; InitializeMocks(httpResponseMessage); HttpClient httpClient = new HttpClient(_handlerMock.Object); SblCookieDecryptionService target = new SblCookieDecryptionService(httpClient, _generalSettingsOptions.Object, _logger.Object); // Act UserAuthenticationModel actual = await target.DecryptTicket("random and irrelevant bytes"); // Assert _handlerMock.VerifyAll(); Assert.Null(actual); }
public async Task DecryptTicket_SblBridgeResponseIsOk_ReturnsUserModel() { // Arrange UserAuthenticationModel userModel = new UserAuthenticationModel(); HttpResponseMessage httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonSerializer.Serialize(userModel), Encoding.UTF8, "application/json"), }; InitializeMocks(httpResponseMessage); HttpClient httpClient = new HttpClient(_handlerMock.Object); SblCookieDecryptionService target = new SblCookieDecryptionService(httpClient, _generalSettingsOptions.Object, _logger.Object); // Act UserAuthenticationModel actual = await target.DecryptTicket("random and irrelevant bytes"); // Assert _handlerMock.VerifyAll(); Assert.NotNull(actual); }