Bug fix on StoreRoleId parsing

This commit is contained in:
nicolas.dorier
2023-05-27 12:51:48 +09:00
parent 783e4ccb35
commit 418b476725
2 changed files with 21 additions and 2 deletions

View File

@@ -26,6 +26,7 @@ using BTCPayServer.Services;
using BTCPayServer.Services.Invoices;
using BTCPayServer.Services.Labels;
using BTCPayServer.Services.Rates;
using BTCPayServer.Services.Stores;
using BTCPayServer.Validation;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
@@ -1382,6 +1383,24 @@ namespace BTCPayServer.Tests
Assert.Equal(cache.States[0].Rates[0].Pair, cache2.States[0].Rates[0].Pair);
}
[Fact]
public void CanParseStoreRoleId()
{
var id = StoreRoleId.Parse("test::lol");
Assert.Equal("test", id.StoreId);
Assert.Equal("lol", id.Role);
Assert.Equal("test::lol", id.ToString());
Assert.Equal("test::lol", id.Id);
Assert.False(id.IsServerRole);
id = StoreRoleId.Parse("lol");
Assert.Null(id.StoreId);
Assert.Equal("lol", id.Role);
Assert.Equal("lol", id.ToString());
Assert.Equal("lol", id.Id);
Assert.True(id.IsServerRole);
}
[Fact]
public void KitchenSinkTest()
{

View File

@@ -603,8 +603,8 @@ retry:
}
else
{
role = str[0..i];
storeId = str[(i + 2)..];
storeId = str[0..i];
role = str[(i + 2)..];
return new StoreRoleId(storeId, role);
}
}