mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-14 14:02:49 +00:00
Move Yandex secret validation tests to a different folder
This commit is contained in:
parent
119c3838e1
commit
acfb70c267
3 changed files with 23 additions and 18 deletions
|
@ -0,0 +1,17 @@
|
||||||
|
package com.beemdevelopment.aegis.otp;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import com.beemdevelopment.aegis.crypto.otp.HOTPTest;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class HotpInfoTest {
|
||||||
|
@Test
|
||||||
|
public void testHotpInfoOtp() throws OtpInfoException {
|
||||||
|
for (int i = 0; i < HOTPTest.VECTORS.length; i++) {
|
||||||
|
HotpInfo info = new HotpInfo(HOTPTest.SECRET, OtpInfo.DEFAULT_ALGORITHM, OtpInfo.DEFAULT_DIGITS, i);
|
||||||
|
assertEquals(HOTPTest.VECTORS[i], info.getOtp());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,21 +1,12 @@
|
||||||
package com.beemdevelopment.aegis.otp;
|
package com.beemdevelopment.aegis.otp;
|
||||||
|
|
||||||
import com.beemdevelopment.aegis.crypto.otp.HOTPTest;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import com.beemdevelopment.aegis.crypto.otp.TOTPTest;
|
import com.beemdevelopment.aegis.crypto.otp.TOTPTest;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
public class TotpInfoTest {
|
||||||
|
|
||||||
public class OtpTest {
|
|
||||||
@Test
|
|
||||||
public void testHotpInfoOtp() throws OtpInfoException {
|
|
||||||
for (int i = 0; i < HOTPTest.VECTORS.length; i++) {
|
|
||||||
HotpInfo info = new HotpInfo(HOTPTest.SECRET, OtpInfo.DEFAULT_ALGORITHM, OtpInfo.DEFAULT_DIGITS, i);
|
|
||||||
assertEquals(HOTPTest.VECTORS[i], info.getOtp());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTotpInfoOtp() throws OtpInfoException {
|
public void testTotpInfoOtp() throws OtpInfoException {
|
||||||
for (TOTPTest.Vector vector : TOTPTest.VECTORS) {
|
for (TOTPTest.Vector vector : TOTPTest.VECTORS) {
|
|
@ -1,16 +1,13 @@
|
||||||
package com.beemdevelopment.aegis.util;
|
package com.beemdevelopment.aegis.otp;
|
||||||
|
|
||||||
import static org.junit.Assert.assertThrows;
|
import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import com.beemdevelopment.aegis.encoding.Base32;
|
import com.beemdevelopment.aegis.encoding.Base32;
|
||||||
import com.beemdevelopment.aegis.encoding.EncodingException;
|
import com.beemdevelopment.aegis.encoding.EncodingException;
|
||||||
import com.beemdevelopment.aegis.otp.OtpInfoException;
|
|
||||||
import com.beemdevelopment.aegis.otp.YandexInfo;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class YandexUtilsTest {
|
public class YandexInfoTest {
|
||||||
|
|
||||||
private static final String[] vectors = new String[]{
|
private static final String[] vectors = new String[]{
|
||||||
"LA2V6KMCGYMWWVEW64RNP3JA3IAAAAAAHTSG4HRZPI", // correct
|
"LA2V6KMCGYMWWVEW64RNP3JA3IAAAAAAHTSG4HRZPI", // correct
|
||||||
"LA2V6KMCGYMWWVEW64RNP3JA3I", // secret from QR - no validation
|
"LA2V6KMCGYMWWVEW64RNP3JA3I", // secret from QR - no validation
|
||||||
|
@ -19,7 +16,7 @@ public class YandexUtilsTest {
|
||||||
};
|
};
|
||||||
|
|
||||||
@Test(expected = Test.None.class)
|
@Test(expected = Test.None.class)
|
||||||
public void testValidationOk() throws EncodingException, OtpInfoException {
|
public void testYandexSecretValidationOk() throws EncodingException, OtpInfoException {
|
||||||
YandexInfo.validateSecret(getBase32Vector(0));
|
YandexInfo.validateSecret(getBase32Vector(0));
|
||||||
YandexInfo.validateSecret(getBase32Vector(1));
|
YandexInfo.validateSecret(getBase32Vector(1));
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue