public void Should_Call_Confidentials_With_Post_And_Receive_Unauthorized() { var controller = new ConfidentialsController(credentialsRepository); controller.Request = new HttpRequestMessage(); IHttpActionResult actionResult = controller.ConfidentialsPost("rien"); var contentResult = actionResult as UnauthorizedResult; Assert.IsNotNull(contentResult); Assert.IsNotNull(contentResult.Challenges); Assert.AreEqual("WWW-Authenticate", contentResult.Challenges.ElementAt(0).Scheme); Assert.AreEqual("Basic realm=\"SimpleWebApi\"", contentResult.Challenges.ElementAt(0).Parameter); }
public void Should_Call_Confidentials_With_Get_And_Receive_Ok_False() { var controller = new ConfidentialsController(credentialsRepository); controller.Request = new HttpRequestMessage(); controller.Request.Headers.Authorization = new AuthenticationHeaderValue("Basic", "Something Or Somewhere"); IHttpActionResult actionResult = controller.ConfidentialsGet(); var contentResult = actionResult as OkNegotiatedContentResult <bool>; Assert.IsNotNull(contentResult); Assert.IsNotNull(contentResult.Content); Assert.AreEqual(false, contentResult.Content); }
public void Should_Call_Confidentials_With_Post_And_Receive_Ok_True() { var base64String = Convert.ToBase64String(Encoding.UTF8.GetBytes("[email protected]:motdepasse")); var controller = new ConfidentialsController(credentialsRepository); controller.Request = new HttpRequestMessage(); controller.Request.Headers.Authorization = new AuthenticationHeaderValue("Basic", base64String); IHttpActionResult actionResult = controller.ConfidentialsPost("rien"); var contentResult = actionResult as OkNegotiatedContentResult <bool>; Assert.IsNotNull(contentResult); Assert.IsNotNull(contentResult.Content); Assert.AreEqual(true, contentResult.Content); }