From c172e80ee17cfe56a5b4ea90cd5cdf8115c9f1ed Mon Sep 17 00:00:00 2001 From: voommen-livefront Date: Mon, 13 Apr 2026 09:23:19 -0500 Subject: [PATCH 1/6] PM-34822 when lacking permissions return a Forbid() response --- .../OrganizationIntegrationController.cs | 15 +++++----- .../OrganizationIntegrationControllerTests.cs | 29 ++++++++++++------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/Api/Dirt/Controllers/OrganizationIntegrationController.cs b/src/Api/Dirt/Controllers/OrganizationIntegrationController.cs index 44a42dfe181a..c173df06d91b 100644 --- a/src/Api/Dirt/Controllers/OrganizationIntegrationController.cs +++ b/src/Api/Dirt/Controllers/OrganizationIntegrationController.cs @@ -38,7 +38,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 +50,7 @@ public async Task> CreateAsyn if (!await HasPermission(organizationId)) { - throw new NotFoundException(); + return Forbid(); } var integration = model.ToOrganizationIntegration(organizationId); @@ -67,28 +67,29 @@ public async Task> CreateAsyn } [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 Forbid(); } 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 Forbid(); } await deleteCommand.DeleteAsync(organizationId, integrationId); + return NoContent(); } [HttpPost("{integrationId:guid}/delete")] diff --git a/test/Api.Test/Dirt/Controllers/OrganizationIntegrationControllerTests.cs b/test/Api.Test/Dirt/Controllers/OrganizationIntegrationControllerTests.cs index 5e80d5684b10..a805eefdb573 100644 --- a/test/Api.Test/Dirt/Controllers/OrganizationIntegrationControllerTests.cs +++ b/test/Api.Test/Dirt/Controllers/OrganizationIntegrationControllerTests.cs @@ -129,7 +129,7 @@ public async Task CreateAsync_TheTypeAlreadyExists_ThrowsConflict( } [Theory, BitAutoData] - public async Task CreateAsync_UserIsNotOrganizationAdmin_ThrowsNotFound( + public async Task CreateAsync_UserIsNotOrganizationAdmin_ReturnsForbid( SutProvider sutProvider, Guid organizationId) { @@ -138,8 +138,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 +179,7 @@ await sutProvider.GetDependency().Receive } [Theory, BitAutoData] - public async Task DeleteAsync_UserIsNotOrganizationAdmin_ThrowsNotFound( + public async Task DeleteAsync_UserIsNotOrganizationAdmin_ReturnsForbid( SutProvider sutProvider, Guid organizationId, Guid integrationId) @@ -188,8 +189,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 +219,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_ReturnsForbid( SutProvider sutProvider, Guid organizationId, Guid integrationId) @@ -232,7 +238,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); } } From d294408ed861d98e0af24525f6d0cff5681d916f Mon Sep 17 00:00:00 2001 From: voommen-livefront Date: Mon, 13 Apr 2026 10:38:02 -0500 Subject: [PATCH 2/6] PM-34822 for consistency update the Get method and unit tests to return Forbid when the user has not permissions --- .../OrganizationIntegrationController.cs | 13 ++++++------- .../OrganizationIntegrationControllerTests.cs | 17 +++++++++++------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Api/Dirt/Controllers/OrganizationIntegrationController.cs b/src/Api/Dirt/Controllers/OrganizationIntegrationController.cs index c173df06d91b..978fe764663a 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 Forbid(); } var integrations = await getQuery.GetManyByOrganizationAsync(organizationId); - return integrations + return Ok(integrations .Select(integration => new OrganizationIntegrationResponseModel(integration)) - .ToList(); + .ToList()); } /// @@ -94,9 +93,9 @@ public async Task DeleteAsync(Guid organizationId, Guid integrati [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/test/Api.Test/Dirt/Controllers/OrganizationIntegrationControllerTests.cs b/test/Api.Test/Dirt/Controllers/OrganizationIntegrationControllerTests.cs index a805eefdb573..2078faa81fc2 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] From 8f33e3e7c2605991091b2e1be154b8266847dd35 Mon Sep 17 00:00:00 2001 From: voommen-livefront Date: Wed, 22 Apr 2026 13:55:55 -0500 Subject: [PATCH 3/6] PM-34822 replace 403 with 422 --- .../Controllers/OrganizationIntegrationController.cs | 10 +++++----- .../OrganizationIntegrationControllerTests.cs | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Api/Dirt/Controllers/OrganizationIntegrationController.cs b/src/Api/Dirt/Controllers/OrganizationIntegrationController.cs index 978fe764663a..a3e0b810ab9a 100644 --- a/src/Api/Dirt/Controllers/OrganizationIntegrationController.cs +++ b/src/Api/Dirt/Controllers/OrganizationIntegrationController.cs @@ -21,7 +21,7 @@ public async Task>> GetA { if (!await HasPermission(organizationId)) { - return Forbid(); + return UnprocessableEntity(); } var integrations = await getQuery.GetManyByOrganizationAsync(organizationId); @@ -37,7 +37,7 @@ public async Task>> GetA /// /// /// - /// 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) @@ -49,7 +49,7 @@ public async Task> CreateAsyn if (!await HasPermission(organizationId)) { - return Forbid(); + return UnprocessableEntity(); } var integration = model.ToOrganizationIntegration(organizationId); @@ -70,7 +70,7 @@ public async Task> UpdateAsyn { if (!await HasPermission(organizationId)) { - return Forbid(); + return UnprocessableEntity(); } var integration = model.ToOrganizationIntegration(organizationId); @@ -84,7 +84,7 @@ public async Task DeleteAsync(Guid organizationId, Guid integrati { if (!await HasPermission(organizationId)) { - return Forbid(); + return UnprocessableEntity(); } await deleteCommand.DeleteAsync(organizationId, integrationId); diff --git a/test/Api.Test/Dirt/Controllers/OrganizationIntegrationControllerTests.cs b/test/Api.Test/Dirt/Controllers/OrganizationIntegrationControllerTests.cs index 2078faa81fc2..7571ff7cdf44 100644 --- a/test/Api.Test/Dirt/Controllers/OrganizationIntegrationControllerTests.cs +++ b/test/Api.Test/Dirt/Controllers/OrganizationIntegrationControllerTests.cs @@ -34,7 +34,7 @@ public async Task GetAsync_UserIsNotOrganizationAdmin_ThrowsNotFound( .Returns(false); var result = await sutProvider.Sut.GetAsync(organizationId); - Assert.IsType(result.Result); + Assert.IsType(result.Result); } [Theory, BitAutoData] @@ -145,7 +145,7 @@ public async Task CreateAsync_UserIsNotOrganizationAdmin_ReturnsForbid( var response = await sutProvider.Sut.CreateAsync(organizationId, _webhookRequestModel); - Assert.IsType(response.Result); + Assert.IsType(response.Result); } [Theory, BitAutoData] @@ -196,7 +196,7 @@ public async Task DeleteAsync_UserIsNotOrganizationAdmin_ReturnsForbid( var response = await sutProvider.Sut.DeleteAsync(organizationId, integrationId); - Assert.IsType(response); + Assert.IsType(response); } [Theory, BitAutoData] @@ -245,6 +245,6 @@ public async Task UpdateAsync_UserIsNotOrganizationAdmin_ReturnsForbid( var response = await sutProvider.Sut.UpdateAsync(organizationId, integrationId, _webhookRequestModel); - Assert.IsType(response.Result); + Assert.IsType(response.Result); } } From 8bdd4e451909d27f84cd32fd9016899ef45da148 Mon Sep 17 00:00:00 2001 From: voommen-livefront Date: Wed, 22 Apr 2026 15:13:32 -0500 Subject: [PATCH 4/6] PM-34822 replace 422 with 400 Badrequest in case of errors and added unit tests Co-authored-by: Copilot --- .../OrganizationIntegrationController.cs | 52 +++++++++---- .../OrganizationIntegrationControllerTests.cs | 73 +++++++++++++++++-- 2 files changed, 104 insertions(+), 21 deletions(-) diff --git a/src/Api/Dirt/Controllers/OrganizationIntegrationController.cs b/src/Api/Dirt/Controllers/OrganizationIntegrationController.cs index a3e0b810ab9a..6b9d3fcc1816 100644 --- a/src/Api/Dirt/Controllers/OrganizationIntegrationController.cs +++ b/src/Api/Dirt/Controllers/OrganizationIntegrationController.cs @@ -14,14 +14,15 @@ public class OrganizationIntegrationController( ICreateOrganizationIntegrationCommand createCommand, IUpdateOrganizationIntegrationCommand updateCommand, IDeleteOrganizationIntegrationCommand deleteCommand, - IGetOrganizationIntegrationsQuery getQuery) : Controller + IGetOrganizationIntegrationsQuery getQuery, + ILogger logger) : Controller { [HttpGet("")] public async Task>> GetAsync(Guid organizationId) { if (!await HasPermission(organizationId)) { - return UnprocessableEntity(); + return NotFound(); } var integrations = await getQuery.GetManyByOrganizationAsync(organizationId); @@ -37,7 +38,7 @@ public async Task>> GetA /// /// /// - /// 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) @@ -49,7 +50,7 @@ public async Task> CreateAsyn if (!await HasPermission(organizationId)) { - return UnprocessableEntity(); + return NotFound(); } var integration = model.ToOrganizationIntegration(organizationId); @@ -60,9 +61,16 @@ public async Task> CreateAsyn return Conflict(); } - var created = await createCommand.CreateAsync(integration); - - return Ok(new OrganizationIntegrationResponseModel(created)); + try + { + var created = await createCommand.CreateAsync(integration); + return Ok(new OrganizationIntegrationResponseModel(created)); + } + catch (System.Exception e) + { + logger.LogError(e, "Error creating organization integration for organization {OrganizationId} with type {IntegrationType}", organizationId, integration.Type); + return BadRequest(); + } } [HttpPut("{integrationId:guid}")] @@ -70,13 +78,21 @@ public async Task> UpdateAsyn { if (!await HasPermission(organizationId)) { - return UnprocessableEntity(); + return NotFound(); } - var integration = model.ToOrganizationIntegration(organizationId); - var updated = await updateCommand.UpdateAsync(organizationId, integrationId, integration); - - return Ok(new OrganizationIntegrationResponseModel(updated)); + try + { + var integration = model.ToOrganizationIntegration(organizationId); + var updated = await updateCommand.UpdateAsync(organizationId, integrationId, integration); + + return Ok(new OrganizationIntegrationResponseModel(updated)); + } + catch (System.Exception e) + { + logger.LogError(e, "Error updating organization integration for organization {OrganizationId} with integration {IntegrationId}", organizationId, integrationId); + return BadRequest(); + } } [HttpDelete("{integrationId:guid}")] @@ -84,10 +100,18 @@ public async Task DeleteAsync(Guid organizationId, Guid integrati { if (!await HasPermission(organizationId)) { - return UnprocessableEntity(); + return NotFound(); } - await deleteCommand.DeleteAsync(organizationId, integrationId); + try + { + await deleteCommand.DeleteAsync(organizationId, integrationId); + } + catch (System.Exception e) + { + logger.LogError(e, "Error deleting organization integration for organization {OrganizationId} with integration {IntegrationId}", organizationId, integrationId); + return BadRequest(); + } return NoContent(); } diff --git a/test/Api.Test/Dirt/Controllers/OrganizationIntegrationControllerTests.cs b/test/Api.Test/Dirt/Controllers/OrganizationIntegrationControllerTests.cs index 7571ff7cdf44..6822f2e0d83e 100644 --- a/test/Api.Test/Dirt/Controllers/OrganizationIntegrationControllerTests.cs +++ b/test/Api.Test/Dirt/Controllers/OrganizationIntegrationControllerTests.cs @@ -34,7 +34,7 @@ public async Task GetAsync_UserIsNotOrganizationAdmin_ThrowsNotFound( .Returns(false); var result = await sutProvider.Sut.GetAsync(organizationId); - Assert.IsType(result.Result); + Assert.IsType(result.Result); } [Theory, BitAutoData] @@ -134,7 +134,7 @@ public async Task CreateAsync_TheTypeAlreadyExists_ThrowsConflict( } [Theory, BitAutoData] - public async Task CreateAsync_UserIsNotOrganizationAdmin_ReturnsForbid( + public async Task CreateAsync_UserIsNotOrganizationAdmin_ReturnsNotFound( SutProvider sutProvider, Guid organizationId) { @@ -145,7 +145,28 @@ public async Task CreateAsync_UserIsNotOrganizationAdmin_ReturnsForbid( var response = await sutProvider.Sut.CreateAsync(organizationId, _webhookRequestModel); - Assert.IsType(response.Result); + Assert.IsType(response.Result); + } + + [Theory, BitAutoData] + public async Task CreateAsync_ExceptionThrown_ReturnsBadRequest( + SutProvider sutProvider, + Guid organizationId) + { + sutProvider.Sut.Url = Substitute.For(); + sutProvider.GetDependency() + .OrganizationOwner(organizationId) + .Returns(true); + sutProvider.GetDependency() + .CanCreateAsync(Arg.Any()) + .Returns(true); + sutProvider.GetDependency() + .CreateAsync(Arg.Any()) + .Returns(Task.FromException(new Exception())); + + var response = await sutProvider.Sut.CreateAsync(organizationId, _webhookRequestModel); + + Assert.IsType(response.Result); } [Theory, BitAutoData] @@ -184,7 +205,7 @@ await sutProvider.GetDependency().Receive } [Theory, BitAutoData] - public async Task DeleteAsync_UserIsNotOrganizationAdmin_ReturnsForbid( + public async Task DeleteAsync_UserIsNotOrganizationAdmin_ReturnsNotFound( SutProvider sutProvider, Guid organizationId, Guid integrationId) @@ -196,7 +217,26 @@ public async Task DeleteAsync_UserIsNotOrganizationAdmin_ReturnsForbid( var response = await sutProvider.Sut.DeleteAsync(organizationId, integrationId); - Assert.IsType(response); + Assert.IsType(response); + } + + [Theory, BitAutoData] + public async Task DeleteAsync_ExceptionThrown_ReturnsBadRequest( + SutProvider sutProvider, + Guid organizationId, + Guid integrationId) + { + sutProvider.Sut.Url = Substitute.For(); + sutProvider.GetDependency() + .OrganizationOwner(organizationId) + .Returns(true); + sutProvider.GetDependency() + .DeleteAsync(organizationId, integrationId) + .Returns(Task.FromException(new Exception())); + + var response = await sutProvider.Sut.DeleteAsync(organizationId, integrationId); + + Assert.IsType(response); } [Theory, BitAutoData] @@ -233,7 +273,7 @@ await sutProvider.GetDependency().Receive } [Theory, BitAutoData] - public async Task UpdateAsync_UserIsNotOrganizationAdmin_ReturnsForbid( + public async Task UpdateAsync_UserIsNotOrganizationAdmin_ReturnsNotFound( SutProvider sutProvider, Guid organizationId, Guid integrationId) @@ -245,6 +285,25 @@ public async Task UpdateAsync_UserIsNotOrganizationAdmin_ReturnsForbid( var response = await sutProvider.Sut.UpdateAsync(organizationId, integrationId, _webhookRequestModel); - Assert.IsType(response.Result); + Assert.IsType(response.Result); + } + + [Theory, BitAutoData] + public async Task UpdateAsync_ExceptionThrown_ReturnsBadRequest( + SutProvider sutProvider, + Guid organizationId, + Guid integrationId) + { + sutProvider.Sut.Url = Substitute.For(); + sutProvider.GetDependency() + .OrganizationOwner(organizationId) + .Returns(true); + sutProvider.GetDependency() + .UpdateAsync(organizationId, integrationId, Arg.Any()) + .Returns(Task.FromException(new Exception())); + + var response = await sutProvider.Sut.UpdateAsync(organizationId, integrationId, _webhookRequestModel); + + Assert.IsType(response.Result); } } From 1c0aee301cc1ae1d429dfbe3667660e8863cc69c Mon Sep 17 00:00:00 2001 From: voommen-livefront Date: Wed, 22 Apr 2026 16:12:08 -0500 Subject: [PATCH 5/6] PM-34822 changed commands to return BadRequest instead of NotFound Co-authored-by: Copilot --- .../OrganizationIntegrationController.cs | 43 +++----------- .../DeleteOrganizationIntegrationCommand.cs | 2 +- .../IDeleteOrganizationIntegrationCommand.cs | 2 +- .../IUpdateOrganizationIntegrationCommand.cs | 2 +- .../UpdateOrganizationIntegrationCommand.cs | 2 +- .../OrganizationIntegrationControllerTests.cs | 59 ------------------- ...leteOrganizationIntegrationCommandTests.cs | 8 +-- ...dateOrganizationIntegrationCommandTests.cs | 12 ++-- 8 files changed, 23 insertions(+), 107 deletions(-) diff --git a/src/Api/Dirt/Controllers/OrganizationIntegrationController.cs b/src/Api/Dirt/Controllers/OrganizationIntegrationController.cs index 6b9d3fcc1816..31acbddd5237 100644 --- a/src/Api/Dirt/Controllers/OrganizationIntegrationController.cs +++ b/src/Api/Dirt/Controllers/OrganizationIntegrationController.cs @@ -14,8 +14,7 @@ public class OrganizationIntegrationController( ICreateOrganizationIntegrationCommand createCommand, IUpdateOrganizationIntegrationCommand updateCommand, IDeleteOrganizationIntegrationCommand deleteCommand, - IGetOrganizationIntegrationsQuery getQuery, - ILogger logger) : Controller + IGetOrganizationIntegrationsQuery getQuery) : Controller { [HttpGet("")] public async Task>> GetAsync(Guid organizationId) @@ -38,7 +37,7 @@ public async Task>> GetA /// /// /// - /// 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) @@ -61,16 +60,9 @@ public async Task> CreateAsyn return Conflict(); } - try - { - var created = await createCommand.CreateAsync(integration); - return Ok(new OrganizationIntegrationResponseModel(created)); - } - catch (System.Exception e) - { - logger.LogError(e, "Error creating organization integration for organization {OrganizationId} with type {IntegrationType}", organizationId, integration.Type); - return BadRequest(); - } + var created = await createCommand.CreateAsync(integration); + return Ok(new OrganizationIntegrationResponseModel(created)); + } [HttpPut("{integrationId:guid}")] @@ -81,18 +73,9 @@ public async Task> UpdateAsyn return NotFound(); } - try - { - var integration = model.ToOrganizationIntegration(organizationId); - var updated = await updateCommand.UpdateAsync(organizationId, integrationId, integration); - - return Ok(new OrganizationIntegrationResponseModel(updated)); - } - catch (System.Exception e) - { - logger.LogError(e, "Error updating organization integration for organization {OrganizationId} with integration {IntegrationId}", organizationId, integrationId); - return BadRequest(); - } + var integration = model.ToOrganizationIntegration(organizationId); + var updated = await updateCommand.UpdateAsync(organizationId, integrationId, integration); + return Ok(new OrganizationIntegrationResponseModel(updated)); } [HttpDelete("{integrationId:guid}")] @@ -103,15 +86,7 @@ public async Task DeleteAsync(Guid organizationId, Guid integrati return NotFound(); } - try - { - await deleteCommand.DeleteAsync(organizationId, integrationId); - } - catch (System.Exception e) - { - logger.LogError(e, "Error deleting organization integration for organization {OrganizationId} with integration {IntegrationId}", organizationId, integrationId); - return BadRequest(); - } + await deleteCommand.DeleteAsync(organizationId, integrationId); return NoContent(); } 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 6822f2e0d83e..5e55732b6d4e 100644 --- a/test/Api.Test/Dirt/Controllers/OrganizationIntegrationControllerTests.cs +++ b/test/Api.Test/Dirt/Controllers/OrganizationIntegrationControllerTests.cs @@ -148,27 +148,6 @@ public async Task CreateAsync_UserIsNotOrganizationAdmin_ReturnsNotFound( Assert.IsType(response.Result); } - [Theory, BitAutoData] - public async Task CreateAsync_ExceptionThrown_ReturnsBadRequest( - SutProvider sutProvider, - Guid organizationId) - { - sutProvider.Sut.Url = Substitute.For(); - sutProvider.GetDependency() - .OrganizationOwner(organizationId) - .Returns(true); - sutProvider.GetDependency() - .CanCreateAsync(Arg.Any()) - .Returns(true); - sutProvider.GetDependency() - .CreateAsync(Arg.Any()) - .Returns(Task.FromException(new Exception())); - - var response = await sutProvider.Sut.CreateAsync(organizationId, _webhookRequestModel); - - Assert.IsType(response.Result); - } - [Theory, BitAutoData] public async Task DeleteAsync_AllParamsProvided_Succeeds( SutProvider sutProvider, @@ -220,25 +199,6 @@ public async Task DeleteAsync_UserIsNotOrganizationAdmin_ReturnsNotFound( Assert.IsType(response); } - [Theory, BitAutoData] - public async Task DeleteAsync_ExceptionThrown_ReturnsBadRequest( - SutProvider sutProvider, - Guid organizationId, - Guid integrationId) - { - sutProvider.Sut.Url = Substitute.For(); - sutProvider.GetDependency() - .OrganizationOwner(organizationId) - .Returns(true); - sutProvider.GetDependency() - .DeleteAsync(organizationId, integrationId) - .Returns(Task.FromException(new Exception())); - - var response = await sutProvider.Sut.DeleteAsync(organizationId, integrationId); - - Assert.IsType(response); - } - [Theory, BitAutoData] public async Task UpdateAsync_AllParamsProvided_Succeeds( SutProvider sutProvider, @@ -287,23 +247,4 @@ public async Task UpdateAsync_UserIsNotOrganizationAdmin_ReturnsNotFound( Assert.IsType(response.Result); } - - [Theory, BitAutoData] - public async Task UpdateAsync_ExceptionThrown_ReturnsBadRequest( - SutProvider sutProvider, - Guid organizationId, - Guid integrationId) - { - sutProvider.Sut.Url = Substitute.For(); - sutProvider.GetDependency() - .OrganizationOwner(organizationId) - .Returns(true); - sutProvider.GetDependency() - .UpdateAsync(organizationId, integrationId, Arg.Any()) - .Returns(Task.FromException(new Exception())); - - var response = await sutProvider.Sut.UpdateAsync(organizationId, integrationId, _webhookRequestModel); - - Assert.IsType(response.Result); - } } 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() From a080efbeb111f213cb38ecfa6d4a5f72b9a402be Mon Sep 17 00:00:00 2001 From: voommen-livefront Date: Thu, 23 Apr 2026 09:32:47 -0500 Subject: [PATCH 6/6] PM-34822 return badrequest from commands Co-authored-by: Copilot --- ...rganizationIntegrationConfigurationCommand.cs | 2 +- ...rganizationIntegrationConfigurationCommand.cs | 4 ++-- ...rganizationIntegrationConfigurationCommand.cs | 2 +- ...rganizationIntegrationConfigurationCommand.cs | 2 +- ...rganizationIntegrationConfigurationCommand.cs | 4 ++-- ...zationIntegrationConfigurationCommandTests.cs | 8 ++++---- ...zationIntegrationConfigurationCommandTests.cs | 16 ++++++++-------- ...zationIntegrationConfigurationCommandTests.cs | 16 ++++++++-------- 8 files changed, 27 insertions(+), 27 deletions(-) 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/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()