public void MauvaisMessage() { const string p = "Snort"; byte[] hash; using (HMACSHA256 sha = new HMACSHA256(Key)) { hash = sha.ComputeHash(Encoding.UTF8.GetBytes(p)); } using (RdvController rc = new RdvController()) { rc.Request = new HttpRequestMessage(); rc.Configuration = new HttpConfiguration(); rc.Request.Headers.Add(LapinSignature, BitConverter.ToString(hash).Replace("-", "").ToUpperInvariant()); rc.Request.Method = HttpMethod.Post; rc.Request.Content = new StringContent(p); HttpResponseMessage hrm = rc.NewCalendarEvent(); string s = hrm.Content.ReadAsStringAsync().Result; Reponse r = JsonConvert.DeserializeObject <Reponse>(s); Assert.IsTrue(r.Signature); Assert.IsTrue("Unexpected character encountered while parsing value: S. Path '', line 0, position 0.".Equals(r.Erreur, StringComparison.Ordinal)); } }
public void NoHash() { using (RdvController rc = new RdvController()) { rc.Request = new HttpRequestMessage(); rc.Configuration = new HttpConfiguration(); rc.Request.Method = HttpMethod.Post; rc.Request.Content = new StringContent(Rdv); HttpResponseMessage hrm = rc.NewCalendarEvent(); string s = hrm.Content.ReadAsStringAsync().Result; Reponse r = JsonConvert.DeserializeObject <Reponse>(s); Assert.IsFalse(r.Signature); } }
public void MauvaisHash() { byte[] hash; using (HMACSHA256 sha = new HMACSHA256(Encoding.UTF8.GetBytes("clé"))) { hash = sha.ComputeHash(Encoding.UTF8.GetBytes(Rdv)); } using (RdvController rc = new RdvController()) { rc.Request = new HttpRequestMessage(); rc.Configuration = new HttpConfiguration(); rc.Request.Headers.Add(LapinSignature, BitConverter.ToString(hash).Replace("-", "").ToUpperInvariant()); rc.Request.Method = HttpMethod.Post; rc.Request.Content = new StringContent(Rdv); HttpResponseMessage hrm = rc.NewCalendarEvent(); string s = hrm.Content.ReadAsStringAsync().Result; Reponse r = JsonConvert.DeserializeObject <Reponse>(s); Assert.IsFalse(r.Signature); } }