mirror of
https://github.com/bitwarden/server.git
synced 2025-05-31 00:00:34 -05:00

* [PM-17562] Add support for retires on event integrations * Add additional test coverage * Fixed missing await call * Remove debug organization id * Respond to PR feedback * Change NotBeforeUtc to DelayUntilDate. Adjust comments. * Respond to PR feedback
43 lines
1.5 KiB
C#
43 lines
1.5 KiB
C#
using Bit.Core.AdminConsole.Models.Data.Integrations;
|
|
using Bit.Core.Services;
|
|
using Bit.Test.Common.AutoFixture;
|
|
using Bit.Test.Common.AutoFixture.Attributes;
|
|
using Bit.Test.Common.Helpers;
|
|
using NSubstitute;
|
|
using Xunit;
|
|
|
|
namespace Bit.Core.Test.Services;
|
|
|
|
[SutProviderCustomize]
|
|
public class SlackIntegrationHandlerTests
|
|
{
|
|
private readonly ISlackService _slackService = Substitute.For<ISlackService>();
|
|
private readonly string _channelId = "C12345";
|
|
private readonly string _token = "xoxb-test-token";
|
|
|
|
private SutProvider<SlackIntegrationHandler> GetSutProvider()
|
|
{
|
|
return new SutProvider<SlackIntegrationHandler>()
|
|
.SetDependency(_slackService)
|
|
.Create();
|
|
}
|
|
|
|
[Theory, BitAutoData]
|
|
public async Task HandleAsync_SuccessfulRequest_ReturnsSuccess(IntegrationMessage<SlackIntegrationConfigurationDetails> message)
|
|
{
|
|
var sutProvider = GetSutProvider();
|
|
message.Configuration = new SlackIntegrationConfigurationDetails(_channelId, _token);
|
|
|
|
var result = await sutProvider.Sut.HandleAsync(message);
|
|
|
|
Assert.True(result.Success);
|
|
Assert.Equal(result.Message, message);
|
|
|
|
await sutProvider.GetDependency<ISlackService>().Received(1).SendSlackMessageByChannelIdAsync(
|
|
Arg.Is(AssertHelper.AssertPropertyEqual(_token)),
|
|
Arg.Is(AssertHelper.AssertPropertyEqual(message.RenderedTemplate)),
|
|
Arg.Is(AssertHelper.AssertPropertyEqual(_channelId))
|
|
);
|
|
}
|
|
}
|