@@ -1325,7 +1325,7 @@ public function testCreateUserWithWeakPasswordThrowsUserPasswordValidationExcept
1325
1325
1326
1326
try {
1327
1327
// This call will fail with a "UserPasswordValidationException" because the
1328
- // the password does not follow specified rules.
1328
+ // password does not follow specified rules.
1329
1329
$ this ->createTestUserWithPassword ('pass ' , $ userContentType );
1330
1330
} catch (ContentFieldValidationException $ e ) {
1331
1331
// Exception is caught, as there is no other way to check exception properties.
@@ -2177,13 +2177,41 @@ public function testUpdateUserPasswordWithUnsupportedHashType(): void
2177
2177
$ wrongHashType = 1 ;
2178
2178
$ this ->updateRawPasswordHash ($ user ->getUserId (), $ wrongHashType );
2179
2179
$ newPassword = 'new_secret123 ' ;
2180
- // no need to invalidate cache since there was no load between create & raw database update
2180
+ // no need to invalidate cache since there was no load between creation
2181
+ // and raw database update
2181
2182
$ user = $ userService ->updateUserPassword ($ user , $ newPassword );
2182
2183
2183
2184
self ::assertTrue ($ userService ->checkUserCredentials ($ user , $ newPassword ));
2184
2185
self ::assertNotEquals ($ oldPasswordHash , $ user ->passwordHash );
2185
2186
}
2186
2187
2188
+ /**
2189
+ * @throws \Doctrine\DBAL\Exception
2190
+ * @throws \ErrorException
2191
+ * @throws \Ibexa\Contracts\Core\Repository\Exceptions\ContentFieldValidationException
2192
+ * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException
2193
+ */
2194
+ public function testUpdateUserPasswordHashToArgon2Id (): void
2195
+ {
2196
+ $ repository = $ this ->getRepository ();
2197
+ $ userService = $ repository ->getUserService ();
2198
+
2199
+ $ user = $ this ->createUser ('john.doe ' , 'John ' , 'Doe ' );
2200
+ $ oldPasswordHash = $ user ->passwordHash ;
2201
+
2202
+ $ argon2IdHashType = User::PASSWORD_HASH_ARGON2ID ;
2203
+ $ this ->updateRawPasswordHash ($ user ->getUserId (), $ argon2IdHashType );
2204
+ $ newPassword = 'new_secret123 ' ;
2205
+ // no need to invalidate cache since there was no load between creation
2206
+ // and raw database update
2207
+ $ user = $ userService ->updateUserPassword ($ user , $ newPassword );
2208
+ $ passwordInfo = password_get_info ($ user ->passwordHash );
2209
+
2210
+ self ::assertTrue ($ userService ->checkUserCredentials ($ user , $ newPassword ));
2211
+ self ::assertNotEquals ($ oldPasswordHash , $ user ->passwordHash );
2212
+ self ::assertEquals (PASSWORD_ARGON2ID , $ passwordInfo ['algo ' ]);
2213
+ }
2214
+
2187
2215
/**
2188
2216
* Test for the loadUserGroupsOfUser() method.
2189
2217
*
0 commit comments