mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-04 20:30:36 +00:00
Disable some fields if Steam OTP type is selected
Also, move some magic default OTP parameters to constants
This commit is contained in:
parent
bc6cb35dc0
commit
2c8a64f943
15 changed files with 55 additions and 29 deletions
|
@ -8,6 +8,7 @@ import androidx.test.core.app.ApplicationProvider;
|
|||
import com.beemdevelopment.aegis.encoding.Base32;
|
||||
import com.beemdevelopment.aegis.encoding.EncodingException;
|
||||
import com.beemdevelopment.aegis.otp.HotpInfo;
|
||||
import com.beemdevelopment.aegis.otp.OtpInfo;
|
||||
import com.beemdevelopment.aegis.otp.OtpInfoException;
|
||||
import com.beemdevelopment.aegis.otp.SteamInfo;
|
||||
import com.beemdevelopment.aegis.otp.TotpInfo;
|
||||
|
@ -178,11 +179,11 @@ public class DatabaseImporterTest {
|
|||
for (VaultEntry entry : entries) {
|
||||
// Google Authenticator doesn't support different hash algorithms, periods or digits, so fix those up here
|
||||
VaultEntry entryVector = getEntryVectorBySecret(entry.getInfo().getSecret());
|
||||
entryVector.getInfo().setDigits(6);
|
||||
entryVector.getInfo().setDigits(OtpInfo.DEFAULT_DIGITS);
|
||||
if (entryVector.getInfo() instanceof TotpInfo) {
|
||||
((TotpInfo) entryVector.getInfo()).setPeriod(30);
|
||||
((TotpInfo) entryVector.getInfo()).setPeriod(TotpInfo.DEFAULT_PERIOD);
|
||||
}
|
||||
entryVector.getInfo().setAlgorithm("SHA1");
|
||||
entryVector.getInfo().setAlgorithm(OtpInfo.DEFAULT_ALGORITHM);
|
||||
checkImportedEntry(entryVector, entry);
|
||||
}
|
||||
}
|
||||
|
@ -264,7 +265,7 @@ public class DatabaseImporterTest {
|
|||
for (VaultEntry entry : entries) {
|
||||
// Authy doesn't support different hash algorithms or periods, so fix those up here
|
||||
VaultEntry entryVector = getEntryVectorBySecret(entry.getInfo().getSecret());
|
||||
entryVector.getInfo().setAlgorithm("SHA1");
|
||||
entryVector.getInfo().setAlgorithm(OtpInfo.DEFAULT_ALGORITHM);
|
||||
((TotpInfo) entry.getInfo()).setPeriod(((TotpInfo) entryVector.getInfo()).getPeriod());
|
||||
checkImportedEntry(entryVector, entry);
|
||||
}
|
||||
|
@ -274,9 +275,9 @@ public class DatabaseImporterTest {
|
|||
for (VaultEntry entry : entries) {
|
||||
// TOTP Authenticator doesn't support different hash algorithms, periods or digits, so fix those up here
|
||||
VaultEntry entryVector = getEntryVectorBySecret(entry.getInfo().getSecret());
|
||||
entryVector.getInfo().setDigits(6);
|
||||
((TotpInfo) entryVector.getInfo()).setPeriod(30);
|
||||
entryVector.getInfo().setAlgorithm("SHA1");
|
||||
entryVector.getInfo().setDigits(OtpInfo.DEFAULT_DIGITS);
|
||||
((TotpInfo) entryVector.getInfo()).setPeriod(TotpInfo.DEFAULT_PERIOD);
|
||||
entryVector.getInfo().setAlgorithm(OtpInfo.DEFAULT_ALGORITHM);
|
||||
entryVector.setName(entryVector.getName().toLowerCase());
|
||||
checkImportedEntry(entryVector, entry);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ public class OtpTest {
|
|||
@Test
|
||||
public void testHotpInfoOtp() throws OtpInfoException {
|
||||
for (int i = 0; i < HOTPTest.VECTORS.length; i++) {
|
||||
HotpInfo info = new HotpInfo(HOTPTest.SECRET, "SHA1", 6, i);
|
||||
HotpInfo info = new HotpInfo(HOTPTest.SECRET, OtpInfo.DEFAULT_ALGORITHM, OtpInfo.DEFAULT_DIGITS, i);
|
||||
assertEquals(HOTPTest.VECTORS[i], info.getOtp());
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public class OtpTest {
|
|||
public void testTotpInfoOtp() throws OtpInfoException {
|
||||
for (TOTPTest.Vector vector : TOTPTest.VECTORS) {
|
||||
byte[] seed = TOTPTest.getSeed(vector.Algo);
|
||||
TotpInfo info = new TotpInfo(seed, vector.Algo, 8, 30);
|
||||
TotpInfo info = new TotpInfo(seed, vector.Algo, 8, TotpInfo.DEFAULT_PERIOD);
|
||||
assertEquals(vector.OTP, info.getOtp(vector.Time));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue