2017-09-13 15:47:34 +09:00
|
|
|
|
using BTCPayServer.Controllers;
|
|
|
|
|
using BTCPayServer.Models.AccountViewModels;
|
2017-09-13 23:50:36 +09:00
|
|
|
|
using BTCPayServer.Models.StoreViewModels;
|
2017-09-15 16:06:57 +09:00
|
|
|
|
using BTCPayServer.Servcices.Invoices;
|
2017-09-13 15:47:34 +09:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using NBitcoin;
|
|
|
|
|
using NBitpayClient;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace BTCPayServer.Tests
|
|
|
|
|
{
|
|
|
|
|
public class TestAccount
|
|
|
|
|
{
|
|
|
|
|
ServerTester parent;
|
|
|
|
|
public TestAccount(ServerTester parent)
|
|
|
|
|
{
|
|
|
|
|
this.parent = parent;
|
|
|
|
|
BitPay = new Bitpay(new Key(), parent.PayTester.ServerUri);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void GrantAccess()
|
|
|
|
|
{
|
|
|
|
|
GrantAccessAsync().GetAwaiter().GetResult();
|
|
|
|
|
}
|
|
|
|
|
public async Task GrantAccessAsync()
|
|
|
|
|
{
|
|
|
|
|
var extKey = new ExtKey().GetWif(parent.Network);
|
|
|
|
|
var pairingCode = BitPay.RequestClientAuthorization("test", Facade.Merchant);
|
|
|
|
|
var account = parent.PayTester.GetController<AccountController>();
|
|
|
|
|
await account.Register(new RegisterViewModel()
|
|
|
|
|
{
|
|
|
|
|
Email = "Bob@toto.com",
|
|
|
|
|
ConfirmPassword = "Kitten0@",
|
|
|
|
|
Password = "Kitten0@",
|
|
|
|
|
});
|
|
|
|
|
UserId = account.RegisteredUserId;
|
2017-09-13 23:50:36 +09:00
|
|
|
|
|
|
|
|
|
var store = parent.PayTester.GetController<StoresController>(account.RegisteredUserId);
|
|
|
|
|
await store.CreateStore(new CreateStoreViewModel() { Name = "Test Store" });
|
|
|
|
|
StoreId = store.CreatedStoreId;
|
|
|
|
|
|
|
|
|
|
await store.UpdateStore(StoreId, new StoreViewModel()
|
2017-09-13 15:47:34 +09:00
|
|
|
|
{
|
|
|
|
|
ExtPubKey = extKey.Neuter().ToString(),
|
|
|
|
|
SpeedPolicy = SpeedPolicy.MediumSpeed
|
|
|
|
|
});
|
2017-09-13 23:50:36 +09:00
|
|
|
|
Assert.IsType<ViewResult>(await store.RequestPairing(pairingCode.ToString()));
|
|
|
|
|
await store.Pair(pairingCode.ToString(), StoreId);
|
2017-09-13 15:47:34 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Bitpay BitPay
|
|
|
|
|
{
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
|
|
|
|
public string UserId
|
|
|
|
|
{
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string StoreId
|
|
|
|
|
{
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|