public void StoreTokenRequestAndSetTransferDestinationsTest() { using (Tokenio.Tpp.TokenClient tokenClient = TestUtil.CreateClient()) { TppMember payee = tokenClient.CreateMemberBlocking(TestUtil.RandomAlias()); string requestId = StoreAndRetrieveTokenRequestSample .StoreTransferTokenRequestWithDestinationsCallback( payee, setTransferDestinationsUrl); StoreAndRetrieveTokenRequestSample.SetTokenRequestTransferDestinations( payee, requestId, tokenClient, setTransferDestinationsCallback); TokenRequest request = tokenClient.RetrieveTokenRequestBlocking(requestId); Assert.NotNull(request); Assert.NotEqual(0, request .GetTokenRequestPayload() .TransferBody .Instructions .TransferDestinations.Count); Assert.True(request .GetTokenRequestPayload() .TransferBody .Instructions .TransferDestinations[0].FasterPayments != null); } }
public void RecoveryComplex() { using (Tokenio.Tpp.TokenClient tokenClient = TestUtil.CreateClient()) { MemberRecoverySample mrs = new MemberRecoverySample(); Tokenio.Tpp.TokenClient agentTokenIO = TestUtil.CreateClient(); Alias agentAlias = TestUtil.RandomAlias(); TppMember agentMember = agentTokenIO.CreateMemberBlocking(agentAlias); mrs.agentMember = agentMember; // set up Alias originalAlias = TestUtil.RandomAlias(); TppMember originalMember = tokenClient.CreateMemberBlocking(originalAlias); mrs.SetUpComplexRecoveryRule(originalMember, tokenClient, agentAlias); // recover Tokenio.Tpp.TokenClient otherTokenClient = TestUtil.CreateClient(); TppMember recoveredMember = mrs.RecoverWithComplexRule( otherTokenClient, originalAlias); // make sure it worked Alias recoveredAlias = recoveredMember.GetFirstAliasBlocking(); Assert.Equal(recoveredAlias, originalAlias); } }
public void GetTransactionsTest() { using (Tokenio.Tpp.TokenClient tokenClient = TestUtil.CreateClient()) { UserMember payer = TestUtil.CreateUserMember(); Alias payeeAlias = TestUtil.RandomAlias(); TppMember payee = tokenClient.CreateMemberBlocking(payeeAlias); Account payeeAccount = payee.CreateTestBankAccountBlocking(1000, "EUR"); Token token = TestUtil.CreateTransferToken(payer, payeeAlias); Transfer transfer = RedeemTransferTokenSample.RedeemTransferToken( payee, payeeAccount.Id(), token.Id); string transactionId = transfer.TransactionId; Transaction transaction = payer.GetTransactionBlocking( payer.GetAccountsBlocking()[0].Id(), transactionId, Key.Types.Level.Standard); Assert.Equal(transaction.TokenId, token.Id); } }
public void ProfilesTest() { using (Tokenio.Tpp.TokenClient tokenClient = TestUtil.CreateClient()) { TppMember member = tokenClient.CreateMemberBlocking(TestUtil.RandomAlias()); Profile profile = MemberMethodsSample.Profiles(member); Assert.NotEmpty(profile.DisplayNameFirst); } }
public void KeysTest() { using (Tokenio.Tpp.TokenClient tokenClient = TestUtil.CreateClient()) { IKeyStore keyStore = new InMemoryKeyStore(); ICryptoEngine cryptoEngine = new TokenCryptoEngine("member-id", keyStore); TppMember member = tokenClient.CreateMemberBlocking(TestUtil.RandomAlias()); MemberMethodsSample.Keys(cryptoEngine, member); } }
public void StoreAndRetrieveAccessTokenTest() { using (Tokenio.Tpp.TokenClient tokenClient = TestUtil.CreateClient()) { TppMember grantee = tokenClient.CreateMemberBlocking(TestUtil.RandomAlias()); string requestId = StoreAndRetrieveTokenRequestSample.StoreTransferTokenRequest(grantee); TokenRequest request = tokenClient.RetrieveTokenRequestBlocking(requestId); Assert.NotNull(request); } }
public void AccountGetBalanceSampleTest() { using (Tokenio.Tpp.TokenClient tokenClient = TestUtil.CreateClient()) { TppMember member = tokenClient.CreateMemberBlocking(TestUtil.RandomAlias()); member.CreateTestBankAccountBlocking(1000.0, "EUR"); var sums = GetBalanceSample.AccountGetBalanceSample(member); Assert.Equal(sums["EUR"], 1000.0); } }
public void CancelTransferTokenByGranteeTest() { using (Tokenio.Tpp.TokenClient tokenClient = TestUtil.CreateClient()) { UserMember grantor = TestUtil.CreateUserMember(); Alias granteeAlias = TestUtil.RandomAlias(); TppMember grantee = tokenClient.CreateMemberBlocking(granteeAlias); Token token = TestUtil.CreateTransferToken(grantor, granteeAlias); TokenOperationResult result = CancelTransferTokenSample.CancelTransferToken(grantee, token.Id); Assert.Equal(result.Status, TokenOperationResult.Types.Status.Success); } }
public void TriggerBalanceStepUpNotificationTest() { using (Tokenio.Tpp.TokenClient tokenClient = TestUtil.CreateClient()) { TppMember member = tokenClient.CreateMemberBlocking(TestUtil.RandomAlias()); NotifyStatus status = member.TriggerBalanceStepUpNotificationBlocking( (new[] { "123", "456" }).ToImmutableList()); Assert.NotNull(status); } }
public void CancelAccessTokenByGranteeTest() { using (Tokenio.Tpp.TokenClient tokenClient = TestUtil.CreateClient()) { Tokenio.User.Member grantor = TestUtil.CreateUserMember(); string accountId = grantor.GetAccountsBlocking()[0].Id(); Alias granteeAlias = TestUtil.RandomAlias(); TppMember grantee = tokenClient.CreateMemberBlocking(granteeAlias); Token token = TestUtil.CreateAccessToken(grantor, accountId, granteeAlias); TokenOperationResult result = CancelAccessTokenSample.CancelAccessToken(grantee, token.Id); Assert.Equal(result.Status, TokenOperationResult.Types.Status.Success); } }
public void WebhookTest() { using (Tokenio.Tpp.TokenClient tokenClient = TestUtil.CreateClient()) { TppMember tpp = tokenClient.CreateMemberBlocking(TestUtil.RandomAlias()); Assert.Throws <AggregateException>(() => WebhookSample.GetWebhookConfig(tpp)); WebhookSample.SetWebhookConfig(tpp); Assert.NotNull(WebhookSample.GetWebhookConfig(tpp)); WebhookSample.DeleteWebhookConfig(tpp); Assert.Throws <AggregateException>(() => WebhookSample.GetWebhookConfig(tpp)); } }
public void RedeemAccessTokenTest() { using (Tokenio.Tpp.TokenClient tokenClient = TestUtil.CreateClient()) { UserMember grantor = TestUtil.CreateUserMember(); string accountId = grantor.GetAccountsBlocking()[0].Id(); Alias granteeAlias = TestUtil.RandomAlias(); TppMember grantee = tokenClient.CreateMemberBlocking(granteeAlias); Token token = TestUtil.CreateAccessToken(grantor, accountId, granteeAlias); Money balance0 = RedeemAccessTokenSample.RedeemAccessToken(grantee, token.Id); Assert.True(Convert.ToDecimal(balance0.Value) > (decimal.One * 10)); } }
public void MemberGetBalancesSampleTest() { using (Tokenio.Tpp.TokenClient tokenClient = TestUtil.CreateClient()) { TppMember member = tokenClient.CreateMemberBlocking(TestUtil.RandomAlias()); member.CreateTestBankAccountBlocking(1000.0, "EUR"); member.CreateTestBankAccountBlocking(500.0, "EUR"); List <Balance> balances = (List <Balance>)GetBalanceSample.memberGetBalanceListSample(member); Assert.Equal(balances.Count, 2); Assert.True(balances.Exists(b => double.Parse(b.Current.Value).Equals(500.0))); Assert.True(balances.Exists(b => double.Parse(b.Current.Value).Equals(1000.0))); } }
public void DeleteMemberTest() { using (Tokenio.Tpp.TokenClient tokenClient = TestUtil.CreateClient()) { TppMember member = tokenClient.CreateMemberBlocking(TestUtil.RandomAlias()); Assert.Equal(tokenClient.GetMemberBlocking(member.MemberId()).MemberId(), member.MemberId()); member.DeleteMemberBlocking(); Assert.Throws <AggregateException>(() => tokenClient.GetMemberBlocking(member.MemberId()) ); } }
public void RecoveryDefault() { // "normal consumer" recovery using "shortcuts" using (Tokenio.Tpp.TokenClient tokenClient = TestUtil.CreateClient()) { MemberRecoverySample mrs = new MemberRecoverySample(); // set up Alias originalAlias = TestUtil.RandomAlias(); TppMember originalMember = tokenClient.CreateMemberBlocking(originalAlias); mrs.SetUpDefaultRecoveryRule(originalMember); Tokenio.Tpp.TokenClient otherTokenClient = TestUtil.CreateClient(); TppMember recoveredMember = mrs.RecoverWithDefaultRule( otherTokenClient, originalAlias); Alias recoveredAlias = recoveredMember.GetFirstAliasBlocking(); Assert.Equal(recoveredAlias, originalAlias); } }
public void GetTokenTest() { using (Tokenio.Tpp.TokenClient tokenClient = TestUtil.CreateClient()) { UserMember payer = TestUtil.CreateUserMember(); Alias payeeAlias = TestUtil.RandomAlias(); TppMember payee = tokenClient.CreateMemberBlocking(payeeAlias); Token token = TestUtil.CreateTransferToken(payer, payeeAlias); Assert.Equal(GetTokensSample.GetToken(payee, token.Id).Id, token.Id); var sigList = GetTokensSample.GetToken(payee, token.Id).PayloadSignatures.Where(sig => sig.Action == TokenSignature.Types.Action.Cancelled).ToList(); Assert.Empty(sigList); // cancel token payee.CancelTokenBlocking(token); sigList = GetTokensSample.GetToken(payee, token.Id).PayloadSignatures.Where(sig => sig.Action == TokenSignature.Types.Action.Cancelled).ToList(); Assert.NotEmpty(sigList); } }
public void RedeemPaymentTokenTest() { using (Tokenio.Tpp.TokenClient tokenClient = TestUtil.CreateClient()) { UserMember payer = TestUtil.CreateUserMember(); Alias payeeAlias = TestUtil.RandomAlias(); TppMember payee = tokenClient.CreateMemberBlocking(payeeAlias); Account payeeAccount = payee.CreateTestBankAccountBlocking(1000, "EUR"); Token token = TestUtil.CreateTransferToken(payer, payeeAlias); Transfer transfer = RedeemTransferTokenSample.RedeemTransferToken( payee, payeeAccount.Id(), token.Id); Assert.NotNull(transfer); } }
/// <summary> /// Creates and returns a new token member. /// </summary> /// <returns>a new Member instance</returns> public static TppMember CreateMember() { // Create the client, which communicates with // the Token cloud. try { var key = Directory.CreateDirectory("./keys"); Tokenio.Tpp.TokenClient tokenClient = Tokenio.Tpp.TokenClient.NewBuilder() .ConnectTo(Tokenio.TokenCluster.SANDBOX) .WithKeyStore(new UnsecuredFileSystemKeyStore(key.FullName)) .Build(); // An alias is a "human-readable" reference to a member. // Here, we use a random email. This works in test environments. // but in production, TokenOS would try to verify we own the address, // so a random address wouldn't be useful for much. // We use a random address because otherwise, if we ran a second // time, Token would say the alias was already taken. Alias alias = new Alias { Value = TestUtil.RandomNumeric(10) + "*****@*****.**", Type = Alias.Types.Type.Email }; TppMember newMember = tokenClient.CreateMemberBlocking(alias); // let user recover member by verifying email if they lose keys newMember.UseDefaultRecoveryRule(); return(newMember); } catch (IOException ioe) { throw new ArgumentException("", ioe); } }
public void GetTransferTest() { using (Tokenio.Tpp.TokenClient tokenClient = TestUtil.CreateClient()) { UserMember payer = TestUtil.CreateUserMember(); Alias payeeAlias = TestUtil.RandomAlias(); TppMember payee = tokenClient.CreateMemberBlocking(payeeAlias); Account payeeAccount = payee.CreateTestBankAccountBlocking(1000, "EUR"); Token token = TestUtil.CreateTransferToken(payer, payeeAlias); Transfer redeemedTransfer = RedeemTransferTokenSample.RedeemTransferToken( payee, payeeAccount.Id(), token.Id); Transfer gotTransfer = GetTransfersSample.GetTransferSample( payee, redeemedTransfer.Id); Assert.Equal(gotTransfer, redeemedTransfer); } }