-
Notifications
You must be signed in to change notification settings - Fork 3
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 #234 from shlinkio/develop
Release 9.4.0
- Loading branch information
Showing
9 changed files
with
209 additions
and
11 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
24 changes: 24 additions & 0 deletions
24
src/Config/Option/Database/DatabaseUseEncryptionConfigOption.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,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shlinkio\Shlink\Installer\Config\Option\Database; | ||
|
||
use Symfony\Component\Console\Style\StyleInterface; | ||
|
||
class DatabaseUseEncryptionConfigOption extends AbstractNonSqliteDependentConfigOption | ||
{ | ||
public function getEnvVar(): string | ||
{ | ||
return 'DB_USE_ENCRYPTION'; | ||
} | ||
|
||
public function ask(StyleInterface $io, array $currentOptions): bool | ||
{ | ||
return $io->confirm( | ||
'Do you want the database connection to be encrypted? Enabling this will make database connections fail if ' | ||
. 'your database server does not support or enforce encryption.', | ||
default: false, | ||
); | ||
} | ||
} |
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
45 changes: 45 additions & 0 deletions
45
src/Config/Option/UrlShortener/ExtraPathModeConfigOption.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,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shlinkio\Shlink\Installer\Config\Option\UrlShortener; | ||
|
||
use Shlinkio\Shlink\Installer\Config\Option\BaseConfigOption; | ||
use Symfony\Component\Console\Style\StyleInterface; | ||
|
||
class ExtraPathModeConfigOption extends BaseConfigOption | ||
{ | ||
public const MODES = [ | ||
'default' => 'Match strictly', | ||
'append' => 'Append extra path', | ||
'ignore' => 'Discard extra path', | ||
]; | ||
|
||
public function getEnvVar(): string | ||
{ | ||
return 'REDIRECT_EXTRA_PATH_MODE'; | ||
} | ||
|
||
public function ask(StyleInterface $io, array $currentOptions): string | ||
{ | ||
return $io->choice( | ||
question: <<<QUESTION | ||
Do you want Shlink to redirect short URLs as soon as the first segment of the path matches a short code? | ||
append: | ||
* {shortDomain}/{shortCode}/[...extraPath] -> {longUrl}/[...extraPath] | ||
* https://s.test/abc123 -> https://www.example.com | ||
* https://s.test/abc123/shlinkio -> https://www.example.com/shlinkio | ||
ignore: | ||
* {shortDomain}/{shortCode}/[...extraPath] -> {longUrl} | ||
* https://s.test/abc123 -> https://www.example.com | ||
* https://s.test/abc123/shlinkio -> https://www.example.com | ||
QUESTION, | ||
choices: self::MODES, | ||
default: 'default', | ||
); | ||
} | ||
} |
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
44 changes: 44 additions & 0 deletions
44
test/Config/Option/Database/DatabaseUseEncryptionConfigOptionTest.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,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ShlinkioTest\Shlink\Installer\Config\Option\Database; | ||
|
||
use PHPUnit\Framework\Attributes\Test; | ||
use PHPUnit\Framework\Attributes\TestWith; | ||
use PHPUnit\Framework\TestCase; | ||
use Shlinkio\Shlink\Installer\Config\Option\Database\DatabaseUseEncryptionConfigOption; | ||
use Symfony\Component\Console\Style\StyleInterface; | ||
|
||
class DatabaseUseEncryptionConfigOptionTest extends TestCase | ||
{ | ||
private DatabaseUseEncryptionConfigOption $configOption; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->configOption = new DatabaseUseEncryptionConfigOption(); | ||
} | ||
|
||
#[Test] | ||
public function returnsExpectedEnvVar(): void | ||
{ | ||
self::assertEquals('DB_USE_ENCRYPTION', $this->configOption->getEnvVar()); | ||
} | ||
|
||
#[Test] | ||
#[TestWith([true])] | ||
#[TestWith([false])] | ||
public function expectedQuestionIsAsked(bool $expectedAnswer): void | ||
{ | ||
$io = $this->createMock(StyleInterface::class); | ||
$io->expects($this->once())->method('confirm')->with( | ||
'Do you want the database connection to be encrypted? Enabling this will make database connections fail if ' | ||
. 'your database server does not support or enforce encryption.', | ||
false, | ||
)->willReturn($expectedAnswer); | ||
|
||
$answer = $this->configOption->ask($io, []); | ||
|
||
self::assertEquals($expectedAnswer, $answer); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
test/Config/Option/UrlShortener/ExtraPathModeConfigOptionTest.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,63 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ShlinkioTest\Shlink\Installer\Config\Option\UrlShortener; | ||
|
||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use PHPUnit\Framework\Attributes\Test; | ||
use PHPUnit\Framework\TestCase; | ||
use Shlinkio\Shlink\Installer\Config\Option\UrlShortener\ExtraPathModeConfigOption; | ||
use Symfony\Component\Console\Style\StyleInterface; | ||
|
||
class ExtraPathModeConfigOptionTest extends TestCase | ||
{ | ||
private ExtraPathModeConfigOption $configOption; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->configOption = new ExtraPathModeConfigOption(); | ||
} | ||
|
||
#[Test] | ||
public function returnsExpectedEnvVar(): void | ||
{ | ||
self::assertEquals('REDIRECT_EXTRA_PATH_MODE', $this->configOption->getEnvVar()); | ||
} | ||
|
||
#[Test, DataProvider('provideChoices')] | ||
public function expectedQuestionIsAsked(string $choice): void | ||
{ | ||
$io = $this->createMock(StyleInterface::class); | ||
$io->expects($this->once())->method('choice')->with( | ||
<<<QUESTION | ||
Do you want Shlink to redirect short URLs as soon as the first segment of the path matches a short code? | ||
append: | ||
* {shortDomain}/{shortCode}/[...extraPath] -> {longUrl}/[...extraPath] | ||
* https://s.test/abc123 -> https://www.example.com | ||
* https://s.test/abc123/shlinkio -> https://www.example.com/shlinkio | ||
ignore: | ||
* {shortDomain}/{shortCode}/[...extraPath] -> {longUrl} | ||
* https://s.test/abc123 -> https://www.example.com | ||
* https://s.test/abc123/shlinkio -> https://www.example.com | ||
QUESTION, | ||
ExtraPathModeConfigOption::MODES, | ||
'default', | ||
)->willReturn($choice); | ||
|
||
$answer = $this->configOption->ask($io, []); | ||
|
||
self::assertEquals($choice, $answer); | ||
} | ||
|
||
public static function provideChoices(): iterable | ||
{ | ||
foreach (ExtraPathModeConfigOption::MODES as $mode => $_) { | ||
yield $mode => [$mode]; | ||
} | ||
} | ||
} |