mirror of
https://github.com/debauchee/barrier.git
synced 2024-12-25 12:06:26 +03:00
#5657 Use SerialKey class in ServerArgs
This commit is contained in:
parent
88c59b4ca6
commit
99dbdc5eb3
@ -455,13 +455,9 @@ Server::switchScreen(BaseClientProxy* dst,
|
||||
assert(dst != NULL);
|
||||
|
||||
// if trial is expired, exit the process
|
||||
if (!m_args.m_serial.empty()) {
|
||||
SerialKey serial(m_args.m_serial);
|
||||
if (!serial.isValid(std::time(0))) {
|
||||
if (!m_args.m_serial.isExpired(std::time(0))) {
|
||||
LOG((CLOG_ERR "trial is expired, aborting server"));
|
||||
exit(kExitSuccess);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
@ -48,9 +48,6 @@ private:
|
||||
|
||||
#ifdef TEST_ENV
|
||||
private:
|
||||
FRIEND_TEST(SerialKeyTests, decode_empty_returnEmptyString);
|
||||
FRIEND_TEST(SerialKeyTests, decode_invalidDigit_returnEmptyString);
|
||||
FRIEND_TEST(SerialKeyTests, decode_validSerial_returnPlainText);
|
||||
FRIEND_TEST(SerialKeyTests, parse_noParty_invalid);
|
||||
FRIEND_TEST(SerialKeyTests, parse_invalidPartsLenghth_invalid);
|
||||
FRIEND_TEST(SerialKeyTests, parse_validV1Serial_valid);
|
||||
|
@ -71,7 +71,7 @@ ArgParser::parseServerArgs(ServerArgs& args, int argc, const char* const* argv)
|
||||
DpiHelper::s_primaryHeightCenter = synergy::string::stringToSizeType(argv[++i]);
|
||||
}
|
||||
else if (isArg(i, argc, argv, "", "--serial-key", 1)) {
|
||||
args.m_serial = argv[++i];
|
||||
args.m_serial = SerialKey(argv[++i]);
|
||||
}
|
||||
else {
|
||||
LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_pname, argv[i], args.m_pname));
|
||||
|
@ -18,6 +18,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "synergy/ArgsBase.h"
|
||||
#include "shared/SerialKey.h"
|
||||
|
||||
class NetworkAddress;
|
||||
class Config;
|
||||
@ -28,6 +29,6 @@ public:
|
||||
|
||||
public:
|
||||
String m_configFile;
|
||||
String m_serial;
|
||||
SerialKey m_serial;
|
||||
Config* m_config;
|
||||
};
|
||||
|
@ -64,17 +64,3 @@ TEST(ServerArgsParsingTests, parseServerArgs_configArg_setConfigFile)
|
||||
|
||||
EXPECT_EQ("mock_configFile", serverArgs.m_configFile);
|
||||
}
|
||||
|
||||
TEST(ServerArgsParsingTests, parseServerArgs_serialArg_setSerial)
|
||||
{
|
||||
NiceMock<MockArgParser> argParser;
|
||||
ON_CALL(argParser, parseGenericArgs(_, _, _)).WillByDefault(Invoke(server_stubParseGenericArgs));
|
||||
ON_CALL(argParser, checkUnexpectedArgs()).WillByDefault(Invoke(server_stubCheckUnexpectedArgs));
|
||||
ServerArgs serverArgs;
|
||||
const int argc = 3;
|
||||
const char* kSerialCmd[argc] = { "stub", "--serial-key", "mock_serial" };
|
||||
|
||||
argParser.parseServerArgs(serverArgs, argc, kSerialCmd);
|
||||
|
||||
EXPECT_EQ("mock_serial", serverArgs.m_serial);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user