mirror of
https://github.com/laravel/valet.git
synced 2026-02-06 08:40:09 +01:00
Merge branch 'master' into feature/links-with-parked
This commit is contained in:
@@ -146,11 +146,21 @@ function parked()
|
||||
*/
|
||||
function getCertificates($path)
|
||||
{
|
||||
$config = $this->config->read();
|
||||
|
||||
return collect($this->files->scandir($path))->filter(function ($value, $key) {
|
||||
return ends_with($value, '.crt');
|
||||
})->map(function ($cert) {
|
||||
})->map(function ($cert) use ($config) {
|
||||
$certWithoutSuffix = substr($cert, 0, -4);
|
||||
return substr($certWithoutSuffix, 0, strrpos($certWithoutSuffix, '.'));
|
||||
$trimToString = '.';
|
||||
|
||||
// If we have the cert ending in our tld strip that tld specifically
|
||||
// if not then just strip the last segment for backwards compatibility.
|
||||
if (ends_with($certWithoutSuffix, $config['tld'])) {
|
||||
$trimToString .= $config['tld'];
|
||||
}
|
||||
|
||||
return substr($certWithoutSuffix, 0, strrpos($certWithoutSuffix, $trimToString));
|
||||
})->flip();
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
*/
|
||||
Container::setInstance(new Container);
|
||||
|
||||
$version = '2.4.2';
|
||||
$version = '2.5.0';
|
||||
|
||||
$app = new Application('Laravel Valet', $version);
|
||||
|
||||
@@ -250,7 +250,7 @@
|
||||
* Stop the daemon services.
|
||||
*/
|
||||
$app->command('stop', function () {
|
||||
PhpFpm::stop();
|
||||
PhpFpm::stopRunning();
|
||||
|
||||
Nginx::stop();
|
||||
|
||||
|
||||
@@ -28,6 +28,28 @@ public function tearDown()
|
||||
}
|
||||
|
||||
|
||||
public function test_get_certificates_will_return_with_multi_segment_tld()
|
||||
{
|
||||
$files = Mockery::mock(Filesystem::class);
|
||||
$files->shouldReceive('scandir')
|
||||
->once()
|
||||
->with($certPath = '/Users/testuser/.config/valet/Certificates')
|
||||
->andReturn(['helloworld.multi.segment.tld.com.crt']);
|
||||
$config = Mockery::mock(Configuration::class);
|
||||
$config->shouldReceive('read')
|
||||
->once()
|
||||
->andReturn(['tld' => 'multi.segment.tld.com']);
|
||||
|
||||
swap(Filesystem::class, $files);
|
||||
swap(Configuration::class, $config);
|
||||
|
||||
/** @var Site $site */
|
||||
$site = resolve(Site::class);
|
||||
$certs = $site->getCertificates($certPath);
|
||||
$this->assertSame(['helloworld' => 0], $certs->all());
|
||||
}
|
||||
|
||||
|
||||
public function test_get_sites_will_return_if_secured()
|
||||
{
|
||||
$files = Mockery::mock(Filesystem::class);
|
||||
@@ -206,6 +228,12 @@ public function test_certificates_trim_tld_for_custom_tlds()
|
||||
'fiveletters.local.crt',
|
||||
]);
|
||||
|
||||
$config = Mockery::mock(Configuration::class);
|
||||
$config->shouldReceive('read')
|
||||
->once()
|
||||
->andReturn(['tld' => 'other']);
|
||||
|
||||
swap(Configuration::class, $config);
|
||||
swap(Filesystem::class, $files);
|
||||
|
||||
$site = resolve(Site::class);
|
||||
|
||||
Reference in New Issue
Block a user