mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-04 10:42:23 +00:00
Co-authored-by: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Co-authored-by: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: rosslh <ross@rosshill.ca>
51 lines
1.3 KiB
PHP
51 lines
1.3 KiB
PHP
<?php
|
|
|
|
use App\Rules\ValidServerIp;
|
|
use Tests\TestCase;
|
|
|
|
uses(TestCase::class);
|
|
|
|
it('accepts private and reserved IP addresses like the next branch', function (string $ip) {
|
|
$rule = new ValidServerIp;
|
|
$failCalled = false;
|
|
|
|
$rule->validate('ip', $ip, function () use (&$failCalled): void {
|
|
$failCalled = true;
|
|
});
|
|
|
|
expect($failCalled)->toBeFalse();
|
|
})->with([
|
|
'private IPv4' => '192.168.1.10',
|
|
'loopback IPv4' => '127.0.0.1',
|
|
'link-local IPv4' => '169.254.1.10',
|
|
'loopback IPv6' => '::1',
|
|
'unique local IPv6' => 'fd00::1',
|
|
]);
|
|
|
|
it('accepts an IPv6 address in brackets', function (string $ip) {
|
|
$failCalled = false;
|
|
|
|
(new ValidServerIp)->validate('ip', $ip, function () use (&$failCalled): void {
|
|
$failCalled = true;
|
|
});
|
|
|
|
expect($failCalled)->toBeFalse();
|
|
})->with([
|
|
'short form' => '[2a01:4f8::1]',
|
|
'long form' => '[2A01:04F8:0000:0000:0000:0000:0000:0001]',
|
|
]);
|
|
|
|
it('rejects brackets around anything other than an IPv6 address', function (string $ip) {
|
|
$failCalled = false;
|
|
|
|
(new ValidServerIp)->validate('ip', $ip, function () use (&$failCalled): void {
|
|
$failCalled = true;
|
|
});
|
|
|
|
expect($failCalled)->toBeTrue();
|
|
})->with([
|
|
'IPv4' => '[192.168.1.10]',
|
|
'hostname' => '[server.example.com]',
|
|
'missing closing bracket' => '[2a01:4f8::1',
|
|
]);
|