Masking smtp server email returned over greenfield api and test

This commit is contained in:
rockstardev 2025-02-15 00:41:42 -06:00
parent 884126864e
commit 47ff3c3595
No known key found for this signature in database
GPG key ID: 4F224698945A6EE7
2 changed files with 9 additions and 2 deletions

View file

@ -4156,6 +4156,8 @@ namespace BTCPayServer.Tests
};
await adminClient.UpdateStoreEmailSettings(admin.StoreId, data);
var s = await adminClient.GetStoreEmailSettings(admin.StoreId);
// email password is masked and not returned from the server once set
data.Password = ServerEmailSettingsData.PasswordMask;
Assert.Equal(JsonConvert.SerializeObject(s), JsonConvert.SerializeObject(data));
await AssertValidationError(new[] { nameof(EmailSettingsData.From) },
async () => await adminClient.UpdateStoreEmailSettings(admin.StoreId,

View file

@ -55,7 +55,6 @@ namespace BTCPayServer.Controllers.GreenField
[HttpGet("~/api/v1/stores/{storeId}/email")]
public IActionResult GetStoreEmailSettings()
{
var store = HttpContext.GetStoreData();
return store == null ? StoreNotFound() : Ok(FromModel(store));
}
@ -87,7 +86,13 @@ namespace BTCPayServer.Controllers.GreenField
}
private EmailSettings FromModel(Data.StoreData data)
{
return data.GetStoreBlob().EmailSettings ?? new();
var emailSettings = data.GetStoreBlob().EmailSettings;
if (emailSettings == null)
return new EmailSettings();
emailSettings.Password = ServerEmailSettingsData.PasswordMask;
return emailSettings;
}
private IActionResult StoreNotFound()
{