public void AreNotNull(LoginDataRequest loginData, Hash sut) { //Act var data = sut.GenerateHash(loginData); //Arrange Assert.NotNull(data); }
public void AfterEachCallResultAreSame(LoginDataRequest loginData, Hash sut) { //Act var result = sut.GenerateHash(loginData); var result2 = sut.GenerateHash(loginData); //Arrange Assert.AreEqual(result, result2); }
public async Task <HashResponse> GetHashCode(LoginDataRequest request) { var client = _httpClientFactory.CreateClient(); var response = await client.PostAsJsonAsync(_appConfig.HashFunction, request); response.EnsureSuccessStatusCode(); var hash = await response.Content.ReadFromJsonAsync <HashResponse>(); return(hash); }
public void CheckSumShouldBeGeneratedForEmptyString(Hash sut) { //Arrange var loginData = new LoginDataRequest(); //Act var result = sut.GenerateHash(loginData); //Arrange Assert.NotNull(result); }
public string GenerateHash(LoginDataRequest logindata) { MD5 md5 = new MD5CryptoServiceProvider(); //compute hash from the bytes of text md5.ComputeHash(ASCIIEncoding.ASCII.GetBytes($"{logindata.Login}{logindata.Password}")); byte[] result = md5.Hash; StringBuilder strBuilder = new StringBuilder(); for (int i = 0; i < result.Length; i++) { //change it into 2 hexadecimal digits //for each byte strBuilder.Append(result[i].ToString("x2")); } return(strBuilder.ToString()); }
public async Task <LoginResponse> Login(LoginRequest lr) { var loginResponse = await LoginDataRequest.Login(lr); return(loginResponse); }
public async Task <IActionResult> GenerateHash(LoginDataRequest loginDataRequest) { var hash = await _webApi.GetHashCode(loginDataRequest); return(Ok(hash)); }