dbxapp 4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
Loading...
Searching...
No Matches
dbxUserProfilePassword_test.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5$root = dirname(__DIR__, 3);
6require_once $root . '/include/dbxPasswordPolicy.class.php';
7
8function profile_password_assert(bool $condition, string $message): void
9{
10 if (!$condition) {
11 throw new RuntimeException($message);
12 }
13}
14
19 'Die zentrale Passwort-Mindestlänge wird nicht korrekt begrenzt.'
20);
21
24 str_contains((string)($weakErrors['password'] ?? ''), 'mindestens 6 Zeichen')
25 && str_contains((string)($weakErrors['password'] ?? ''), 'ein Großbuchstabe')
26 && str_contains((string)($weakErrors['password'] ?? ''), 'eine Zahl')
27 && str_contains((string)($weakErrors['password'] ?? ''), 'ein Sonderzeichen')
28 && isset($weakErrors['repeat']),
29 'Die Profilprüfung muss alle fehlenden Kriterien und Abweichungen nennen.'
30);
31
32$strongPassword = 'Ab1!xy';
37 '',
38 6
39 ) === array(),
40 'Ein gültiges Profilpasswort wird abgelehnt.'
41);
46 password_hash($strongPassword, PASSWORD_DEFAULT),
47 6
48 )['password']),
49 'Das bisherige Passwort darf nicht unverändert erneut gespeichert werden.'
50);
51
52$profileSource = (string)file_get_contents(
53 dirname(__DIR__) . '/include/dbxUser_profil.class.php'
54);
55$adminSource = (string)file_get_contents(
56 $root . '/modules/dbxUser_admin/include/dbxUser_profil.class.php'
57);
58$profileTemplate = (string)file_get_contents(
59 dirname(__DIR__) . '/tpl/htm/form-profil.htm'
60);
61$adminTemplate = (string)file_get_contents(
62 $root . '/modules/dbxUser_admin/tpl/htm/form-profil.htm'
63);
64$utilities = (string)file_get_contents($root . '/js/lib/utilities.js');
65$formCss = (string)file_get_contents(
66 $root . '/design/dbxapp/css/c-form.css'
67);
68
69foreach (array($profileSource, $adminSource) as $source) {
71 str_contains($source, '\\dbxPasswordPolicy::errors(')
72 && str_contains($source, 'password_hash(')
73 && str_contains($source, 'password_changed_at')
74 && str_contains($source, "unset(\$settings['password_reset_required'])"),
75 'Profil und Admin-Profil müssen dieselbe moderne Passwortpolicy verwenden.'
76 );
77}
79 !str_contains($adminSource, 'md5($pas)')
80 && str_contains($adminSource, "'pass_repeat'")
81 && str_contains($adminSource, "'varchar|max=128'"),
82 'Das Admin-Profil muss Passwortwiederholung und moderne Hashes verwenden.'
83);
84
85foreach (array($profileTemplate, $adminTemplate) as $template) {
87 str_contains($template, 'class="dbx-password-rules--compact"')
88 && str_contains($template, 'data-dbx-password-rules')
89 && str_contains($template, 'data-password-rule="length"')
90 && str_contains($template, 'data-password-rule="letters"')
91 && str_contains($template, 'data-password-rule="number"')
92 && str_contains($template, 'data-password-rule="special"')
93 && str_contains($template, 'data-password-rule="match"'),
94 'Die kompakte Profilanzeige enthält nicht alle Passwortkriterien.'
95 );
96}
98 str_contains($utilities, 'function initPasswordCriteria(')
99 && str_contains($utilities, 'passwordRules:')
100 && str_contains($formCss, '.dbx-password-rules--compact'),
101 'Die wiederverwendbare Live-Prüfung oder ihre kompakte Darstellung fehlt.'
102);
103
104echo "OK compact profile password policy and modern hashes\n";
static errors(string $password, string $repeat, string $currentHash='', ?int $minimumLength=null)
static minimumLength(?int $configured=null)
profile_password_assert(bool $condition, string $message)