mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-16 23:12:51 +00:00
Add a test for the Duo importer
This commit is contained in:
parent
5c196f1ca5
commit
aec639cc53
4 changed files with 39 additions and 5 deletions
|
@ -32,7 +32,7 @@ public abstract class DatabaseImporter {
|
|||
_importers.add(new Definition("andOTP", AndOtpImporter.class, R.string.importer_help_andotp, false));
|
||||
_importers.add(new Definition("Authenticator Plus", AuthenticatorPlusImporter.class, R.string.importer_help_authenticator_plus, false));
|
||||
_importers.add(new Definition("Authy", AuthyImporter.class, R.string.importer_help_authy, true));
|
||||
_importers.add(new Definition("DUO", DuoImporter.class, R.string.importer_help_duo, true));
|
||||
_importers.add(new Definition("Duo", DuoImporter.class, R.string.importer_help_duo, true));
|
||||
_importers.add(new Definition("FreeOTP", FreeOtpImporter.class, R.string.importer_help_freeotp, true));
|
||||
_importers.add(new Definition("FreeOTP+", FreeOtpPlusImporter.class, R.string.importer_help_freeotp_plus, true));
|
||||
_importers.add(new Definition("Google Authenticator", GoogleAuthImporter.class, R.string.importer_help_google_authenticator, true));
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.content.Context;
|
|||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.beemdevelopment.aegis.encoding.Base32;
|
||||
import com.beemdevelopment.aegis.encoding.EncodingException;
|
||||
|
@ -83,11 +82,8 @@ public class DuoImporter extends DatabaseImporter {
|
|||
) throws DatabaseImporterEntryException {
|
||||
try {
|
||||
String label = entry.optString("name");
|
||||
|
||||
JSONObject otpData = entry.getJSONObject("otpGenerator");
|
||||
|
||||
byte[] secret = Base32.decode(otpData.getString("otpSecret"));
|
||||
|
||||
Long counter = otpData.has("counter") ? otpData.getLong("counter") : null;
|
||||
|
||||
OtpInfo otp = counter == null
|
||||
|
|
|
@ -81,6 +81,19 @@ public class DatabaseImporterTest {
|
|||
checkImportedEntries(entries);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testImportDuo() throws IOException, DatabaseImporterException, OtpInfoException {
|
||||
List<VaultEntry> entries = importPlain(DuoImporter.class, "duo.json");
|
||||
for (VaultEntry entry : entries) {
|
||||
VaultEntry entryVector = getEntryVectorBySecret(entry.getInfo().getSecret());
|
||||
entryVector.setIssuer("");
|
||||
if (entryVector.getInfo() instanceof HotpInfo) {
|
||||
((HotpInfo) entry.getInfo()).setCounter(1);
|
||||
}
|
||||
checkImportedEntry(entryVector, entry);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testImportWinAuth() throws IOException, DatabaseImporterException {
|
||||
List<VaultEntry> entries = importPlain(WinAuthImporter.class, "plain.txt");
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
[
|
||||
{
|
||||
"version": 1.0,
|
||||
"accountType": "OtpAccount",
|
||||
"name": "Mason",
|
||||
"otpGenerator": {
|
||||
"otpSecret": "4SJHB4GSD43FZBAI7C2HLRJGPQ"
|
||||
},
|
||||
"logoUri": "file:///data/user/0/com.duosecurity.duomobile/files/duokit/logos/9a011a29-0496-4c0b-b53a-b9125eea14a3.png",
|
||||
"pkey": "9a011a29-0496-4c0b-b53a-b9125eea14a3",
|
||||
"serviceTypeLabelIsCustom": true
|
||||
},
|
||||
{
|
||||
"version": 1.0,
|
||||
"accountType": "OtpAccount",
|
||||
"name": "James",
|
||||
"otpGenerator": {
|
||||
"otpSecret": "YOOMIXWS5GN6RTBPUFFWKTW5M4",
|
||||
"counter": 3
|
||||
},
|
||||
"logoUri": "file:///data/user/0/com.duosecurity.duomobile/files/duokit/logos/907d30f0-d322-4fa5-baff-4b7c603f5141.png",
|
||||
"pkey": "907d30f0-d322-4fa5-baff-4b7c603f5141",
|
||||
"serviceTypeLabelIsCustom": true
|
||||
}
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue