fix: scope csrf fields and block past dates
This commit is contained in:
@@ -75,3 +75,26 @@ test('rule validator rejects unsupported response frequency', function (): void
|
||||
}
|
||||
throw new RuntimeException('Expected invalid frequency to fail');
|
||||
});
|
||||
|
||||
test('rule validator rejects start date before current date', function (): void {
|
||||
$settingsPath = TEST_TMP . '/validator-past.conf';
|
||||
test_write($settingsPath, "GLOBAL_AUTORESPONDER_TIMEZONE=Europe/Warsaw\nGLOBAL_AUTORESPONDER_BACKEND=exim\n");
|
||||
$settings = Settings::load($settingsPath);
|
||||
$tz = new DateTimeZone($settings->timezone());
|
||||
$yesterday = (new DateTimeImmutable('yesterday', $tz))->format('Y-m-d');
|
||||
$tomorrow = (new DateTimeImmutable('tomorrow', $tz))->format('Y-m-d');
|
||||
|
||||
try {
|
||||
RuleValidator::validate([
|
||||
'subject_prefix' => 'Urlop',
|
||||
'reply_frequency' => '1440',
|
||||
'body' => 'Body',
|
||||
'start_value' => $yesterday . 'T09:00',
|
||||
'end_value' => $tomorrow . 'T17:00',
|
||||
], $settings);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
assert_contains('wcześniejsza niż aktualna', $e->getMessage());
|
||||
return;
|
||||
}
|
||||
throw new RuntimeException('Expected past start date to fail');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user