#1141 2FA implementation fixes

- Merge TotpService into TotpAuthenticator
- Add missing tests
- Migrate old 2fa enabled key to new one
This commit is contained in:
ljacqu
2018-05-01 22:49:07 +02:00
parent 29ac3a7022
commit 1e3ed795c1
13 changed files with 356 additions and 79 deletions
@@ -100,6 +100,23 @@ public class MessageUpdaterTest {
equalTo("seconds in plural"));
}
@Test
public void shouldPerformNewerMigrations() throws IOException {
// given
File messagesFile = temporaryFolder.newFile();
Files.copy(TestHelper.getJarFile(TestHelper.PROJECT_ROOT + "message/messages_test2.yml"), messagesFile);
// when
boolean wasChanged = messageUpdater.migrateAndSave(messagesFile, "messages/messages_en.yml", "messages/messages_en.yml");
// then
assertThat(wasChanged, equalTo(true));
FileConfiguration configuration = YamlConfiguration.loadConfiguration(messagesFile);
assertThat(configuration.getString(MessageKey.TWO_FACTOR_CREATE.getKey()), equalTo("Old 2fa create text"));
assertThat(configuration.getString(MessageKey.WRONG_PASSWORD.getKey()), equalTo("test2 - wrong password")); // from pre-5.5 key
assertThat(configuration.getString(MessageKey.SECOND.getKey()), equalTo("second")); // from messages_en.yml
}
@Test
public void shouldHaveAllKeysInConfigurationData() {
// given