mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 01:43:50 +01:00
Warning if not using 'simple using'
This commit is contained in:
parent
c6a7e90c1a
commit
50d4b55f73
@ -122,6 +122,7 @@ csharp_space_between_method_declaration_parameter_list_parentheses = false
|
|||||||
csharp_space_between_parentheses = false
|
csharp_space_between_parentheses = false
|
||||||
csharp_space_between_square_brackets = false
|
csharp_space_between_square_brackets = false
|
||||||
csharp_style_prefer_null_check_over_type_check = true:warning
|
csharp_style_prefer_null_check_over_type_check = true:warning
|
||||||
|
csharp_prefer_simple_using_statement = true:warning
|
||||||
|
|
||||||
# C++ Files
|
# C++ Files
|
||||||
|
|
||||||
|
@ -21,12 +21,10 @@ namespace BTCPayServer
|
|||||||
public static string Unzip(byte[] bytes)
|
public static string Unzip(byte[] bytes)
|
||||||
{
|
{
|
||||||
MemoryStream ms = new MemoryStream(bytes);
|
MemoryStream ms = new MemoryStream(bytes);
|
||||||
using (GZipStream gzip = new GZipStream(ms, CompressionMode.Decompress))
|
using GZipStream gzip = new GZipStream(ms, CompressionMode.Decompress);
|
||||||
{
|
|
||||||
StreamReader reader = new StreamReader(gzip, Encoding.UTF8);
|
StreamReader reader = new StreamReader(gzip, Encoding.UTF8);
|
||||||
var unzipped = reader.ReadToEnd();
|
var unzipped = reader.ReadToEnd();
|
||||||
return unzipped;
|
return unzipped;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,7 @@ namespace BTCPayServer.Tests
|
|||||||
//as a user through your profile
|
//as a user through your profile
|
||||||
//as an external application requesting an api key from a user
|
//as an external application requesting an api key from a user
|
||||||
|
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
var tester = s.Server;
|
var tester = s.Server;
|
||||||
|
|
||||||
@ -195,7 +194,6 @@ namespace BTCPayServer.Tests
|
|||||||
var apikeydata = await TestApiAgainstAccessToken<ApiKeyData>(allAPIKey, $"api/v1/api-keys/current", tester.PayTester.HttpClient);
|
var apikeydata = await TestApiAgainstAccessToken<ApiKeyData>(allAPIKey, $"api/v1/api-keys/current", tester.PayTester.HttpClient);
|
||||||
Assert.Equal(checkedPermissionCount, apikeydata.Permissions.Length);
|
Assert.Equal(checkedPermissionCount, apikeydata.Permissions.Length);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
async Task TestApiAgainstAccessToken(string accessToken, ServerTester tester, TestAccount testAccount,
|
async Task TestApiAgainstAccessToken(string accessToken, ServerTester tester, TestAccount testAccount,
|
||||||
params string[] expectedPermissionsArr)
|
params string[] expectedPermissionsArr)
|
||||||
|
@ -243,11 +243,9 @@ namespace BTCPayServer.Tests
|
|||||||
private async Task WaitSiteIsOperational()
|
private async Task WaitSiteIsOperational()
|
||||||
{
|
{
|
||||||
_ = HttpClient.GetAsync("/").ConfigureAwait(false);
|
_ = HttpClient.GetAsync("/").ConfigureAwait(false);
|
||||||
using (var cts = new CancellationTokenSource(20_000))
|
using var cts = new CancellationTokenSource(20_000);
|
||||||
{
|
|
||||||
var synching = WaitIsFullySynched(cts.Token);
|
var synching = WaitIsFullySynched(cts.Token);
|
||||||
await Task.WhenAll(synching).ConfigureAwait(false);
|
await Task.WhenAll(synching).ConfigureAwait(false);
|
||||||
}
|
|
||||||
// Opportunistic call to wake up view compilation in debug mode, we don't need to await.
|
// Opportunistic call to wake up view compilation in debug mode, we don't need to await.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,8 +23,7 @@ namespace BTCPayServer.Tests
|
|||||||
public async Task CanHandleRefundEmailForm()
|
public async Task CanHandleRefundEmailForm()
|
||||||
{
|
{
|
||||||
|
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
s.GoToRegister();
|
s.GoToRegister();
|
||||||
s.RegisterNewUser();
|
s.RegisterNewUser();
|
||||||
@ -67,14 +66,12 @@ namespace BTCPayServer.Tests
|
|||||||
s.Driver.Navigate().Refresh();
|
s.Driver.Navigate().Refresh();
|
||||||
s.Driver.AssertElementNotFound(By.Id("emailAddressFormInput"));
|
s.Driver.AssertElementNotFound(By.Id("emailAddressFormInput"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
public async Task CanHandleRefundEmailForm2()
|
public async Task CanHandleRefundEmailForm2()
|
||||||
{
|
{
|
||||||
|
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
// Prepare user account and store
|
// Prepare user account and store
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
s.GoToRegister();
|
s.GoToRegister();
|
||||||
@ -129,13 +126,11 @@ namespace BTCPayServer.Tests
|
|||||||
s.Driver.Navigate().Refresh();
|
s.Driver.Navigate().Refresh();
|
||||||
s.Driver.AssertElementNotFound(By.Id("emailAddressFormInput"));
|
s.Driver.AssertElementNotFound(By.Id("emailAddressFormInput"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
public async Task CanUseLanguageDropdown()
|
public async Task CanUseLanguageDropdown()
|
||||||
{
|
{
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
s.GoToRegister();
|
s.GoToRegister();
|
||||||
s.RegisterNewUser();
|
s.RegisterNewUser();
|
||||||
@ -159,14 +154,12 @@ namespace BTCPayServer.Tests
|
|||||||
|
|
||||||
s.Driver.Quit();
|
s.Driver.Quit();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
[Trait("Lightning", "Lightning")]
|
[Trait("Lightning", "Lightning")]
|
||||||
public async Task CanSetDefaultPaymentMethod()
|
public async Task CanSetDefaultPaymentMethod()
|
||||||
{
|
{
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
s.Server.ActivateLightning();
|
s.Server.ActivateLightning();
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
s.GoToRegister();
|
s.GoToRegister();
|
||||||
@ -181,14 +174,12 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Equal("Bitcoin (Lightning) (BTC)", s.Driver.FindElement(By.ClassName("payment__currencies")).Text);
|
Assert.Equal("Bitcoin (Lightning) (BTC)", s.Driver.FindElement(By.ClassName("payment__currencies")).Text);
|
||||||
s.Driver.Quit();
|
s.Driver.Quit();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
[Trait("Lightning", "Lightning")]
|
[Trait("Lightning", "Lightning")]
|
||||||
public async Task CanUseLightningSatsFeature()
|
public async Task CanUseLightningSatsFeature()
|
||||||
{
|
{
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
s.Server.ActivateLightning();
|
s.Server.ActivateLightning();
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
s.GoToRegister();
|
s.GoToRegister();
|
||||||
@ -205,13 +196,11 @@ namespace BTCPayServer.Tests
|
|||||||
s.GoToInvoiceCheckout(invoiceId);
|
s.GoToInvoiceCheckout(invoiceId);
|
||||||
Assert.Contains("Sats", s.Driver.FindElement(By.ClassName("payment__currencies_noborder")).Text);
|
Assert.Contains("Sats", s.Driver.FindElement(By.ClassName("payment__currencies_noborder")).Text);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
public async Task CanUseJSModal()
|
public async Task CanUseJSModal()
|
||||||
{
|
{
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
s.GoToRegister();
|
s.GoToRegister();
|
||||||
s.RegisterNewUser();
|
s.RegisterNewUser();
|
||||||
@ -245,5 +234,4 @@ namespace BTCPayServer.Tests
|
|||||||
new Uri(s.ServerUri, $"tests/index.html?invoice={invoiceId}").ToString());
|
new Uri(s.ServerUri, $"tests/index.html?invoice={invoiceId}").ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanCreateAndDeleteCrowdfundApp()
|
public async Task CanCreateAndDeleteCrowdfundApp()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
await user.GrantAccessAsync();
|
await user.GrantAccessAsync();
|
||||||
@ -60,14 +59,12 @@ namespace BTCPayServer.Tests
|
|||||||
appList = Assert.IsType<ListAppsViewModel>(Assert.IsType<ViewResult>(apps.ListApps(user.StoreId).Result).Model);
|
appList = Assert.IsType<ListAppsViewModel>(Assert.IsType<ViewResult>(apps.ListApps(user.StoreId).Result).Model);
|
||||||
Assert.Empty(appList.Apps);
|
Assert.Empty(appList.Apps);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = LongRunningTestTimeout)]
|
[Fact(Timeout = LongRunningTestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanContributeOnlyWhenAllowed()
|
public async Task CanContributeOnlyWhenAllowed()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
await user.GrantAccessAsync();
|
await user.GrantAccessAsync();
|
||||||
@ -149,14 +146,12 @@ namespace BTCPayServer.Tests
|
|||||||
Amount = new decimal(0.05)
|
Amount = new decimal(0.05)
|
||||||
}, default));
|
}, default));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = LongRunningTestTimeout)]
|
[Fact(Timeout = LongRunningTestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanComputeCrowdfundModel()
|
public async Task CanComputeCrowdfundModel()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
await user.GrantAccessAsync();
|
await user.GrantAccessAsync();
|
||||||
@ -277,5 +272,4 @@ namespace BTCPayServer.Tests
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,7 @@ namespace BTCPayServer.Tests
|
|||||||
|
|
||||||
public async Task<JObject> GetNextRequest()
|
public async Task<JObject> GetNextRequest()
|
||||||
{
|
{
|
||||||
using (CancellationTokenSource cancellation = new CancellationTokenSource(2000000))
|
using CancellationTokenSource cancellation = new CancellationTokenSource(2000000);
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
JObject req = null;
|
JObject req = null;
|
||||||
@ -59,7 +58,6 @@ namespace BTCPayServer.Tests
|
|||||||
throw new Xunit.Sdk.XunitException("Callback to the webserver was expected, check if the callback url is accessible from internet");
|
throw new Xunit.Sdk.XunitException("Callback to the webserver was expected, check if the callback url is accessible from internet");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
@ -60,8 +60,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task MissingPermissionTest()
|
public async Task MissingPermissionTest()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
user.GrantAccess();
|
user.GrantAccess();
|
||||||
@ -72,14 +71,12 @@ namespace BTCPayServer.Tests
|
|||||||
GreenfieldPermissionAPIError permissionError = Assert.IsType<GreenfieldPermissionAPIError>(e.APIError);
|
GreenfieldPermissionAPIError permissionError = Assert.IsType<GreenfieldPermissionAPIError>(e.APIError);
|
||||||
Assert.Equal(permissionError.MissingPermission, Policies.CanModifyStoreSettings);
|
Assert.Equal(permissionError.MissingPermission, Policies.CanModifyStoreSettings);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task ApiKeysControllerTests()
|
public async Task ApiKeysControllerTests()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
user.GrantAccess();
|
user.GrantAccess();
|
||||||
@ -101,7 +98,6 @@ namespace BTCPayServer.Tests
|
|||||||
//a client using Basic Auth has no business here
|
//a client using Basic Auth has no business here
|
||||||
await AssertHttpError(401, async () => await clientBasic.RevokeCurrentAPIKeyInfo());
|
await AssertHttpError(401, async () => await clientBasic.RevokeCurrentAPIKeyInfo());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
@ -129,8 +125,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task SpecificCanModifyStoreCantCreateNewStore()
|
public async Task SpecificCanModifyStoreCantCreateNewStore()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var acc = tester.NewAccount();
|
var acc = tester.NewAccount();
|
||||||
await acc.GrantAccessAsync();
|
await acc.GrantAccessAsync();
|
||||||
@ -148,14 +143,12 @@ namespace BTCPayServer.Tests
|
|||||||
restricted = new BTCPayServerClient(unrestricted.Host, apiKey);
|
restricted = new BTCPayServerClient(unrestricted.Host, apiKey);
|
||||||
await restricted.CreateStore(new CreateStoreRequest() { Name = "store2" });
|
await restricted.CreateStore(new CreateStoreRequest() { Name = "store2" });
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanCreateAndDeleteAPIKeyViaAPI()
|
public async Task CanCreateAndDeleteAPIKeyViaAPI()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var acc = tester.NewAccount();
|
var acc = tester.NewAccount();
|
||||||
await acc.GrantAccessAsync();
|
await acc.GrantAccessAsync();
|
||||||
@ -180,7 +173,6 @@ namespace BTCPayServer.Tests
|
|||||||
await unrestricted.RevokeAPIKey(apiKey.ApiKey);
|
await unrestricted.RevokeAPIKey(apiKey.ApiKey);
|
||||||
await AssertAPIError("apikey-not-found", () => unrestricted.RevokeAPIKey(apiKey.ApiKey));
|
await AssertAPIError("apikey-not-found", () => unrestricted.RevokeAPIKey(apiKey.ApiKey));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
@ -225,8 +217,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanCreateUsersViaAPI()
|
public async Task CanCreateUsersViaAPI()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester(newDb: true))
|
using var tester = CreateServerTester(newDb: true);
|
||||||
{
|
|
||||||
tester.PayTester.DisableRegistration = true;
|
tester.PayTester.DisableRegistration = true;
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var unauthClient = new BTCPayServerClient(tester.PayTester.ServerUri);
|
var unauthClient = new BTCPayServerClient(tester.PayTester.ServerUri);
|
||||||
@ -354,16 +345,13 @@ namespace BTCPayServer.Tests
|
|||||||
new CreateApplicationUserRequest() { Email = "test9@gmail.com", Password = "afewfoiewiou" }));
|
new CreateApplicationUserRequest() { Email = "test9@gmail.com", Password = "afewfoiewiou" }));
|
||||||
await adminClient.CreateUser(
|
await adminClient.CreateUser(
|
||||||
new CreateApplicationUserRequest() { Email = "test9@gmail.com", Password = "afewfoiewiou" });
|
new CreateApplicationUserRequest() { Email = "test9@gmail.com", Password = "afewfoiewiou" });
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanUsePullPaymentViaAPI()
|
public async Task CanUsePullPaymentViaAPI()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var acc = tester.NewAccount();
|
var acc = tester.NewAccount();
|
||||||
acc.Register();
|
acc.Register();
|
||||||
@ -595,7 +583,6 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Equal(PayoutState.Completed, payout.State);
|
Assert.Equal(PayoutState.Completed, payout.State);
|
||||||
await AssertAPIError("invalid-state", async () => await client.MarkPayoutPaid(storeId, payout.Id));
|
await AssertAPIError("invalid-state", async () => await client.MarkPayoutPaid(storeId, payout.Id));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private DateTimeOffset RoundSeconds(DateTimeOffset dateTimeOffset)
|
private DateTimeOffset RoundSeconds(DateTimeOffset dateTimeOffset)
|
||||||
{
|
{
|
||||||
@ -620,8 +607,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task StoresControllerTests()
|
public async Task StoresControllerTests()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
user.GrantAccess();
|
user.GrantAccess();
|
||||||
@ -673,7 +659,6 @@ namespace BTCPayServer.Tests
|
|||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
await AssertHttpError(403, async () => await client.UpdateStore(newStore.Id, new UpdateStoreRequest() { Name = "B" }));
|
await AssertHttpError(403, async () => await client.UpdateStore(newStore.Id, new UpdateStoreRequest() { Name = "B" }));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<GreenfieldValidationException> AssertValidationError(string[] fields, Func<Task> act)
|
private async Task<GreenfieldValidationException> AssertValidationError(string[] fields, Func<Task> act)
|
||||||
{
|
{
|
||||||
@ -698,8 +683,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task UsersControllerTests()
|
public async Task UsersControllerTests()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester(newDb: true))
|
using var tester = CreateServerTester(newDb: true);
|
||||||
{
|
|
||||||
tester.PayTester.DisableRegistration = true;
|
tester.PayTester.DisableRegistration = true;
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
@ -758,7 +742,6 @@ namespace BTCPayServer.Tests
|
|||||||
await clientServer.CreateUser(
|
await clientServer.CreateUser(
|
||||||
new CreateApplicationUserRequest() { Password = Guid.NewGuid().ToString() }));
|
new CreateApplicationUserRequest() { Password = Guid.NewGuid().ToString() }));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
@ -865,8 +848,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task HealthControllerTests()
|
public async Task HealthControllerTests()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var unauthClient = new BTCPayServerClient(tester.PayTester.ServerUri);
|
var unauthClient = new BTCPayServerClient(tester.PayTester.ServerUri);
|
||||||
|
|
||||||
@ -874,14 +856,12 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.NotNull(apiHealthData);
|
Assert.NotNull(apiHealthData);
|
||||||
Assert.True(apiHealthData.Synchronized);
|
Assert.True(apiHealthData.Synchronized);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task ServerInfoControllerTests()
|
public async Task ServerInfoControllerTests()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var unauthClient = new BTCPayServerClient(tester.PayTester.ServerUri);
|
var unauthClient = new BTCPayServerClient(tester.PayTester.ServerUri);
|
||||||
await AssertHttpError(401, async () => await unauthClient.GetServerInfo());
|
await AssertHttpError(401, async () => await unauthClient.GetServerInfo());
|
||||||
@ -899,14 +879,12 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.NotNull(serverInfoData.SyncStatus);
|
Assert.NotNull(serverInfoData.SyncStatus);
|
||||||
Assert.Single(serverInfoData.SyncStatus.Select(s => s.CryptoCode == "BTC"));
|
Assert.Single(serverInfoData.SyncStatus.Select(s => s.CryptoCode == "BTC"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task PaymentControllerTests()
|
public async Task PaymentControllerTests()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
user.GrantAccess();
|
user.GrantAccess();
|
||||||
@ -991,7 +969,6 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Equal(PaymentRequestData.PaymentRequestStatus.Completed, (await client.GetPaymentRequest(user.StoreId, paymentTestPaymentRequest.Id)).Status);
|
Assert.Equal(PaymentRequestData.PaymentRequestStatus.Completed, (await client.GetPaymentRequest(user.StoreId, paymentTestPaymentRequest.Id)).Status);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
@ -1065,8 +1042,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanOverpayInvoice()
|
public async Task CanOverpayInvoice()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
await user.RegisterDerivationSchemeAsync("BTC");
|
await user.RegisterDerivationSchemeAsync("BTC");
|
||||||
@ -1091,7 +1067,6 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Equal(amount + 1.0m, method.TotalPaid);
|
Assert.Equal(amount + 1.0m, method.TotalPaid);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
@ -1440,8 +1415,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Trait("Lightning", "Lightning")]
|
[Trait("Lightning", "Lightning")]
|
||||||
public async Task CanUseLightningAPI()
|
public async Task CanUseLightningAPI()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
tester.ActivateLightning();
|
tester.ActivateLightning();
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
await tester.EnsureChannelsSetup();
|
await tester.EnsureChannelsSetup();
|
||||||
@ -1542,7 +1516,6 @@ namespace BTCPayServer.Tests
|
|||||||
// Can use lightning node is only granted to store's owner
|
// Can use lightning node is only granted to store's owner
|
||||||
await AssertPermissionError("btcpay.store.canuselightningnode", () => client.GetLightningNodeInfo(user.StoreId, "BTC"));
|
await AssertPermissionError("btcpay.store.canuselightningnode", () => client.GetLightningNodeInfo(user.StoreId, "BTC"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
|
@ -18,8 +18,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanAutoDetectLanguage()
|
public async Task CanAutoDetectLanguage()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var languageService = tester.PayTester.GetService<LanguageService>();
|
var languageService = tester.PayTester.GetService<LanguageService>();
|
||||||
|
|
||||||
@ -47,5 +46,4 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Null(lang4);
|
Assert.Null(lang4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanUsePoSApp1()
|
public async Task CanUsePoSApp1()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
await user.GrantAccessAsync();
|
await user.GrantAccessAsync();
|
||||||
@ -69,5 +68,4 @@ donation:
|
|||||||
.ViewPointOfSale(app.Id, PosViewType.Cart, 0, null, null, null, null, "apple").Result);
|
.ViewPointOfSale(app.Id, PosViewType.Cart, 0, null, null, null, null, "apple").Result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanPlayWithPSBT()
|
public async Task CanPlayWithPSBT()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
user.GrantAccess();
|
user.GrantAccess();
|
||||||
@ -135,7 +134,6 @@ namespace BTCPayServer.Tests
|
|||||||
UploadedPSBTFile = TestUtils.GetFormFile("base64", signedPSBT.ToBase64())
|
UploadedPSBTFile = TestUtils.GetFormFile("base64", signedPSBT.ToBase64())
|
||||||
})).Model).PSBT));
|
})).Model).PSBT));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static string AssertRedirectedPSBT(IActionResult view, string actionName)
|
private static string AssertRedirectedPSBT(IActionResult view, string actionName)
|
||||||
{
|
{
|
||||||
|
@ -46,8 +46,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanUseTheDelayedBroadcaster()
|
public async Task CanUseTheDelayedBroadcaster()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var network = tester.NetworkProvider.GetNetwork<BTCPayNetwork>("BTC");
|
var network = tester.NetworkProvider.GetNetwork<BTCPayNetwork>("BTC");
|
||||||
var broadcaster = tester.PayTester.GetService<DelayedTransactionBroadcaster>();
|
var broadcaster = tester.PayTester.GetService<DelayedTransactionBroadcaster>();
|
||||||
@ -62,13 +61,11 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Equal(1, await broadcaster.ProcessAll());
|
Assert.Equal(1, await broadcaster.ProcessAll());
|
||||||
Assert.Equal(0, await broadcaster.ProcessAll());
|
Assert.Equal(0, await broadcaster.ProcessAll());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanUsePayjoinRepository()
|
public async Task CanUsePayjoinRepository()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var network = tester.NetworkProvider.GetNetwork<BTCPayNetwork>("BTC");
|
var network = tester.NetworkProvider.GetNetwork<BTCPayNetwork>("BTC");
|
||||||
var repo = tester.PayTester.GetService<PayJoinRepository>();
|
var repo = tester.PayTester.GetService<PayJoinRepository>();
|
||||||
@ -101,14 +98,12 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.False(await repo.TryLockInputs(new[] { outpoint2, outpoint1 }));
|
Assert.False(await repo.TryLockInputs(new[] { outpoint2, outpoint1 }));
|
||||||
Assert.True(await repo.TryLockInputs(new[] { outpoint2 }));
|
Assert.True(await repo.TryLockInputs(new[] { outpoint2 }));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task ChooseBestUTXOsForPayjoin()
|
public async Task ChooseBestUTXOsForPayjoin()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var network = tester.NetworkProvider.GetNetwork<BTCPayNetwork>("BTC");
|
var network = tester.NetworkProvider.GetNetwork<BTCPayNetwork>("BTC");
|
||||||
var controller = tester.PayTester.GetService<PayJoinEndpointController>();
|
var controller = tester.PayTester.GetService<PayJoinEndpointController>();
|
||||||
@ -138,7 +133,6 @@ namespace BTCPayServer.Tests
|
|||||||
result = await controller.SelectUTXO(network, utxos, inputs, paymentAmount, otherOutputs);
|
result = await controller.SelectUTXO(network, utxos, inputs, paymentAmount, otherOutputs);
|
||||||
Assert.Equal(PayJoinEndpointController.PayjoinUtxoSelectionType.HeuristicBased, result.selectionType);
|
Assert.Equal(PayJoinEndpointController.PayjoinUtxoSelectionType.HeuristicBased, result.selectionType);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -168,8 +162,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanOnlyUseCorrectAddressFormatsForPayjoin()
|
public async Task CanOnlyUseCorrectAddressFormatsForPayjoin()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var broadcaster = tester.PayTester.GetService<DelayedTransactionBroadcaster>();
|
var broadcaster = tester.PayTester.GetService<DelayedTransactionBroadcaster>();
|
||||||
var payjoinRepository = tester.PayTester.GetService<PayJoinRepository>();
|
var payjoinRepository = tester.PayTester.GetService<PayJoinRepository>();
|
||||||
@ -222,16 +215,13 @@ namespace BTCPayServer.Tests
|
|||||||
var pj = await senderUser.SubmitPayjoin(invoice, psbt, errorCode, false);
|
var pj = await senderUser.SubmitPayjoin(invoice, psbt, errorCode, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[Trait("Selenium", "Selenium")]
|
[Trait("Selenium", "Selenium")]
|
||||||
public async Task CanUsePayjoinForTopUp()
|
public async Task CanUsePayjoinForTopUp()
|
||||||
{
|
{
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
s.RegisterNewUser(true);
|
s.RegisterNewUser(true);
|
||||||
var receiver = s.CreateNewStore();
|
var receiver = s.CreateNewStore();
|
||||||
@ -275,14 +265,12 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Equal(0.023m, invoice.Price);
|
Assert.Equal(0.023m, invoice.Price);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[Trait("Selenium", "Selenium")]
|
[Trait("Selenium", "Selenium")]
|
||||||
public async Task CanUsePayjoinViaUI()
|
public async Task CanUsePayjoinViaUI()
|
||||||
{
|
{
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
var invoiceRepository = s.Server.PayTester.GetService<InvoiceRepository>();
|
var invoiceRepository = s.Server.PayTester.GetService<InvoiceRepository>();
|
||||||
s.RegisterNewUser(true);
|
s.RegisterNewUser(true);
|
||||||
@ -410,14 +398,12 @@ namespace BTCPayServer.Tests
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanUsePayjoin2()
|
public async Task CanUsePayjoin2()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var pjClient = tester.PayTester.GetService<PayjoinClient>();
|
var pjClient = tester.PayTester.GetService<PayjoinClient>();
|
||||||
var nbx = tester.PayTester.GetService<ExplorerClientProvider>().GetExplorerClient("BTC");
|
var nbx = tester.PayTester.GetService<ExplorerClientProvider>().GetExplorerClient("BTC");
|
||||||
@ -629,7 +615,6 @@ namespace BTCPayServer.Tests
|
|||||||
var ex2 = await Assert.ThrowsAsync<PayjoinReceiverException>(async () => await pjClient.RequestPayjoin(endpoint, new PayjoinWallet(derivationSchemeSettings), psbt, default));
|
var ex2 = await Assert.ThrowsAsync<PayjoinReceiverException>(async () => await pjClient.RequestPayjoin(endpoint, new PayjoinWallet(derivationSchemeSettings), psbt, default));
|
||||||
Assert.Equal(PayjoinReceiverWellknownErrors.NotEnoughMoney, ex2.WellknownError);
|
Assert.Equal(PayjoinReceiverWellknownErrors.NotEnoughMoney, ex2.WellknownError);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static async Task<PSBT> ParsePSBT(Microsoft.AspNetCore.Http.HttpContext request)
|
private static async Task<PSBT> ParsePSBT(Microsoft.AspNetCore.Http.HttpContext request)
|
||||||
{
|
{
|
||||||
|
@ -24,8 +24,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanCreateViewUpdateAndDeletePaymentRequest()
|
public async Task CanCreateViewUpdateAndDeletePaymentRequest()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
await user.GrantAccessAsync();
|
await user.GrantAccessAsync();
|
||||||
@ -91,14 +90,12 @@ namespace BTCPayServer.Tests
|
|||||||
.IsType<ListPaymentRequestsViewModel>(Assert
|
.IsType<ListPaymentRequestsViewModel>(Assert
|
||||||
.IsType<ViewResult>(await paymentRequestController.GetPaymentRequests(user.StoreId)).Model).Items);
|
.IsType<ViewResult>(await paymentRequestController.GetPaymentRequests(user.StoreId)).Model).Items);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = 60 * 2 * 1000)]
|
[Fact(Timeout = 60 * 2 * 1000)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanPayPaymentRequestWhenPossible()
|
public async Task CanPayPaymentRequestWhenPossible()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
await user.GrantAccessAsync();
|
await user.GrantAccessAsync();
|
||||||
@ -157,14 +154,12 @@ namespace BTCPayServer.Tests
|
|||||||
.IsType<BadRequestObjectResult>(
|
.IsType<BadRequestObjectResult>(
|
||||||
await paymentRequestController.PayPaymentRequest(response.Value.ToString(), false));
|
await paymentRequestController.PayPaymentRequest(response.Value.ToString(), false));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = 60 * 2 * 1000)]
|
[Fact(Timeout = 60 * 2 * 1000)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanCancelPaymentWhenPossible()
|
public async Task CanCancelPaymentWhenPossible()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
user.GrantAccess();
|
user.GrantAccess();
|
||||||
@ -241,5 +236,4 @@ namespace BTCPayServer.Tests
|
|||||||
await paymentRequestController.CancelUnpaidPendingInvoice(paymentRequestId);
|
await paymentRequestController.CancelUnpaidPendingInvoice(paymentRequestId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
public async Task CanNavigateServerSettings()
|
public async Task CanNavigateServerSettings()
|
||||||
{
|
{
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
s.RegisterNewUser(true);
|
s.RegisterNewUser(true);
|
||||||
s.Driver.FindElement(By.Id("Nav-ServerSettings")).Click();
|
s.Driver.FindElement(By.Id("Nav-ServerSettings")).Click();
|
||||||
@ -64,14 +63,12 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Contains("Starting listening NBXplorer", s.Driver.PageSource);
|
Assert.Contains("Starting listening NBXplorer", s.Driver.PageSource);
|
||||||
s.Driver.Quit();
|
s.Driver.Quit();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
[Trait("Lightning", "Lightning")]
|
[Trait("Lightning", "Lightning")]
|
||||||
public async Task CanUseLndSeedBackup()
|
public async Task CanUseLndSeedBackup()
|
||||||
{
|
{
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
s.Server.ActivateLightning();
|
s.Server.ActivateLightning();
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
s.RegisterNewUser(true);
|
s.RegisterNewUser(true);
|
||||||
@ -96,14 +93,12 @@ namespace BTCPayServer.Tests
|
|||||||
seedEl = s.Driver.FindElement(By.Id("Seed"));
|
seedEl = s.Driver.FindElement(By.Id("Seed"));
|
||||||
Assert.Contains("Seed removed", seedEl.Text, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains("Seed removed", seedEl.Text, StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
[Trait("Selenium", "Selenium")]
|
[Trait("Selenium", "Selenium")]
|
||||||
public async Task CanChangeUserMail()
|
public async Task CanChangeUserMail()
|
||||||
{
|
{
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
|
|
||||||
var tester = s.Server;
|
var tester = s.Server;
|
||||||
@ -136,13 +131,11 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.NotNull(await manager.FindByNameAsync(changedEmail));
|
Assert.NotNull(await manager.FindByNameAsync(changedEmail));
|
||||||
Assert.NotNull(await manager.FindByEmailAsync(changedEmail));
|
Assert.NotNull(await manager.FindByEmailAsync(changedEmail));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
public async Task NewUserLogin()
|
public async Task NewUserLogin()
|
||||||
{
|
{
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
//Register & Log Out
|
//Register & Log Out
|
||||||
var email = s.RegisterNewUser();
|
var email = s.RegisterNewUser();
|
||||||
@ -220,13 +213,11 @@ namespace BTCPayServer.Tests
|
|||||||
|
|
||||||
Assert.Contains("/login", s.Driver.Url);
|
Assert.Contains("/login", s.Driver.Url);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
public async Task CanUseSSHService()
|
public async Task CanUseSSHService()
|
||||||
{
|
{
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
var settings = s.Server.PayTester.GetService<SettingsRepository>();
|
var settings = s.Server.PayTester.GetService<SettingsRepository>();
|
||||||
var policies = await settings.GetSettingAsync<PoliciesSettings>() ?? new PoliciesSettings();
|
var policies = await settings.GetSettingAsync<PoliciesSettings>() ?? new PoliciesSettings();
|
||||||
@ -277,13 +268,11 @@ namespace BTCPayServer.Tests
|
|||||||
policies.DisableSSHService = false;
|
policies.DisableSSHService = false;
|
||||||
await settings.UpdateSetting(policies);
|
await settings.UpdateSetting(policies);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
public async Task CanSetupEmailServer()
|
public async Task CanSetupEmailServer()
|
||||||
{
|
{
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
s.RegisterNewUser(isAdmin: true);
|
s.RegisterNewUser(isAdmin: true);
|
||||||
s.Driver.Navigate().GoToUrl(s.Link("/server/emails"));
|
s.Driver.Navigate().GoToUrl(s.Link("/server/emails"));
|
||||||
@ -297,13 +286,11 @@ namespace BTCPayServer.Tests
|
|||||||
s.GoToUrl($"stores/{s.StoreId}/emails");
|
s.GoToUrl($"stores/{s.StoreId}/emails");
|
||||||
CanSetupEmailCore(s);
|
CanSetupEmailCore(s);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
public async Task CanUseDynamicDns()
|
public async Task CanUseDynamicDns()
|
||||||
{
|
{
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
s.RegisterNewUser(isAdmin: true);
|
s.RegisterNewUser(isAdmin: true);
|
||||||
s.Driver.Navigate().GoToUrl(s.Link("/server/services"));
|
s.Driver.Navigate().GoToUrl(s.Link("/server/services"));
|
||||||
@ -348,7 +335,6 @@ namespace BTCPayServer.Tests
|
|||||||
|
|
||||||
Assert.DoesNotContain("/server/services/dynamic-dns/pouet.hello.com/delete", s.Driver.PageSource);
|
Assert.DoesNotContain("/server/services/dynamic-dns/pouet.hello.com/delete", s.Driver.PageSource);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
public async Task CanCreateInvoiceInUI()
|
public async Task CanCreateInvoiceInUI()
|
||||||
{
|
{
|
||||||
@ -384,8 +370,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
public async Task CanSetupStoreViaGuide()
|
public async Task CanSetupStoreViaGuide()
|
||||||
{
|
{
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
s.RegisterNewUser();
|
s.RegisterNewUser();
|
||||||
s.GoToUrl("/");
|
s.GoToUrl("/");
|
||||||
@ -403,14 +388,12 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.True(s.Driver.PageSource.Contains("id=\"StoreSelectorDropdown\""), "Store selector dropdown should be present");
|
Assert.True(s.Driver.PageSource.Contains("id=\"StoreSelectorDropdown\""), "Store selector dropdown should be present");
|
||||||
Assert.False(s.Driver.PageSource.Contains("id=\"SetupGuide\""), "Setup guide should not be present");
|
Assert.False(s.Driver.PageSource.Contains("id=\"SetupGuide\""), "Setup guide should not be present");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
[Trait("Lightning", "Lightning")]
|
[Trait("Lightning", "Lightning")]
|
||||||
public async Task CanCreateStores()
|
public async Task CanCreateStores()
|
||||||
{
|
{
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
s.Server.ActivateLightning();
|
s.Server.ActivateLightning();
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
var alice = s.RegisterNewUser(true);
|
var alice = s.RegisterNewUser(true);
|
||||||
@ -542,13 +525,11 @@ namespace BTCPayServer.Tests
|
|||||||
s.GoToUrl(storeUrl);
|
s.GoToUrl(storeUrl);
|
||||||
Assert.Contains("ReturnUrl", s.Driver.Url);
|
Assert.Contains("ReturnUrl", s.Driver.Url);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
public async Task CanUsePairing()
|
public async Task CanUsePairing()
|
||||||
{
|
{
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
s.Driver.Navigate().GoToUrl(s.Link("/api-access-request"));
|
s.Driver.Navigate().GoToUrl(s.Link("/api-access-request"));
|
||||||
Assert.Contains("ReturnUrl", s.Driver.Url);
|
Assert.Contains("ReturnUrl", s.Driver.Url);
|
||||||
@ -587,13 +568,11 @@ namespace BTCPayServer.Tests
|
|||||||
s.Driver.FindElement(By.Id("ApprovePairing")).Click();
|
s.Driver.FindElement(By.Id("ApprovePairing")).Click();
|
||||||
AssertUrlHasPairingCode(s);
|
AssertUrlHasPairingCode(s);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
public async Task CanCreateAppPoS()
|
public async Task CanCreateAppPoS()
|
||||||
{
|
{
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
s.RegisterNewUser();
|
s.RegisterNewUser();
|
||||||
s.CreateNewStore();
|
s.CreateNewStore();
|
||||||
@ -625,13 +604,11 @@ namespace BTCPayServer.Tests
|
|||||||
s.Driver.Url = posBaseUrl + "/cart";
|
s.Driver.Url = posBaseUrl + "/cart";
|
||||||
Assert.True(s.Driver.PageSource.Contains("Cart"), "Cart PoS not showing correct view");
|
Assert.True(s.Driver.PageSource.Contains("Cart"), "Cart PoS not showing correct view");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
public async Task CanCreateCrowdfundingApp()
|
public async Task CanCreateCrowdfundingApp()
|
||||||
{
|
{
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
s.RegisterNewUser();
|
s.RegisterNewUser();
|
||||||
s.CreateNewStore();
|
s.CreateNewStore();
|
||||||
@ -650,13 +627,11 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Equal("currently active!",
|
Assert.Equal("currently active!",
|
||||||
s.Driver.FindElement(By.CssSelector("[data-test='time-state']")).Text);
|
s.Driver.FindElement(By.CssSelector("[data-test='time-state']")).Text);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
public async Task CanCreatePayRequest()
|
public async Task CanCreatePayRequest()
|
||||||
{
|
{
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
s.RegisterNewUser();
|
s.RegisterNewUser();
|
||||||
s.CreateNewStore();
|
s.CreateNewStore();
|
||||||
@ -694,13 +669,11 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Equal("Pay Invoice",
|
Assert.Equal("Pay Invoice",
|
||||||
s.Driver.FindElement(By.CssSelector("[data-test='pay-button']")).Text.Trim());
|
s.Driver.FindElement(By.CssSelector("[data-test='pay-button']")).Text.Trim());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
public async Task CanUseCoinSelection()
|
public async Task CanUseCoinSelection()
|
||||||
{
|
{
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
s.RegisterNewUser(true);
|
s.RegisterNewUser(true);
|
||||||
(_, string storeId) = s.CreateNewStore();
|
(_, string storeId) = s.CreateNewStore();
|
||||||
@ -756,13 +729,11 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Single(tx.Inputs);
|
Assert.Single(tx.Inputs);
|
||||||
Assert.Equal(spentOutpoint, tx.Inputs[0].PrevOut);
|
Assert.Equal(spentOutpoint, tx.Inputs[0].PrevOut);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
public async Task CanUseWebhooks()
|
public async Task CanUseWebhooks()
|
||||||
{
|
{
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
s.RegisterNewUser(true);
|
s.RegisterNewUser(true);
|
||||||
s.CreateNewStore();
|
s.CreateNewStore();
|
||||||
@ -875,13 +846,11 @@ namespace BTCPayServer.Tests
|
|||||||
s.Driver.FindElement(By.Id("ConfirmContinue")).Click();
|
s.Driver.FindElement(By.Id("ConfirmContinue")).Click();
|
||||||
s.FindAlertMessage();
|
s.FindAlertMessage();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
public async Task CanImportMnemonic()
|
public async Task CanImportMnemonic()
|
||||||
{
|
{
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
s.RegisterNewUser(true);
|
s.RegisterNewUser(true);
|
||||||
foreach (var isHotwallet in new[] { false, true })
|
foreach (var isHotwallet in new[] { false, true })
|
||||||
@ -896,13 +865,11 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.DoesNotContain("View seed", s.Driver.PageSource);
|
Assert.DoesNotContain("View seed", s.Driver.PageSource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
public async Task CanManageWallet()
|
public async Task CanManageWallet()
|
||||||
{
|
{
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
s.RegisterNewUser(true);
|
s.RegisterNewUser(true);
|
||||||
(_, string storeId) = s.CreateNewStore();
|
(_, string storeId) = s.CreateNewStore();
|
||||||
@ -1058,13 +1025,11 @@ namespace BTCPayServer.Tests
|
|||||||
s.Driver.FindElement(By.Id("proceed")).Click();
|
s.Driver.FindElement(By.Id("proceed")).Click();
|
||||||
Assert.Equal(settingsUrl, s.Driver.Url);
|
Assert.Equal(settingsUrl, s.Driver.Url);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
public async Task CanImportWallet()
|
public async Task CanImportWallet()
|
||||||
{
|
{
|
||||||
using (var s = CreateSeleniumTester())
|
using var s = CreateSeleniumTester();
|
||||||
{
|
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
s.RegisterNewUser(true);
|
s.RegisterNewUser(true);
|
||||||
(_, string storeId) = s.CreateNewStore();
|
(_, string storeId) = s.CreateNewStore();
|
||||||
@ -1078,7 +1043,6 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Contains("m/84'/1'/0'",
|
Assert.Contains("m/84'/1'/0'",
|
||||||
s.Driver.FindElement(By.Id("AccountKeys_0__AccountKeyPath")).GetAttribute("value"));
|
s.Driver.FindElement(By.Id("AccountKeys_0__AccountKeyPath")).GetAttribute("value"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[Trait("Selenium", "Selenium")]
|
[Trait("Selenium", "Selenium")]
|
||||||
|
@ -37,8 +37,7 @@ namespace BTCPayServer.Tests
|
|||||||
[FactWithSecret("AzureBlobStorageConnectionString")]
|
[FactWithSecret("AzureBlobStorageConnectionString")]
|
||||||
public async Task CanUseAzureBlobStorage()
|
public async Task CanUseAzureBlobStorage()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
user.GrantAccess();
|
user.GrantAccess();
|
||||||
@ -71,7 +70,6 @@ namespace BTCPayServer.Tests
|
|||||||
|
|
||||||
await UnitTest1.CanUploadRemoveFiles(controller);
|
await UnitTest1.CanUploadRemoveFiles(controller);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void CanQueryDirectProviders()
|
public void CanQueryDirectProviders()
|
||||||
@ -338,8 +336,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Fact]
|
[Fact]
|
||||||
public async Task CanUseExchangeSpecificRate()
|
public async Task CanUseExchangeSpecificRate()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
tester.PayTester.MockRates = false;
|
tester.PayTester.MockRates = false;
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
@ -357,7 +354,6 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Single(rates.Where(r => r == rate));
|
Assert.Single(rates.Where(r => r == rate));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static async Task<decimal> CreateInvoice(ServerTester tester, TestAccount user, string exchange,
|
private static async Task<decimal> CreateInvoice(ServerTester tester, TestAccount user, string exchange,
|
||||||
string currency = "USD")
|
string currency = "USD")
|
||||||
|
@ -134,8 +134,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CheckSwaggerIsConformToSchema()
|
public async Task CheckSwaggerIsConformToSchema()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var acc = tester.NewAccount();
|
var acc = tester.NewAccount();
|
||||||
|
|
||||||
@ -158,14 +157,12 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Empty(errors);
|
Assert.Empty(errors);
|
||||||
Assert.True(valid);
|
Assert.True(valid);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task EnsureSwaggerPermissionsDocumented()
|
public async Task EnsureSwaggerPermissionsDocumented()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var acc = tester.NewAccount();
|
var acc = tester.NewAccount();
|
||||||
|
|
||||||
@ -198,7 +195,6 @@ namespace BTCPayServer.Tests
|
|||||||
|
|
||||||
Assert.Equal(description, json["components"]["securitySchemes"]["API Key"]["description"].Value<string>());
|
Assert.Equal(description, json["components"]["securitySchemes"]["API Key"]["description"].Value<string>());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private async Task CheckDeadLinks(Regex regex, HttpClient httpClient, string file)
|
private async Task CheckDeadLinks(Regex regex, HttpClient httpClient, string file)
|
||||||
{
|
{
|
||||||
@ -271,8 +267,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanAcceptInvoiceWithTolerance2()
|
public async Task CanAcceptInvoiceWithTolerance2()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
user.GrantAccess();
|
user.GrantAccess();
|
||||||
@ -309,14 +304,12 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Equal("paid", localInvoice.Status);
|
Assert.Equal("paid", localInvoice.Status);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanThrowBitpay404Error()
|
public async Task CanThrowBitpay404Error()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
user.GrantAccess();
|
user.GrantAccess();
|
||||||
@ -349,7 +342,6 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Equal(HttpStatusCode.Unauthorized, result.StatusCode);
|
Assert.Equal(HttpStatusCode.Unauthorized, result.StatusCode);
|
||||||
Assert.Equal(0, result.Content.Headers.ContentLength.Value);
|
Assert.Equal(0, result.Content.Headers.ContentLength.Value);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = 60 * 2 * 1000)]
|
[Fact(Timeout = 60 * 2 * 1000)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
@ -418,8 +410,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Trait("Lightning", "Lightning")]
|
[Trait("Lightning", "Lightning")]
|
||||||
public async Task CanSetLightningServer()
|
public async Task CanSetLightningServer()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
tester.ActivateLightning();
|
tester.ActivateLightning();
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
await tester.EnsureChannelsSetup();
|
await tester.EnsureChannelsSetup();
|
||||||
@ -456,7 +447,6 @@ namespace BTCPayServer.Tests
|
|||||||
.IsType<ViewResult>(storeResponse).Model);
|
.IsType<ViewResult>(storeResponse).Model);
|
||||||
Assert.Single(storeVm.LightningNodes.Where(l => !string.IsNullOrEmpty(l.Address)));
|
Assert.Single(storeVm.LightningNodes.Where(l => !string.IsNullOrEmpty(l.Address)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = 60 * 2 * 1000)]
|
[Fact(Timeout = 60 * 2 * 1000)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
@ -487,8 +477,7 @@ namespace BTCPayServer.Tests
|
|||||||
// For easier debugging and testing
|
// For easier debugging and testing
|
||||||
// LightningLikePaymentHandler.LIGHTNING_TIMEOUT = int.MaxValue;
|
// LightningLikePaymentHandler.LIGHTNING_TIMEOUT = int.MaxValue;
|
||||||
|
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
tester.ActivateLightning();
|
tester.ActivateLightning();
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
await tester.EnsureChannelsSetup();
|
await tester.EnsureChannelsSetup();
|
||||||
@ -503,7 +492,6 @@ namespace BTCPayServer.Tests
|
|||||||
.Select(_ => CanSendLightningPaymentCore(tester, user))
|
.Select(_ => CanSendLightningPaymentCore(tester, user))
|
||||||
.ToArray());
|
.ToArray());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
async Task CanSendLightningPaymentCore(ServerTester tester, TestAccount user)
|
async Task CanSendLightningPaymentCore(ServerTester tester, TestAccount user)
|
||||||
{
|
{
|
||||||
var invoice = await user.BitPay.CreateInvoiceAsync(new Invoice()
|
var invoice = await user.BitPay.CreateInvoiceAsync(new Invoice()
|
||||||
@ -531,8 +519,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanUseServerInitiatedPairingCode()
|
public async Task CanUseServerInitiatedPairingCode()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var acc = tester.NewAccount();
|
var acc = tester.NewAccount();
|
||||||
acc.Register();
|
acc.Register();
|
||||||
@ -552,16 +539,13 @@ namespace BTCPayServer.Tests
|
|||||||
acc.BitPay.AuthorizeClient(new PairingCode(pairingCode)).GetAwaiter().GetResult();
|
acc.BitPay.AuthorizeClient(new PairingCode(pairingCode)).GetAwaiter().GetResult();
|
||||||
Assert.True(acc.BitPay.TestAccess(Facade.Merchant));
|
Assert.True(acc.BitPay.TestAccess(Facade.Merchant));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = LongRunningTestTimeout)]
|
[Fact(Timeout = LongRunningTestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanSendIPN()
|
public async Task CanSendIPN()
|
||||||
{
|
{
|
||||||
using (var callbackServer = new CustomServer())
|
using var callbackServer = new CustomServer();
|
||||||
{
|
using var tester = CreateServerTester();
|
||||||
using (var tester = CreateServerTester())
|
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var acc = tester.NewAccount();
|
var acc = tester.NewAccount();
|
||||||
acc.GrantAccess();
|
acc.GrantAccess();
|
||||||
@ -622,15 +606,12 @@ namespace BTCPayServer.Tests
|
|||||||
var invoice2 = acc.BitPay.GetInvoice(invoice.Id);
|
var invoice2 = acc.BitPay.GetInvoice(invoice.Id);
|
||||||
Assert.NotNull(invoice2);
|
Assert.NotNull(invoice2);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = LongRunningTestTimeout)]
|
[Fact(Timeout = LongRunningTestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CantPairTwiceWithSamePubkey()
|
public async Task CantPairTwiceWithSamePubkey()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var acc = tester.NewAccount();
|
var acc = tester.NewAccount();
|
||||||
acc.Register();
|
acc.Register();
|
||||||
@ -647,14 +628,12 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Contains(nameof(PairingResult.ReusedKey),
|
Assert.Contains(nameof(PairingResult.ReusedKey),
|
||||||
(string)store2.TempData[WellKnownTempData.ErrorMessage], StringComparison.CurrentCultureIgnoreCase);
|
(string)store2.TempData[WellKnownTempData.ErrorMessage], StringComparison.CurrentCultureIgnoreCase);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = LongRunningTestTimeout)]
|
[Fact(Timeout = LongRunningTestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanUseTorClient()
|
public async Task CanUseTorClient()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var httpFactory = tester.PayTester.GetService<IHttpClientFactory>();
|
var httpFactory = tester.PayTester.GetService<IHttpClientFactory>();
|
||||||
var client = httpFactory.CreateClient(PayjoinServerCommunicator.PayjoinOnionNamedClient);
|
var client = httpFactory.CreateClient(PayjoinServerCommunicator.PayjoinOnionNamedClient);
|
||||||
@ -689,14 +668,12 @@ namespace BTCPayServer.Tests
|
|||||||
TestLogs.LogInformation("Querying valid onion but unreachable");
|
TestLogs.LogInformation("Querying valid onion but unreachable");
|
||||||
await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync("http://nzwsosflsoquxirwb2zikz6uxr3u5n5u73l33umtdx4hq5mzm5dycuqd.onion/"));
|
await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync("http://nzwsosflsoquxirwb2zikz6uxr3u5n5u73l33umtdx4hq5mzm5dycuqd.onion/"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = LongRunningTestTimeout)]
|
[Fact(Timeout = LongRunningTestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanRescanWallet()
|
public async Task CanRescanWallet()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var acc = tester.NewAccount();
|
var acc = tester.NewAccount();
|
||||||
acc.GrantAccess();
|
acc.GrantAccess();
|
||||||
@ -791,14 +768,12 @@ namespace BTCPayServer.Tests
|
|||||||
var walletInfo = await tester.PayTester.GetService<WalletRepository>().GetWalletInfo(walletId);
|
var walletInfo = await tester.PayTester.GetService<WalletRepository>().GetWalletInfo(walletId);
|
||||||
Assert.Single(walletInfo.LabelColors); // the test2 color should have been removed
|
Assert.Single(walletInfo.LabelColors); // the test2 color should have been removed
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = LongRunningTestTimeout)]
|
[Fact(Timeout = LongRunningTestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanListInvoices()
|
public async Task CanListInvoices()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var acc = tester.NewAccount();
|
var acc = tester.NewAccount();
|
||||||
await acc.GrantAccessAsync();
|
await acc.GrantAccessAsync();
|
||||||
@ -843,14 +818,12 @@ namespace BTCPayServer.Tests
|
|||||||
AssertSearchInvoice(acc, false, invoice.Id,
|
AssertSearchInvoice(acc, false, invoice.Id,
|
||||||
$"enddate:{time.AddSeconds(-1).ToString("yyyy-MM-dd HH:mm:ss")}");
|
$"enddate:{time.AddSeconds(-1).ToString("yyyy-MM-dd HH:mm:ss")}");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = LongRunningTestTimeout)]
|
[Fact(Timeout = LongRunningTestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanListNotifications()
|
public async Task CanListNotifications()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var acc = tester.NewAccount();
|
var acc = tester.NewAccount();
|
||||||
acc.GrantAccess(true);
|
acc.GrantAccess(true);
|
||||||
@ -876,14 +849,12 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Equal($"https://github.com/btcpayserver/btcpayserver/releases/tag/v{newVersion}", fn.ActionLink);
|
Assert.Equal($"https://github.com/btcpayserver/btcpayserver/releases/tag/v{newVersion}", fn.ActionLink);
|
||||||
Assert.False(fn.Seen);
|
Assert.False(fn.Seen);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanGetRates()
|
public async Task CanGetRates()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var acc = tester.NewAccount();
|
var acc = tester.NewAccount();
|
||||||
acc.GrantAccess();
|
acc.GrantAccess();
|
||||||
@ -935,7 +906,6 @@ namespace BTCPayServer.Tests
|
|||||||
$"http://127.0.0.1:{tester.PayTester.Port}/rates?storeId={acc.StoreId}");
|
$"http://127.0.0.1:{tester.PayTester.Port}/rates?storeId={acc.StoreId}");
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void AssertSearchInvoice(TestAccount acc, bool expected, string invoiceId, string filter, string storeId = null)
|
private void AssertSearchInvoice(TestAccount acc, bool expected, string invoiceId, string filter, string storeId = null)
|
||||||
{
|
{
|
||||||
@ -950,8 +920,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanRBFPayment()
|
public async Task CanRBFPayment()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
await user.GrantAccessAsync();
|
await user.GrantAccessAsync();
|
||||||
@ -1100,7 +1069,6 @@ namespace BTCPayServer.Tests
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// [Fact(Timeout = TestTimeout)]
|
// [Fact(Timeout = TestTimeout)]
|
||||||
[Fact()]
|
[Fact()]
|
||||||
@ -1135,13 +1103,11 @@ namespace BTCPayServer.Tests
|
|||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async void CheckCORSSetOnBitpayAPI()
|
public async void CheckCORSSetOnBitpayAPI()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
foreach (var req in new[] { "invoices/", "invoices", "rates", "tokens" }.Select(async path =>
|
foreach (var req in new[] { "invoices/", "invoices", "rates", "tokens" }.Select(async path =>
|
||||||
{
|
{
|
||||||
using (HttpClient client = new HttpClient())
|
using HttpClient client = new HttpClient();
|
||||||
{
|
|
||||||
HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Options,
|
HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Options,
|
||||||
tester.PayTester.ServerUri.AbsoluteUri + path);
|
tester.PayTester.ServerUri.AbsoluteUri + path);
|
||||||
message.Headers.Add("Access-Control-Request-Headers", "test");
|
message.Headers.Add("Access-Control-Request-Headers", "test");
|
||||||
@ -1151,7 +1117,6 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Equal("*", val.FirstOrDefault());
|
Assert.Equal("*", val.FirstOrDefault());
|
||||||
Assert.True(response.Headers.TryGetValues("Access-Control-Allow-Headers", out val));
|
Assert.True(response.Headers.TryGetValues("Access-Control-Allow-Headers", out val));
|
||||||
Assert.Equal("test", val.FirstOrDefault());
|
Assert.Equal("test", val.FirstOrDefault());
|
||||||
}
|
|
||||||
}).ToList())
|
}).ToList())
|
||||||
{
|
{
|
||||||
await req;
|
await req;
|
||||||
@ -1164,14 +1129,12 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.True(response2.Headers.TryGetValues("Access-Control-Allow-Origin", out var val2));
|
Assert.True(response2.Headers.TryGetValues("Access-Control-Allow-Origin", out var val2));
|
||||||
Assert.Equal("*", val2.FirstOrDefault());
|
Assert.Equal("*", val2.FirstOrDefault());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = LongRunningTestTimeout)]
|
[Fact(Timeout = LongRunningTestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task TestAccessBitpayAPI()
|
public async Task TestAccessBitpayAPI()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
Assert.False(user.BitPay.TestAccess(Facade.Merchant));
|
Assert.False(user.BitPay.TestAccess(Facade.Merchant));
|
||||||
@ -1241,16 +1204,15 @@ namespace BTCPayServer.Tests
|
|||||||
mess.Method = HttpMethod.Get;
|
mess.Method = HttpMethod.Get;
|
||||||
result = client.SendAsync(mess).GetAwaiter().GetResult();
|
result = client.SendAsync(mess).GetAwaiter().GetResult();
|
||||||
Assert.Equal(System.Net.HttpStatusCode.Unauthorized, result.StatusCode);
|
Assert.Equal(System.Net.HttpStatusCode.Unauthorized, result.StatusCode);
|
||||||
|
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = LongRunningTestTimeout)]
|
[Fact(Timeout = LongRunningTestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanUseAnyoneCanCreateInvoice()
|
public async Task CanUseAnyoneCanCreateInvoice()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
user.GrantAccess();
|
user.GrantAccess();
|
||||||
@ -1295,14 +1257,12 @@ namespace BTCPayServer.Tests
|
|||||||
});
|
});
|
||||||
Assert.Equal(200, (int)response.StatusCode);
|
Assert.Equal(200, (int)response.StatusCode);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = LongRunningTestTimeout)]
|
[Fact(Timeout = LongRunningTestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanTweakRate()
|
public async Task CanTweakRate()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
user.GrantAccess();
|
user.GrantAccess();
|
||||||
@ -1342,15 +1302,13 @@ namespace BTCPayServer.Tests
|
|||||||
var expectedCoins = invoice2.Price / expectedRate;
|
var expectedCoins = invoice2.Price / expectedRate;
|
||||||
Assert.True(invoice2.BtcPrice.Almost(Money.Coins(expectedCoins), 0.00001m));
|
Assert.True(invoice2.BtcPrice.Almost(Money.Coins(expectedCoins), 0.00001m));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[Fact(Timeout = LongRunningTestTimeout)]
|
[Fact(Timeout = LongRunningTestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanCreateTopupInvoices()
|
public async Task CanCreateTopupInvoices()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
user.GrantAccess();
|
user.GrantAccess();
|
||||||
@ -1371,7 +1329,6 @@ namespace BTCPayServer.Tests
|
|||||||
await AssertTopUpBtcPrice(tester, user, Money.Coins(v), 5000.0m * v, networkFeeMode);
|
await AssertTopUpBtcPrice(tester, user, Money.Coins(v), 5000.0m * v, networkFeeMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static async Task AssertTopUpBtcPrice(ServerTester tester, TestAccount user, Money btcSent, decimal expectedPriceWithoutNetworkFee, NetworkFeeMode networkFeeMode)
|
private static async Task AssertTopUpBtcPrice(ServerTester tester, TestAccount user, Money btcSent, decimal expectedPriceWithoutNetworkFee, NetworkFeeMode networkFeeMode)
|
||||||
{
|
{
|
||||||
@ -1432,8 +1389,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanModifyRates()
|
public async Task CanModifyRates()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
user.GrantAccess();
|
user.GrantAccess();
|
||||||
@ -1493,14 +1449,12 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.True(rateVm.ShowScripting);
|
Assert.True(rateVm.ShowScripting);
|
||||||
Assert.Contains("DOGE_X", rateVm.Script, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains("DOGE_X", rateVm.Script, StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanUseDefaultCurrency()
|
public async Task CanUseDefaultCurrency()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
await user.GrantAccessAsync(true);
|
await user.GrantAccessAsync(true);
|
||||||
@ -1534,14 +1488,12 @@ namespace BTCPayServer.Tests
|
|||||||
var walletSend = await walletController.WalletSend(new WalletId(user.StoreId, "BTC")).AssertViewModelAsync<WalletSendModel>();
|
var walletSend = await walletController.WalletSend(new WalletId(user.StoreId, "BTC")).AssertViewModelAsync<WalletSendModel>();
|
||||||
Assert.Equal("EUR", walletSend.Fiat);
|
Assert.Equal("EUR", walletSend.Fiat);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[Trait("Lightning", "Lightning")]
|
[Trait("Lightning", "Lightning")]
|
||||||
public async Task CanSetPaymentMethodLimits()
|
public async Task CanSetPaymentMethodLimits()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
tester.ActivateLightning();
|
tester.ActivateLightning();
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
@ -1612,14 +1564,12 @@ namespace BTCPayServer.Tests
|
|||||||
checkout = (await user.GetController<UIInvoiceController>().Checkout(invoice.Id)).AssertViewModel<PaymentModel>();
|
checkout = (await user.GetController<UIInvoiceController>().Checkout(invoice.Id)).AssertViewModel<PaymentModel>();
|
||||||
Assert.Equal(btcMethod, checkout.PaymentMethodId);
|
Assert.Equal(btcMethod, checkout.PaymentMethodId);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanSetUnifiedQrCode()
|
public async Task CanSetUnifiedQrCode()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
tester.ActivateLightning();
|
tester.ActivateLightning();
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
await tester.EnsureChannelsSetup();
|
await tester.EnsureChannelsSetup();
|
||||||
@ -1673,15 +1623,13 @@ namespace BTCPayServer.Tests
|
|||||||
var lightningFallback = paymentMethodSecond.InvoiceBitcoinUrlQR.Split(new[] { "&lightning=" }, StringSplitOptions.None)[1];
|
var lightningFallback = paymentMethodSecond.InvoiceBitcoinUrlQR.Split(new[] { "&lightning=" }, StringSplitOptions.None)[1];
|
||||||
Assert.True(lightningFallback.ToUpperInvariant() == lightningFallback);
|
Assert.True(lightningFallback.ToUpperInvariant() == lightningFallback);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = 60 * 2 * 1000)]
|
[Fact(Timeout = 60 * 2 * 1000)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
[Trait("Lightning", "Lightning")]
|
[Trait("Lightning", "Lightning")]
|
||||||
public async Task CanSetPaymentMethodLimitsLightning()
|
public async Task CanSetPaymentMethodLimitsLightning()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
tester.ActivateLightning();
|
tester.ActivateLightning();
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
await tester.EnsureChannelsSetup();
|
await tester.EnsureChannelsSetup();
|
||||||
@ -1735,14 +1683,12 @@ namespace BTCPayServer.Tests
|
|||||||
Currency = "USD"
|
Currency = "USD"
|
||||||
}, Facade.Merchant));
|
}, Facade.Merchant));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = LongRunningTestTimeout)]
|
[Fact(Timeout = LongRunningTestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task PosDataParser_ParsesCorrectly_Slower()
|
public async Task PosDataParser_ParsesCorrectly_Slower()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
user.GrantAccess();
|
user.GrantAccess();
|
||||||
@ -1785,7 +1731,6 @@ namespace BTCPayServer.Tests
|
|||||||
|
|
||||||
await Task.WhenAll(tasks);
|
await Task.WhenAll(tasks);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = LongRunningTestTimeout)]
|
[Fact(Timeout = LongRunningTestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
@ -1798,8 +1743,7 @@ namespace BTCPayServer.Tests
|
|||||||
return decimal.Parse(match.Groups[1].Value.Trim(), CultureInfo.InvariantCulture);
|
return decimal.Parse(match.Groups[1].Value.Trim(), CultureInfo.InvariantCulture);
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
await user.GrantAccessAsync();
|
await user.GrantAccessAsync();
|
||||||
@ -1864,14 +1808,12 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Contains("\"InvoiceDue\": 0", pay3str);
|
Assert.Contains("\"InvoiceDue\": 0", pay3str);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = LongRunningTestTimeout)]
|
[Fact(Timeout = LongRunningTestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanChangeNetworkFeeMode()
|
public async Task CanChangeNetworkFeeMode()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
var btc = new PaymentMethodId("BTC", PaymentTypes.BTCLike);
|
var btc = new PaymentMethodId("BTC", PaymentTypes.BTCLike);
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
@ -1955,14 +1897,12 @@ namespace BTCPayServer.Tests
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = LongRunningTestTimeout)]
|
[Fact(Timeout = LongRunningTestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanExportInvoicesCsv()
|
public async Task CanExportInvoicesCsv()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
await user.GrantAccessAsync();
|
await user.GrantAccessAsync();
|
||||||
@ -1996,14 +1936,12 @@ namespace BTCPayServer.Tests
|
|||||||
paidresult.Content);
|
paidresult.Content);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = LongRunningTestTimeout)]
|
[Fact(Timeout = LongRunningTestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanCreateAndDeleteApps()
|
public async Task CanCreateAndDeleteApps()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
await user.GrantAccessAsync();
|
await user.GrantAccessAsync();
|
||||||
@ -2036,15 +1974,13 @@ namespace BTCPayServer.Tests
|
|||||||
appList = Assert.IsType<ListAppsViewModel>(Assert.IsType<ViewResult>(apps.ListApps(user.StoreId).Result).Model);
|
appList = Assert.IsType<ListAppsViewModel>(Assert.IsType<ViewResult>(apps.ListApps(user.StoreId).Result).Model);
|
||||||
Assert.Empty(appList.Apps);
|
Assert.Empty(appList.Apps);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = LongRunningTestTimeout)]
|
[Fact(Timeout = LongRunningTestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
[Trait("Lightning", "Lightning")]
|
[Trait("Lightning", "Lightning")]
|
||||||
public async Task CanCreateStrangeInvoice()
|
public async Task CanCreateStrangeInvoice()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
tester.ActivateLightning();
|
tester.ActivateLightning();
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
@ -2131,14 +2067,12 @@ namespace BTCPayServer.Tests
|
|||||||
var zeroInvoicePM = await greenfield.GetInvoicePaymentMethods(user.StoreId, zeroInvoice.Id);
|
var zeroInvoicePM = await greenfield.GetInvoicePaymentMethods(user.StoreId, zeroInvoice.Id);
|
||||||
Assert.Empty(zeroInvoicePM);
|
Assert.Empty(zeroInvoicePM);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = LongRunningTestTimeout)]
|
[Fact(Timeout = LongRunningTestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task InvoiceFlowThroughDifferentStatesCorrectly()
|
public async Task InvoiceFlowThroughDifferentStatesCorrectly()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
user.GrantAccess();
|
user.GrantAccess();
|
||||||
@ -2335,14 +2269,12 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.StartsWith(txId.ToString(), c.Payment.Id);
|
Assert.StartsWith(txId.ToString(), c.Payment.Id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = LongRunningTestTimeout)]
|
[Fact(Timeout = LongRunningTestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CheckLogsRoute()
|
public async Task CheckLogsRoute()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
user.GrantAccess();
|
user.GrantAccess();
|
||||||
@ -2352,14 +2284,12 @@ namespace BTCPayServer.Tests
|
|||||||
var vm = Assert.IsType<LogsViewModel>(
|
var vm = Assert.IsType<LogsViewModel>(
|
||||||
Assert.IsType<ViewResult>(await serverController.LogsView()).Model);
|
Assert.IsType<ViewResult>(await serverController.LogsView()).Model);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = LongRunningTestTimeout)]
|
[Fact(Timeout = LongRunningTestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanLoginWithNoSecondaryAuthSystemsOrRequestItWhenAdded()
|
public async Task CanLoginWithNoSecondaryAuthSystemsOrRequestItWhenAdded()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
user.GrantAccess();
|
user.GrantAccess();
|
||||||
@ -2427,14 +2357,12 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Null(vm.LoginWith2FaViewModel);
|
Assert.Null(vm.LoginWith2FaViewModel);
|
||||||
Assert.NotNull(vm.LoginWithFido2ViewModel);
|
Assert.NotNull(vm.LoginWithFido2ViewModel);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = LongRunningTestTimeout)]
|
[Fact(Timeout = LongRunningTestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async void CheckOnionlocationForNonOnionHtmlRequests()
|
public async void CheckOnionlocationForNonOnionHtmlRequests()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var url = tester.PayTester.ServerUri.AbsoluteUri;
|
var url = tester.PayTester.ServerUri.AbsoluteUri;
|
||||||
|
|
||||||
@ -2455,7 +2383,6 @@ namespace BTCPayServer.Tests
|
|||||||
otherResponse.EnsureSuccessStatusCode();
|
otherResponse.EnsureSuccessStatusCode();
|
||||||
Assert.False(otherResponse.Headers.Contains("Onion-Location"));
|
Assert.False(otherResponse.Headers.Contains("Onion-Location"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static bool IsMapped(Invoice invoice, ApplicationDbContext ctx)
|
private static bool IsMapped(Invoice invoice, ApplicationDbContext ctx)
|
||||||
{
|
{
|
||||||
@ -2479,8 +2406,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanCheckForNewVersion()
|
public async Task CanCheckForNewVersion()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester(newDb: true))
|
using var tester = CreateServerTester(newDb: true);
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
|
|
||||||
var acc = tester.NewAccount();
|
var acc = tester.NewAccount();
|
||||||
@ -2519,14 +2445,12 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Equal($"https://github.com/btcpayserver/btcpayserver/releases/tag/v{newVersion}", fn.ActionLink);
|
Assert.Equal($"https://github.com/btcpayserver/btcpayserver/releases/tag/v{newVersion}", fn.ActionLink);
|
||||||
Assert.False(fn.Seen);
|
Assert.False(fn.Seen);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(Timeout = LongRunningTestTimeout)]
|
[Fact(Timeout = LongRunningTestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanDoLightningInternalNodeMigration()
|
public async Task CanDoLightningInternalNodeMigration()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester(newDb: true))
|
using var tester = CreateServerTester(newDb: true);
|
||||||
{
|
|
||||||
tester.ActivateLightning(LightningConnectionType.CLightning);
|
tester.ActivateLightning(LightningConnectionType.CLightning);
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var acc = tester.NewAccount();
|
var acc = tester.NewAccount();
|
||||||
@ -2597,15 +2521,13 @@ namespace BTCPayServer.Tests
|
|||||||
lnMethod = store.GetSupportedPaymentMethods(tester.NetworkProvider).OfType<LightningSupportedPaymentMethod>().First();
|
lnMethod = store.GetSupportedPaymentMethods(tester.NetworkProvider).OfType<LightningSupportedPaymentMethod>().First();
|
||||||
Assert.True(lnMethod.IsInternalNode);
|
Assert.True(lnMethod.IsInternalNode);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[Fact(Timeout = LongRunningTestTimeout)]
|
[Fact(Timeout = LongRunningTestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanDoInvoiceMigrations()
|
public async Task CanDoInvoiceMigrations()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester(newDb: true))
|
using var tester = CreateServerTester(newDb: true);
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
|
|
||||||
var acc = tester.NewAccount();
|
var acc = tester.NewAccount();
|
||||||
@ -2668,8 +2590,6 @@ namespace BTCPayServer.Tests
|
|||||||
method is DerivationSchemeSettings dss &&
|
method is DerivationSchemeSettings dss &&
|
||||||
method.PaymentId == new PaymentMethodId("BTC", BitcoinPaymentType.Instance) &&
|
method.PaymentId == new PaymentMethodId("BTC", BitcoinPaymentType.Instance) &&
|
||||||
dss.AccountKeyPath == new KeyPath("44'/0'/0'"));
|
dss.AccountKeyPath == new KeyPath("44'/0'/0'"));
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task RestartMigration(ServerTester tester)
|
private static async Task RestartMigration(ServerTester tester)
|
||||||
@ -2685,8 +2605,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task EmailSenderTests()
|
public async Task EmailSenderTests()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester(newDb: true))
|
using var tester = CreateServerTester(newDb: true);
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
|
|
||||||
var acc = tester.NewAccount();
|
var acc = tester.NewAccount();
|
||||||
@ -2725,16 +2644,13 @@ namespace BTCPayServer.Tests
|
|||||||
}), ""));
|
}), ""));
|
||||||
|
|
||||||
Assert.Equal("store@store.com", (await Assert.IsType<StoreEmailSender>(await emailSenderFactory.GetEmailSender(acc.StoreId)).GetEmailSettings()).Login);
|
Assert.Equal("store@store.com", (await Assert.IsType<StoreEmailSender>(await emailSenderFactory.GetEmailSender(acc.StoreId)).GetEmailSettings()).Login);
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact(Timeout = TestUtils.TestTimeout)]
|
[Fact(Timeout = TestUtils.TestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task CanConfigureStorage()
|
public async Task CanConfigureStorage()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
user.GrantAccess();
|
user.GrantAccess();
|
||||||
@ -2810,14 +2726,12 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.True(viewFilesViewModel.StorageConfigured);
|
Assert.True(viewFilesViewModel.StorageConfigured);
|
||||||
Assert.Empty(viewFilesViewModel.Files);
|
Assert.Empty(viewFilesViewModel.Files);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async void CanUseLocalProviderFiles()
|
public async void CanUseLocalProviderFiles()
|
||||||
{
|
{
|
||||||
using (var tester = CreateServerTester())
|
using var tester = CreateServerTester();
|
||||||
{
|
|
||||||
await tester.StartAsync();
|
await tester.StartAsync();
|
||||||
var user = tester.NewAccount();
|
var user = tester.NewAccount();
|
||||||
user.GrantAccess();
|
user.GrantAccess();
|
||||||
@ -2838,7 +2752,6 @@ namespace BTCPayServer.Tests
|
|||||||
|
|
||||||
await CanUploadRemoveFiles(controller);
|
await CanUploadRemoveFiles(controller);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
internal static async Task CanUploadRemoveFiles(UIServerController controller)
|
internal static async Task CanUploadRemoveFiles(UIServerController controller)
|
||||||
{
|
{
|
||||||
|
@ -16,8 +16,7 @@ namespace BTCPayServer.Tests
|
|||||||
{
|
{
|
||||||
lock (_portLock)
|
lock (_portLock)
|
||||||
{
|
{
|
||||||
using (var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
using var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||||
{
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -37,7 +36,6 @@ namespace BTCPayServer.Tests
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// http://stackoverflow.com/a/14933880/2061103
|
// http://stackoverflow.com/a/14933880/2061103
|
||||||
public static void DeleteDirectory(string destinationDir)
|
public static void DeleteDirectory(string destinationDir)
|
||||||
|
@ -871,12 +871,10 @@ namespace BTCPayServer.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var sshClient = await _Options.SSHSettings.ConnectAsync())
|
using var sshClient = await _Options.SSHSettings.ConnectAsync();
|
||||||
{
|
|
||||||
var result = await sshClient.RunBash("cat ~/.ssh/authorized_keys", TimeSpan.FromSeconds(10));
|
var result = await sshClient.RunBash("cat ~/.ssh/authorized_keys", TimeSpan.FromSeconds(10));
|
||||||
vm.SSHKeyFileContent = result.Output;
|
vm.SSHKeyFileContent = result.Output;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
return View(vm);
|
return View(vm);
|
||||||
@ -1106,18 +1104,14 @@ namespace BTCPayServer.Controllers
|
|||||||
return NotFound();
|
return NotFound();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var fileStream = new FileStream(
|
using var fileStream = new FileStream(
|
||||||
fi.FullName,
|
fi.FullName,
|
||||||
FileMode.Open,
|
FileMode.Open,
|
||||||
FileAccess.Read,
|
FileAccess.Read,
|
||||||
FileShare.ReadWrite))
|
FileShare.ReadWrite);
|
||||||
{
|
using var reader = new StreamReader(fileStream);
|
||||||
using (var reader = new StreamReader(fileStream))
|
|
||||||
{
|
|
||||||
vm.Log = await reader.ReadToEndAsync();
|
vm.Log = await reader.ReadToEndAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
return NotFound();
|
return NotFound();
|
||||||
|
@ -810,11 +810,9 @@ namespace BTCPayServer.Controllers
|
|||||||
|
|
||||||
private async Task<string> ReadAllText(IFormFile file)
|
private async Task<string> ReadAllText(IFormFile file)
|
||||||
{
|
{
|
||||||
using (var stream = new StreamReader(file.OpenReadStream()))
|
using var stream = new StreamReader(file.OpenReadStream());
|
||||||
{
|
|
||||||
return await stream.ReadToEndAsync();
|
return await stream.ReadToEndAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private string WalletWarning(bool isHotWallet, string info)
|
private string WalletWarning(bool isHotWallet, string info)
|
||||||
{
|
{
|
||||||
|
@ -125,13 +125,11 @@ namespace BTCPayServer
|
|||||||
{
|
{
|
||||||
if (webSocket.State == WebSocketState.Open)
|
if (webSocket.State == WebSocketState.Open)
|
||||||
{
|
{
|
||||||
using (CancellationTokenSource cts = new CancellationTokenSource())
|
using CancellationTokenSource cts = new CancellationTokenSource();
|
||||||
{
|
|
||||||
cts.CancelAfter(5000);
|
cts.CancelAfter(5000);
|
||||||
await webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Closing", cts.Token);
|
await webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Closing", cts.Token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch { }
|
catch { }
|
||||||
finally { try { webSocket.Dispose(); } catch { } }
|
finally { try { webSocket.Dispose(); } catch { } }
|
||||||
}
|
}
|
||||||
|
@ -40,13 +40,11 @@ retry:
|
|||||||
Logs.Configuration.LogInformation($"SSH settings detected, testing connection to {_options.SSHSettings.Username}@{_options.SSHSettings.Server} on port {_options.SSHSettings.Port} ...");
|
Logs.Configuration.LogInformation($"SSH settings detected, testing connection to {_options.SSHSettings.Username}@{_options.SSHSettings.Server} on port {_options.SSHSettings.Port} ...");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var connection = await _options.SSHSettings.ConnectAsync(_cancellationTokenSource.Token))
|
using var connection = await _options.SSHSettings.ConnectAsync(_cancellationTokenSource.Token);
|
||||||
{
|
|
||||||
await connection.DisconnectAsync(_cancellationTokenSource.Token);
|
await connection.DisconnectAsync(_cancellationTokenSource.Token);
|
||||||
Logs.Configuration.LogInformation($"SSH connection succeeded");
|
Logs.Configuration.LogInformation($"SSH connection succeeded");
|
||||||
canUseSSH = true;
|
canUseSSH = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Renci.SshNet.Common.SshAuthenticationException ex)
|
catch (Renci.SshNet.Common.SshAuthenticationException ex)
|
||||||
{
|
{
|
||||||
Logs.Configuration.LogWarning($"SSH invalid credentials ({ex.Message})");
|
Logs.Configuration.LogWarning($"SSH invalid credentials ({ex.Message})");
|
||||||
|
@ -59,13 +59,11 @@ namespace BTCPayServer.HostedServices
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
using (var delayCancel = CancellationTokenSource.CreateLinkedTokenSource(Cancellation))
|
using var delayCancel = CancellationTokenSource.CreateLinkedTokenSource(Cancellation);
|
||||||
{
|
|
||||||
var delay = Task.Delay(Period, delayCancel.Token);
|
var delay = Task.Delay(Period, delayCancel.Token);
|
||||||
var changed = SettingsRepository.WaitSettingsChanged<DynamicDnsSettings>(Cancellation);
|
var changed = SettingsRepository.WaitSettingsChanged<DynamicDnsSettings>(Cancellation);
|
||||||
await Task.WhenAny(delay, changed);
|
await Task.WhenAny(delay, changed);
|
||||||
delayCancel.Cancel();
|
delayCancel.Cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -463,8 +463,7 @@ retry:
|
|||||||
private async Task ConvertConvertWalletKeyPathRoots()
|
private async Task ConvertConvertWalletKeyPathRoots()
|
||||||
{
|
{
|
||||||
bool save = false;
|
bool save = false;
|
||||||
using (var ctx = _DBContextFactory.CreateContext())
|
using var ctx = _DBContextFactory.CreateContext();
|
||||||
{
|
|
||||||
foreach (var store in await ctx.Stores.AsQueryable().ToArrayAsync())
|
foreach (var store in await ctx.Stores.AsQueryable().ToArrayAsync())
|
||||||
{
|
{
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
@ -496,12 +495,10 @@ retry:
|
|||||||
if (save)
|
if (save)
|
||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private async Task ConvertCrowdfundOldSettings()
|
private async Task ConvertCrowdfundOldSettings()
|
||||||
{
|
{
|
||||||
using (var ctx = _DBContextFactory.CreateContext())
|
using var ctx = _DBContextFactory.CreateContext();
|
||||||
{
|
|
||||||
foreach (var app in await ctx.Apps.Where(a => a.AppType == "Crowdfund").ToArrayAsync())
|
foreach (var app in await ctx.Apps.Where(a => a.AppType == "Crowdfund").ToArrayAsync())
|
||||||
{
|
{
|
||||||
var settings = app.GetSettings<Services.Apps.CrowdfundSettings>();
|
var settings = app.GetSettings<Services.Apps.CrowdfundSettings>();
|
||||||
@ -514,12 +511,10 @@ retry:
|
|||||||
}
|
}
|
||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private async Task MigratePaymentMethodCriteria()
|
private async Task MigratePaymentMethodCriteria()
|
||||||
{
|
{
|
||||||
using (var ctx = _DBContextFactory.CreateContext())
|
using var ctx = _DBContextFactory.CreateContext();
|
||||||
{
|
|
||||||
foreach (var store in await ctx.Stores.AsQueryable().ToArrayAsync())
|
foreach (var store in await ctx.Stores.AsQueryable().ToArrayAsync())
|
||||||
{
|
{
|
||||||
var blob = store.GetStoreBlob();
|
var blob = store.GetStoreBlob();
|
||||||
@ -570,12 +565,10 @@ retry:
|
|||||||
|
|
||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private async Task ConvertNetworkFeeProperty()
|
private async Task ConvertNetworkFeeProperty()
|
||||||
{
|
{
|
||||||
using (var ctx = _DBContextFactory.CreateContext())
|
using var ctx = _DBContextFactory.CreateContext();
|
||||||
{
|
|
||||||
foreach (var store in await ctx.Stores.AsQueryable().ToArrayAsync())
|
foreach (var store in await ctx.Stores.AsQueryable().ToArrayAsync())
|
||||||
{
|
{
|
||||||
var blob = store.GetStoreBlob();
|
var blob = store.GetStoreBlob();
|
||||||
@ -593,12 +586,10 @@ retry:
|
|||||||
}
|
}
|
||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private async Task ConvertMultiplierToSpread()
|
private async Task ConvertMultiplierToSpread()
|
||||||
{
|
{
|
||||||
using (var ctx = _DBContextFactory.CreateContext())
|
using var ctx = _DBContextFactory.CreateContext();
|
||||||
{
|
|
||||||
foreach (var store in await ctx.Stores.AsQueryable().ToArrayAsync())
|
foreach (var store in await ctx.Stores.AsQueryable().ToArrayAsync())
|
||||||
{
|
{
|
||||||
var blob = store.GetStoreBlob();
|
var blob = store.GetStoreBlob();
|
||||||
@ -621,7 +612,6 @@ retry:
|
|||||||
}
|
}
|
||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public class RateRule_Obsolete
|
public class RateRule_Obsolete
|
||||||
{
|
{
|
||||||
@ -646,8 +636,7 @@ retry:
|
|||||||
|
|
||||||
private async Task DeprecatedLightningConnectionStringCheck()
|
private async Task DeprecatedLightningConnectionStringCheck()
|
||||||
{
|
{
|
||||||
using (var ctx = _DBContextFactory.CreateContext())
|
using var ctx = _DBContextFactory.CreateContext();
|
||||||
{
|
|
||||||
foreach (var store in await ctx.Stores.AsQueryable().ToArrayAsync())
|
foreach (var store in await ctx.Stores.AsQueryable().ToArrayAsync())
|
||||||
{
|
{
|
||||||
foreach (var method in store.GetSupportedPaymentMethods(_NetworkProvider).OfType<Payments.Lightning.LightningSupportedPaymentMethod>())
|
foreach (var method in store.GetSupportedPaymentMethods(_NetworkProvider).OfType<Payments.Lightning.LightningSupportedPaymentMethod>())
|
||||||
@ -663,5 +652,4 @@ retry:
|
|||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,8 @@ namespace BTCPayServer.Hosting
|
|||||||
{
|
{
|
||||||
_BundlesByName = new Lazy<Dictionary<string, Bundle>>(() =>
|
_BundlesByName = new Lazy<Dictionary<string, Bundle>>(() =>
|
||||||
{
|
{
|
||||||
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("BTCPayServer.bundleconfig.json"))
|
using var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("BTCPayServer.bundleconfig.json");
|
||||||
using (var reader = new StreamReader(stream, Encoding.UTF8))
|
using var reader = new StreamReader(stream, Encoding.UTF8);
|
||||||
{
|
|
||||||
var content = reader.ReadToEnd();
|
var content = reader.ReadToEnd();
|
||||||
return JArray.Parse(content).OfType<JObject>()
|
return JArray.Parse(content).OfType<JObject>()
|
||||||
.Select(jobj => new Bundle()
|
.Select(jobj => new Bundle()
|
||||||
@ -30,7 +29,6 @@ namespace BTCPayServer.Hosting
|
|||||||
Name = jobj.Property("name", StringComparison.OrdinalIgnoreCase)?.Value.Value<string>() ?? jobj.Property("outputFileName", StringComparison.OrdinalIgnoreCase).Value.Value<string>(),
|
Name = jobj.Property("name", StringComparison.OrdinalIgnoreCase)?.Value.Value<string>() ?? jobj.Property("outputFileName", StringComparison.OrdinalIgnoreCase).Value.Value<string>(),
|
||||||
OutputFileUrl = Path.Combine(hosting.ContentRootPath, jobj.Property("outputFileName", StringComparison.OrdinalIgnoreCase).Value.Value<string>())
|
OutputFileUrl = Path.Combine(hosting.ContentRootPath, jobj.Property("outputFileName", StringComparison.OrdinalIgnoreCase).Value.Value<string>())
|
||||||
}).ToDictionary(o => o.Name, o => o);
|
}).ToDictionary(o => o.Name, o => o);
|
||||||
}
|
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -43,10 +43,8 @@ namespace BTCPayServer.Models
|
|||||||
}
|
}
|
||||||
context.HttpContext.Response.Headers.Add("Content-Type", new Microsoft.Extensions.Primitives.StringValues("application/json"));
|
context.HttpContext.Response.Headers.Add("Content-Type", new Microsoft.Extensions.Primitives.StringValues("application/json"));
|
||||||
var str = JsonConvert.SerializeObject(jobj);
|
var str = JsonConvert.SerializeObject(jobj);
|
||||||
await using (var writer = new StreamWriter(context.HttpContext.Response.Body, new UTF8Encoding(false), 1024 * 10, true))
|
await using var writer = new StreamWriter(context.HttpContext.Response.Body, new UTF8Encoding(false), 1024 * 10, true);
|
||||||
{
|
|
||||||
await writer.WriteAsync(str);
|
await writer.WriteAsync(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -130,8 +130,7 @@ namespace BTCPayServer.Payments.Lightning
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var cts = new CancellationTokenSource(LIGHTNING_TIMEOUT))
|
using var cts = new CancellationTokenSource(LIGHTNING_TIMEOUT);
|
||||||
{
|
|
||||||
var client = CreateLightningClient(supportedPaymentMethod, network);
|
var client = CreateLightningClient(supportedPaymentMethod, network);
|
||||||
LightningNodeInformation info;
|
LightningNodeInformation info;
|
||||||
try
|
try
|
||||||
@ -166,7 +165,6 @@ namespace BTCPayServer.Payments.Lightning
|
|||||||
|
|
||||||
return nodeInfo;
|
return nodeInfo;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception e) when (!throws)
|
catch (Exception e) when (!throws)
|
||||||
{
|
{
|
||||||
invoiceLogs.Write($"NodeInfo failed to be fetched: {e.Message}", InvoiceEventData.EventSeverity.Error);
|
invoiceLogs.Write($"NodeInfo failed to be fetched: {e.Message}", InvoiceEventData.EventSeverity.Error);
|
||||||
@ -197,9 +195,7 @@ namespace BTCPayServer.Payments.Lightning
|
|||||||
if (!Utils.TryParseEndpoint(nodeInfo.Host, nodeInfo.Port, out var endpoint))
|
if (!Utils.TryParseEndpoint(nodeInfo.Host, nodeInfo.Port, out var endpoint))
|
||||||
throw new PaymentMethodUnavailableException($"Could not parse the endpoint {nodeInfo.Host}");
|
throw new PaymentMethodUnavailableException($"Could not parse the endpoint {nodeInfo.Host}");
|
||||||
|
|
||||||
using (var tcp = await _socketFactory.ConnectAsync(endpoint, cancellation))
|
using var tcp = await _socketFactory.ConnectAsync(endpoint, cancellation);
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -458,8 +458,7 @@ namespace BTCPayServer.Payments.Lightning
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var lightningClient = _lightningClientFactory.Create(ConnectionString, _network);
|
var lightningClient = _lightningClientFactory.Create(ConnectionString, _network);
|
||||||
using (var session = await lightningClient.Listen(cancellation))
|
using var session = await lightningClient.Listen(cancellation);
|
||||||
{
|
|
||||||
// Just in case the payment arrived after our last poll but before we listened.
|
// Just in case the payment arrived after our last poll but before we listened.
|
||||||
await PollAllListenedInvoices(cancellation);
|
await PollAllListenedInvoices(cancellation);
|
||||||
if (_ErrorAlreadyLogged)
|
if (_ErrorAlreadyLogged)
|
||||||
@ -493,7 +492,6 @@ namespace BTCPayServer.Payments.Lightning
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception ex) when (!cancellation.IsCancellationRequested && !_ErrorAlreadyLogged)
|
catch (Exception ex) when (!cancellation.IsCancellationRequested && !_ErrorAlreadyLogged)
|
||||||
{
|
{
|
||||||
_ErrorAlreadyLogged = true;
|
_ErrorAlreadyLogged = true;
|
||||||
|
@ -29,22 +29,18 @@ namespace BTCPayServer.Security.Bitpay
|
|||||||
{
|
{
|
||||||
if (sin == null)
|
if (sin == null)
|
||||||
return Array.Empty<BitTokenEntity>();
|
return Array.Empty<BitTokenEntity>();
|
||||||
using (var ctx = _Factory.CreateContext())
|
using var ctx = _Factory.CreateContext();
|
||||||
{
|
|
||||||
return (await ctx.PairedSINData.Where(p => p.SIN == sin)
|
return (await ctx.PairedSINData.Where(p => p.SIN == sin)
|
||||||
.ToArrayAsync())
|
.ToArrayAsync())
|
||||||
.Select(p => CreateTokenEntity(p))
|
.Select(p => CreateTokenEntity(p))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<String> GetStoreIdFromAPIKey(string apiKey)
|
public async Task<String> GetStoreIdFromAPIKey(string apiKey)
|
||||||
{
|
{
|
||||||
using (var ctx = _Factory.CreateContext())
|
using var ctx = _Factory.CreateContext();
|
||||||
{
|
|
||||||
return await ctx.ApiKeys.Where(o => o.Id == apiKey).Select(o => o.StoreId).FirstOrDefaultAsync();
|
return await ctx.ApiKeys.Where(o => o.Id == apiKey).Select(o => o.StoreId).FirstOrDefaultAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task GenerateLegacyAPIKey(string storeId)
|
public async Task GenerateLegacyAPIKey(string storeId)
|
||||||
{
|
{
|
||||||
@ -57,8 +53,7 @@ namespace BTCPayServer.Security.Bitpay
|
|||||||
generated[i] = chars[(int)(RandomUtils.GetUInt32() % generated.Length)];
|
generated[i] = chars[(int)(RandomUtils.GetUInt32() % generated.Length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var ctx = _Factory.CreateContext())
|
using var ctx = _Factory.CreateContext();
|
||||||
{
|
|
||||||
var existing = await ctx.ApiKeys.Where(o => o.StoreId == storeId && o.Type == APIKeyType.Legacy).ToListAsync();
|
var existing = await ctx.ApiKeys.Where(o => o.StoreId == storeId && o.Type == APIKeyType.Legacy).ToListAsync();
|
||||||
if (existing.Any())
|
if (existing.Any())
|
||||||
{
|
{
|
||||||
@ -67,7 +62,6 @@ namespace BTCPayServer.Security.Bitpay
|
|||||||
ctx.ApiKeys.Add(new APIKeyData() { Id = new string(generated), StoreId = storeId });
|
ctx.ApiKeys.Add(new APIKeyData() { Id = new string(generated), StoreId = storeId });
|
||||||
await ctx.SaveChangesAsync().ConfigureAwait(false);
|
await ctx.SaveChangesAsync().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task RevokeLegacyAPIKeys(string storeId)
|
public async Task RevokeLegacyAPIKeys(string storeId)
|
||||||
{
|
{
|
||||||
@ -77,20 +71,16 @@ namespace BTCPayServer.Security.Bitpay
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var ctx = _Factory.CreateContext())
|
using var ctx = _Factory.CreateContext();
|
||||||
{
|
|
||||||
ctx.ApiKeys.RemoveRange(keys.Select(s => new APIKeyData() { Id = s }));
|
ctx.ApiKeys.RemoveRange(keys.Select(s => new APIKeyData() { Id = s }));
|
||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<string[]> GetLegacyAPIKeys(string storeId)
|
public async Task<string[]> GetLegacyAPIKeys(string storeId)
|
||||||
{
|
{
|
||||||
using (var ctx = _Factory.CreateContext())
|
using var ctx = _Factory.CreateContext();
|
||||||
{
|
|
||||||
return await ctx.ApiKeys.Where(o => o.StoreId == storeId && o.Type == APIKeyType.Legacy).Select(c => c.Id).ToArrayAsync();
|
return await ctx.ApiKeys.Where(o => o.StoreId == storeId && o.Type == APIKeyType.Legacy).Select(c => c.Id).ToArrayAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private BitTokenEntity CreateTokenEntity(PairedSINData data)
|
private BitTokenEntity CreateTokenEntity(PairedSINData data)
|
||||||
{
|
{
|
||||||
@ -131,19 +121,16 @@ namespace BTCPayServer.Security.Bitpay
|
|||||||
|
|
||||||
public async Task<PairingCodeEntity> UpdatePairingCode(PairingCodeEntity pairingCodeEntity)
|
public async Task<PairingCodeEntity> UpdatePairingCode(PairingCodeEntity pairingCodeEntity)
|
||||||
{
|
{
|
||||||
using (var ctx = _Factory.CreateContext())
|
using var ctx = _Factory.CreateContext();
|
||||||
{
|
|
||||||
var pairingCode = await ctx.PairingCodes.FindAsync(pairingCodeEntity.Id);
|
var pairingCode = await ctx.PairingCodes.FindAsync(pairingCodeEntity.Id);
|
||||||
pairingCode.Label = pairingCodeEntity.Label;
|
pairingCode.Label = pairingCodeEntity.Label;
|
||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
return CreatePairingCodeEntity(pairingCode);
|
return CreatePairingCodeEntity(pairingCode);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<PairingResult> PairWithStoreAsync(string pairingCodeId, string storeId)
|
public async Task<PairingResult> PairWithStoreAsync(string pairingCodeId, string storeId)
|
||||||
{
|
{
|
||||||
using (var ctx = _Factory.CreateContext())
|
using var ctx = _Factory.CreateContext();
|
||||||
{
|
|
||||||
var pairingCode = await ctx.PairingCodes.FindAsync(pairingCodeId);
|
var pairingCode = await ctx.PairingCodes.FindAsync(pairingCodeId);
|
||||||
if (pairingCode == null || pairingCode.Expiration < DateTimeOffset.UtcNow)
|
if (pairingCode == null || pairingCode.Expiration < DateTimeOffset.UtcNow)
|
||||||
return PairingResult.Expired;
|
return PairingResult.Expired;
|
||||||
@ -152,12 +139,10 @@ namespace BTCPayServer.Security.Bitpay
|
|||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<PairingResult> PairWithSINAsync(string pairingCodeId, string sin)
|
public async Task<PairingResult> PairWithSINAsync(string pairingCodeId, string sin)
|
||||||
{
|
{
|
||||||
using (var ctx = _Factory.CreateContext())
|
using var ctx = _Factory.CreateContext();
|
||||||
{
|
|
||||||
var pairingCode = await ctx.PairingCodes.FindAsync(pairingCodeId);
|
var pairingCode = await ctx.PairingCodes.FindAsync(pairingCodeId);
|
||||||
if (pairingCode == null || pairingCode.Expiration < DateTimeOffset.UtcNow)
|
if (pairingCode == null || pairingCode.Expiration < DateTimeOffset.UtcNow)
|
||||||
return PairingResult.Expired;
|
return PairingResult.Expired;
|
||||||
@ -166,7 +151,6 @@ namespace BTCPayServer.Security.Bitpay
|
|||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private async Task<PairingResult> ActivateIfComplete(ApplicationDbContext ctx, PairingCodeData pairingCode)
|
private async Task<PairingResult> ActivateIfComplete(ApplicationDbContext ctx, PairingCodeData pairingCode)
|
||||||
@ -195,21 +179,17 @@ namespace BTCPayServer.Security.Bitpay
|
|||||||
|
|
||||||
public async Task<BitTokenEntity[]> GetTokensByStoreIdAsync(string storeId)
|
public async Task<BitTokenEntity[]> GetTokensByStoreIdAsync(string storeId)
|
||||||
{
|
{
|
||||||
using (var ctx = _Factory.CreateContext())
|
using var ctx = _Factory.CreateContext();
|
||||||
{
|
|
||||||
return (await ctx.PairedSINData.Where(p => p.StoreDataId == storeId).ToListAsync())
|
return (await ctx.PairedSINData.Where(p => p.StoreDataId == storeId).ToListAsync())
|
||||||
.Select(c => CreateTokenEntity(c))
|
.Select(c => CreateTokenEntity(c))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<PairingCodeEntity> GetPairingAsync(string pairingCode)
|
public async Task<PairingCodeEntity> GetPairingAsync(string pairingCode)
|
||||||
{
|
{
|
||||||
using (var ctx = _Factory.CreateContext())
|
using var ctx = _Factory.CreateContext();
|
||||||
{
|
|
||||||
return CreatePairingCodeEntity(await ctx.PairingCodes.FindAsync(pairingCode));
|
return CreatePairingCodeEntity(await ctx.PairingCodes.FindAsync(pairingCode));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private PairingCodeEntity CreatePairingCodeEntity(PairingCodeData data)
|
private PairingCodeEntity CreatePairingCodeEntity(PairingCodeData data)
|
||||||
{
|
{
|
||||||
@ -229,8 +209,7 @@ namespace BTCPayServer.Security.Bitpay
|
|||||||
|
|
||||||
public async Task<bool> DeleteToken(string tokenId)
|
public async Task<bool> DeleteToken(string tokenId)
|
||||||
{
|
{
|
||||||
using (var ctx = _Factory.CreateContext())
|
using var ctx = _Factory.CreateContext();
|
||||||
{
|
|
||||||
var token = await ctx.PairedSINData.FindAsync(tokenId);
|
var token = await ctx.PairedSINData.FindAsync(tokenId);
|
||||||
if (token == null)
|
if (token == null)
|
||||||
return false;
|
return false;
|
||||||
@ -238,18 +217,15 @@ namespace BTCPayServer.Security.Bitpay
|
|||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<BitTokenEntity> GetToken(string tokenId)
|
public async Task<BitTokenEntity> GetToken(string tokenId)
|
||||||
{
|
{
|
||||||
using (var ctx = _Factory.CreateContext())
|
using var ctx = _Factory.CreateContext();
|
||||||
{
|
|
||||||
var token = await ctx.PairedSINData.FindAsync(tokenId);
|
var token = await ctx.PairedSINData.FindAsync(tokenId);
|
||||||
if (token == null)
|
if (token == null)
|
||||||
return null;
|
return null;
|
||||||
return CreateTokenEntity(token);
|
return CreateTokenEntity(token);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,7 @@ namespace BTCPayServer.Security.Greenfield
|
|||||||
|
|
||||||
public async Task<List<APIKeyData>> GetKeys(APIKeyQuery query)
|
public async Task<List<APIKeyData>> GetKeys(APIKeyQuery query)
|
||||||
{
|
{
|
||||||
using (var context = _applicationDbContextFactory.CreateContext())
|
using var context = _applicationDbContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var queryable = context.ApiKeys.AsQueryable();
|
var queryable = context.ApiKeys.AsQueryable();
|
||||||
if (query != null)
|
if (query != null)
|
||||||
{
|
{
|
||||||
@ -41,7 +40,6 @@ namespace BTCPayServer.Security.Greenfield
|
|||||||
|
|
||||||
return await queryable.ToListAsync();
|
return await queryable.ToListAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task CreateKey(APIKeyData key)
|
public async Task CreateKey(APIKeyData key)
|
||||||
{
|
{
|
||||||
@ -50,12 +48,10 @@ namespace BTCPayServer.Security.Greenfield
|
|||||||
throw new InvalidOperationException("cannot save a bitpay legacy api key with this repository");
|
throw new InvalidOperationException("cannot save a bitpay legacy api key with this repository");
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var context = _applicationDbContextFactory.CreateContext())
|
using var context = _applicationDbContextFactory.CreateContext();
|
||||||
{
|
|
||||||
await context.ApiKeys.AddAsync(key);
|
await context.ApiKeys.AddAsync(key);
|
||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<bool> Remove(string id, string getUserId)
|
public async Task<bool> Remove(string id, string getUserId)
|
||||||
{
|
{
|
||||||
|
@ -209,29 +209,24 @@ namespace BTCPayServer.Services.Apps
|
|||||||
|
|
||||||
public async Task<StoreData[]> GetOwnedStores(string userId)
|
public async Task<StoreData[]> GetOwnedStores(string userId)
|
||||||
{
|
{
|
||||||
using (var ctx = _ContextFactory.CreateContext())
|
using var ctx = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
return await ctx.UserStore
|
return await ctx.UserStore
|
||||||
.Where(us => us.ApplicationUserId == userId && us.Role == StoreRoles.Owner)
|
.Where(us => us.ApplicationUserId == userId && us.Role == StoreRoles.Owner)
|
||||||
.Select(u => u.StoreData)
|
.Select(u => u.StoreData)
|
||||||
.ToArrayAsync();
|
.ToArrayAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<bool> DeleteApp(AppData appData)
|
public async Task<bool> DeleteApp(AppData appData)
|
||||||
{
|
{
|
||||||
using (var ctx = _ContextFactory.CreateContext())
|
using var ctx = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
ctx.Apps.Add(appData);
|
ctx.Apps.Add(appData);
|
||||||
ctx.Entry(appData).State = EntityState.Deleted;
|
ctx.Entry(appData).State = EntityState.Deleted;
|
||||||
return await ctx.SaveChangesAsync() == 1;
|
return await ctx.SaveChangesAsync() == 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<ListAppsViewModel.ListAppViewModel[]> GetAllApps(string userId, bool allowNoUser = false, string storeId = null)
|
public async Task<ListAppsViewModel.ListAppViewModel[]> GetAllApps(string userId, bool allowNoUser = false, string storeId = null)
|
||||||
{
|
{
|
||||||
using (var ctx = _ContextFactory.CreateContext())
|
using var ctx = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var listApps = await ctx.UserStore
|
var listApps = await ctx.UserStore
|
||||||
.Where(us =>
|
.Where(us =>
|
||||||
(allowNoUser && string.IsNullOrEmpty(userId) || us.ApplicationUserId == userId) &&
|
(allowNoUser && string.IsNullOrEmpty(userId) || us.ApplicationUserId == userId) &&
|
||||||
@ -256,7 +251,6 @@ namespace BTCPayServer.Services.Apps
|
|||||||
|
|
||||||
return listApps;
|
return listApps;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<string> GetAppViewStyleAsync(string appId, string appType)
|
public async Task<string> GetAppViewStyleAsync(string appId, string appType)
|
||||||
{
|
{
|
||||||
@ -284,8 +278,7 @@ namespace BTCPayServer.Services.Apps
|
|||||||
|
|
||||||
public async Task<List<AppData>> GetApps(string[] appIds, bool includeStore = false)
|
public async Task<List<AppData>> GetApps(string[] appIds, bool includeStore = false)
|
||||||
{
|
{
|
||||||
using (var ctx = _ContextFactory.CreateContext())
|
using var ctx = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var query = ctx.Apps
|
var query = ctx.Apps
|
||||||
.Where(us => appIds.Contains(us.Id));
|
.Where(us => appIds.Contains(us.Id));
|
||||||
|
|
||||||
@ -295,12 +288,10 @@ namespace BTCPayServer.Services.Apps
|
|||||||
}
|
}
|
||||||
return await query.ToListAsync();
|
return await query.ToListAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<AppData> GetApp(string appId, AppType? appType, bool includeStore = false)
|
public async Task<AppData> GetApp(string appId, AppType? appType, bool includeStore = false)
|
||||||
{
|
{
|
||||||
using (var ctx = _ContextFactory.CreateContext())
|
using var ctx = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var query = ctx.Apps
|
var query = ctx.Apps
|
||||||
.Where(us => us.Id == appId &&
|
.Where(us => us.Id == appId &&
|
||||||
(appType == null || us.AppType == appType.ToString()));
|
(appType == null || us.AppType == appType.ToString()));
|
||||||
@ -311,7 +302,6 @@ namespace BTCPayServer.Services.Apps
|
|||||||
}
|
}
|
||||||
return await query.FirstOrDefaultAsync();
|
return await query.FirstOrDefaultAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Task<StoreData> GetStore(AppData app)
|
public Task<StoreData> GetStore(AppData app)
|
||||||
{
|
{
|
||||||
@ -525,8 +515,7 @@ namespace BTCPayServer.Services.Apps
|
|||||||
{
|
{
|
||||||
if (userId == null || appId == null)
|
if (userId == null || appId == null)
|
||||||
return null;
|
return null;
|
||||||
using (var ctx = _ContextFactory.CreateContext())
|
using var ctx = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var app = await ctx.UserStore
|
var app = await ctx.UserStore
|
||||||
.Where(us => us.ApplicationUserId == userId && us.Role == StoreRoles.Owner)
|
.Where(us => us.ApplicationUserId == userId && us.Role == StoreRoles.Owner)
|
||||||
.SelectMany(us => us.StoreData.Apps.Where(a => a.Id == appId))
|
.SelectMany(us => us.StoreData.Apps.Where(a => a.Id == appId))
|
||||||
@ -537,12 +526,10 @@ namespace BTCPayServer.Services.Apps
|
|||||||
return null;
|
return null;
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task UpdateOrCreateApp(AppData app)
|
public async Task UpdateOrCreateApp(AppData app)
|
||||||
{
|
{
|
||||||
using (var ctx = _ContextFactory.CreateContext())
|
using var ctx = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(app.Id))
|
if (string.IsNullOrEmpty(app.Id))
|
||||||
{
|
{
|
||||||
app.Id = Encoders.Base58.EncodeData(RandomUtils.GetBytes(20));
|
app.Id = Encoders.Base58.EncodeData(RandomUtils.GetBytes(20));
|
||||||
@ -558,7 +545,6 @@ namespace BTCPayServer.Services.Apps
|
|||||||
}
|
}
|
||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static bool TryParseJson(string json, out JObject result)
|
private static bool TryParseJson(string json, out JObject result)
|
||||||
{
|
{
|
||||||
|
@ -28,15 +28,13 @@ namespace BTCPayServer.Services
|
|||||||
|
|
||||||
public async Task UpdateInvoiceExpiry(string invoiceId, DateTimeOffset dateTimeOffset)
|
public async Task UpdateInvoiceExpiry(string invoiceId, DateTimeOffset dateTimeOffset)
|
||||||
{
|
{
|
||||||
using (var ctx = _applicationDbContextFactory.CreateContext())
|
using var ctx = _applicationDbContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var invoiceData = await ctx.Invoices.FindAsync(invoiceId).ConfigureAwait(false);
|
var invoiceData = await ctx.Invoices.FindAsync(invoiceId).ConfigureAwait(false);
|
||||||
if (invoiceData == null)
|
if (invoiceData == null)
|
||||||
return;
|
return;
|
||||||
// TODO change the expiry time. But how?
|
// TODO change the expiry time. But how?
|
||||||
await ctx.SaveChangesAsync().ConfigureAwait(false);
|
await ctx.SaveChangesAsync().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Task IHostedService.StartAsync(CancellationToken cancellationToken)
|
Task IHostedService.StartAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
@ -44,8 +44,7 @@ namespace BTCPayServer.Services
|
|||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(transaction);
|
ArgumentNullException.ThrowIfNull(transaction);
|
||||||
ArgumentNullException.ThrowIfNull(network);
|
ArgumentNullException.ThrowIfNull(network);
|
||||||
using (var db = _dbContextFactory.CreateContext())
|
using var db = _dbContextFactory.CreateContext();
|
||||||
{
|
|
||||||
db.PlannedTransactions.Add(new PlannedTransaction()
|
db.PlannedTransactions.Add(new PlannedTransaction()
|
||||||
{
|
{
|
||||||
Id = $"{network.CryptoCode}-{transaction.GetHash()}",
|
Id = $"{network.CryptoCode}-{transaction.GetHash()}",
|
||||||
@ -60,7 +59,6 @@ namespace BTCPayServer.Services
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<int> ProcessAll(CancellationToken cancellationToken = default)
|
public async Task<int> ProcessAll(CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
|
@ -67,8 +67,7 @@ namespace BTCPayServer.Services.Invoices
|
|||||||
public async Task<bool> RemovePendingInvoice(string invoiceId)
|
public async Task<bool> RemovePendingInvoice(string invoiceId)
|
||||||
{
|
{
|
||||||
Logs.PayServer.LogInformation($"Remove pending invoice {invoiceId}");
|
Logs.PayServer.LogInformation($"Remove pending invoice {invoiceId}");
|
||||||
using (var ctx = _applicationDbContextFactory.CreateContext())
|
using var ctx = _applicationDbContextFactory.CreateContext();
|
||||||
{
|
|
||||||
ctx.PendingInvoices.Remove(new PendingInvoiceData() { Id = invoiceId });
|
ctx.PendingInvoices.Remove(new PendingInvoiceData() { Id = invoiceId });
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -77,12 +76,10 @@ namespace BTCPayServer.Services.Invoices
|
|||||||
}
|
}
|
||||||
catch (DbUpdateException) { return false; }
|
catch (DbUpdateException) { return false; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<IEnumerable<InvoiceEntity>> GetInvoicesFromAddresses(string[] addresses)
|
public async Task<IEnumerable<InvoiceEntity>> GetInvoicesFromAddresses(string[] addresses)
|
||||||
{
|
{
|
||||||
using (var db = _applicationDbContextFactory.CreateContext())
|
using var db = _applicationDbContextFactory.CreateContext();
|
||||||
{
|
|
||||||
return (await db.AddressInvoices
|
return (await db.AddressInvoices
|
||||||
.Include(a => a.InvoiceData.Payments)
|
.Include(a => a.InvoiceData.Payments)
|
||||||
#pragma warning disable CS0618
|
#pragma warning disable CS0618
|
||||||
@ -91,15 +88,12 @@ namespace BTCPayServer.Services.Invoices
|
|||||||
.Select(a => a.InvoiceData)
|
.Select(a => a.InvoiceData)
|
||||||
.ToListAsync()).Select(ToEntity);
|
.ToListAsync()).Select(ToEntity);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<string[]> GetPendingInvoices()
|
public async Task<string[]> GetPendingInvoices()
|
||||||
{
|
{
|
||||||
using (var ctx = _applicationDbContextFactory.CreateContext())
|
using var ctx = _applicationDbContextFactory.CreateContext();
|
||||||
{
|
|
||||||
return await ctx.PendingInvoices.AsQueryable().Select(data => data.Id).ToArrayAsync();
|
return await ctx.PendingInvoices.AsQueryable().Select(data => data.Id).ToArrayAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<List<Data.WebhookDeliveryData>> GetWebhookDeliveries(string invoiceId)
|
public async Task<List<Data.WebhookDeliveryData>> GetWebhookDeliveries(string invoiceId)
|
||||||
{
|
{
|
||||||
@ -115,16 +109,13 @@ namespace BTCPayServer.Services.Invoices
|
|||||||
public async Task<AppData[]> GetAppsTaggingStore(string storeId)
|
public async Task<AppData[]> GetAppsTaggingStore(string storeId)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(storeId);
|
ArgumentNullException.ThrowIfNull(storeId);
|
||||||
using (var ctx = _applicationDbContextFactory.CreateContext())
|
using var ctx = _applicationDbContextFactory.CreateContext();
|
||||||
{
|
|
||||||
return await ctx.Apps.Where(a => a.StoreDataId == storeId && a.TagAllInvoices).ToArrayAsync();
|
return await ctx.Apps.Where(a => a.StoreDataId == storeId && a.TagAllInvoices).ToArrayAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task UpdateInvoice(string invoiceId, UpdateCustomerModel data)
|
public async Task UpdateInvoice(string invoiceId, UpdateCustomerModel data)
|
||||||
{
|
{
|
||||||
using (var ctx = _applicationDbContextFactory.CreateContext())
|
using var ctx = _applicationDbContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var invoiceData = await ctx.Invoices.FindAsync(invoiceId).ConfigureAwait(false);
|
var invoiceData = await ctx.Invoices.FindAsync(invoiceId).ConfigureAwait(false);
|
||||||
if (invoiceData == null)
|
if (invoiceData == null)
|
||||||
return;
|
return;
|
||||||
@ -135,12 +126,10 @@ namespace BTCPayServer.Services.Invoices
|
|||||||
}
|
}
|
||||||
await ctx.SaveChangesAsync().ConfigureAwait(false);
|
await ctx.SaveChangesAsync().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task ExtendInvoiceMonitor(string invoiceId)
|
public async Task ExtendInvoiceMonitor(string invoiceId)
|
||||||
{
|
{
|
||||||
using (var ctx = _applicationDbContextFactory.CreateContext())
|
using var ctx = _applicationDbContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var invoiceData = await ctx.Invoices.FindAsync(invoiceId);
|
var invoiceData = await ctx.Invoices.FindAsync(invoiceId);
|
||||||
|
|
||||||
var invoice = invoiceData.GetBlob(_btcPayNetworkProvider);
|
var invoice = invoiceData.GetBlob(_btcPayNetworkProvider);
|
||||||
@ -149,7 +138,6 @@ namespace BTCPayServer.Services.Invoices
|
|||||||
|
|
||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<InvoiceEntity> CreateInvoiceAsync(string storeId, InvoiceEntity invoice, string[] additionalSearchTerms = null)
|
public async Task<InvoiceEntity> CreateInvoiceAsync(string storeId, InvoiceEntity invoice, string[] additionalSearchTerms = null)
|
||||||
{
|
{
|
||||||
@ -316,8 +304,7 @@ namespace BTCPayServer.Services.Invoices
|
|||||||
|
|
||||||
public async Task UpdateInvoicePaymentMethod(string invoiceId, PaymentMethod paymentMethod)
|
public async Task UpdateInvoicePaymentMethod(string invoiceId, PaymentMethod paymentMethod)
|
||||||
{
|
{
|
||||||
using (var context = _applicationDbContextFactory.CreateContext())
|
using var context = _applicationDbContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var invoice = await context.Invoices.FindAsync(invoiceId);
|
var invoice = await context.Invoices.FindAsync(invoiceId);
|
||||||
if (invoice == null)
|
if (invoice == null)
|
||||||
return;
|
return;
|
||||||
@ -343,14 +330,11 @@ namespace BTCPayServer.Services.Invoices
|
|||||||
invoice.Blob = ToBytes(invoiceEntity, network);
|
invoice.Blob = ToBytes(invoiceEntity, network);
|
||||||
AddToTextSearch(context, invoice, paymentMethod.GetPaymentMethodDetails().GetPaymentDestination());
|
AddToTextSearch(context, invoice, paymentMethod.GetPaymentMethodDetails().GetPaymentDestination());
|
||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync();
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddPendingInvoiceIfNotPresent(string invoiceId)
|
public async Task AddPendingInvoiceIfNotPresent(string invoiceId)
|
||||||
{
|
{
|
||||||
using (var context = _applicationDbContextFactory.CreateContext())
|
using var context = _applicationDbContextFactory.CreateContext();
|
||||||
{
|
|
||||||
if (!context.PendingInvoices.Any(a => a.Id == invoiceId))
|
if (!context.PendingInvoices.Any(a => a.Id == invoiceId))
|
||||||
{
|
{
|
||||||
context.PendingInvoices.Add(new PendingInvoiceData() { Id = invoiceId });
|
context.PendingInvoices.Add(new PendingInvoiceData() { Id = invoiceId });
|
||||||
@ -361,7 +345,6 @@ namespace BTCPayServer.Services.Invoices
|
|||||||
catch (DbUpdateException) { } // Already exists
|
catch (DbUpdateException) { } // Already exists
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task AddInvoiceEvent(string invoiceId, object evt, InvoiceEventData.EventSeverity severity)
|
public async Task AddInvoiceEvent(string invoiceId, object evt, InvoiceEventData.EventSeverity severity)
|
||||||
{
|
{
|
||||||
@ -419,8 +402,7 @@ namespace BTCPayServer.Services.Invoices
|
|||||||
|
|
||||||
public async Task UpdateInvoiceStatus(string invoiceId, InvoiceState invoiceState)
|
public async Task UpdateInvoiceStatus(string invoiceId, InvoiceState invoiceState)
|
||||||
{
|
{
|
||||||
using (var context = _applicationDbContextFactory.CreateContext())
|
using var context = _applicationDbContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var invoiceData = await context.FindAsync<Data.InvoiceData>(invoiceId).ConfigureAwait(false);
|
var invoiceData = await context.FindAsync<Data.InvoiceData>(invoiceId).ConfigureAwait(false);
|
||||||
if (invoiceData == null)
|
if (invoiceData == null)
|
||||||
return;
|
return;
|
||||||
@ -428,13 +410,11 @@ namespace BTCPayServer.Services.Invoices
|
|||||||
invoiceData.ExceptionStatus = InvoiceState.ToString(invoiceState.ExceptionStatus);
|
invoiceData.ExceptionStatus = InvoiceState.ToString(invoiceState.ExceptionStatus);
|
||||||
await context.SaveChangesAsync().ConfigureAwait(false);
|
await context.SaveChangesAsync().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
internal async Task UpdateInvoicePrice(string invoiceId, InvoiceEntity invoice)
|
internal async Task UpdateInvoicePrice(string invoiceId, InvoiceEntity invoice)
|
||||||
{
|
{
|
||||||
if (invoice.Type != InvoiceType.TopUp)
|
if (invoice.Type != InvoiceType.TopUp)
|
||||||
throw new ArgumentException("The invoice type should be TopUp to be able to update invoice price", nameof(invoice));
|
throw new ArgumentException("The invoice type should be TopUp to be able to update invoice price", nameof(invoice));
|
||||||
using (var context = _applicationDbContextFactory.CreateContext())
|
using var context = _applicationDbContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var invoiceData = await context.FindAsync<Data.InvoiceData>(invoiceId).ConfigureAwait(false);
|
var invoiceData = await context.FindAsync<Data.InvoiceData>(invoiceId).ConfigureAwait(false);
|
||||||
if (invoiceData == null)
|
if (invoiceData == null)
|
||||||
return;
|
return;
|
||||||
@ -444,12 +424,10 @@ namespace BTCPayServer.Services.Invoices
|
|||||||
invoiceData.Blob = ToBytes(blob, null);
|
invoiceData.Blob = ToBytes(blob, null);
|
||||||
await context.SaveChangesAsync().ConfigureAwait(false);
|
await context.SaveChangesAsync().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task MassArchive(string[] invoiceIds, bool archive = true)
|
public async Task MassArchive(string[] invoiceIds, bool archive = true)
|
||||||
{
|
{
|
||||||
using (var context = _applicationDbContextFactory.CreateContext())
|
using var context = _applicationDbContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var items = context.Invoices.Where(a => invoiceIds.Contains(a.Id));
|
var items = context.Invoices.Where(a => invoiceIds.Contains(a.Id));
|
||||||
if (items == null)
|
if (items == null)
|
||||||
{
|
{
|
||||||
@ -463,12 +441,10 @@ namespace BTCPayServer.Services.Invoices
|
|||||||
|
|
||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task ToggleInvoiceArchival(string invoiceId, bool archived, string storeId = null)
|
public async Task ToggleInvoiceArchival(string invoiceId, bool archived, string storeId = null)
|
||||||
{
|
{
|
||||||
using (var context = _applicationDbContextFactory.CreateContext())
|
using var context = _applicationDbContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var invoiceData = await context.FindAsync<InvoiceData>(invoiceId).ConfigureAwait(false);
|
var invoiceData = await context.FindAsync<InvoiceData>(invoiceId).ConfigureAwait(false);
|
||||||
if (invoiceData == null || invoiceData.Archived == archived ||
|
if (invoiceData == null || invoiceData.Archived == archived ||
|
||||||
(storeId != null &&
|
(storeId != null &&
|
||||||
@ -477,11 +453,9 @@ namespace BTCPayServer.Services.Invoices
|
|||||||
invoiceData.Archived = archived;
|
invoiceData.Archived = archived;
|
||||||
await context.SaveChangesAsync().ConfigureAwait(false);
|
await context.SaveChangesAsync().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
public async Task<InvoiceEntity> UpdateInvoiceMetadata(string invoiceId, string storeId, JObject metadata)
|
public async Task<InvoiceEntity> UpdateInvoiceMetadata(string invoiceId, string storeId, JObject metadata)
|
||||||
{
|
{
|
||||||
using (var context = _applicationDbContextFactory.CreateContext())
|
using var context = _applicationDbContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var invoiceData = await GetInvoiceRaw(invoiceId, context);
|
var invoiceData = await GetInvoiceRaw(invoiceId, context);
|
||||||
if (invoiceData == null || (storeId != null &&
|
if (invoiceData == null || (storeId != null &&
|
||||||
!invoiceData.StoreDataId.Equals(storeId,
|
!invoiceData.StoreDataId.Equals(storeId,
|
||||||
@ -493,7 +467,6 @@ namespace BTCPayServer.Services.Invoices
|
|||||||
await context.SaveChangesAsync().ConfigureAwait(false);
|
await context.SaveChangesAsync().ConfigureAwait(false);
|
||||||
return ToEntity(invoiceData);
|
return ToEntity(invoiceData);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
public async Task<bool> MarkInvoiceStatus(string invoiceId, InvoiceStatus status)
|
public async Task<bool> MarkInvoiceStatus(string invoiceId, InvoiceStatus status)
|
||||||
{
|
{
|
||||||
using (var context = _applicationDbContextFactory.CreateContext())
|
using (var context = _applicationDbContextFactory.CreateContext())
|
||||||
@ -541,17 +514,14 @@ namespace BTCPayServer.Services.Invoices
|
|||||||
|
|
||||||
public async Task<InvoiceEntity> GetInvoice(string id, bool includeAddressData = false)
|
public async Task<InvoiceEntity> GetInvoice(string id, bool includeAddressData = false)
|
||||||
{
|
{
|
||||||
using (var context = _applicationDbContextFactory.CreateContext())
|
using var context = _applicationDbContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var res = await GetInvoiceRaw(id, context, includeAddressData);
|
var res = await GetInvoiceRaw(id, context, includeAddressData);
|
||||||
return res == null ? null : ToEntity(res);
|
return res == null ? null : ToEntity(res);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
public async Task<InvoiceEntity[]> GetInvoices(string[] invoiceIds)
|
public async Task<InvoiceEntity[]> GetInvoices(string[] invoiceIds)
|
||||||
{
|
{
|
||||||
var invoiceIdSet = invoiceIds.ToHashSet();
|
var invoiceIdSet = invoiceIds.ToHashSet();
|
||||||
using (var context = _applicationDbContextFactory.CreateContext())
|
using var context = _applicationDbContextFactory.CreateContext();
|
||||||
{
|
|
||||||
IQueryable<Data.InvoiceData> query =
|
IQueryable<Data.InvoiceData> query =
|
||||||
context
|
context
|
||||||
.Invoices
|
.Invoices
|
||||||
@ -560,7 +530,6 @@ namespace BTCPayServer.Services.Invoices
|
|||||||
|
|
||||||
return (await query.ToListAsync()).Select(o => ToEntity(o)).ToArray();
|
return (await query.ToListAsync()).Select(o => ToEntity(o)).ToArray();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<InvoiceData> GetInvoiceRaw(string id, ApplicationDbContext dbContext, bool includeAddressData = false)
|
private async Task<InvoiceData> GetInvoiceRaw(string id, ApplicationDbContext dbContext, bool includeAddressData = false)
|
||||||
{
|
{
|
||||||
@ -710,17 +679,14 @@ namespace BTCPayServer.Services.Invoices
|
|||||||
|
|
||||||
public async Task<int> GetInvoicesTotal(InvoiceQuery queryObject)
|
public async Task<int> GetInvoicesTotal(InvoiceQuery queryObject)
|
||||||
{
|
{
|
||||||
using (var context = _applicationDbContextFactory.CreateContext())
|
using var context = _applicationDbContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var query = GetInvoiceQuery(context, queryObject);
|
var query = GetInvoiceQuery(context, queryObject);
|
||||||
return await query.CountAsync();
|
return await query.CountAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<InvoiceEntity[]> GetInvoices(InvoiceQuery queryObject)
|
public async Task<InvoiceEntity[]> GetInvoices(InvoiceQuery queryObject)
|
||||||
{
|
{
|
||||||
using (var context = _applicationDbContextFactory.CreateContext())
|
using var context = _applicationDbContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var query = GetInvoiceQuery(context, queryObject);
|
var query = GetInvoiceQuery(context, queryObject);
|
||||||
query = query.Include(o => o.Payments);
|
query = query.Include(o => o.Payments);
|
||||||
if (queryObject.IncludeAddresses)
|
if (queryObject.IncludeAddresses)
|
||||||
@ -730,7 +696,6 @@ namespace BTCPayServer.Services.Invoices
|
|||||||
var data = await query.ToArrayAsync().ConfigureAwait(false);
|
var data = await query.ToArrayAsync().ConfigureAwait(false);
|
||||||
return data.Select(ToEntity).ToArray();
|
return data.Select(ToEntity).ToArray();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private string NormalizeExceptionStatus(string status)
|
private string NormalizeExceptionStatus(string status)
|
||||||
{
|
{
|
||||||
|
@ -37,12 +37,10 @@ namespace BTCPayServer.Services
|
|||||||
var result = new List<Language>();
|
var result = new List<Language>();
|
||||||
foreach (var file in files)
|
foreach (var file in files)
|
||||||
{
|
{
|
||||||
using (var stream = new StreamReader(file))
|
using var stream = new StreamReader(file);
|
||||||
{
|
|
||||||
var json = stream.ReadToEnd();
|
var json = stream.ReadToEnd();
|
||||||
result.Add(JObject.Parse(json).ToObject<Language>());
|
result.Add(JObject.Parse(json).ToObject<Language>());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
_languages = result.ToArray();
|
_languages = result.ToArray();
|
||||||
}
|
}
|
||||||
|
@ -30,12 +30,10 @@ namespace BTCPayServer.Services.Mails
|
|||||||
Logs.Configuration.LogWarning("Should have sent email, but email settings are not configured");
|
Logs.Configuration.LogWarning("Should have sent email, but email settings are not configured");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
using (var smtp = await emailSettings.CreateSmtpClient())
|
using var smtp = await emailSettings.CreateSmtpClient();
|
||||||
{
|
|
||||||
var mail = emailSettings.CreateMailMessage(new MailboxAddress(email, email), subject, message, true);
|
var mail = emailSettings.CreateMailMessage(new MailboxAddress(email, email), subject, message, true);
|
||||||
await smtp.SendAsync(mail, cancellationToken);
|
await smtp.SendAsync(mail, cancellationToken);
|
||||||
await smtp.DisconnectAsync(true, cancellationToken);
|
await smtp.DisconnectAsync(true, cancellationToken);
|
||||||
}
|
|
||||||
}, TimeSpan.Zero);
|
}, TimeSpan.Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,8 +22,7 @@ namespace BTCPayServer.Services.PaymentRequests
|
|||||||
|
|
||||||
public async Task<PaymentRequestData> CreateOrUpdatePaymentRequest(PaymentRequestData entity)
|
public async Task<PaymentRequestData> CreateOrUpdatePaymentRequest(PaymentRequestData entity)
|
||||||
{
|
{
|
||||||
using (var context = _ContextFactory.CreateContext())
|
using var context = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(entity.Id))
|
if (string.IsNullOrEmpty(entity.Id))
|
||||||
{
|
{
|
||||||
entity.Id = Guid.NewGuid().ToString();
|
entity.Id = Guid.NewGuid().ToString();
|
||||||
@ -37,7 +36,6 @@ namespace BTCPayServer.Services.PaymentRequests
|
|||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync();
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<PaymentRequestData> FindPaymentRequest(string id, string userId, CancellationToken cancellationToken = default)
|
public async Task<PaymentRequestData> FindPaymentRequest(string id, string userId, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
@ -46,8 +44,7 @@ namespace BTCPayServer.Services.PaymentRequests
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var context = _ContextFactory.CreateContext())
|
using var context = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var result = await context.PaymentRequests.Include(x => x.StoreData)
|
var result = await context.PaymentRequests.Include(x => x.StoreData)
|
||||||
.Where(data =>
|
.Where(data =>
|
||||||
string.IsNullOrEmpty(userId) ||
|
string.IsNullOrEmpty(userId) ||
|
||||||
@ -55,7 +52,6 @@ namespace BTCPayServer.Services.PaymentRequests
|
|||||||
.SingleOrDefaultAsync(x => x.Id == id, cancellationToken);
|
.SingleOrDefaultAsync(x => x.Id == id, cancellationToken);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<bool> IsPaymentRequestAdmin(string paymentRequestId, string userId)
|
public async Task<bool> IsPaymentRequestAdmin(string paymentRequestId, string userId)
|
||||||
{
|
{
|
||||||
@ -63,31 +59,26 @@ namespace BTCPayServer.Services.PaymentRequests
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
using (var context = _ContextFactory.CreateContext())
|
using var context = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
return await context.PaymentRequests.Include(x => x.StoreData)
|
return await context.PaymentRequests.Include(x => x.StoreData)
|
||||||
.AnyAsync(data =>
|
.AnyAsync(data =>
|
||||||
data.Id == paymentRequestId &&
|
data.Id == paymentRequestId &&
|
||||||
(data.StoreData != null && data.StoreData.UserStores.Any(u => u.ApplicationUserId == userId)));
|
(data.StoreData != null && data.StoreData.UserStores.Any(u => u.ApplicationUserId == userId)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task UpdatePaymentRequestStatus(string paymentRequestId, Client.Models.PaymentRequestData.PaymentRequestStatus status, CancellationToken cancellationToken = default)
|
public async Task UpdatePaymentRequestStatus(string paymentRequestId, Client.Models.PaymentRequestData.PaymentRequestStatus status, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
using (var context = _ContextFactory.CreateContext())
|
using var context = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var invoiceData = await context.FindAsync<PaymentRequestData>(paymentRequestId);
|
var invoiceData = await context.FindAsync<PaymentRequestData>(paymentRequestId);
|
||||||
if (invoiceData == null)
|
if (invoiceData == null)
|
||||||
return;
|
return;
|
||||||
invoiceData.Status = status;
|
invoiceData.Status = status;
|
||||||
await context.SaveChangesAsync(cancellationToken);
|
await context.SaveChangesAsync(cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<(int Total, PaymentRequestData[] Items)> FindPaymentRequests(PaymentRequestQuery query, CancellationToken cancellationToken = default)
|
public async Task<(int Total, PaymentRequestData[] Items)> FindPaymentRequests(PaymentRequestQuery query, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
using (var context = _ContextFactory.CreateContext())
|
using var context = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var queryable = context.PaymentRequests.Include(data => data.StoreData).AsQueryable();
|
var queryable = context.PaymentRequests.Include(data => data.StoreData).AsQueryable();
|
||||||
|
|
||||||
if (!query.IncludeArchived)
|
if (!query.IncludeArchived)
|
||||||
@ -133,7 +124,6 @@ namespace BTCPayServer.Services.PaymentRequests
|
|||||||
}
|
}
|
||||||
return (total, await queryable.ToArrayAsync(cancellationToken));
|
return (total, await queryable.ToArrayAsync(cancellationToken));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<InvoiceEntity[]> GetInvoicesForPaymentRequest(string paymentRequestId,
|
public async Task<InvoiceEntity[]> GetInvoicesForPaymentRequest(string paymentRequestId,
|
||||||
InvoiceQuery invoiceQuery = null)
|
InvoiceQuery invoiceQuery = null)
|
||||||
|
@ -26,12 +26,10 @@ namespace BTCPayServer.Services.Stores
|
|||||||
{
|
{
|
||||||
if (storeId == null)
|
if (storeId == null)
|
||||||
return null;
|
return null;
|
||||||
using (var ctx = _ContextFactory.CreateContext())
|
using var ctx = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var result = await ctx.FindAsync<StoreData>(storeId).ConfigureAwait(false);
|
var result = await ctx.FindAsync<StoreData>(storeId).ConfigureAwait(false);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<StoreData> FindStore(string storeId, string userId)
|
public async Task<StoreData> FindStore(string storeId, string userId)
|
||||||
{
|
{
|
||||||
@ -62,8 +60,7 @@ namespace BTCPayServer.Services.Stores
|
|||||||
public async Task<StoreUser[]> GetStoreUsers(string storeId)
|
public async Task<StoreUser[]> GetStoreUsers(string storeId)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(storeId);
|
ArgumentNullException.ThrowIfNull(storeId);
|
||||||
using (var ctx = _ContextFactory.CreateContext())
|
using var ctx = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
return await ctx
|
return await ctx
|
||||||
.UserStore
|
.UserStore
|
||||||
.Where(u => u.StoreDataId == storeId)
|
.Where(u => u.StoreDataId == storeId)
|
||||||
@ -74,12 +71,10 @@ namespace BTCPayServer.Services.Stores
|
|||||||
Role = u.Role
|
Role = u.Role
|
||||||
}).ToArrayAsync();
|
}).ToArrayAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<StoreData[]> GetStoresByUserId(string userId, IEnumerable<string> storeIds = null)
|
public async Task<StoreData[]> GetStoresByUserId(string userId, IEnumerable<string> storeIds = null)
|
||||||
{
|
{
|
||||||
using (var ctx = _ContextFactory.CreateContext())
|
using var ctx = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
return (await ctx.UserStore
|
return (await ctx.UserStore
|
||||||
.Where(u => u.ApplicationUserId == userId && (storeIds == null || storeIds.Contains(u.StoreDataId)))
|
.Where(u => u.ApplicationUserId == userId && (storeIds == null || storeIds.Contains(u.StoreDataId)))
|
||||||
.Select(u => new { u.StoreData, u.Role })
|
.Select(u => new { u.StoreData, u.Role })
|
||||||
@ -90,7 +85,6 @@ namespace BTCPayServer.Services.Stores
|
|||||||
return u.StoreData;
|
return u.StoreData;
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<StoreData> GetStoreByInvoiceId(string invoiceId)
|
public async Task<StoreData> GetStoreByInvoiceId(string invoiceId)
|
||||||
{
|
{
|
||||||
@ -102,8 +96,7 @@ namespace BTCPayServer.Services.Stores
|
|||||||
|
|
||||||
public async Task<bool> AddStoreUser(string storeId, string userId, string role)
|
public async Task<bool> AddStoreUser(string storeId, string userId, string role)
|
||||||
{
|
{
|
||||||
using (var ctx = _ContextFactory.CreateContext())
|
using var ctx = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var userStore = new UserStore() { StoreDataId = storeId, ApplicationUserId = userId, Role = role };
|
var userStore = new UserStore() { StoreDataId = storeId, ApplicationUserId = userId, Role = role };
|
||||||
ctx.UserStore.Add(userStore);
|
ctx.UserStore.Add(userStore);
|
||||||
try
|
try
|
||||||
@ -116,12 +109,10 @@ namespace BTCPayServer.Services.Stores
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task CleanUnreachableStores()
|
public async Task CleanUnreachableStores()
|
||||||
{
|
{
|
||||||
using (var ctx = _ContextFactory.CreateContext())
|
using var ctx = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
if (!ctx.Database.SupportDropForeignKey())
|
if (!ctx.Database.SupportDropForeignKey())
|
||||||
return;
|
return;
|
||||||
foreach (var store in await ctx.Stores.Where(s => !s.UserStores.Where(u => u.Role == StoreRoles.Owner).Any()).ToArrayAsync())
|
foreach (var store in await ctx.Stores.Where(s => !s.UserStores.Where(u => u.Role == StoreRoles.Owner).Any()).ToArrayAsync())
|
||||||
@ -130,7 +121,6 @@ namespace BTCPayServer.Services.Stores
|
|||||||
}
|
}
|
||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task RemoveStoreUser(string storeId, string userId)
|
public async Task RemoveStoreUser(string storeId, string userId)
|
||||||
{
|
{
|
||||||
@ -147,8 +137,7 @@ namespace BTCPayServer.Services.Stores
|
|||||||
|
|
||||||
private async Task DeleteStoreIfOrphan(string storeId)
|
private async Task DeleteStoreIfOrphan(string storeId)
|
||||||
{
|
{
|
||||||
using (var ctx = _ContextFactory.CreateContext())
|
using var ctx = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
if (ctx.Database.SupportDropForeignKey())
|
if (ctx.Database.SupportDropForeignKey())
|
||||||
{
|
{
|
||||||
if (!await ctx.UserStore.Where(u => u.StoreDataId == storeId && u.Role == StoreRoles.Owner).AnyAsync())
|
if (!await ctx.UserStore.Where(u => u.StoreDataId == storeId && u.Role == StoreRoles.Owner).AnyAsync())
|
||||||
@ -162,7 +151,6 @@ namespace BTCPayServer.Services.Stores
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void SetNewStoreHints(ref StoreData storeData)
|
private void SetNewStoreHints(ref StoreData storeData)
|
||||||
{
|
{
|
||||||
@ -182,8 +170,7 @@ namespace BTCPayServer.Services.Stores
|
|||||||
if (string.IsNullOrEmpty(storeData.StoreName))
|
if (string.IsNullOrEmpty(storeData.StoreName))
|
||||||
throw new ArgumentException("name should not be empty", nameof(storeData.StoreName));
|
throw new ArgumentException("name should not be empty", nameof(storeData.StoreName));
|
||||||
ArgumentNullException.ThrowIfNull(ownerId);
|
ArgumentNullException.ThrowIfNull(ownerId);
|
||||||
using (var ctx = _ContextFactory.CreateContext())
|
using var ctx = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
storeData.Id = Encoders.Base58.EncodeData(RandomUtils.GetBytes(32));
|
storeData.Id = Encoders.Base58.EncodeData(RandomUtils.GetBytes(32));
|
||||||
var userStore = new UserStore
|
var userStore = new UserStore
|
||||||
{
|
{
|
||||||
@ -198,7 +185,6 @@ namespace BTCPayServer.Services.Stores
|
|||||||
ctx.Add(userStore);
|
ctx.Add(userStore);
|
||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<StoreData> CreateStore(string ownerId, string name)
|
public async Task<StoreData> CreateStore(string ownerId, string name)
|
||||||
{
|
{
|
||||||
@ -343,18 +329,15 @@ namespace BTCPayServer.Services.Stores
|
|||||||
|
|
||||||
public async Task UpdateStore(StoreData store)
|
public async Task UpdateStore(StoreData store)
|
||||||
{
|
{
|
||||||
using (var ctx = _ContextFactory.CreateContext())
|
using var ctx = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var existing = await ctx.FindAsync<StoreData>(store.Id);
|
var existing = await ctx.FindAsync<StoreData>(store.Id);
|
||||||
ctx.Entry(existing).CurrentValues.SetValues(store);
|
ctx.Entry(existing).CurrentValues.SetValues(store);
|
||||||
await ctx.SaveChangesAsync().ConfigureAwait(false);
|
await ctx.SaveChangesAsync().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<bool> DeleteStore(string storeId)
|
public async Task<bool> DeleteStore(string storeId)
|
||||||
{
|
{
|
||||||
using (var ctx = _ContextFactory.CreateContext())
|
using var ctx = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
if (!ctx.Database.SupportDropForeignKey())
|
if (!ctx.Database.SupportDropForeignKey())
|
||||||
return false;
|
return false;
|
||||||
var store = await ctx.Stores.FindAsync(storeId);
|
var store = await ctx.Stores.FindAsync(storeId);
|
||||||
@ -370,14 +353,11 @@ namespace BTCPayServer.Services.Stores
|
|||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public bool CanDeleteStores()
|
public bool CanDeleteStores()
|
||||||
{
|
{
|
||||||
using (var ctx = _ContextFactory.CreateContext())
|
using var ctx = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
return ctx.Database.SupportDropForeignKey();
|
return ctx.Database.SupportDropForeignKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,7 @@ namespace BTCPayServer.Services
|
|||||||
public async Task SetWalletInfo(WalletId walletId, WalletBlobInfo blob)
|
public async Task SetWalletInfo(WalletId walletId, WalletBlobInfo blob)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(walletId);
|
ArgumentNullException.ThrowIfNull(walletId);
|
||||||
using (var ctx = _ContextFactory.CreateContext())
|
using var ctx = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var walletData = new WalletData() { Id = walletId.ToString() };
|
var walletData = new WalletData() { Id = walletId.ToString() };
|
||||||
walletData.SetBlobInfo(blob);
|
walletData.SetBlobInfo(blob);
|
||||||
var entity = await ctx.Wallets.AddAsync(walletData);
|
var entity = await ctx.Wallets.AddAsync(walletData);
|
||||||
@ -35,13 +34,11 @@ namespace BTCPayServer.Services
|
|||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<Dictionary<string, WalletTransactionInfo>> GetWalletTransactionsInfo(WalletId walletId, string[] transactionIds = null)
|
public async Task<Dictionary<string, WalletTransactionInfo>> GetWalletTransactionsInfo(WalletId walletId, string[] transactionIds = null)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(walletId);
|
ArgumentNullException.ThrowIfNull(walletId);
|
||||||
using (var ctx = _ContextFactory.CreateContext())
|
using var ctx = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
return (await ctx.WalletTransactions
|
return (await ctx.WalletTransactions
|
||||||
.Where(w => w.WalletDataId == walletId.ToString())
|
.Where(w => w.WalletDataId == walletId.ToString())
|
||||||
.Where(data => transactionIds == null || transactionIds.Contains(data.TransactionId))
|
.Where(data => transactionIds == null || transactionIds.Contains(data.TransactionId))
|
||||||
@ -49,27 +46,23 @@ namespace BTCPayServer.Services
|
|||||||
.ToArrayAsync())
|
.ToArrayAsync())
|
||||||
.ToDictionary(w => w.TransactionId, w => w.GetBlobInfo());
|
.ToDictionary(w => w.TransactionId, w => w.GetBlobInfo());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<WalletBlobInfo> GetWalletInfo(WalletId walletId)
|
public async Task<WalletBlobInfo> GetWalletInfo(WalletId walletId)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(walletId);
|
ArgumentNullException.ThrowIfNull(walletId);
|
||||||
using (var ctx = _ContextFactory.CreateContext())
|
using var ctx = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var data = await ctx.Wallets
|
var data = await ctx.Wallets
|
||||||
.Where(w => w.Id == walletId.ToString())
|
.Where(w => w.Id == walletId.ToString())
|
||||||
.Select(w => w)
|
.Select(w => w)
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
return data?.GetBlobInfo() ?? new WalletBlobInfo();
|
return data?.GetBlobInfo() ?? new WalletBlobInfo();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task SetWalletTransactionInfo(WalletId walletId, string transactionId, WalletTransactionInfo walletTransactionInfo)
|
public async Task SetWalletTransactionInfo(WalletId walletId, string transactionId, WalletTransactionInfo walletTransactionInfo)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(walletId);
|
ArgumentNullException.ThrowIfNull(walletId);
|
||||||
ArgumentNullException.ThrowIfNull(transactionId);
|
ArgumentNullException.ThrowIfNull(transactionId);
|
||||||
using (var ctx = _ContextFactory.CreateContext())
|
using var ctx = _ContextFactory.CreateContext();
|
||||||
{
|
|
||||||
var walletData = new WalletTransactionData() { WalletDataId = walletId.ToString(), TransactionId = transactionId };
|
var walletData = new WalletTransactionData() { WalletDataId = walletId.ToString(), TransactionId = transactionId };
|
||||||
walletData.SetBlobInfo(walletTransactionInfo);
|
walletData.SetBlobInfo(walletTransactionInfo);
|
||||||
var entity = await ctx.WalletTransactions.AddAsync(walletData);
|
var entity = await ctx.WalletTransactions.AddAsync(walletData);
|
||||||
@ -93,5 +86,4 @@ namespace BTCPayServer.Services
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,7 @@ namespace BTCPayServer.Storage.Services
|
|||||||
filesQuery = new FilesQuery();
|
filesQuery = new FilesQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var context = _ApplicationDbContextFactory.CreateContext())
|
using var context = _ApplicationDbContextFactory.CreateContext();
|
||||||
{
|
|
||||||
return await context.Files
|
return await context.Files
|
||||||
.Include(file => file.ApplicationUser)
|
.Include(file => file.ApplicationUser)
|
||||||
.Where(file =>
|
.Where(file =>
|
||||||
@ -39,26 +38,21 @@ namespace BTCPayServer.Storage.Services
|
|||||||
.OrderByDescending(file => file.Timestamp)
|
.OrderByDescending(file => file.Timestamp)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task RemoveFile(StoredFile file)
|
public async Task RemoveFile(StoredFile file)
|
||||||
{
|
{
|
||||||
using (var context = _ApplicationDbContextFactory.CreateContext())
|
using var context = _ApplicationDbContextFactory.CreateContext();
|
||||||
{
|
|
||||||
context.Attach(file);
|
context.Attach(file);
|
||||||
context.Files.Remove(file);
|
context.Files.Remove(file);
|
||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task AddFile(StoredFile storedFile)
|
public async Task AddFile(StoredFile storedFile)
|
||||||
{
|
{
|
||||||
using (var context = _ApplicationDbContextFactory.CreateContext())
|
using var context = _ApplicationDbContextFactory.CreateContext();
|
||||||
{
|
|
||||||
await context.AddAsync(storedFile);
|
await context.AddAsync(storedFile);
|
||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public class FilesQuery
|
public class FilesQuery
|
||||||
{
|
{
|
||||||
|
@ -94,14 +94,10 @@ namespace BTCPayServer
|
|||||||
public async Task Send(string evt, CancellationToken cancellation = default)
|
public async Task Send(string evt, CancellationToken cancellation = default)
|
||||||
{
|
{
|
||||||
var bytes = UTF8.GetBytes(evt);
|
var bytes = UTF8.GetBytes(evt);
|
||||||
using (var cts = new CancellationTokenSource(5000))
|
using var cts = new CancellationTokenSource(5000);
|
||||||
{
|
using var cts2 = CancellationTokenSource.CreateLinkedTokenSource(cancellation);
|
||||||
using (var cts2 = CancellationTokenSource.CreateLinkedTokenSource(cancellation))
|
|
||||||
{
|
|
||||||
await Socket.SendAsync(new ArraySegment<byte>(bytes), WebSocketMessageType.Text, true, cts2.Token);
|
await Socket.SendAsync(new ArraySegment<byte>(bytes), WebSocketMessageType.Text, true, cts2.Token);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task DisposeAsync(CancellationToken cancellation)
|
public async Task DisposeAsync(CancellationToken cancellation)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user