@@ -49,18 +49,16 @@ public class TransportChangePasswordActionTests extends ESTestCase {
49
49
50
50
public void testAnonymousUser () {
51
51
final String hashingAlgorithm = randomFrom ("pbkdf2" , "pbkdf2_1000" , "bcrypt" , "bcrypt9" );
52
- Settings settings = Settings .builder ().put (AnonymousUser .ROLES_SETTING .getKey (), "superuser" ).build ();
52
+ Settings settings = Settings .builder ().put (AnonymousUser .ROLES_SETTING .getKey (), "superuser" )
53
+ .put (XPackSettings .PASSWORD_HASHING_ALGORITHM .getKey (), hashingAlgorithm ).build ();
53
54
AnonymousUser anonymousUser = new AnonymousUser (settings );
54
55
NativeUsersStore usersStore = mock (NativeUsersStore .class );
55
- Settings passwordHashingSettings = Settings .builder ().
56
- put (XPackSettings .PASSWORD_HASHING_ALGORITHM .getKey (), hashingAlgorithm ).build ();
57
- TransportService transportService = new TransportService (passwordHashingSettings , mock (Transport .class ), null ,
56
+ TransportService transportService = new TransportService (Settings .EMPTY , mock (Transport .class ), null ,
58
57
TransportService .NOOP_TRANSPORT_INTERCEPTOR , x -> null , null , Collections .emptySet ());
59
58
TransportChangePasswordAction action = new TransportChangePasswordAction (settings , transportService ,
60
59
mock (ActionFilters .class ), usersStore );
61
-
62
- ChangePasswordRequest request = new ChangePasswordRequest ();
63
60
// Request will fail before the request hashing algorithm is checked, but we use the same algorithm as in settings for consistency
61
+ ChangePasswordRequest request = new ChangePasswordRequest ();
64
62
request .username (anonymousUser .principal ());
65
63
request .passwordHash (Hasher .resolve (hashingAlgorithm ).hash (SecuritySettingsSourceField .TEST_PASSWORD_SECURE_STRING ));
66
64
@@ -89,14 +87,13 @@ public void testInternalUsers() {
89
87
NativeUsersStore usersStore = mock (NativeUsersStore .class );
90
88
Settings passwordHashingSettings = Settings .builder ().
91
89
put (XPackSettings .PASSWORD_HASHING_ALGORITHM .getKey (), hashingAlgorithm ).build ();
92
- TransportService transportService = new TransportService (passwordHashingSettings , mock (Transport .class ), null ,
90
+ TransportService transportService = new TransportService (Settings . EMPTY , mock (Transport .class ), null ,
93
91
TransportService .NOOP_TRANSPORT_INTERCEPTOR , x -> null , null , Collections .emptySet ());
94
- TransportChangePasswordAction action = new TransportChangePasswordAction (Settings . EMPTY , transportService ,
92
+ TransportChangePasswordAction action = new TransportChangePasswordAction (passwordHashingSettings , transportService ,
95
93
mock (ActionFilters .class ), usersStore );
96
-
94
+ // Request will fail before the request hashing algorithm is checked, but we use the same algorithm as in settings for consistency
97
95
ChangePasswordRequest request = new ChangePasswordRequest ();
98
96
request .username (randomFrom (SystemUser .INSTANCE .principal (), XPackUser .INSTANCE .principal ()));
99
- // Request will fail before the request hashing algorithm is checked, but we use the same algorithm as in settings for consistency
100
97
request .passwordHash (Hasher .resolve (hashingAlgorithm ).hash (SecuritySettingsSourceField .TEST_PASSWORD_SECURE_STRING ));
101
98
102
99
final AtomicReference <Throwable > throwableRef = new AtomicReference <>();
0 commit comments