File tree Expand file tree Collapse file tree
tests/unit/OpenConext/EngineBlock/Service/Consent Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,4 +82,31 @@ public function test_unstable_attribute_hash_key_order_normalized_in_names_only_
8282 $ this ->chs ->getUnstableAttributesHash ($ reversed , false )
8383 );
8484 }
85+
86+ /**
87+ * Ensure the 'old' consent hash produces a manually verified hash
88+ * (if the old hash algorithm is accidentally changed, this test fails)
89+ */
90+ public function test_unstable_hash_golden_values_must_never_change (): void
91+ {
92+ $ attributes = [
93+ 'urn:mace:dir:attribute-def:uid ' => ['joe-f12 ' ],
94+ 'urn:mace:dir:attribute-def:displayName ' => ['John Doe ' ],
95+ 'urn:mace:dir:attribute-def:mail ' => ['joe@example.org ' ],
96+ ];
97+
98+ // Algorithm: sort(array_keys($attributes)), sha1(implode('|', ...))
99+ $ this ->assertSame (
100+ '65d6f8f1f7064a70921882e3840e807e1d14e535 ' ,
101+ $ this ->chs ->getUnstableAttributesHash ($ attributes , false ),
102+ 'Unstable names-only hash must never change — existing DB rows depend on it '
103+ );
104+
105+ // Algorithm: ksort($attributes), sha1(serialize(...))
106+ $ this ->assertSame (
107+ 'c4861f8908bd9311ea8e11df579a8ecb14c7ac66 ' ,
108+ $ this ->chs ->getUnstableAttributesHash ($ attributes , true ),
109+ 'Unstable with-values hash must never change — existing DB rows depend on it '
110+ );
111+ }
85112}
You can’t perform that action at this time.
0 commit comments