Skip to content

Commit

Permalink
Set passport errors instead of id card
Browse files Browse the repository at this point in the history
  • Loading branch information
poulad committed Sep 3, 2018
1 parent 2639d80 commit a22c179
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 25 deletions.
2 changes: 1 addition & 1 deletion test/IntegrationTests/Framework/TestCollectionOrderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class TestCollectionOrderer : ITestCollectionOrderer
"Identity card and utility bill",

// setting data errors
"Identity card errors",
"Passport document errors",
"Passport registration errors",
"Unspecified error",
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace IntegrationTests
{
[Collection("Identity card errors")]
[Collection("Passport document errors")]
[TestCaseOrderer(Constants.TestCaseOrderer, Constants.AssemblyName)]
public class IdentityCardErrorTests : IClassFixture<IdentityCardErrorTests.Fixture>
{
Expand All @@ -33,7 +33,7 @@ public IdentityCardErrorTests(TestsFixture fixture, Fixture classFixture)
}

[OrderedFact("Should generate passport authorization request link")]
public async Task Should_generate_auth_link()
public async Task Should_Generate_Auth_Link()
{
const string publicKey = "-----BEGIN PUBLIC KEY-----\n" +
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0VElWoQA2SK1csG2/sY/\n" +
Expand All @@ -46,7 +46,7 @@ public async Task Should_generate_auth_link()
"-----END PUBLIC KEY-----";
PassportScope scope = new PassportScope(new[]
{
new PassportScopeElementOne(PassportEnums.Scope.IdentityCard)
new PassportScopeElementOne(PassportEnums.Scope.Passport)
{
Selfie = true,
Translation = true,
Expand All @@ -55,13 +55,13 @@ public async Task Should_generate_auth_link()
AuthorizationRequest authReq = new AuthorizationRequest(
botId: _fixture.BotUser.Id,
publicKey: publicKey,
nonce: "Test nonce for identity card",
nonce: "Test nonce for passport",
scope: scope
);

await BotClient.SendTextMessageAsync(
_fixture.SupergroupChat,
"Share your *identity card* with its *translation* and a *selfie* using Telegram Passport.\n\n" +
"Share your *passport* with its *translation* and a *selfie* using Telegram Passport.\n\n" +
"1. Click inline button\n" +
"2. Open link in browser to redirect you back to Telegram passport\n" +
"3. Authorize bot to access the info",
Expand All @@ -79,15 +79,15 @@ await BotClient.SendTextMessageAsync(
Credentials credentials =
decrypter.DecryptCredentials(passportUpdate.Message.PassportData.Credentials, key);

Assert.Equal("Test nonce for identity card", credentials.Nonce);
Assert.Equal("Test nonce for passport", credentials.Nonce);

_classFixture.AuthorizationRequest = authReq;
_classFixture.Credentials = credentials;
_classFixture.Message = passportUpdate.Message;
}

[OrderedFact("Should set multiple errors for identity card")]
public async Task Should_set_errors_identity_card()
[OrderedFact("Should set multiple errors for passport")]
public async Task Should_Set_Errors_Passport()
{
AuthorizationRequest authReq = _classFixture.AuthorizationRequest;
Credentials credentials = _classFixture.Credentials;
Expand All @@ -96,29 +96,24 @@ public async Task Should_set_errors_identity_card()
PassportElementError[] errors =
{
new PassportElementErrorDataField(
PassportEnums.Scope.IdentityCard,
PassportEnums.Scope.Passport,
"document_no",
credentials.SecureData.IdentityCard.Data.DataHash,
"Invalid card number"
credentials.SecureData.Passport.Data.DataHash,
"Invalid passport number"
),
new PassportElementErrorFrontSide(
PassportEnums.Scope.IdentityCard,
credentials.SecureData.IdentityCard.FrontSide.FileHash,
PassportEnums.Scope.Passport,
credentials.SecureData.Passport.FrontSide.FileHash,
"Document scan is redacted"
),
new PassportElementErrorReverseSide(
PassportEnums.Scope.IdentityCard,
credentials.SecureData.IdentityCard.ReverseSide.FileHash,
"Bar code is not readable"
),
new PassportElementErrorSelfie(
PassportEnums.Scope.IdentityCard,
credentials.SecureData.IdentityCard.Selfie.FileHash,
"This is Mr. Bean. Not you"
PassportEnums.Scope.Passport,
credentials.SecureData.Passport.Selfie.FileHash,
"Take a selfie without glasses"
),
new PassportElementErrorTranslationFile(
PassportEnums.Scope.IdentityCard,
credentials.SecureData.IdentityCard.Translation[0].FileHash,
PassportEnums.Scope.Passport,
credentials.SecureData.Passport.Translation[0].FileHash,
"Document photo is blury"
),
};
Expand All @@ -130,7 +125,7 @@ await BotClient.SetPassportDataErrorsAsync(

await BotClient.SendTextMessageAsync(
_fixture.SupergroupChat,
"Errors are set on all identity card data.\n" +
"Errors are set on all passport data and documents.\n" +
"You can see error message with opening the request link again.",
replyMarkup: (InlineKeyboardMarkup) InlineKeyboardButton.WithUrl(
"Passport Authorization Request",
Expand Down

0 comments on commit a22c179

Please sign in to comment.