public void FailedAuthorization2() { var bootstrapper = new TestingBootstrapper(); var browser = new Browser(bootstrapper); var result = browser.Get("http://localhost:8070/api/pilots/1", with => { with.Accept(new MediaRange("application/json")); }); Assert.AreEqual(HttpStatusCode.Accepted, result.StatusCode); var error = result.Body.DeserializeJson <ts.dto.Error>(); Assert.AreEqual(strings.InvalidSessionKey, error.ErrorMessage); }
public void NormalFlow() { var bootstrapper = new TestingBootstrapper(); var browser = new Browser(bootstrapper); var result = browser.Post("http://*****:*****@a.a"); with.FormValue("password", "123"); with.Accept(new MediaRange("application/json")); }); Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); var key = result.Body.AsString(); Assert.IsTrue(key.Length > 0); }
public void ErrorFlow() { var bootstrapper = new TestingBootstrapper(); var browser = new Browser(bootstrapper); var result = browser.Post("http://*****:*****@a.a"); with.FormValue("password", "123"); with.Accept(new MediaRange("application/json")); }); Assert.AreEqual(HttpStatusCode.Accepted, result.StatusCode); var error = result.Body.DeserializeJson <ts.dto.Error>(); Assert.AreEqual(strings.InvalidUserPassword, error.ErrorMessage); }
public void WithAuthorization() { var bootstrapper = new TestingBootstrapper(); var browser = new Browser(bootstrapper); var result = browser.Post("http://*****:*****@a2.a"); with.FormValue("password", "123"); with.Accept(new MediaRange("application/json")); }); Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); var skey = result.Body.DeserializeJson <SingleStringDto>().Value; result = browser.Get("http://localhost:8070/api/pilots", with => { with.Header("jwt", skey); with.Accept(new MediaRange("application/json")); }); Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); }