Review fixes

This commit is contained in:
Weslly 2017-05-03 20:54:19 -03:00
parent bf57a28654
commit 4c9b8c7794
9 changed files with 117 additions and 62 deletions

View file

@ -25,6 +25,7 @@
#include "crypto/Crypto.h"
#include "totp/totp.h"
#include "totp/base32.h"
QTEST_GUILESS_MAIN(TestTotp)
@ -34,7 +35,7 @@ void TestTotp::initTestCase()
}
void TestTotp::testSecret()
void TestTotp::testParseSecret()
{
quint8 digits = 0;
quint8 step = 0;
@ -61,19 +62,19 @@ void TestTotp::testSecret()
void TestTotp::testBase32()
{
QByteArray key = QString("JBSW Y3DP EB3W 64TM MQXC 4LQA").toLatin1();
QByteArray secret = QTotp::base32_decode(key);
QByteArray secret = Base32::base32_decode(key);
QCOMPARE(QString::fromLatin1(secret), QString("Hello world..."));
key = QString("gezdgnbvgy3tqojqgezdgnbvgy3tqojq").toLatin1();
secret = QTotp::base32_decode(key);
secret = Base32::base32_decode(key);
QCOMPARE(QString::fromLatin1(secret), QString("12345678901234567890"));
key = QString("ORSXG5A=").toLatin1();
secret = QTotp::base32_decode(key);
secret = Base32::base32_decode(key);
QCOMPARE(QString::fromLatin1(secret), QString("test"));
key = QString("MZXW6YTBOI======").toLatin1();
secret = QTotp::base32_decode(key);
secret = Base32::base32_decode(key);
QCOMPARE(QString::fromLatin1(secret), QString("foobar"));
}