diff --git a/Application/EdFi.Ods.Api/ExceptionHandling/Translators/NonUniqueObjectExceptionTranslator.cs b/Application/EdFi.Ods.Api/ExceptionHandling/Translators/NonUniqueObjectExceptionTranslator.cs index d41f4190e7..12b7fb07d7 100644 --- a/Application/EdFi.Ods.Api/ExceptionHandling/Translators/NonUniqueObjectExceptionTranslator.cs +++ b/Application/EdFi.Ods.Api/ExceptionHandling/Translators/NonUniqueObjectExceptionTranslator.cs @@ -36,7 +36,7 @@ public bool TryTranslate(Exception ex, out IEdFiProblemDetails problemDetails) match.Groups["property"].Value, match.Groups["entityPropertyId"].Value)); - problemDetails = new ConflictException("A problem occurred while processing the request.", + problemDetails = new NonUniqueConflictException("A problem occurred while processing the request.", new[] { $"Two {match.Groups["subject"]} entities with the same identifier were associated with the session. See log for additional details." }); return true; diff --git a/Application/EdFi.Ods.Api/ExceptionHandling/Translators/Postgres/PostgresDuplicateKeyExceptionTranslator.cs b/Application/EdFi.Ods.Api/ExceptionHandling/Translators/Postgres/PostgresDuplicateKeyExceptionTranslator.cs index f2c6e63d88..2264023612 100644 --- a/Application/EdFi.Ods.Api/ExceptionHandling/Translators/Postgres/PostgresDuplicateKeyExceptionTranslator.cs +++ b/Application/EdFi.Ods.Api/ExceptionHandling/Translators/Postgres/PostgresDuplicateKeyExceptionTranslator.cs @@ -51,7 +51,7 @@ public bool TryTranslate(Exception ex, out IEdFiProblemDetails problemDetails) string message = GetMessageUsingRequestContext(constraintName) ?? GetMessageUsingPostgresException(); - problemDetails = new ConflictException(message); + problemDetails = new NonUniqueConflictException(message); return true; } diff --git a/Application/EdFi.Ods.Api/ExceptionHandling/Translators/Postgres/PostgresForeignKeyExceptionTranslator.cs b/Application/EdFi.Ods.Api/ExceptionHandling/Translators/Postgres/PostgresForeignKeyExceptionTranslator.cs index 6e1343638e..03b0a5fa30 100644 --- a/Application/EdFi.Ods.Api/ExceptionHandling/Translators/Postgres/PostgresForeignKeyExceptionTranslator.cs +++ b/Application/EdFi.Ods.Api/ExceptionHandling/Translators/Postgres/PostgresForeignKeyExceptionTranslator.cs @@ -57,7 +57,7 @@ public bool TryTranslate(Exception ex, out IEdFiProblemDetails problemDetails) ? NoDetailsUpdateOrDeleteMessage : NoDetailsInsertOrUpdateMessage; - problemDetails = new ConflictException(noDetailsMessage); + problemDetails = new InvalidReferenceConflictException(noDetailsMessage); return true; } @@ -66,7 +66,7 @@ public bool TryTranslate(Exception ex, out IEdFiProblemDetails problemDetails) ? string.Format(UpdateOrDeleteMessageFormat, association.ThisEntity.Name) : string.Format(InsertOrUpdateMessageFormat, association.OtherEntity.Name); - problemDetails = new ConflictException(message); + problemDetails = new InvalidReferenceConflictException(message); return true; } diff --git a/Application/EdFi.Ods.Api/ExceptionHandling/Translators/SqlServer/SqlServerConstraintExceptionTranslator.cs b/Application/EdFi.Ods.Api/ExceptionHandling/Translators/SqlServer/SqlServerConstraintExceptionTranslator.cs index b5434b1568..a53dfbdcc9 100644 --- a/Application/EdFi.Ods.Api/ExceptionHandling/Translators/SqlServer/SqlServerConstraintExceptionTranslator.cs +++ b/Application/EdFi.Ods.Api/ExceptionHandling/Translators/SqlServer/SqlServerConstraintExceptionTranslator.cs @@ -94,7 +94,7 @@ public bool TryTranslate(Exception ex, out IEdFiProblemDetails problemDetails) string errorMessage = string.Format(errorMessageFormat, tableName, columnName); - problemDetails = new ConflictException(errorMessage); + problemDetails = new InvalidReferenceConflictException(errorMessage); return true; } diff --git a/Application/EdFi.Ods.Api/ExceptionHandling/Translators/SqlServer/SqlServerPrimaryKeyConstraintExceptionTranslator.cs b/Application/EdFi.Ods.Api/ExceptionHandling/Translators/SqlServer/SqlServerPrimaryKeyConstraintExceptionTranslator.cs index 146adf8591..817cd0d258 100644 --- a/Application/EdFi.Ods.Api/ExceptionHandling/Translators/SqlServer/SqlServerPrimaryKeyConstraintExceptionTranslator.cs +++ b/Application/EdFi.Ods.Api/ExceptionHandling/Translators/SqlServer/SqlServerPrimaryKeyConstraintExceptionTranslator.cs @@ -51,7 +51,7 @@ public bool TryTranslate(Exception ex, out IEdFiProblemDetails problemDetails) var message = string.Format(MessageFormat, resourceEntity.Name, columnNames, values); - problemDetails = new ConflictException(message); + problemDetails = new NaturalKeyConflictException(message); return true; } } diff --git a/Application/EdFi.Ods.Api/ExceptionHandling/Translators/SqlServer/SqlServerUniqueIndexExceptionTranslator.cs b/Application/EdFi.Ods.Api/ExceptionHandling/Translators/SqlServer/SqlServerUniqueIndexExceptionTranslator.cs index c0acddf949..b3e7b82679 100644 --- a/Application/EdFi.Ods.Api/ExceptionHandling/Translators/SqlServer/SqlServerUniqueIndexExceptionTranslator.cs +++ b/Application/EdFi.Ods.Api/ExceptionHandling/Translators/SqlServer/SqlServerUniqueIndexExceptionTranslator.cs @@ -70,7 +70,7 @@ public bool TryTranslate(Exception ex, out IEdFiProblemDetails problemDetails) message = string.Format(MultipleMessageFormat, values, columnNames, tableName); } - problemDetails = new ConflictException(message); + problemDetails = new NonUniqueConflictException(message); return true; } } diff --git a/Application/EdFi.Ods.Api/ExceptionHandling/Translators/StaleObjectStateExceptionTranslator.cs b/Application/EdFi.Ods.Api/ExceptionHandling/Translators/StaleObjectStateExceptionTranslator.cs index 2e633bd1e8..870fc240e2 100644 --- a/Application/EdFi.Ods.Api/ExceptionHandling/Translators/StaleObjectStateExceptionTranslator.cs +++ b/Application/EdFi.Ods.Api/ExceptionHandling/Translators/StaleObjectStateExceptionTranslator.cs @@ -21,7 +21,7 @@ public bool TryTranslate(Exception ex, out IEdFiProblemDetails problemDetails) // This is probably a timing issue and is not expected under normal operations, so we'll log it. _logger.Error(ex); - problemDetails = new ConflictException( + problemDetails = new NaturalKeyConflictException( "A natural key conflict occurred when attempting to update a new resource with a duplicate key."); return true; diff --git a/Application/EdFi.Ods.Common/Exceptions/EdFiProblemDetailsExceptionBase.cs b/Application/EdFi.Ods.Common/Exceptions/EdFiProblemDetailsExceptionBase.cs index f0c5fef932..26bc9cf736 100644 --- a/Application/EdFi.Ods.Common/Exceptions/EdFiProblemDetailsExceptionBase.cs +++ b/Application/EdFi.Ods.Common/Exceptions/EdFiProblemDetailsExceptionBase.cs @@ -43,6 +43,16 @@ namespace EdFi.Ods.Common.Exceptions; │ ┌───────────────────┐ ├──┤ ConflictException | 409 Conflict │ └───────────────────┘ + │ △ + │ │ ┌─────────────────────────────┐ + │ ├──┤ NonUniqueConflictException | + │ │ └─────────────────────────────┘ + │ │ ┌──────────────────────────────────────┐ + │ │──┤ InvalidReferenceConflictException | + │ │ └──────────────────────────────────────┘ + │ │ ┌──────────────────────────────────────┐ + │ └──┤ NaturalKeyConflictException | + │ └──────────────────────────────────────┘ │ ┌──────────────────────┐ ├──┤ ConcurrencyException | 412 Precondition Failed │ └──────────────────────┘ diff --git a/Application/EdFi.Ods.Common/Exceptions/InvalidReferenceConflictException.cs b/Application/EdFi.Ods.Common/Exceptions/InvalidReferenceConflictException.cs new file mode 100644 index 0000000000..4f4e33b040 --- /dev/null +++ b/Application/EdFi.Ods.Common/Exceptions/InvalidReferenceConflictException.cs @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: Apache-2.0 +// Licensed to the Ed-Fi Alliance under one or more agreements. +// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. +// See the LICENSE and NOTICES files in the project root for more information. + +using System; +using System.Collections.Generic; +using Microsoft.AspNetCore.Http; + +namespace EdFi.Ods.Common.Exceptions; + +public class InvalidReferenceConflictException : ConflictException +{ + // Fields containing override values for Problem Details + private const string TypePart = "invalid-reference"; + private const string TitleText = "Resource Not Unique Conflict due to invalid-reference"; + private const int StatusValue = StatusCodes.Status409Conflict; + + public InvalidReferenceConflictException(string detail) + : base(detail) { } + + public InvalidReferenceConflictException(string detail, Exception innerException) + : base(detail, innerException) { } + + + public InvalidReferenceConflictException(string detail, string[] errors) + : base(detail) + { + ((IEdFiProblemDetails)this).Errors = errors; + } + // --------------------------- + // Boilerplate for overrides + // --------------------------- + public override string Title { get => TitleText; } + + public override int Status { get => StatusValue; } + + protected override IEnumerable GetTypeParts() + { + foreach (var part in base.GetTypeParts()) + { + yield return part; + } + + yield return TypePart; + } + // --------------------------- +} diff --git a/Application/EdFi.Ods.Common/Exceptions/NaturalKeyConflictException.cs b/Application/EdFi.Ods.Common/Exceptions/NaturalKeyConflictException.cs new file mode 100644 index 0000000000..f33d51da5e --- /dev/null +++ b/Application/EdFi.Ods.Common/Exceptions/NaturalKeyConflictException.cs @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: Apache-2.0 +// Licensed to the Ed-Fi Alliance under one or more agreements. +// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. +// See the LICENSE and NOTICES files in the project root for more information. + +using System; +using System.Collections.Generic; +using Microsoft.AspNetCore.Http; + +namespace EdFi.Ods.Common.Exceptions; + +public class NaturalKeyConflictException : ConflictException +{ + // Fields containing override values for Problem Details + private const string TypePart = "natural-key"; + private const string TitleText = "Resource Not Unique Conflict due to natural-key"; + private const int StatusValue = StatusCodes.Status409Conflict; + + public NaturalKeyConflictException(string detail) + : base(detail) { } + + public NaturalKeyConflictException(string detail, Exception innerException) + : base(detail, innerException) { } + + + public NaturalKeyConflictException(string detail, string[] errors) + : base(detail) + { + ((IEdFiProblemDetails)this).Errors = errors; + } + // --------------------------- + // Boilerplate for overrides + // --------------------------- + public override string Title { get => TitleText; } + + public override int Status { get => StatusValue; } + + protected override IEnumerable GetTypeParts() + { + foreach (var part in base.GetTypeParts()) + { + yield return part; + } + + yield return TypePart; + } + // --------------------------- +} diff --git a/Application/EdFi.Ods.Common/Exceptions/NonUniqueConflictException.cs b/Application/EdFi.Ods.Common/Exceptions/NonUniqueConflictException.cs new file mode 100644 index 0000000000..b039c1f6a3 --- /dev/null +++ b/Application/EdFi.Ods.Common/Exceptions/NonUniqueConflictException.cs @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: Apache-2.0 +// Licensed to the Ed-Fi Alliance under one or more agreements. +// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. +// See the LICENSE and NOTICES files in the project root for more information. + +using System; +using System.Collections.Generic; +using Microsoft.AspNetCore.Http; + +namespace EdFi.Ods.Common.Exceptions; + +public class NonUniqueConflictException : ConflictException +{ + // Fields containing override values for Problem Details + private const string TypePart = "not-unique"; + private const string TitleText = "Resource Not Unique Conflict Due to Not-Unique"; + private const int StatusValue = StatusCodes.Status409Conflict; + + public NonUniqueConflictException(string detail) + : base(detail) { } + + public NonUniqueConflictException(string detail, Exception innerException) + : base(detail, innerException) { } + + + public NonUniqueConflictException(string detail, string[] errors) + : base(detail) + { + ((IEdFiProblemDetails)this).Errors = errors; + } + // --------------------------- + // Boilerplate for overrides + // --------------------------- + public override string Title { get => TitleText; } + + public override int Status { get => StatusValue; } + + protected override IEnumerable GetTypeParts() + { + foreach (var part in base.GetTypeParts()) + { + yield return part; + } + + yield return TypePart; + } + // --------------------------- +} diff --git a/Application/EdFi.Ods.Tests/EdFi.Ods.Api/ExceptionHandling/Translators/NonUniqueObjectExceptionTranslatorTests.cs b/Application/EdFi.Ods.Tests/EdFi.Ods.Api/ExceptionHandling/Translators/NonUniqueObjectExceptionTranslatorTests.cs index 4fbe2cb365..faca8d1fad 100644 --- a/Application/EdFi.Ods.Tests/EdFi.Ods.Api/ExceptionHandling/Translators/NonUniqueObjectExceptionTranslatorTests.cs +++ b/Application/EdFi.Ods.Tests/EdFi.Ods.Api/ExceptionHandling/Translators/NonUniqueObjectExceptionTranslatorTests.cs @@ -30,7 +30,7 @@ public void TryTranslate_WithNonUniqueObjectException_ShouldReturnTrueAndSetProb // Assert result.ShouldBeTrue(); problemDetails.ShouldNotBeNull(); - problemDetails.ShouldBeOfType(); + problemDetails.ShouldBeOfType(); problemDetails.Detail.ShouldBe("A problem occurred while processing the request."); problemDetails.Errors.ShouldContain( diff --git a/Application/EdFi.Ods.Tests/EdFi.Ods.Api/ExceptionHandling/Translators/Postgres/PostgresDuplicateKeyExceptionTranslatorTests.cs b/Application/EdFi.Ods.Tests/EdFi.Ods.Api/ExceptionHandling/Translators/Postgres/PostgresDuplicateKeyExceptionTranslatorTests.cs index 8c29e94468..7756654daa 100644 --- a/Application/EdFi.Ods.Tests/EdFi.Ods.Api/ExceptionHandling/Translators/Postgres/PostgresDuplicateKeyExceptionTranslatorTests.cs +++ b/Application/EdFi.Ods.Tests/EdFi.Ods.Api/ExceptionHandling/Translators/Postgres/PostgresDuplicateKeyExceptionTranslatorTests.cs @@ -183,7 +183,7 @@ public void Should_RestError_show_single_value_message() AssertHelper.All( () => actualError.ShouldNotBeNull(), () => actualError.Status.ShouldBe(409), - () => actualError.Type.ShouldBe(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict")), + () => actualError.Type.ShouldBe(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict:not-unique")), () => actualError.Detail.ShouldBe("The value supplied for property 'Property1' of entity 'Something' is not unique.") ); } @@ -231,7 +231,7 @@ public void Should_RestError_show_multiple_values_message() AssertHelper.All( () => actualError.ShouldNotBeNull(), () => actualError.Status.ShouldBe(409), - () => actualError.Type.ShouldBe(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict")), + () => actualError.Type.ShouldBe(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict:not-unique")), () => actualError.Detail.ShouldBe("The values supplied for properties 'Property1', 'Property2' of entity 'Something' are not unique.") ); } @@ -277,7 +277,7 @@ public void Should_RestError_show_unknown_value_message() AssertHelper.All( () => actualError.ShouldNotBeNull(), () => actualError.Status.ShouldBe(409), - () => actualError.Type.ShouldBe(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict")), + () => actualError.Type.ShouldBe(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict:not-unique")), () => actualError.Detail.ShouldBe("The value(s) supplied for the resource are not unique.") ); } @@ -327,7 +327,7 @@ public void Should_RestError_show_unknown_value_message() AssertHelper.All( () => actualError.ShouldNotBeNull(), () => actualError.Status.ShouldBe(409), - () => actualError.Type.ShouldBe(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict")), + () => actualError.Type.ShouldBe(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict:not-unique")), () => actualError.Detail.ShouldBe("The values supplied for properties 'property1, property2, property3' of entity 'something' are not unique.") ); } diff --git a/Application/EdFi.Ods.Tests/EdFi.Ods.Api/ExceptionHandling/Translators/Postgres/PostgresForeignKeyExceptionTranslatorTests.cs b/Application/EdFi.Ods.Tests/EdFi.Ods.Api/ExceptionHandling/Translators/Postgres/PostgresForeignKeyExceptionTranslatorTests.cs index 7b82ff69f9..b0c261a572 100644 --- a/Application/EdFi.Ods.Tests/EdFi.Ods.Api/ExceptionHandling/Translators/Postgres/PostgresForeignKeyExceptionTranslatorTests.cs +++ b/Application/EdFi.Ods.Tests/EdFi.Ods.Api/ExceptionHandling/Translators/Postgres/PostgresForeignKeyExceptionTranslatorTests.cs @@ -149,7 +149,7 @@ public void Should_RestError_show_simple_constraint_message() AssertHelper.All( () => _actualError.ShouldNotBeNull(), () => _actualError.Status.ShouldBe(409), - () => _actualError.Type.ShouldBe(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict")), + () => _actualError.Type.ShouldBe(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict:invalid-reference")), () => _actualError.Detail.ShouldBe("The referenced 'School' resource does not exist.") ); } @@ -214,7 +214,7 @@ public void Should_return_a_409_Conflict_error_with_a_message_identifying_the_de AssertHelper.All( () => actualError.ShouldNotBeNull(), () => actualError.Status.ShouldBe(409), - () => actualError.Type.ShouldBe(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict")), + () => actualError.Type.ShouldBe(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict:invalid-reference")), () => actualError.Detail.ShouldBe("The operation cannot be performed because the resource is a dependency of the 'StudentSchoolAssociation' resource.") ); } @@ -279,7 +279,7 @@ public void Should_return_a_409_Conflict_error_with_a_message_indicating_a_depen actualError.ShouldSatisfyAllConditions( e => e.ShouldNotBeNull(), e => e.Status.ShouldBe(409), - e => e.Type.ShouldBe(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict")), + e => e.Type.ShouldBe(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict:invalid-reference")), e => e.Detail.ShouldBe( "The operation cannot be performed because the resource is a dependency of another resource.")); } diff --git a/Application/EdFi.Ods.Tests/EdFi.Ods.Api/ExceptionHandling/Translators/SqlServer/ExceptionTranslatorFixtures.cs b/Application/EdFi.Ods.Tests/EdFi.Ods.Api/ExceptionHandling/Translators/SqlServer/ExceptionTranslatorFixtures.cs index eb6516615e..8a64957f92 100644 --- a/Application/EdFi.Ods.Tests/EdFi.Ods.Api/ExceptionHandling/Translators/SqlServer/ExceptionTranslatorFixtures.cs +++ b/Application/EdFi.Ods.Tests/EdFi.Ods.Api/ExceptionHandling/Translators/SqlServer/ExceptionTranslatorFixtures.cs @@ -42,7 +42,7 @@ protected override void Act() public virtual void Should_respond_with_a_409_Conflict() { Assert.That(_actualError.Status, Is.EqualTo((int) HttpStatusCode.Conflict)); - Assert.That(_actualError.Type, Is.EqualTo(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict"))); + Assert.That(_actualError.Type, Is.EqualTo(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict:invalid-reference"))); } [Test] @@ -76,7 +76,7 @@ protected override void Act() public virtual void Should_respond_with_a_409_Conflict() { Assert.That(_actualError.Status, Is.EqualTo((int) HttpStatusCode.Conflict)); - Assert.That(_actualError.Type, Is.EqualTo(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict"))); + Assert.That(_actualError.Type, Is.EqualTo(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict:invalid-reference"))); } [Test] @@ -111,7 +111,7 @@ protected override void Act() public virtual void Should_respond_with_a_409_Conflict() { Assert.That(_actualError.Status, Is.EqualTo((int) HttpStatusCode.Conflict)); - Assert.That(_actualError.Type, Is.EqualTo(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict"))); + Assert.That(_actualError.Type, Is.EqualTo(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict:invalid-reference"))); } [Test] @@ -147,7 +147,7 @@ protected override void Act() public virtual void Should_respond_with_a_409_Conflict() { Assert.That(_actualError.Status, Is.EqualTo((int) HttpStatusCode.Conflict)); - Assert.That(_actualError.Type, Is.EqualTo(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict"))); + Assert.That(_actualError.Type, Is.EqualTo(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict:invalid-reference"))); } [Test] @@ -196,7 +196,7 @@ protected override void Act() public virtual void Should_respond_with_a_409_Conflict() { Assert.That(_actualError.Status, Is.EqualTo((int) HttpStatusCode.Conflict)); - Assert.That(_actualError.Type, Is.EqualTo(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict"))); + Assert.That(_actualError.Type, Is.EqualTo(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict:not-unique"))); } [Test] @@ -246,7 +246,7 @@ protected override void Act() public virtual void Should_respond_with_a_409_Conflict() { Assert.That(_actualError.Status, Is.EqualTo((int) HttpStatusCode.Conflict)); - Assert.That(_actualError.Type, Is.EqualTo(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict"))); + Assert.That(_actualError.Type, Is.EqualTo(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict:not-unique"))); } [Test] @@ -294,7 +294,7 @@ protected override void Act() public virtual void Should_respond_with_a_409_Conflict() { Assert.That(_actualError.Status, Is.EqualTo((int) HttpStatusCode.Conflict)); - Assert.That(_actualError.Type, Is.EqualTo(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict"))); + Assert.That(_actualError.Type, Is.EqualTo(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict:not-unique"))); } [Test] diff --git a/Application/EdFi.Ods.Tests/EdFi.Ods.Api/ExceptionHandling/Translators/SqlServer/SqlServerPrimaryKeyConstraintExceptionTranslatorTests.cs b/Application/EdFi.Ods.Tests/EdFi.Ods.Api/ExceptionHandling/Translators/SqlServer/SqlServerPrimaryKeyConstraintExceptionTranslatorTests.cs index 29924b2748..fb83403b94 100644 --- a/Application/EdFi.Ods.Tests/EdFi.Ods.Api/ExceptionHandling/Translators/SqlServer/SqlServerPrimaryKeyConstraintExceptionTranslatorTests.cs +++ b/Application/EdFi.Ods.Tests/EdFi.Ods.Api/ExceptionHandling/Translators/SqlServer/SqlServerPrimaryKeyConstraintExceptionTranslatorTests.cs @@ -145,7 +145,7 @@ public void Should_set_a_reasonable_message() [Test] public void Should_set_the_exception_type_to_conflict() { - actualError.Type.ShouldBe(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict")); + actualError.Type.ShouldBe(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict:natural-key")); } [Test] @@ -199,7 +199,7 @@ public void Should_set_a_reasonable_message() [Test] public void Should_set_the_exception_type_to_conflict() { - actualError.Type.ShouldBe(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict")); + actualError.Type.ShouldBe(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict:natural-key")); } [Test] diff --git a/Application/EdFi.Ods.Tests/EdFi.Ods.Api/ExceptionHandling/Translators/SqlServer/StaleObjectStateExceptionTranslatorTests.cs b/Application/EdFi.Ods.Tests/EdFi.Ods.Api/ExceptionHandling/Translators/SqlServer/StaleObjectStateExceptionTranslatorTests.cs index fdb0c89ff4..0d0dc4e492 100644 --- a/Application/EdFi.Ods.Tests/EdFi.Ods.Api/ExceptionHandling/Translators/SqlServer/StaleObjectStateExceptionTranslatorTests.cs +++ b/Application/EdFi.Ods.Tests/EdFi.Ods.Api/ExceptionHandling/Translators/SqlServer/StaleObjectStateExceptionTranslatorTests.cs @@ -134,7 +134,7 @@ public void Should_set_a_reasonable_message() [Test] public void Should_set_the_exception_type_to_conflict() { - actualError.Type.ShouldBe(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict")); + actualError.Type.ShouldBe(string.Join(':', EdFiProblemDetailsExceptionBase.BaseTypePrefix, "conflict:natural-key")); } [Test] diff --git a/Postman Test Suite/Ed-Fi ODS-API Integration Test Suite AuthorizationTests Multiple Key-Secrets.postman_collection.json b/Postman Test Suite/Ed-Fi ODS-API Integration Test Suite AuthorizationTests Multiple Key-Secrets.postman_collection.json index eee739eb33..3674cdec95 100644 --- a/Postman Test Suite/Ed-Fi ODS-API Integration Test Suite AuthorizationTests Multiple Key-Secrets.postman_collection.json +++ b/Postman Test Suite/Ed-Fi ODS-API Integration Test Suite AuthorizationTests Multiple Key-Secrets.postman_collection.json @@ -1,9 +1,10 @@ { "info": { - "_postman_id": "919fbd13-24f9-42a4-94f1-79fdb5ec3e94", + "_postman_id": "5a5bbebb-a20e-4231-9424-13068a227c55", "name": "Ed-Fi ODS/API Integration Test Suite AuthorizationTests Multiple Key/Secrets", "description": "Localhost integration testing using Postman Scripts", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "26378282" }, "item": [ { @@ -5913,7 +5914,13 @@ "pm.test(\"Response is 404 or 409\", () => {", " pm.expect(pm.response.code).to.be.oneOf([404, 409]) ", " });", - "" + "", + "const problemDetails = pm.response.json();", + "", + "pm.test(\"Should return a problem details result for invalid-reference conflict\", () => {", + " pm.expect(pm.response.code).equal(problemDetails.status);", + " pm.expect(problemDetails.type).to.equal(\"urn:ed-fi:api:conflict:invalid-reference\");", + "});" ], "type": "text/javascript" } diff --git a/Postman Test Suite/Ed-Fi ODS-API Integration Test Suite AuthorizationTests.postman_collection.json b/Postman Test Suite/Ed-Fi ODS-API Integration Test Suite AuthorizationTests.postman_collection.json index b190c2ac46..7789dcc98e 100644 --- a/Postman Test Suite/Ed-Fi ODS-API Integration Test Suite AuthorizationTests.postman_collection.json +++ b/Postman Test Suite/Ed-Fi ODS-API Integration Test Suite AuthorizationTests.postman_collection.json @@ -5262,7 +5262,12 @@ "pm.test(\"Response is 409\", () => {", " pm.expect(pm.response.code).to.equal(409) ", " });", - "" + "const problemDetails = pm.response.json();", + "", + "pm.test(\"Should return a problem details result for invalid-reference conflict\", () => {", + " pm.expect(pm.response.code).equal(problemDetails.status);", + " pm.expect(problemDetails.type).to.equal(\"urn:ed-fi:api:conflict:invalid-reference\");", + "});" ], "type": "text/javascript" } diff --git a/Postman Test Suite/Ed-Fi ODS-API Integration Test Suite ResponseTests.postman_collection.json b/Postman Test Suite/Ed-Fi ODS-API Integration Test Suite ResponseTests.postman_collection.json index ad68b7a5f2..44559bbe3d 100644 --- a/Postman Test Suite/Ed-Fi ODS-API Integration Test Suite ResponseTests.postman_collection.json +++ b/Postman Test Suite/Ed-Fi ODS-API Integration Test Suite ResponseTests.postman_collection.json @@ -5428,7 +5428,7 @@ "\r", "pm.test(\"Should return a problem details result\", () => {\r", " pm.expect(pm.response.code).equal(problemDetails.status);\r", - " pm.expect(problemDetails.type).to.equal(\"urn:ed-fi:api:conflict\");\r", + " pm.expect(problemDetails.type).to.equal(\"urn:ed-fi:api:conflict:invalid-reference\");\r", " pm.expect(problemDetails.detail).to.equal(\"The referenced 'Student' resource does not exist.\");\r", "});\r", "\r", @@ -7910,7 +7910,13 @@ "pm.test(\"Status code is 409\", () => {", " pm.expect(pm.response.code).to.equal(409);", "});", - "" + "const problemDetails = pm.response.json();", + "", + "pm.test(\"Should return a problem details result for invalid-reference conflict\", () => {", + " pm.expect(pm.response.code).equal(problemDetails.status);", + " pm.expect(problemDetails.type).to.equal(\"urn:ed-fi:api:conflict:invalid-reference\");", + "", + "});" ], "type": "text/javascript" }