From 40a7d5a112143e7e305c092997d7eac0258b3933 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Tue, 3 Aug 2021 18:33:50 +0200 Subject: [PATCH] Documented error when trying to edit default domain redirects through endpoint --- docs/swagger/paths/v2_domains_redirects.json | 10 ++++++++++ module/Core/src/Exception/InvalidDomainException.php | 2 +- .../Core/test/Exception/InvalidDomainExceptionTest.php | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/swagger/paths/v2_domains_redirects.json b/docs/swagger/paths/v2_domains_redirects.json index bba6fbb7..9bf16841 100644 --- a/docs/swagger/paths/v2_domains_redirects.json +++ b/docs/swagger/paths/v2_domains_redirects.json @@ -99,6 +99,16 @@ } } }, + "403": { + "description": "Default domain was provided, and it cannot be edited this way.", + "content": { + "application/problem+json": { + "schema": { + "$ref": "../definitions/Error.json" + } + } + } + }, "500": { "description": "Unexpected error.", "content": { diff --git a/module/Core/src/Exception/InvalidDomainException.php b/module/Core/src/Exception/InvalidDomainException.php index 6e71c831..d41e71ac 100644 --- a/module/Core/src/Exception/InvalidDomainException.php +++ b/module/Core/src/Exception/InvalidDomainException.php @@ -26,7 +26,7 @@ class InvalidDomainException extends DomainException implements ProblemDetailsEx $e->detail = $e->getMessage(); $e->title = self::TITLE; $e->type = self::TYPE; - $e->status = StatusCodeInterface::STATUS_BAD_REQUEST; + $e->status = StatusCodeInterface::STATUS_FORBIDDEN; return $e; } diff --git a/module/Core/test/Exception/InvalidDomainExceptionTest.php b/module/Core/test/Exception/InvalidDomainExceptionTest.php index e4592cd8..06b78ff2 100644 --- a/module/Core/test/Exception/InvalidDomainExceptionTest.php +++ b/module/Core/test/Exception/InvalidDomainExceptionTest.php @@ -19,6 +19,6 @@ class InvalidDomainExceptionTest extends TestCase self::assertEquals($expected, $e->getDetail()); self::assertEquals('Invalid domain', $e->getTitle()); self::assertEquals('INVALID_DOMAIN', $e->getType()); - self::assertEquals(400, $e->getStatus()); + self::assertEquals(403, $e->getStatus()); } }