Add company and email into serial key #4715

This commit is contained in:
Jerry (Xinyu Hou) 2015-11-12 10:08:35 -08:00
parent 9eec299278
commit 55df81b1a6
3 changed files with 10 additions and 5 deletions

View File

@ -22,6 +22,8 @@
struct SubscriptionKey { struct SubscriptionKey {
String m_name; String m_name;
String m_type; String m_type;
String m_email;
String m_company;
int m_userLimit; int m_userLimit;
int m_warnTime; int m_warnTime;
int m_expireTime; int m_expireTime;

View File

@ -140,14 +140,16 @@ SubscriptionManager::parsePlainSerial(const String& plainText, SubscriptionKey&
pos += 1; pos += 1;
} }
// e.g.: {v1;trial;Bob;1;1398297600;1398384000} // e.g.: {v1;trial;Bob;1;email;company name;1398297600;1398384000}
if ((parts.size() == 6) if ((parts.size() == 8)
&& (parts.at(0).find("v1") != String::npos)) { && (parts.at(0).find("v1") != String::npos)) {
key.m_type = parts.at(1); key.m_type = parts.at(1);
key.m_name = parts.at(2); key.m_name = parts.at(2);
sscanf(parts.at(3).c_str(), "%d", &key.m_userLimit); sscanf(parts.at(3).c_str(), "%d", &key.m_userLimit);
sscanf(parts.at(4).c_str(), "%d", &key.m_warnTime); key.m_email = parts.at(4);
sscanf(parts.at(5).c_str(), "%d", &key.m_expireTime); key.m_company = parts.at(5);
sscanf(parts.at(6).c_str(), "%d", &key.m_warnTime);
sscanf(parts.at(7).c_str(), "%d", &key.m_expireTime);
// TODO: use Arch time // TODO: use Arch time
if (time(0) > key.m_expireTime && if (time(0) > key.m_expireTime &&

View File

@ -37,13 +37,14 @@ public:
private: private:
FRIEND_TEST(SubscriptionTests, decode_invalidLength_throwException); FRIEND_TEST(SubscriptionTests, decode_invalidLength_throwException);
FRIEND_TEST(SubscriptionTests, decode_unrecognizedDigit_throwException);
FRIEND_TEST(SubscriptionTests, decode_invalidSerial_outputPlainText); FRIEND_TEST(SubscriptionTests, decode_invalidSerial_outputPlainText);
FRIEND_TEST(SubscriptionTests, decode_unrecognizedDigit_throwException);
FRIEND_TEST(SubscriptionTests, parsePlainSerial_noParity_throwException); FRIEND_TEST(SubscriptionTests, parsePlainSerial_noParity_throwException);
FRIEND_TEST(SubscriptionTests, parsePlainSerial_invalidSerial_throwException); FRIEND_TEST(SubscriptionTests, parsePlainSerial_invalidSerial_throwException);
FRIEND_TEST(SubscriptionTests, parsePlainSerial_validSerial_validSubscriptionKey); FRIEND_TEST(SubscriptionTests, parsePlainSerial_validSerial_validSubscriptionKey);
FRIEND_TEST(SubscriptionTests, parsePlainSerial_expiredTrialSerial_throwException); FRIEND_TEST(SubscriptionTests, parsePlainSerial_expiredTrialSerial_throwException);
FRIEND_TEST(SubscriptionTests, parsePlainSerial_expiredBasicSerial_validSubscriptionKey); FRIEND_TEST(SubscriptionTests, parsePlainSerial_expiredBasicSerial_validSubscriptionKey);
FRIEND_TEST(SubscriptionTests, parsePlainSerial_validSerialWithoutCompany_validSubscriptionKey);
private: private:
String decode(const String& input); String decode(const String& input);