-
-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #974 from shlinkio/develop
Release 2.5.1
- Loading branch information
Showing
14 changed files
with
226 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ShlinkMigrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
final class Version20210118153932 extends AbstractMigration | ||
{ | ||
public function up(Schema $schema): void | ||
{ | ||
// Prev migration used to set the length to 256, which made some set-ups crash | ||
// It has been updated to 255, and this migration ensures whoever managed to run the prev one, gets the value | ||
// also updated to 255 | ||
|
||
$rolesTable = $schema->getTable('api_key_roles'); | ||
$nameColumn = $rolesTable->getColumn('role_name'); | ||
$nameColumn->setLength(255); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
module/Rest/test-api/Action/SingleStepCreateShortUrlTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ShlinkioApiTest\Shlink\Rest\Action; | ||
|
||
use GuzzleHttp\RequestOptions; | ||
use Psr\Http\Message\ResponseInterface; | ||
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase; | ||
|
||
class SingleStepCreateShortUrlTest extends ApiTestCase | ||
{ | ||
/** | ||
* @test | ||
* @dataProvider provideFormats | ||
*/ | ||
public function createsNewShortUrlWithExpectedResponse(?string $format, string $expectedContentType): void | ||
{ | ||
$resp = $this->createShortUrl($format, 'valid_api_key'); | ||
|
||
self::assertEquals(self::STATUS_OK, $resp->getStatusCode()); | ||
self::assertEquals($expectedContentType, $resp->getHeaderLine('Content-Type')); | ||
} | ||
|
||
public function provideFormats(): iterable | ||
{ | ||
yield 'txt format' => ['txt', 'text/plain']; | ||
yield 'json format' => ['json', 'application/json']; | ||
yield '<empty> format' => [null, 'application/json']; | ||
} | ||
|
||
/** @test */ | ||
public function authorizationErrorIsReturnedIfNoApiKeyIsSent(): void | ||
{ | ||
$expectedDetail = 'Expected authentication to be provided in "apiKey" query param'; | ||
|
||
$resp = $this->createShortUrl(); | ||
$payload = $this->getJsonResponsePayload($resp); | ||
|
||
self::assertEquals(self::STATUS_UNAUTHORIZED, $resp->getStatusCode()); | ||
self::assertEquals(self::STATUS_UNAUTHORIZED, $payload['status']); | ||
self::assertEquals('INVALID_AUTHORIZATION', $payload['type']); | ||
self::assertEquals($expectedDetail, $payload['detail']); | ||
self::assertEquals('Invalid authorization', $payload['title']); | ||
} | ||
|
||
private function createShortUrl(?string $format = 'json', ?string $apiKey = null): ResponseInterface | ||
{ | ||
$query = [ | ||
'longUrl' => 'https://app.shlink.io', | ||
'apiKey' => $apiKey, | ||
'format' => $format, | ||
]; | ||
return $this->callApi(self::METHOD_GET, '/short-urls/shorten', [RequestOptions::QUERY => $query]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.