mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-06 23:33:13 +08:00
Ensured trying to fetch a short URL for any operation through the API results in 404 if it does not match with porovided domain
This commit is contained in:
@@ -46,25 +46,16 @@ class DeleteShortUrlActionTest extends ApiTestCase
|
||||
/** @test */
|
||||
public function properShortUrlIsDeletedWhenDomainIsProvided(): void
|
||||
{
|
||||
$fetchWithDomainBefore = $this->getJsonResponsePayload(
|
||||
$this->callApiWithKey(self::METHOD_GET, '/short-urls/ghi789?domain=example.com'),
|
||||
);
|
||||
$fetchWithoutDomainBefore = $this->getJsonResponsePayload(
|
||||
$this->callApiWithKey(self::METHOD_GET, '/short-urls/ghi789'),
|
||||
);
|
||||
$fetchWithDomainBefore = $this->callApiWithKey(self::METHOD_GET, '/short-urls/ghi789?domain=example.com');
|
||||
$fetchWithoutDomainBefore = $this->callApiWithKey(self::METHOD_GET, '/short-urls/ghi789');
|
||||
$deleteResp = $this->callApiWithKey(self::METHOD_DELETE, '/short-urls/ghi789?domain=example.com');
|
||||
$fetchWithDomainAfter = $this->getJsonResponsePayload(
|
||||
$this->callApiWithKey(self::METHOD_GET, '/short-urls/ghi789?domain=example.com'),
|
||||
);
|
||||
$fetchWithoutDomainAfter = $this->getJsonResponsePayload(
|
||||
$this->callApiWithKey(self::METHOD_GET, '/short-urls/ghi789'),
|
||||
);
|
||||
$fetchWithDomainAfter = $this->callApiWithKey(self::METHOD_GET, '/short-urls/ghi789?domain=example.com');
|
||||
$fetchWithoutDomainAfter = $this->callApiWithKey(self::METHOD_GET, '/short-urls/ghi789');
|
||||
|
||||
$this->assertEquals('example.com', $fetchWithDomainBefore['domain']);
|
||||
$this->assertEquals(null, $fetchWithoutDomainBefore['domain']);
|
||||
$this->assertEquals(self::STATUS_OK, $fetchWithDomainBefore->getStatusCode());
|
||||
$this->assertEquals(self::STATUS_OK, $fetchWithoutDomainBefore->getStatusCode());
|
||||
$this->assertEquals(self::STATUS_NO_CONTENT, $deleteResp->getStatusCode());
|
||||
// Falls back to the one without domain, since the other one has been deleted
|
||||
$this->assertEquals(null, $fetchWithDomainAfter['domain']);
|
||||
$this->assertEquals(null, $fetchWithoutDomainAfter['domain']);
|
||||
$this->assertEquals(self::STATUS_NOT_FOUND, $fetchWithDomainAfter->getStatusCode());
|
||||
$this->assertEquals(self::STATUS_OK, $fetchWithoutDomainAfter->getStatusCode());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user