@Then("^the key is added to the keystore$") public void theKeyIsAddedToTheKeystore() throws Throwable { verify(gitManager).commitChanges(); verify(gitManager).push(); verify(keyStore) .put(new KeyHolder(userModel.getName(), sshKeyModel.getName(), sshKeyModel.getContents())); }
@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(); }
UserApi getUserApi() { return usersApi.getUser(userModel.getName()); }