MasterPasswordFeature extends KeyStoreLeveragingFeature { @Override public void setup() throws SetupFailedException { super.setup(); try { this.getStorage() .save(newSecret); } catch (final Exception ex) { throw new SetupFailedException(ex); } } MasterPasswordFeature(final File keystore, final char[] keystoreSecret, final char... newSecret);   MasterPasswordFeature(); @Override String describe(); @Override void setup(); @Override void test();  }
@Test void createNew() throws IOException, SetupFailedException, KeyStoreException { final File f = newTempFile(); final Feature feature = new MasterPasswordFeature(f, ORIG_PASSWORD.toCharArray(), NEW_PASSWORD.toCharArray()); feature.setup(); assertThat(f).exists(); KeyStoreHandler.open(f, NEW_PASSWORD.toCharArray()); }
@Test void reuse() throws IOException, SetupFailedException, KeyStoreException { final File f = newTempFile(); KeyStoreHandler.create(f, ORIG_PASSWORD.toCharArray()); final Feature feature = new MasterPasswordFeature(f, ORIG_PASSWORD.toCharArray(), NEW_PASSWORD.toCharArray()); feature.setup(); KeyStoreHandler.open(f, NEW_PASSWORD.toCharArray()); }