public async Task Should_Decrypt_Front_Side_File() { PassportData passportData = GetPassportData(); IDecrypter decrypter = new Decrypter(); Credentials credentials = decrypter.DecryptCredentials(passportData.Credentials, EncryptionKey.RsaPrivateKey); byte[] encryptedContent = await System.IO.File.ReadAllBytesAsync("Files/driver_license-front_side.jpg.enc"); byte[] content = decrypter.DecryptFile( encryptedContent, credentials.SecureData.DriverLicense.FrontSide ); Assert.NotEmpty(content); await System.IO.File.WriteAllBytesAsync("Files/driver_license-front_side.jpg", content); using (System.IO.MemoryStream encryptedFileStream = new System.IO.MemoryStream(encryptedContent), decryptedFileStream = new System.IO.MemoryStream() ) { await decrypter.DecryptFileAsync( encryptedFileStream, credentials.SecureData.DriverLicense.FrontSide, decryptedFileStream ); Assert.Equal(content, decryptedFileStream.ToArray()); } }
Test3() //Проверим депозитные счета, статус счёта должен быть sleep до момента окончания начисления денег { DateTime futureDateTime = new DateTime(2021, 10, 2); DateTime futureDateTime2 = new DateTime(2021, 9, 2); DateTime futureDateTime3 = new DateTime(2021, 10, 3); List <(double, double)> TermForfirstBank = new List <(double, double)>(); TermForfirstBank.Add((10000, 0.05)); TermForfirstBank.Add((20000, 0.10)); TermForfirstBank.Add((5000, 0.01)); Bank alfaBank = new Bank(TermForfirstBank, 0.1, 0.02, 10000, 3000); IAbstractBank firstBank = alfaBank; Adress newAdress = new Adress("Невского", 10, "Питер"); PassportData firstPersonData = new PassportData(1111, 22222); Person Andrey = new Person("Андрей", "Загудько", newAdress, firstPersonData); Client clientAndrey = firstBank.CreateClient(Andrey); firstBank.AddDepositAccount(clientAndrey, 300000, DateTime.Now, futureDateTime); //клиент, стартовая сумма(она же определяет процент), дата начала, дата окончания. BankAccount firstAndreyAccount = clientAndrey.Accounts.ElementAt(0); firstBank.RefreshInfoAboutAccount(firstAndreyAccount, futureDateTime2); Assert.AreEqual(600000, firstAndreyAccount.AccountStatus); //наш счёт по состоянию на futureDateTime2 Assert.AreEqual(AccountStatus.Sleep, firstAndreyAccount.Status); // должен быть Sleep. firstBank.RefreshInfoAboutAccount(firstAndreyAccount, futureDateTime3); Assert.AreEqual(AccountStatus.Active, firstAndreyAccount.Status); // Изменился на Active? }
public void Should_validate_passport_message() { Update update = _classFixture.Entity; PassportData passportData = update.Message.PassportData; EncryptedPassportElement phoneElement = Assert.Single(passportData.Data, el => el.Type == "phone_number"); Assert.NotNull(phoneElement); Assert.Equal(PassportEnums.Scope.PhoneNumber, phoneElement.Type); Assert.NotEmpty(phoneElement.PhoneNumber); Assert.True(long.TryParse(phoneElement.PhoneNumber, out _)); Assert.NotEmpty(phoneElement.Hash); EncryptedPassportElement emailElement = Assert.Single(passportData.Data, el => el.Type == "email"); Assert.NotNull(emailElement); Assert.Equal(PassportEnums.Scope.Email, emailElement.Type); Assert.NotEmpty(emailElement.Email); Assert.NotEmpty(emailElement.Hash); Assert.NotNull(passportData.Credentials); Assert.NotEmpty(passportData.Credentials.Data); Assert.NotEmpty(passportData.Credentials.Hash); Assert.NotEmpty(passportData.Credentials.Secret); }
public Person(string name, string surname, Adress adress, PassportData data) { Name = name; Surname = surname; PersonAdress = adress; PersonData = data; }
public static Passport MapPassport(PassportData data) { return(new Passport() { IdEmpleado = data.idEmpleado, IdPassport = data.idPassport, NombreEmpleado = data.nombreEmpleado, InicialesEmpleado = data.inicialesEmpleado, EdadEmpleado = data.edadEmpleado, NumEmpleado = data.numEmpleado, Departamento = data.departamento, NameLocalizacion = data.nameLocalizacion, Pais = data.pais, Direccion1 = data.direccion1, Ciudad = data.ciudad, CodigoPostal = data.codigoPostal, Division = data.division, EstadoPasaporte = data.estadoPasaporte, ColorPasaporte = data.colorPasaporte, NumTest = data.numTest, HasMessage = data.hasMessage, EstadoId = data.estadoId, FechaCreacion = data.fechaCreacion != null?DateTime.ParseExact(data.fechaCreacion, DATEFORMAT, CultureInfo.InvariantCulture) : (DateTime?)null, FechaExpiracion = data.fechaExpiracion != null?DateTime.ParseExact(data.fechaExpiracion, DATEFORMAT, CultureInfo.InvariantCulture) : (DateTime?)null }); }
public void Should_Decrypt_Personal_Details_Element() { PassportData passportData = GetPassportData(); IDecrypter decrypter = new Decrypter(); Credentials credentials = decrypter.DecryptCredentials(passportData.Credentials, EncryptionKey.RsaPrivateKey); EncryptedPassportElement element = Assert.Single(passportData.Data, el => el.Type == "personal_details"); PersonalDetails personalDetails = decrypter.DecryptData <PersonalDetails>( encryptedData: element.Data, dataCredentials: credentials.SecureData.PersonalDetails.Data ); Assert.Equal("Poulad", personalDetails.FirstName); Assert.Equal("Ashrafpour", personalDetails.LastName); Assert.Equal("پولاد", personalDetails.FirstNameNative); Assert.Equal("اشرف پور", personalDetails.LastNameNative); Assert.Empty(personalDetails.MiddleName); Assert.Empty(personalDetails.MiddleNameNative); Assert.Equal("male", personalDetails.Gender); Assert.Equal(PassportEnums.Gender.Male, personalDetails.Gender); Assert.Equal("US", personalDetails.CountryCode); // U.S.A Assert.Equal("IR", personalDetails.ResidenceCountryCode); // Iran Assert.Equal("30.07.1990", personalDetails.BirthDate); Assert.InRange(personalDetails.Birthdate, new DateTime(1990, 7, 30), new DateTime(1990, 7, 30, 1, 0, 0)); }
public void Should_Decrypt_Data() { Update update = _classFixture.Entity; PassportData passportData = update.Message.PassportData; EncryptedPassportElement element = passportData.Data.Single(); RSA key = EncryptionKey.ReadAsRsa(); IDecrypter decrypter = new Decrypter(); Credentials credentials = decrypter.DecryptCredentials(passportData.Credentials, key); PersonalDetails personalDetails = decrypter.DecryptData <PersonalDetails>( element.Data, credentials.SecureData.PersonalDetails.Data ); Assert.NotNull(personalDetails); Assert.NotEmpty(personalDetails.FirstName); Assert.NotEmpty(personalDetails.Gender); Assert.NotEmpty(personalDetails.CountryCode); Assert.Equal(2, personalDetails.CountryCode.Length); Assert.NotEmpty(personalDetails.ResidenceCountryCode); Assert.Equal(2, personalDetails.ResidenceCountryCode.Length); Assert.NotEmpty(personalDetails.BirthDate); Assert.InRange(personalDetails.Birthdate, new DateTime(1900, 1, 1), DateTime.Today); }
public async Task Should_Decrypt_Identity_Card_Element_Selfie() { Update update = _classFixture.Entity; PassportData passportData = update.Message.PassportData; RSA key = EncryptionKey.ReadAsRsa(); EncryptedPassportElement idCardEl = Assert.Single(passportData.Data, el => el.Type == "identity_card"); IDecrypter decrypter = new Decrypter(); Credentials credentials = decrypter.DecryptCredentials(passportData.Credentials, key); byte[] encryptedContent; using (System.IO.MemoryStream stream = new System.IO.MemoryStream(idCardEl.Selfie.FileSize)) { await BotClient.GetInfoAndDownloadFileAsync( idCardEl.Selfie.FileId, stream ); encryptedContent = stream.ToArray(); } byte[] content = decrypter.DecryptFile( encryptedContent, credentials.SecureData.IdentityCard.Selfie ); Assert.NotEmpty(content); }
public async Task Should_decrypt_utility_bill_element_translation() { Update update = _classFixture.Entity; PassportData passportData = update.Message.PassportData; RSA key = EncryptionKey.ReadAsRsa(); EncryptedPassportElement billElement = Assert.Single(passportData.Data, el => el.Type == "utility_bill"); PassportFile translationFile = Assert.Single(billElement.Translation); IDecrypter decrypter = new Decrypter(); Credentials credentials = decrypter.DecryptCredentials(passportData.Credentials, key); FileCredentials fileCredentials = Assert.Single(credentials.SecureData.UtilityBill.Translation); File encryptedFileInfo; using (System.IO.Stream decryptedFile = new System.IO.MemoryStream()) { encryptedFileInfo = await BotClient.DownloadAndDecryptPassportFileAsync( translationFile, fileCredentials, decryptedFile ); Assert.InRange(decryptedFile.Length, translationFile.FileSize - 256, translationFile.FileSize + 256); } Assert.NotEmpty(encryptedFileInfo.FilePath); Assert.NotEmpty(encryptedFileInfo.FileId); Assert.InRange(encryptedFileInfo.FileSize, 1_000, 50_000_000); }
public async Task Should_Decrypt_Identity_Card_Element_Reverse_Side() { Update update = _classFixture.Entity; PassportData passportData = update.Message.PassportData; RSA key = EncryptionKey.ReadAsRsa(); EncryptedPassportElement idCardEl = Assert.Single(passportData.Data, el => el.Type == "identity_card"); IDecrypter decrypter = new Decrypter(); Credentials credentials = decrypter.DecryptCredentials(passportData.Credentials, key); string botToken = ConfigurationProvider.TestConfigurations.ApiToken; File encFileInfo = await BotClient.GetFileAsync(idCardEl.ReverseSide.FileId); HttpClient http = new HttpClient(); System.IO.Stream encFileStream = await http.GetStreamAsync( $"https://api.telegram.org/file/bot{botToken}/{encFileInfo.FilePath}" ); string destFilePath = System.IO.Path.GetTempFileName(); using (encFileStream) using (System.IO.Stream reverseSideFile = System.IO.File.OpenWrite(destFilePath)) { await decrypter.DecryptFileAsync( encFileStream, credentials.SecureData.IdentityCard.ReverseSide, reverseSideFile ); Assert.InRange(reverseSideFile.Length, encFileInfo.FileSize - 256, encFileInfo.FileSize + 256); } _output.WriteLine("Reverse side photo is written to file \"{0}\".", destFilePath); }
public void Should_Decrypt_Identity_Card_Element_Document() { Update update = _classFixture.Entity; PassportData passportData = update.Message.PassportData; RSA key = EncryptionKey.ReadAsRsa(); IDecrypter decrypter = new Decrypter(); Credentials credentials = decrypter.DecryptCredentials(passportData.Credentials, key); EncryptedPassportElement idCardEl = Assert.Single(passportData.Data, el => el.Type == "identity_card"); IdDocumentData documentData = decrypter.DecryptData <IdDocumentData>( idCardEl.Data, credentials.SecureData.IdentityCard.Data ); Assert.NotEmpty(documentData.DocumentNo); if (string.IsNullOrEmpty(documentData.ExpiryDate)) { Assert.Null(documentData.Expiry); } else { Assert.NotNull(documentData.Expiry); } }
[Test()] //Тестируем пополнение и снятие средств с счетов public void Test1() { List <(double, double)> TermForfirstBank = new List <(double, double)>(); TermForfirstBank.Add((10000, 0.1)); TermForfirstBank.Add((20000, 0.2)); Bank alfaBank = new Bank(TermForfirstBank, 0.1, 0.2, 10000, 3000); IAbstractBank firstBank = alfaBank; Adress newAdress = new Adress("Невского", 10, "Питер"); PassportData firstPersonData = new PassportData(1111, 22222); Person Andrey = new Person("Андрей", "Загудько", newAdress, firstPersonData); Client clientAndrey = firstBank.CreateClient(Andrey); firstBank.AddDebitAccount(clientAndrey, DateTime.Now); BankAccount firstAndreyAccount = clientAndrey.Accounts.ElementAt(0); firstBank.Replenishment(firstAndreyAccount, 1000); //Закидываем деньги на аккаунт Assert.AreEqual(1000, firstAndreyAccount.AccountStatus); firstBank.CashWithdrawal(firstAndreyAccount, 200); //Снимаем деньги с аккаунта Assert.AreEqual(800, firstAndreyAccount.AccountStatus); firstBank.CashWithdrawal(firstAndreyAccount, 1100); //Снимаем больше чем имеем, поскольку аккаунт дебитовый деньги не снимутся Assert.AreEqual(800, firstAndreyAccount.AccountStatus); }
public async Task Should_Decrypt_Front_Side_File() { Update update = _classFixture.Entity; PassportData passportData = update.Message.PassportData; RSA key = EncryptionKey.ReadAsRsa(); EncryptedPassportElement element = passportData.Data.Single(); IDecrypter decrypter = new Decrypter(); Credentials credentials = decrypter.DecryptCredentials(passportData.Credentials, key); File encryptedFileInfo; string decryptedFilePath = System.IO.Path.GetTempFileName(); using (System.IO.Stream decryptedFile = System.IO.File.OpenWrite(decryptedFilePath)) { encryptedFileInfo = await BotClient.DownloadAndDecryptPassportFileAsync( element.FrontSide, credentials.SecureData.DriverLicense.FrontSide, decryptedFile ); } _output.WriteLine("Front side JPEG file is written to \"{0}\".", decryptedFilePath); Assert.NotEmpty(encryptedFileInfo.FilePath); Assert.NotEmpty(encryptedFileInfo.FileId); Assert.InRange(encryptedFileInfo.FileSize, 1_000, 50_000_000); }
public PassportData GetClientPassportData(int clientId) { Contract.Requires <ArgumentOutOfRangeException>(clientId.IsPositive()); PassportData passportData = this.gangsterBankUnitOfWork.PassportDataRepository.GetPassportDataForClient(clientId); return(passportData); }
public void Should_Decrypt_Credentials() { Update update = _classFixture.Entity; PassportData passportData = update.Message.PassportData; RSA key = EncryptionKey.ReadAsRsa(); IDecrypter decrypter = new Decrypter(); Credentials credentials = decrypter.DecryptCredentials( key: key, encryptedCredentials: passportData.Credentials ); Assert.NotNull(credentials); Assert.NotNull(credentials.SecureData); Assert.Equal("Test nonce for id card & utility bill", credentials.Nonce); // decryption of document data in 'identity_card' element requires accompanying DataCredentials Assert.NotNull(credentials.SecureData.IdentityCard); Assert.NotNull(credentials.SecureData.IdentityCard.Data); Assert.NotEmpty(credentials.SecureData.IdentityCard.Data.Secret); Assert.NotEmpty(credentials.SecureData.IdentityCard.Data.DataHash); // decryption of front side of 'identity_card' element requires accompanying FileCredentials Assert.NotNull(credentials.SecureData.IdentityCard.FrontSide); Assert.NotEmpty(credentials.SecureData.IdentityCard.FrontSide.Secret); Assert.NotEmpty(credentials.SecureData.IdentityCard.FrontSide.FileHash); // decryption of reverse side of 'identity_card' element requires accompanying FileCredentials Assert.NotNull(credentials.SecureData.IdentityCard.ReverseSide); Assert.NotEmpty(credentials.SecureData.IdentityCard.ReverseSide.Secret); Assert.NotEmpty(credentials.SecureData.IdentityCard.ReverseSide.FileHash); // decryption of selfie of 'identity_card' element requires accompanying FileCredentials Assert.NotNull(credentials.SecureData.IdentityCard.Selfie); Assert.NotEmpty(credentials.SecureData.IdentityCard.Selfie.Secret); Assert.NotEmpty(credentials.SecureData.IdentityCard.Selfie.FileHash); Assert.Null(credentials.SecureData.IdentityCard.Translation); Assert.Null(credentials.SecureData.IdentityCard.Files); // decryption of file scan in 'utility_bill' element requires accompanying FileCredentials Assert.NotNull(credentials.SecureData.UtilityBill.Files); FileCredentials billCredentials = Assert.Single(credentials.SecureData.UtilityBill.Files); Assert.NotEmpty(billCredentials.Secret); Assert.NotEmpty(billCredentials.FileHash); // decryption of translation file scan in 'utility_bill' element requires accompanying FileCredentials Assert.NotNull(credentials.SecureData.UtilityBill.Files); FileCredentials billTranslationFileCredentials = Assert.Single(credentials.SecureData.UtilityBill.Translation); Assert.NotEmpty(billTranslationFileCredentials.Secret); Assert.NotEmpty(billTranslationFileCredentials.FileHash); }
private static string GetPassportText(PassportData passportData) { return(string.Format( "{0}, issued by {1} on {2}, valid till {3}", ValueOrUnknown(passportData.PassportNumber), ValueOrUnknown(passportData.Issuer), ValueOrUnknown(passportData.IssueDate), ValueOrUnknown(passportData.ExpirationDate))); }
public void Should_Decrypt_Credentials() { RSA key = EncryptionKey.RsaPrivateKey; PassportData passData = GetPassportData(); IDecrypter decrypter = new Decrypter(); Credentials credentials = decrypter.DecryptCredentials( encryptedCredentials: passData.Credentials, key: key ); Assert.NotNull(credentials); Assert.NotNull(credentials.SecureData); Assert.Equal("TEST", credentials.Nonce); // decryption of document data in 'identity_card' element requires accompanying DataCredentials Assert.NotNull(credentials.SecureData.IdentityCard); Assert.NotNull(credentials.SecureData.IdentityCard.Data); Assert.NotEmpty(credentials.SecureData.IdentityCard.Data.Secret); Assert.NotEmpty(credentials.SecureData.IdentityCard.Data.DataHash); // decryption of front side of 'identity_card' element requires accompanying FileCredentials Assert.NotNull(credentials.SecureData.IdentityCard.FrontSide); Assert.NotEmpty(credentials.SecureData.IdentityCard.FrontSide.Secret); Assert.NotEmpty(credentials.SecureData.IdentityCard.FrontSide.FileHash); // decryption of reverse side of 'identity_card' element requires accompanying FileCredentials Assert.NotNull(credentials.SecureData.IdentityCard.ReverseSide); Assert.NotEmpty(credentials.SecureData.IdentityCard.ReverseSide.Secret); Assert.NotEmpty(credentials.SecureData.IdentityCard.ReverseSide.FileHash); // decryption of selfie of 'identity_card' element requires accompanying FileCredentials Assert.NotNull(credentials.SecureData.IdentityCard.Selfie); Assert.NotEmpty(credentials.SecureData.IdentityCard.Selfie.Secret); Assert.NotEmpty(credentials.SecureData.IdentityCard.Selfie.FileHash); Assert.Null(credentials.SecureData.IdentityCard.Translation); Assert.Null(credentials.SecureData.IdentityCard.Files); // decryption of file scan in 'utility_bill' element requires accompanying FileCredentials Assert.NotNull(credentials.SecureData.UtilityBill.Files); FileCredentials billFileCredentials = Assert.Single(credentials.SecureData.UtilityBill.Files); Assert.NotEmpty(billFileCredentials.Secret); Assert.NotEmpty(billFileCredentials.FileHash); // decryption of translation file scan in 'utility_bill' element requires accompanying FileCredentials Assert.NotNull(credentials.SecureData.UtilityBill.Files); FileCredentials billTranslationFileCredentials = Assert.Single(credentials.SecureData.UtilityBill.Translation); Assert.NotEmpty(billTranslationFileCredentials.Secret); Assert.NotEmpty(billTranslationFileCredentials.FileHash); }
public void LoadPassport() { PassportData data = SaveSystem.LoadPassport(); Debug.Log("loadpasseport"); contrats.changeMat = data.materialIndexData; contrats.nameText = data.nameData; contrats.countryText = data.countryData; Debug.Log(data.nameData); contrats.skinTXT.text = contrats.skinName[data.materialIndexData]; }
public void Should_Validate_Passport_Message() { Update update = _classFixture.Entity; PassportData passportData = update.Message.PassportData; #region identity card element validation EncryptedPassportElement idCardEl = Assert.Single(passportData.Data, el => el.Type == "identity_card"); Assert.NotNull(idCardEl); Assert.Equal(PassportEnums.Scope.IdentityCard, idCardEl.Type); Assert.NotEmpty(idCardEl.Data); Assert.NotEmpty(idCardEl.Hash); Assert.NotNull(idCardEl.FrontSide); Assert.NotEmpty(idCardEl.FrontSide.FileId); Assert.InRange(idCardEl.FrontSide.FileDate, new DateTime(2018, 6, 1), DateTime.UtcNow); Assert.NotNull(idCardEl.ReverseSide); Assert.NotEmpty(idCardEl.ReverseSide.FileId); Assert.InRange(idCardEl.ReverseSide.FileDate, new DateTime(2018, 6, 1), DateTime.UtcNow); Assert.NotNull(idCardEl.Selfie); Assert.NotEmpty(idCardEl.Selfie.FileId); Assert.InRange(idCardEl.Selfie.FileDate, new DateTime(2018, 6, 1), DateTime.UtcNow); #endregion #region utility bill element validation EncryptedPassportElement billElement = Assert.Single(passportData.Data, el => el.Type == "utility_bill"); Assert.NotNull(billElement); Assert.Equal(PassportEnums.Scope.UtilityBill, billElement.Type); Assert.NotEmpty(billElement.Hash); Assert.Null(billElement.Data); PassportFile billScanFile = Assert.Single(billElement.Files); Assert.NotNull(billScanFile); Assert.NotEmpty(billScanFile.FileId); Assert.InRange(billScanFile.FileDate, new DateTime(2018, 6, 1), DateTime.UtcNow); PassportFile billTranslationFile = Assert.Single(billElement.Files); Assert.NotNull(billTranslationFile); Assert.NotEmpty(billTranslationFile.FileId); Assert.InRange(billTranslationFile.FileDate, new DateTime(2018, 6, 1), DateTime.UtcNow); #endregion Assert.NotNull(passportData.Credentials); Assert.NotEmpty(passportData.Credentials.Data); Assert.NotEmpty(passportData.Credentials.Hash); Assert.NotEmpty(passportData.Credentials.Secret); }
public void Should_Decrypt_Credentials() { Update update = _classFixture.Entity; PassportData passportData = update.Message.PassportData; IDecrypter decrypter = new Decrypter(); Credentials credentials = decrypter.DecryptCredentials(passportData.Credentials, EncryptionKey.ReadAsRsa()); Assert.NotNull(credentials); Assert.Equal("Test nonce for address", credentials.Nonce); Assert.NotNull(credentials.SecureData); }
public static void SavePassport(ContratsPanel contrat) { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/passport.fun"; FileStream stream = new FileStream(path, FileMode.Create); Debug.Log(path); PassportData data = new PassportData(contrat); formatter.Serialize(stream, data); stream.Close(); }
[Test()] // Проверим откат наших операций public void Test4() { List <(double, double)> TermForfirstBank = new List <(double, double)>(); List <(double, double)> TermForSecondtBank = new List <(double, double)>(); TermForfirstBank.Add((10000, 0.1)); TermForfirstBank.Add((20000, 0.2)); TermForSecondtBank.Add((10000, 0.3)); TermForSecondtBank.Add((30000, 0.4)); Bank alfaBank = new Bank(TermForfirstBank, 0.1, 0.2, 10000, 3000); Bank sberBank = new Bank(TermForSecondtBank, 0.2, 0.1, 5000, 1000); IAbstractBank firstBank = alfaBank; IAbstractBank secondBank = sberBank; Adress newAdress = new Adress("Невского", 10, "Питер"); Adress additionalAdress = new Adress("Невского", 11, "Питер"); PassportData firstPersonData = new PassportData(1111, 22222); PassportData secondPersonData = new PassportData(1111, 00000); Person Andrey = new Person("Андрей", "Загудько", newAdress, firstPersonData); Person Vasya = new Person("Вася", "Дударь"); Client clientAndrey = firstBank.CreateClient(Andrey); Client clientVasya = secondBank.CreateClient(Vasya); firstBank.AddDebitAccount(clientAndrey, DateTime.Now); secondBank.AddDebitAccount(clientVasya, DateTime.Now); BankAccount firstAndreyAccount = clientAndrey.Accounts.ElementAt(0); BankAccount firstVasyaAccount = clientVasya.Accounts.ElementAt(0); firstBank.Replenishment(firstAndreyAccount, 2000); secondBank.Replenishment(firstVasyaAccount, 100); firstBank.Transfer(firstAndreyAccount, firstVasyaAccount, 400, sberBank); // Переводим 400 рублей Васе, зная что его счёт принадлежит сбербанку. Assert.AreEqual(1600, firstAndreyAccount.AccountStatus); // убеждаемся что Андрей отправил деньги Assert.AreEqual(500, firstVasyaAccount.AccountStatus); // Убеждаемся что Вася получил деньги firstBank.ReturnMoney(clientAndrey, 1); //тк это следующая после пополнения операция, берём первый элемент из истории операции Андрея Assert.AreEqual(2000, firstAndreyAccount.AccountStatus); // Деньги вернулись обратно Assert.AreEqual(100, firstVasyaAccount.AccountStatus); // а вот Васю кинули получается( }
public void SavePassportData(PassportViewModel model, HttpPostedFileBase digitalCopy) { PassportData passportData = this.clientProfileService.GetClientPassportData(model.ClientId); passportData.ExpirationDate = model.ExpirationDate ?? DateTime.MinValue; passportData.IssueDate = model.IssueDate ?? DateTime.MinValue; passportData.Issuer = model.Issuer; passportData.PassportNumber = model.PassportNumber; passportData.PersonalNumber = model.PersonalNumber; if (digitalCopy != null) { passportData.DigitalCopy = digitalCopy.ToByteArray(); } this.clientProfileService.Save(passportData); }
public void Should_Validate_Passport_Update() { Update update = _classFixture.Entity; PassportData passportData = update.Message.PassportData; EncryptedPassportElement encryptedElement = Assert.Single(passportData.Data); Assert.Equal("personal_details", encryptedElement.Type); Assert.Equal(PassportEnums.Scope.PersonalDetails, encryptedElement.Type); Assert.NotEmpty(encryptedElement.Data); Assert.NotEmpty(encryptedElement.Hash); Assert.NotNull(passportData.Credentials); Assert.NotEmpty(passportData.Credentials.Data); Assert.NotEmpty(passportData.Credentials.Hash); Assert.NotEmpty(passportData.Credentials.Secret); }
public void Should_decrypt_credentials() { Update update = _classFixture.Entity; PassportData passportData = update.Message.PassportData; RSA key = EncryptionKey.ReadAsRsa(); IDecrypter decrypter = new Decrypter(); Credentials credentials = decrypter.DecryptCredentials( key: key, encryptedCredentials: passportData.Credentials ); Assert.NotNull(credentials); Assert.NotNull(credentials.SecureData); Assert.Equal("Test nonce for phone and email", credentials.Nonce); }
public void Sample() { var input = new PassportData { PassportNumber = "L898902C" //other input data? }; var expected = new ValidationResult { //what is the expected result? }; this.steps .GivenIHaveTheInput(input) .WhenIValidateTheData() .ThenTheValidationResultShouldBe(expected); }
/// <summary> /// Получатель перевода (наличными) /// </summary> public CashBeneficiary( NameWithHieroglyph name1, NameWithHieroglyph name2, NameWithHieroglyph name3, NameWithHieroglyph name4, AddressData address, PassportData passport ) : base ( name1, name2, name3, name4, address ) { this.Passport = passport; }
public async Task Should_Decrypt_Translation_File() { Update update = _classFixture.Entity; PassportData passportData = update.Message.PassportData; RSA key = EncryptionKey.ReadAsRsa(); EncryptedPassportElement element = passportData.Data.Single(); IDecrypter decrypter = new Decrypter(); Credentials credentials = decrypter.DecryptCredentials(passportData.Credentials, key); for (int i = 0; i < element.Translation.Length; i++) { PassportFile passportFile = element.Translation[i]; FileCredentials fileCredentials = credentials.SecureData.DriverLicense.Translation[i]; byte[] encryptedContent; { File encryptedFileInfo = await BotClient.GetFileAsync(passportFile.FileId); Assert.NotEmpty(encryptedFileInfo.FilePath); Assert.NotEmpty(encryptedFileInfo.FileId); Assert.InRange(encryptedFileInfo.FileSize, 1_000, 50_000_000); using (System.IO.MemoryStream stream = new System.IO.MemoryStream(encryptedFileInfo.FileSize)) { await BotClient.DownloadFileAsync(encryptedFileInfo.FilePath, stream); encryptedContent = stream.ToArray(); } } byte[] translationContent = decrypter.DecryptFile( encryptedContent, fileCredentials ); Assert.NotEmpty(translationContent); string decryptedFilePath = System.IO.Path.GetTempFileName(); await System.IO.File.WriteAllBytesAsync(decryptedFilePath, translationContent); _output.WriteLine("Translation JPEG file is written to \"{0}\".", decryptedFilePath); } }
public void Should_Decrypt_Element_Document() { PassportData passportData = GetPassportData(); IDecrypter decrypter = new Decrypter(); Credentials credentials = decrypter.DecryptCredentials(passportData.Credentials, EncryptionKey.RsaPrivateKey); EncryptedPassportElement idCardEl = Assert.Single(passportData.Data, el => el.Type == "identity_card"); IdDocumentData documentData = decrypter.DecryptData <IdDocumentData>( idCardEl.Data, credentials.SecureData.IdentityCard.Data ); Assert.Equal("9999R", documentData.DocumentNo); Assert.Empty(documentData.ExpiryDate); Assert.Null(documentData.Expiry); }
public void Should_Validate_Passport_Update() { Update update = _classFixture.Entity; PassportData passportData = update.Message.PassportData; EncryptedPassportElement encryptedElement = Assert.Single(passportData.Data); Assert.NotNull(encryptedElement); Assert.Equal("driver_license", encryptedElement.Type); Assert.Equal(PassportEnums.Scope.DriverLicense, encryptedElement.Type); Assert.NotEmpty(encryptedElement.Data); Assert.NotEmpty(encryptedElement.Hash); Assert.NotNull(encryptedElement.FrontSide); Assert.NotEmpty(encryptedElement.FrontSide.FileId); Assert.InRange(encryptedElement.FrontSide.FileSize, 1_000, 50_000_000); Assert.NotNull(encryptedElement.ReverseSide); Assert.NotEmpty(encryptedElement.ReverseSide.FileId); Assert.InRange(encryptedElement.ReverseSide.FileSize, 1_000, 50_000_000); Assert.NotNull(encryptedElement.Selfie); Assert.NotEmpty(encryptedElement.Selfie.FileId); Assert.InRange(encryptedElement.Selfie.FileSize, 1_000, 50_000_000); Assert.NotNull(encryptedElement.Translation); Assert.NotEmpty(encryptedElement.Translation); Assert.All(encryptedElement.Translation, Assert.NotNull); Assert.All( encryptedElement.Translation, translation => Assert.NotEmpty(translation.FileId) ); Assert.All( encryptedElement.Translation, translation => Assert.InRange(translation.FileSize, 1_000, 50_000_000) ); Assert.NotNull(passportData.Credentials); Assert.NotEmpty(passportData.Credentials.Data); Assert.NotEmpty(passportData.Credentials.Hash); Assert.NotEmpty(passportData.Credentials.Secret); }