1
0
mirror of https://github.com/sismics/docs.git synced 2025-12-17 19:51:39 +00:00
This commit is contained in:
jendib
2016-03-22 22:15:19 +01:00
parent b28e08e2c7
commit 6e6babd2e3
11 changed files with 948 additions and 17 deletions

View File

@@ -0,0 +1,26 @@
package com.sismics.util;
import java.util.Date;
import org.junit.Assert;
import org.junit.Test;
import com.sismics.util.totp.GoogleAuthenticator;
import com.sismics.util.totp.GoogleAuthenticatorKey;
/**
* Test of {@link GoogleAuthenticator}
*
* @author bgamard
*/
public class TestGoogleAuthenticator {
@Test
public void testGoogleAuthenticator() {
GoogleAuthenticator gAuth = new GoogleAuthenticator();
GoogleAuthenticatorKey key = gAuth.createCredentials();
Assert.assertNotNull(key.getVerificationCode());
Assert.assertEquals(5, key.getScratchCodes().size());
int validationCode = gAuth.calculateCode(key.getKey(), new Date().getTime() / 30000);
Assert.assertTrue(gAuth.authorize(key.getKey(), validationCode));
}
}