public async Task Save_Encrypted_Data_While_Registering_New_Admin()
        {
            // arrange

            const string email     = "*****@*****.**";
            string       emailHash = new Sha256HashingUtil().Sha256HashEncoding1252(email);

            // act

            await _service.RegisterAsync(
                email,
                "password",
                "first name",
                "last name",
                "phone_number",
                "company",
                "department",
                "jobTitle",
                new List <Permission>());

            // assert

            _adminUsersRepositoryMock.Verify(o => o.TryCreateAsync(It.Is <AdminUserEncrypted>(
                                                                       adminUserEncrypted => adminUserEncrypted.EmailHash == emailHash)));
        }
Beispiel #2
0
 public CustomerCredentialsRepository(
     MsSqlContextFactory <CredentialsContext> contextFactory,
     ILogFactory logFactory,
     Sha256HashingUtil hashingHelper)
 {
     _contextFactory = contextFactory;
     _hashingHelper  = hashingHelper;
     _log            = logFactory.CreateLog(this);
 }
Beispiel #3
0
 public AdminCredentialsRepository(
     MsSqlContextFactory <CredentialsContext> contextFactory,
     IMapper mapper,
     Sha256HashingUtil hashingHelper)
 {
     _contextFactory = contextFactory;
     _mapper         = mapper;
     _hashingHelper  = hashingHelper;
 }
        public void When_CallSha256HashAndPassEncoding1252_Expect_HashedInput()
        {
            var hash  = "2CF24DBA5FB0A30E26E83B2AC5B9E29E1B161E5C1FA7425E73043362938B9824";
            var input = "hello";

            var hashedInput = new Sha256HashingUtil().Sha256Hash(input, Encoding.GetEncoding(1252));

            Assert.Equal(hash, hashedInput);
        }
        public void When_CallSha256HashEncoding1251WithNonNullParameters_Expect_HashedInput()
        {
            var hash  = "2CF24DBA5FB0A30E26E83B2AC5B9E29E1B161E5C1FA7425E73043362938B9824";
            var input = "hello";

            var hashedInput = new Sha256HashingUtil().Sha256HashEncoding1252(input);

            Assert.Equal(hash, hashedInput);
        }
Beispiel #6
0
 public PartnerCredentialsRepository(
     PostgreSQLContextFactory <CredentialsContext> contextFactory,
     IMapper mapper,
     Sha256HashingUtil hashingHelper)
 {
     _contextFactory = contextFactory;
     _mapper         = mapper;
     _hashingHelper  = hashingHelper;
 }
Beispiel #7
0
        public async Task Save_Encrypted_Data_While_Registering_New_Admin()
        {
            // arrange

            const string email     = "*****@*****.**";
            string       emailHash = new Sha256HashingUtil().Sha256HashEncoding1252(email);

            var model = GetRegisterRequest();

            model.Email = email;

            // act

            await _service.RegisterAsync(model);

            // assert

            _adminUsersRepositoryMock.Verify(o => o.TryCreateAsync(It.Is <AdminUserEncrypted>(
                                                                       adminUserEncrypted => adminUserEncrypted.EmailHash == emailHash)));
        }