@Override
    public Mono<User> updatePassword(String username, String newPassword) {
        return getUser(username)
            .filter(user -> !Objects.equals(user.getSpec().getPassword(), newPassword))
            .flatMap(user -> {
                user.getSpec().setPassword(newPassword);
                return client.update(user);
            })
            .doOnNext(user -> publishPasswordChangedEvent(username));
    }
@Test
    void shouldUpdatePasswordIfUserFoundInExtension() {
        var fakeUser = new User();
        fakeUser.setSpec(new User.UserSpec());

        when(client.get(User.class, "faker")).thenReturn(Mono.just(fakeUser));
        when(client.update(eq(fakeUser))).thenReturn(Mono.just(fakeUser));

        StepVerifier.create(userService.updatePassword("faker", "new-fake-password"))
            .expectNext(fakeUser)
            .verifyComplete();

        verify(client, times(1)).get(eq(User.class), eq("faker"));
        verify(client, times(1)).update(argThat(extension -> {
            var user = (User) extension;
            return "new-fake-password".equals(user.getSpec().getPassword());
        }));

        verify(eventPublisher).publishEvent(any(PasswordChangedEvent.class));
    }