@Before
 public void removeOldKeys() {
   ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
   validator = factory.getValidator();
   keyStore
       .getUsers()
       .stream()
       .map(keyStore::getKeys)
       .flatMap(Collection::stream)
       .forEach(unsafe(PersistedKey::delete));
 }
  @Given("^the user has an SSH key in the key store$")
  public void theUserHasAnSSHKeyInTheKeyStore() throws Throwable {
    String contents = IOUtils.toString(UserApiDefinitions.class.getResource("/test_rsa.pub"));
    KeyHolder keyHolder = new KeyHolder(userModel.getName(), contents);
    keyStore.put(keyHolder);
    assertThat(getKeysApi().listSshKeys(), Matchers.not(Matchers.empty()));

    SshKeyModel sshKeyModel = new SshKeyModel();
    sshKeyModel.setContents(contents);
    sshKeyModel.setName(keyHolder.getName());
    Collection<ConstraintViolation<SshKeyModel>> violations = validator.validate(sshKeyModel);
    assertThat(violations, Matchers.empty());

    resetMockCounters();
  }