Merge branch 'master' into SYNERGY-509-sonarcloud-critical-bugs-in-synergy-core
This commit is contained in:
commit
fa17f631c1
7 changed files with 56 additions and 10 deletions
|
|
@ -350,7 +350,7 @@ endif()
|
||||||
#
|
#
|
||||||
# Google Test
|
# Google Test
|
||||||
#
|
#
|
||||||
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/ext/googletest/CMakeLists.txt")
|
if(BUILD_TESTS AND NOT EXISTS "${PROJECT_SOURCE_DIR}/ext/googletest/CMakeLists.txt")
|
||||||
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
|
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ Bug fixes:
|
||||||
- #6817 Configure requires dns_sd.h for enterprise version
|
- #6817 Configure requires dns_sd.h for enterprise version
|
||||||
- #6821 Blocker bugs found by sonar
|
- #6821 Blocker bugs found by sonar
|
||||||
- #6826 SonarCloud Critical bugs
|
- #6826 SonarCloud Critical bugs
|
||||||
|
- #6825 The system requires google test even when tests are disabled with BUILD_TESTS=OFF
|
||||||
|
|
||||||
Enhancements:
|
Enhancements:
|
||||||
- #6750 Integrate SonarCloud for static analysis and test coverage
|
- #6750 Integrate SonarCloud for static analysis and test coverage
|
||||||
|
|
@ -22,6 +23,7 @@ Enhancements:
|
||||||
- #6803 Update Synergy icons
|
- #6803 Update Synergy icons
|
||||||
- #6800 Update behaviour when unregistered
|
- #6800 Update behaviour when unregistered
|
||||||
- #6806 Move to Github Action for general PR builds and tests
|
- #6806 Move to Github Action for general PR builds and tests
|
||||||
|
- #6816 Improve license validation
|
||||||
|
|
||||||
v1.12.0-stable
|
v1.12.0-stable
|
||||||
===========
|
===========
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
LicenseManager::LicenseManager(AppConfig* appConfig) :
|
LicenseManager::LicenseManager(AppConfig* appConfig) :
|
||||||
m_AppConfig(appConfig),
|
m_AppConfig(appConfig),
|
||||||
|
|
@ -44,12 +45,9 @@ LicenseManager::setSerialKey(SerialKey serialKey, bool acceptExpired)
|
||||||
swap (serialKey, m_serialKey);
|
swap (serialKey, m_serialKey);
|
||||||
m_AppConfig->setSerialKey(QString::fromStdString
|
m_AppConfig->setSerialKey(QString::fromStdString
|
||||||
(m_serialKey.toString()));
|
(m_serialKey.toString()));
|
||||||
emit serialKeyChanged(m_serialKey);
|
|
||||||
|
|
||||||
emit showLicenseNotice(getLicenseNotice());
|
emit showLicenseNotice(getLicenseNotice());
|
||||||
if (!m_serialKey.isValid()) {
|
validateSerialKey();
|
||||||
emit InvalidLicense();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_serialKey.edition() != serialKey.edition()) {
|
if (m_serialKey.edition() != serialKey.edition()) {
|
||||||
m_AppConfig->setEdition(m_serialKey.edition());
|
m_AppConfig->setEdition(m_serialKey.edition());
|
||||||
|
|
@ -228,3 +226,16 @@ LicenseManager::getTemporaryNotice() const
|
||||||
|
|
||||||
return Notice;
|
return Notice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
LicenseManager::validateSerialKey() const
|
||||||
|
{
|
||||||
|
if (m_serialKey.isValid()) {
|
||||||
|
if (m_serialKey.isTemporary()){
|
||||||
|
QTimer::singleShot(m_serialKey.getSpanLeft(), this, SLOT(validateSerialKey()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
emit InvalidLicense();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,10 @@ private:
|
||||||
AppConfig* m_AppConfig;
|
AppConfig* m_AppConfig;
|
||||||
SerialKey m_serialKey;
|
SerialKey m_serialKey;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void validateSerialKey() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void serialKeyChanged (SerialKey) const;
|
|
||||||
void editionChanged (Edition) const;
|
void editionChanged (Edition) const;
|
||||||
void InvalidLicense () const;
|
void InvalidLicense () const;
|
||||||
void showLicenseNotice(const QString& notice) const;
|
void showLicenseNotice(const QString& notice) const;
|
||||||
|
|
|
||||||
|
|
@ -171,6 +171,20 @@ SerialKey::daysLeft(time_t currentTime) const
|
||||||
return timeLeft / day + daysLeft;
|
return timeLeft / day + daysLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::chrono::milliseconds
|
||||||
|
SerialKey::getSpanLeft(time_t time) const
|
||||||
|
{
|
||||||
|
std::chrono::milliseconds timeLeft{-1};
|
||||||
|
|
||||||
|
if (isTemporary()){
|
||||||
|
auto expire{std::chrono::system_clock::from_time_t(m_expireTime)};
|
||||||
|
auto target{std::chrono::system_clock::from_time_t(time)};
|
||||||
|
timeLeft = std::chrono::duration_cast<std::chrono::milliseconds>(expire - target);
|
||||||
|
}
|
||||||
|
|
||||||
|
return timeLeft;
|
||||||
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
SerialKey::email() const
|
SerialKey::email() const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
#include <chrono>
|
||||||
#include "EditionType.h"
|
#include "EditionType.h"
|
||||||
#include "SerialKeyType.h"
|
#include "SerialKeyType.h"
|
||||||
#include "SerialKeyEdition.h"
|
#include "SerialKeyEdition.h"
|
||||||
|
|
@ -38,10 +39,11 @@ public:
|
||||||
bool isTrial() const;
|
bool isTrial() const;
|
||||||
bool isTemporary() const;
|
bool isTemporary() const;
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
time_t daysLeft(time_t currentTime) const;
|
time_t daysLeft(time_t currentTime) const;
|
||||||
std::string email() const;
|
std::chrono::milliseconds getSpanLeft(time_t time = ::time(0)) const;
|
||||||
Edition edition() const;
|
std::string email() const;
|
||||||
std::string toString() const;
|
Edition edition() const;
|
||||||
|
std::string toString() const;
|
||||||
|
|
||||||
static std::string decode(const std::string& serial);
|
static std::string decode(const std::string& serial);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -226,4 +226,19 @@ TEST(SerialKeyTests, IsValidExpiredKey_false)
|
||||||
EXPECT_EQ(false, serial.isValid());
|
EXPECT_EQ(false, serial.isValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(SerialKeyTests, test_getSpanLeft)
|
||||||
|
{
|
||||||
|
SerialKey key;
|
||||||
|
std::chrono::milliseconds expected{-1};
|
||||||
|
EXPECT_EQ(expected, key.getSpanLeft());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(SerialKeyTests, test_getSpanLeft_subscription)
|
||||||
|
{
|
||||||
|
// {v2;subscription;basic;Bob;1;email;company name;0;86400}
|
||||||
|
SerialKey key("7B76323B737562736372697074696F6E3B62617369633B426F623B313B656D61696C3B636F6D70616E79206E616D653B303B38363430307D");
|
||||||
|
std::chrono::milliseconds expected{1000};
|
||||||
|
EXPECT_EQ(expected, key.getSpanLeft(86399));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue