diff --git a/src/Api/Dirt/Controllers/OrganizationIntegrationController.cs b/src/Api/Dirt/Controllers/OrganizationIntegrationController.cs index 44a42dfe181a..31acbddd5237 100644 --- a/src/Api/Dirt/Controllers/OrganizationIntegrationController.cs +++ b/src/Api/Dirt/Controllers/OrganizationIntegrationController.cs @@ -2,7 +2,6 @@ using Bit.Api.Dirt.Models.Response; using Bit.Core.Context; using Bit.Core.Dirt.EventIntegrations.OrganizationIntegrations.Interfaces; -using Bit.Core.Exceptions; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -18,17 +17,17 @@ public class OrganizationIntegrationController( IGetOrganizationIntegrationsQuery getQuery) : Controller { [HttpGet("")] - public async Task> GetAsync(Guid organizationId) + public async Task>> GetAsync(Guid organizationId) { if (!await HasPermission(organizationId)) { - throw new NotFoundException(); + return NotFound(); } var integrations = await getQuery.GetManyByOrganizationAsync(organizationId); - return integrations + return Ok(integrations .Select(integration => new OrganizationIntegrationResponseModel(integration)) - .ToList(); + .ToList()); } /// @@ -38,7 +37,7 @@ public async Task> GetAsync(Guid orga /// /// /// - /// Not enough permissions to access the organization. + /// Not enough permissions to access the organization. /// When an integration of the same type already exists for the organization. [HttpPost("")] public async Task> CreateAsync(Guid organizationId, [FromBody] OrganizationIntegrationRequestModel model) @@ -50,7 +49,7 @@ public async Task> CreateAsyn if (!await HasPermission(organizationId)) { - throw new NotFoundException(); + return NotFound(); } var integration = model.ToOrganizationIntegration(organizationId); @@ -62,40 +61,40 @@ public async Task> CreateAsyn } var created = await createCommand.CreateAsync(integration); - return Ok(new OrganizationIntegrationResponseModel(created)); + } [HttpPut("{integrationId:guid}")] - public async Task UpdateAsync(Guid organizationId, Guid integrationId, [FromBody] OrganizationIntegrationRequestModel model) + public async Task> UpdateAsync(Guid organizationId, Guid integrationId, [FromBody] OrganizationIntegrationRequestModel model) { if (!await HasPermission(organizationId)) { - throw new NotFoundException(); + return NotFound(); } var integration = model.ToOrganizationIntegration(organizationId); var updated = await updateCommand.UpdateAsync(organizationId, integrationId, integration); - - return new OrganizationIntegrationResponseModel(updated); + return Ok(new OrganizationIntegrationResponseModel(updated)); } [HttpDelete("{integrationId:guid}")] - public async Task DeleteAsync(Guid organizationId, Guid integrationId) + public async Task DeleteAsync(Guid organizationId, Guid integrationId) { if (!await HasPermission(organizationId)) { - throw new NotFoundException(); + return NotFound(); } await deleteCommand.DeleteAsync(organizationId, integrationId); + return NoContent(); } [HttpPost("{integrationId:guid}/delete")] [Obsolete("This endpoint is deprecated. Use DELETE method instead")] - public async Task PostDeleteAsync(Guid organizationId, Guid integrationId) + public async Task PostDeleteAsync(Guid organizationId, Guid integrationId) { - await DeleteAsync(organizationId, integrationId); + return await DeleteAsync(organizationId, integrationId); } private async Task HasPermission(Guid organizationId) diff --git a/src/Core/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/CreateOrganizationIntegrationConfigurationCommand.cs b/src/Core/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/CreateOrganizationIntegrationConfigurationCommand.cs index 478b43bb7e18..b8bd266e44d4 100644 --- a/src/Core/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/CreateOrganizationIntegrationConfigurationCommand.cs +++ b/src/Core/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/CreateOrganizationIntegrationConfigurationCommand.cs @@ -27,7 +27,7 @@ public async Task CreateAsync( var integration = await integrationRepository.GetByIdAsync(integrationId); if (integration == null || integration.OrganizationId != organizationId) { - throw new NotFoundException(); + throw new BadRequestException(); } if (!validator.ValidateConfiguration(integration.Type, configuration)) { diff --git a/src/Core/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/DeleteOrganizationIntegrationConfigurationCommand.cs b/src/Core/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/DeleteOrganizationIntegrationConfigurationCommand.cs index d6369f1b1ba0..f78e17560c08 100644 --- a/src/Core/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/DeleteOrganizationIntegrationConfigurationCommand.cs +++ b/src/Core/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/DeleteOrganizationIntegrationConfigurationCommand.cs @@ -21,12 +21,12 @@ public async Task DeleteAsync(Guid organizationId, Guid integrationId, Guid conf var integration = await integrationRepository.GetByIdAsync(integrationId); if (integration == null || integration.OrganizationId != organizationId) { - throw new NotFoundException(); + throw new BadRequestException("Integration not found for this organization."); } var configuration = await configurationRepository.GetByIdAsync(configurationId); if (configuration is null || configuration.OrganizationIntegrationId != integrationId) { - throw new NotFoundException(); + throw new BadRequestException("Configuration not found for this integration."); } await configurationRepository.DeleteAsync(configuration); diff --git a/src/Core/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/Interfaces/ICreateOrganizationIntegrationConfigurationCommand.cs b/src/Core/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/Interfaces/ICreateOrganizationIntegrationConfigurationCommand.cs index 629a1ee8edb6..1b327ab81f27 100644 --- a/src/Core/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/Interfaces/ICreateOrganizationIntegrationConfigurationCommand.cs +++ b/src/Core/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/Interfaces/ICreateOrganizationIntegrationConfigurationCommand.cs @@ -14,7 +14,7 @@ public interface ICreateOrganizationIntegrationConfigurationCommand /// The unique identifier of the integration. /// The configuration to create. /// The created configuration. - /// Thrown when the integration does not exist + /// Thrown when the integration does not exist /// or does not belong to the specified organization. /// Thrown when the configuration or filters /// are invalid for the integration type. diff --git a/src/Core/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/Interfaces/IUpdateOrganizationIntegrationConfigurationCommand.cs b/src/Core/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/Interfaces/IUpdateOrganizationIntegrationConfigurationCommand.cs index 3ed680b808c5..0106e2cd5db3 100644 --- a/src/Core/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/Interfaces/IUpdateOrganizationIntegrationConfigurationCommand.cs +++ b/src/Core/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/Interfaces/IUpdateOrganizationIntegrationConfigurationCommand.cs @@ -15,7 +15,7 @@ public interface IUpdateOrganizationIntegrationConfigurationCommand /// The unique identifier of the configuration to update. /// The updated configuration data. /// The updated configuration. - /// + /// Thrown when the integration or the configuration does not exist, /// Thrown when the integration or the configuration does not exist, /// or the integration does not belong to the specified organization, /// or the configuration does not belong to the specified integration. diff --git a/src/Core/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/UpdateOrganizationIntegrationConfigurationCommand.cs b/src/Core/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/UpdateOrganizationIntegrationConfigurationCommand.cs index 69c28f3e7ec5..ce57ed5b91c4 100644 --- a/src/Core/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/UpdateOrganizationIntegrationConfigurationCommand.cs +++ b/src/Core/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/UpdateOrganizationIntegrationConfigurationCommand.cs @@ -28,12 +28,12 @@ public async Task UpdateAsync( var integration = await integrationRepository.GetByIdAsync(integrationId); if (integration == null || integration.OrganizationId != organizationId) { - throw new NotFoundException(); + throw new BadRequestException("Integration not found for this organization."); } var configuration = await configurationRepository.GetByIdAsync(configurationId); if (configuration is null || configuration.OrganizationIntegrationId != integrationId) { - throw new NotFoundException(); + throw new BadRequestException("Configuration not found for this integration."); } if (!validator.ValidateConfiguration(integration.Type, updatedConfiguration)) { diff --git a/src/Core/Dirt/EventIntegrations/OrganizationIntegrations/DeleteOrganizationIntegrationCommand.cs b/src/Core/Dirt/EventIntegrations/OrganizationIntegrations/DeleteOrganizationIntegrationCommand.cs index dc1e7fb1dc52..804585132f86 100644 --- a/src/Core/Dirt/EventIntegrations/OrganizationIntegrations/DeleteOrganizationIntegrationCommand.cs +++ b/src/Core/Dirt/EventIntegrations/OrganizationIntegrations/DeleteOrganizationIntegrationCommand.cs @@ -20,7 +20,7 @@ public async Task DeleteAsync(Guid organizationId, Guid integrationId) var integration = await integrationRepository.GetByIdAsync(integrationId); if (integration is null || integration.OrganizationId != organizationId) { - throw new NotFoundException(); + throw new BadRequestException("Integration not found for this organization."); } await integrationRepository.DeleteAsync(integration); diff --git a/src/Core/Dirt/EventIntegrations/OrganizationIntegrations/Interfaces/IDeleteOrganizationIntegrationCommand.cs b/src/Core/Dirt/EventIntegrations/OrganizationIntegrations/Interfaces/IDeleteOrganizationIntegrationCommand.cs index 8640f03ec83f..6feca70f240a 100644 --- a/src/Core/Dirt/EventIntegrations/OrganizationIntegrations/Interfaces/IDeleteOrganizationIntegrationCommand.cs +++ b/src/Core/Dirt/EventIntegrations/OrganizationIntegrations/Interfaces/IDeleteOrganizationIntegrationCommand.cs @@ -10,7 +10,7 @@ public interface IDeleteOrganizationIntegrationCommand /// /// The unique identifier of the organization. /// The unique identifier of the integration to delete. - /// Thrown when the integration does not exist + /// Thrown when the integration does not exist /// or does not belong to the specified organization. Task DeleteAsync(Guid organizationId, Guid integrationId); } diff --git a/src/Core/Dirt/EventIntegrations/OrganizationIntegrations/Interfaces/IUpdateOrganizationIntegrationCommand.cs b/src/Core/Dirt/EventIntegrations/OrganizationIntegrations/Interfaces/IUpdateOrganizationIntegrationCommand.cs index ddba2bd23304..6e3b6b570080 100644 --- a/src/Core/Dirt/EventIntegrations/OrganizationIntegrations/Interfaces/IUpdateOrganizationIntegrationCommand.cs +++ b/src/Core/Dirt/EventIntegrations/OrganizationIntegrations/Interfaces/IUpdateOrganizationIntegrationCommand.cs @@ -14,7 +14,7 @@ public interface IUpdateOrganizationIntegrationCommand /// The unique identifier of the integration to update. /// The updated organization integration data. /// The updated organization integration. - /// Thrown when the integration does not exist, + /// Thrown when the integration does not exist, /// does not belong to the specified organization, or the integration type does not match. Task UpdateAsync(Guid organizationId, Guid integrationId, OrganizationIntegration updatedIntegration); } diff --git a/src/Core/Dirt/EventIntegrations/OrganizationIntegrations/UpdateOrganizationIntegrationCommand.cs b/src/Core/Dirt/EventIntegrations/OrganizationIntegrations/UpdateOrganizationIntegrationCommand.cs index 77a34482764a..d8ca695bc8ed 100644 --- a/src/Core/Dirt/EventIntegrations/OrganizationIntegrations/UpdateOrganizationIntegrationCommand.cs +++ b/src/Core/Dirt/EventIntegrations/OrganizationIntegrations/UpdateOrganizationIntegrationCommand.cs @@ -27,7 +27,7 @@ public async Task UpdateAsync( integration.OrganizationId != organizationId || integration.Type != updatedIntegration.Type) { - throw new NotFoundException(); + throw new BadRequestException("Integration not found for this organization with the specified type."); } updatedIntegration.Id = integration.Id; diff --git a/test/Api.Test/Dirt/Controllers/OrganizationIntegrationControllerTests.cs b/test/Api.Test/Dirt/Controllers/OrganizationIntegrationControllerTests.cs index 5e80d5684b10..5e55732b6d4e 100644 --- a/test/Api.Test/Dirt/Controllers/OrganizationIntegrationControllerTests.cs +++ b/test/Api.Test/Dirt/Controllers/OrganizationIntegrationControllerTests.cs @@ -5,7 +5,6 @@ using Bit.Core.Dirt.Entities; using Bit.Core.Dirt.Enums; using Bit.Core.Dirt.EventIntegrations.OrganizationIntegrations.Interfaces; -using Bit.Core.Exceptions; using Bit.Test.Common.AutoFixture; using Bit.Test.Common.AutoFixture.Attributes; using Microsoft.AspNetCore.Mvc; @@ -34,7 +33,8 @@ public async Task GetAsync_UserIsNotOrganizationAdmin_ThrowsNotFound( .OrganizationOwner(organizationId) .Returns(false); - await Assert.ThrowsAsync(() => sutProvider.Sut.GetAsync(organizationId)); + var result = await sutProvider.Sut.GetAsync(organizationId); + Assert.IsType(result.Result); } [Theory, BitAutoData] @@ -56,8 +56,11 @@ public async Task GetAsync_IntegrationsExist_ReturnsIntegrations( await sutProvider.GetDependency().Received(1) .GetManyByOrganizationAsync(organizationId); - Assert.Equal(integrations.Count, result.Count); - Assert.All(result, r => Assert.IsType(r)); + Assert.IsType(result.Result); + var okResult = result.Result as OkObjectResult; + var returnedIntegrations = okResult.Value as List; + Assert.Equal(integrations.Count, returnedIntegrations.Count); + Assert.All(returnedIntegrations, r => Assert.IsType(r)); } [Theory, BitAutoData] @@ -71,11 +74,13 @@ public async Task GetAsync_NoIntegrations_ReturnsEmptyList( .Returns(true); sutProvider.GetDependency() .GetManyByOrganizationAsync(organizationId) - .Returns([]); + .Returns(new List()); var result = await sutProvider.Sut.GetAsync(organizationId); - Assert.Empty(result); + var okResult = result.Result as OkObjectResult; + var returnedIntegrations = okResult.Value as List; + Assert.Empty(returnedIntegrations); } [Theory, BitAutoData] @@ -129,7 +134,7 @@ public async Task CreateAsync_TheTypeAlreadyExists_ThrowsConflict( } [Theory, BitAutoData] - public async Task CreateAsync_UserIsNotOrganizationAdmin_ThrowsNotFound( + public async Task CreateAsync_UserIsNotOrganizationAdmin_ReturnsNotFound( SutProvider sutProvider, Guid organizationId) { @@ -138,8 +143,9 @@ public async Task CreateAsync_UserIsNotOrganizationAdmin_ThrowsNotFound( .OrganizationOwner(organizationId) .Returns(false); - await Assert.ThrowsAsync(async () => - await sutProvider.Sut.CreateAsync(organizationId, _webhookRequestModel)); + var response = await sutProvider.Sut.CreateAsync(organizationId, _webhookRequestModel); + + Assert.IsType(response.Result); } [Theory, BitAutoData] @@ -178,7 +184,7 @@ await sutProvider.GetDependency().Receive } [Theory, BitAutoData] - public async Task DeleteAsync_UserIsNotOrganizationAdmin_ThrowsNotFound( + public async Task DeleteAsync_UserIsNotOrganizationAdmin_ReturnsNotFound( SutProvider sutProvider, Guid organizationId, Guid integrationId) @@ -188,8 +194,9 @@ public async Task DeleteAsync_UserIsNotOrganizationAdmin_ThrowsNotFound( .OrganizationOwner(organizationId) .Returns(false); - await Assert.ThrowsAsync(async () => - await sutProvider.Sut.DeleteAsync(organizationId, integrationId)); + var response = await sutProvider.Sut.DeleteAsync(organizationId, integrationId); + + Assert.IsType(response); } [Theory, BitAutoData] @@ -217,12 +224,16 @@ await sutProvider.GetDependency().Receive .UpdateAsync(organizationId, integrationId, Arg.Is(i => i.OrganizationId == organizationId && i.Type == IntegrationType.Webhook)); - Assert.IsType(response); - Assert.Equal(IntegrationType.Webhook, response.Type); + Assert.IsType(response.Result); + var okResult = response.Result as OkObjectResult; + Assert.NotNull(okResult); + var resultValue = okResult!.Value as OrganizationIntegrationResponseModel; + Assert.NotNull(resultValue); + Assert.Equal(IntegrationType.Webhook, resultValue!.Type); } [Theory, BitAutoData] - public async Task UpdateAsync_UserIsNotOrganizationAdmin_ThrowsNotFound( + public async Task UpdateAsync_UserIsNotOrganizationAdmin_ReturnsNotFound( SutProvider sutProvider, Guid organizationId, Guid integrationId) @@ -232,7 +243,8 @@ public async Task UpdateAsync_UserIsNotOrganizationAdmin_ThrowsNotFound( .OrganizationOwner(organizationId) .Returns(false); - await Assert.ThrowsAsync(async () => - await sutProvider.Sut.UpdateAsync(organizationId, integrationId, _webhookRequestModel)); + var response = await sutProvider.Sut.UpdateAsync(organizationId, integrationId, _webhookRequestModel); + + Assert.IsType(response.Result); } } diff --git a/test/Core.Test/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/CreateOrganizationIntegrationConfigurationCommandTests.cs b/test/Core.Test/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/CreateOrganizationIntegrationConfigurationCommandTests.cs index 3ad3569c07c6..4101ce3ec471 100644 --- a/test/Core.Test/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/CreateOrganizationIntegrationConfigurationCommandTests.cs +++ b/test/Core.Test/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/CreateOrganizationIntegrationConfigurationCommandTests.cs @@ -99,7 +99,7 @@ await sutProvider.GetDependency().DidNotReceive() } [Theory, BitAutoData] - public async Task CreateAsync_IntegrationDoesNotExist_ThrowsNotFound( + public async Task CreateAsync_IntegrationDoesNotExist_ThrowsBadRequest( SutProvider sutProvider, Guid organizationId, Guid integrationId, @@ -109,7 +109,7 @@ public async Task CreateAsync_IntegrationDoesNotExist_ThrowsNotFound( .GetByIdAsync(integrationId) .Returns((OrganizationIntegration)null); - await Assert.ThrowsAsync( + await Assert.ThrowsAsync( () => sutProvider.Sut.CreateAsync(organizationId, integrationId, configuration)); await sutProvider.GetDependency().DidNotReceive() @@ -121,7 +121,7 @@ await sutProvider.GetDependency().DidNotReceive() } [Theory, BitAutoData] - public async Task CreateAsync_IntegrationDoesNotBelongToOrganization_ThrowsNotFound( + public async Task CreateAsync_IntegrationDoesNotBelongToOrganization_ThrowsBadRequest( SutProvider sutProvider, Guid organizationId, Guid integrationId, @@ -135,7 +135,7 @@ public async Task CreateAsync_IntegrationDoesNotBelongToOrganization_ThrowsNotFo .GetByIdAsync(integrationId) .Returns(integration); - await Assert.ThrowsAsync( + await Assert.ThrowsAsync( () => sutProvider.Sut.CreateAsync(organizationId, integrationId, configuration)); await sutProvider.GetDependency().DidNotReceive() diff --git a/test/Core.Test/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/DeleteOrganizationIntegrationConfigurationCommandTests.cs b/test/Core.Test/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/DeleteOrganizationIntegrationConfigurationCommandTests.cs index c053a761bb19..339edb7d56ec 100644 --- a/test/Core.Test/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/DeleteOrganizationIntegrationConfigurationCommandTests.cs +++ b/test/Core.Test/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/DeleteOrganizationIntegrationConfigurationCommandTests.cs @@ -98,7 +98,7 @@ await sutProvider.GetDependency().DidNotReceive() } [Theory, BitAutoData] - public async Task DeleteAsync_IntegrationDoesNotExist_ThrowsNotFound( + public async Task DeleteAsync_IntegrationDoesNotExist_ThrowsBadRequest( SutProvider sutProvider, Guid organizationId, Guid integrationId, @@ -108,7 +108,7 @@ public async Task DeleteAsync_IntegrationDoesNotExist_ThrowsNotFound( .GetByIdAsync(integrationId) .Returns((OrganizationIntegration)null); - await Assert.ThrowsAsync( + await Assert.ThrowsAsync( () => sutProvider.Sut.DeleteAsync(organizationId, integrationId, configurationId)); await sutProvider.GetDependency().DidNotReceive() @@ -122,7 +122,7 @@ await sutProvider.GetDependency().DidNotReceive() } [Theory, BitAutoData] - public async Task DeleteAsync_IntegrationDoesNotBelongToOrganization_ThrowsNotFound( + public async Task DeleteAsync_IntegrationDoesNotBelongToOrganization_ThrowsBadRequest( SutProvider sutProvider, Guid organizationId, Guid integrationId, @@ -136,7 +136,7 @@ public async Task DeleteAsync_IntegrationDoesNotBelongToOrganization_ThrowsNotFo .GetByIdAsync(integrationId) .Returns(integration); - await Assert.ThrowsAsync( + await Assert.ThrowsAsync( () => sutProvider.Sut.DeleteAsync(organizationId, integrationId, configurationId)); await sutProvider.GetDependency().DidNotReceive() @@ -150,7 +150,7 @@ await sutProvider.GetDependency().DidNotReceive() } [Theory, BitAutoData] - public async Task DeleteAsync_ConfigurationDoesNotExist_ThrowsNotFound( + public async Task DeleteAsync_ConfigurationDoesNotExist_ThrowsBadRequest( SutProvider sutProvider, Guid organizationId, Guid integrationId, @@ -167,7 +167,7 @@ public async Task DeleteAsync_ConfigurationDoesNotExist_ThrowsNotFound( .GetByIdAsync(configurationId) .Returns((OrganizationIntegrationConfiguration)null); - await Assert.ThrowsAsync( + await Assert.ThrowsAsync( () => sutProvider.Sut.DeleteAsync(organizationId, integrationId, configurationId)); await sutProvider.GetDependency().DidNotReceive() @@ -179,7 +179,7 @@ await sutProvider.GetDependency().DidNotReceive() } [Theory, BitAutoData] - public async Task DeleteAsync_ConfigurationDoesNotBelongToIntegration_ThrowsNotFound( + public async Task DeleteAsync_ConfigurationDoesNotBelongToIntegration_ThrowsBadRequest( SutProvider sutProvider, Guid organizationId, Guid integrationId, @@ -199,7 +199,7 @@ public async Task DeleteAsync_ConfigurationDoesNotBelongToIntegration_ThrowsNotF .GetByIdAsync(configurationId) .Returns(configuration); - await Assert.ThrowsAsync( + await Assert.ThrowsAsync( () => sutProvider.Sut.DeleteAsync(organizationId, integrationId, configurationId)); await sutProvider.GetDependency().DidNotReceive() diff --git a/test/Core.Test/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/UpdateOrganizationIntegrationConfigurationCommandTests.cs b/test/Core.Test/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/UpdateOrganizationIntegrationConfigurationCommandTests.cs index 42ea278aa6a1..9b384d137d46 100644 --- a/test/Core.Test/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/UpdateOrganizationIntegrationConfigurationCommandTests.cs +++ b/test/Core.Test/Dirt/EventIntegrations/OrganizationIntegrationConfigurations/UpdateOrganizationIntegrationConfigurationCommandTests.cs @@ -169,7 +169,7 @@ await sutProvider.GetDependency().DidNotReceive() } [Theory, BitAutoData] - public async Task UpdateAsync_IntegrationDoesNotExist_ThrowsNotFound( + public async Task UpdateAsync_IntegrationDoesNotExist_ThrowsBadRequest( SutProvider sutProvider, Guid organizationId, Guid integrationId, @@ -180,7 +180,7 @@ public async Task UpdateAsync_IntegrationDoesNotExist_ThrowsNotFound( .GetByIdAsync(integrationId) .Returns((OrganizationIntegration)null); - await Assert.ThrowsAsync( + await Assert.ThrowsAsync( () => sutProvider.Sut.UpdateAsync(organizationId, integrationId, configurationId, updatedConfiguration)); await sutProvider.GetDependency().DidNotReceive() @@ -194,7 +194,7 @@ await sutProvider.GetDependency().DidNotReceive() } [Theory, BitAutoData] - public async Task UpdateAsync_IntegrationDoesNotBelongToOrganization_ThrowsNotFound( + public async Task UpdateAsync_IntegrationDoesNotBelongToOrganization_ThrowsBadRequest( SutProvider sutProvider, Guid organizationId, Guid integrationId, @@ -209,7 +209,7 @@ public async Task UpdateAsync_IntegrationDoesNotBelongToOrganization_ThrowsNotFo .GetByIdAsync(integrationId) .Returns(integration); - await Assert.ThrowsAsync( + await Assert.ThrowsAsync( () => sutProvider.Sut.UpdateAsync(organizationId, integrationId, configurationId, updatedConfiguration)); await sutProvider.GetDependency().DidNotReceive() @@ -223,7 +223,7 @@ await sutProvider.GetDependency().DidNotReceive() } [Theory, BitAutoData] - public async Task UpdateAsync_ConfigurationDoesNotExist_ThrowsNotFound( + public async Task UpdateAsync_ConfigurationDoesNotExist_ThrowsBadRequest( SutProvider sutProvider, Guid organizationId, Guid integrationId, @@ -241,7 +241,7 @@ public async Task UpdateAsync_ConfigurationDoesNotExist_ThrowsNotFound( .GetByIdAsync(configurationId) .Returns((OrganizationIntegrationConfiguration)null); - await Assert.ThrowsAsync( + await Assert.ThrowsAsync( () => sutProvider.Sut.UpdateAsync(organizationId, integrationId, configurationId, updatedConfiguration)); await sutProvider.GetDependency().DidNotReceive() @@ -253,7 +253,7 @@ await sutProvider.GetDependency().DidNotReceive() } [Theory, BitAutoData] - public async Task UpdateAsync_ConfigurationDoesNotBelongToIntegration_ThrowsNotFound( + public async Task UpdateAsync_ConfigurationDoesNotBelongToIntegration_ThrowsBadRequest( SutProvider sutProvider, Guid organizationId, Guid integrationId, @@ -274,7 +274,7 @@ public async Task UpdateAsync_ConfigurationDoesNotBelongToIntegration_ThrowsNotF .GetByIdAsync(configurationId) .Returns(existingConfiguration); - await Assert.ThrowsAsync( + await Assert.ThrowsAsync( () => sutProvider.Sut.UpdateAsync(organizationId, integrationId, configurationId, updatedConfiguration)); await sutProvider.GetDependency().DidNotReceive() diff --git a/test/Core.Test/Dirt/EventIntegrations/OrganizationIntegrations/DeleteOrganizationIntegrationCommandTests.cs b/test/Core.Test/Dirt/EventIntegrations/OrganizationIntegrations/DeleteOrganizationIntegrationCommandTests.cs index 15a3b44bcfde..69cbf1c4e714 100644 --- a/test/Core.Test/Dirt/EventIntegrations/OrganizationIntegrations/DeleteOrganizationIntegrationCommandTests.cs +++ b/test/Core.Test/Dirt/EventIntegrations/OrganizationIntegrations/DeleteOrganizationIntegrationCommandTests.cs @@ -43,7 +43,7 @@ await sutProvider.GetDependency().Received(1) } [Theory, BitAutoData] - public async Task DeleteAsync_IntegrationDoesNotExist_ThrowsNotFound( + public async Task DeleteAsync_IntegrationDoesNotExist_ThrowsBadRequest( SutProvider sutProvider, Guid organizationId, Guid integrationId) @@ -52,7 +52,7 @@ public async Task DeleteAsync_IntegrationDoesNotExist_ThrowsNotFound( .GetByIdAsync(integrationId) .Returns((OrganizationIntegration)null); - await Assert.ThrowsAsync( + await Assert.ThrowsAsync( () => sutProvider.Sut.DeleteAsync(organizationId, integrationId)); await sutProvider.GetDependency().DidNotReceive() @@ -62,7 +62,7 @@ await sutProvider.GetDependency().DidNotReceive() } [Theory, BitAutoData] - public async Task DeleteAsync_IntegrationDoesNotBelongToOrganization_ThrowsNotFound( + public async Task DeleteAsync_IntegrationDoesNotBelongToOrganization_ThrowsBadRequest( SutProvider sutProvider, Guid organizationId, Guid integrationId, @@ -75,7 +75,7 @@ public async Task DeleteAsync_IntegrationDoesNotBelongToOrganization_ThrowsNotFo .GetByIdAsync(integrationId) .Returns(integration); - await Assert.ThrowsAsync( + await Assert.ThrowsAsync( () => sutProvider.Sut.DeleteAsync(organizationId, integrationId)); await sutProvider.GetDependency().DidNotReceive() diff --git a/test/Core.Test/Dirt/EventIntegrations/OrganizationIntegrations/UpdateOrganizationIntegrationCommandTests.cs b/test/Core.Test/Dirt/EventIntegrations/OrganizationIntegrations/UpdateOrganizationIntegrationCommandTests.cs index 34bf02c34b7e..2de690bf56d0 100644 --- a/test/Core.Test/Dirt/EventIntegrations/OrganizationIntegrations/UpdateOrganizationIntegrationCommandTests.cs +++ b/test/Core.Test/Dirt/EventIntegrations/OrganizationIntegrations/UpdateOrganizationIntegrationCommandTests.cs @@ -48,7 +48,7 @@ await sutProvider.GetDependency().Received(1) } [Theory, BitAutoData] - public async Task UpdateAsync_IntegrationDoesNotExist_ThrowsNotFound( + public async Task UpdateAsync_IntegrationDoesNotExist_ThrowsBadRequest( SutProvider sutProvider, Guid organizationId, Guid integrationId, @@ -58,7 +58,7 @@ public async Task UpdateAsync_IntegrationDoesNotExist_ThrowsNotFound( .GetByIdAsync(integrationId) .Returns((OrganizationIntegration)null); - await Assert.ThrowsAsync( + await Assert.ThrowsAsync( () => sutProvider.Sut.UpdateAsync(organizationId, integrationId, updatedIntegration)); await sutProvider.GetDependency().DidNotReceive() @@ -68,7 +68,7 @@ await sutProvider.GetDependency().DidNotReceive() } [Theory, BitAutoData] - public async Task UpdateAsync_IntegrationDoesNotBelongToOrganization_ThrowsNotFound( + public async Task UpdateAsync_IntegrationDoesNotBelongToOrganization_ThrowsBadRequest( SutProvider sutProvider, Guid organizationId, Guid integrationId, @@ -82,7 +82,7 @@ public async Task UpdateAsync_IntegrationDoesNotBelongToOrganization_ThrowsNotFo .GetByIdAsync(integrationId) .Returns(existingIntegration); - await Assert.ThrowsAsync( + await Assert.ThrowsAsync( () => sutProvider.Sut.UpdateAsync(organizationId, integrationId, updatedIntegration)); await sutProvider.GetDependency().DidNotReceive() @@ -92,7 +92,7 @@ await sutProvider.GetDependency().DidNotReceive() } [Theory, BitAutoData] - public async Task UpdateAsync_IntegrationIsDifferentType_ThrowsNotFound( + public async Task UpdateAsync_IntegrationIsDifferentType_ThrowsBadRequest( SutProvider sutProvider, Guid organizationId, Guid integrationId, @@ -110,7 +110,7 @@ public async Task UpdateAsync_IntegrationIsDifferentType_ThrowsNotFound( .GetByIdAsync(integrationId) .Returns(existingIntegration); - await Assert.ThrowsAsync( + await Assert.ThrowsAsync( () => sutProvider.Sut.UpdateAsync(organizationId, integrationId, updatedIntegration)); await sutProvider.GetDependency().DidNotReceive()