コード例 #1
0
        public void AreNotNull(LoginDataRequest loginData, Hash sut)
        {
            //Act
            var data = sut.GenerateHash(loginData);

            //Arrange
            Assert.NotNull(data);
        }
コード例 #2
0
        public void AfterEachCallResultAreSame(LoginDataRequest loginData, Hash sut)
        {
            //Act
            var result  = sut.GenerateHash(loginData);
            var result2 = sut.GenerateHash(loginData);

            //Arrange
            Assert.AreEqual(result, result2);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        public void CheckSumShouldBeGeneratedForEmptyString(Hash sut)
        {
            //Arrange
            var loginData = new LoginDataRequest();

            //Act
            var result = sut.GenerateHash(loginData);

            //Arrange
            Assert.NotNull(result);
        }
コード例 #5
0
        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());
        }
コード例 #6
0
        public async Task <LoginResponse> Login(LoginRequest lr)
        {
            var loginResponse = await LoginDataRequest.Login(lr);

            return(loginResponse);
        }
コード例 #7
0
        public async Task <IActionResult> GenerateHash(LoginDataRequest loginDataRequest)
        {
            var hash = await _webApi.GetHashCode(loginDataRequest);

            return(Ok(hash));
        }