tests: support env-backed smoke passwords
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
#include <cstdlib>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -381,13 +382,28 @@ int main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Expect(argc == 6, "usage: metin_login_smoke <host> <auth_port> <channel_port> <login> <password>");
|
Expect(argc == 6,
|
||||||
|
"usage: metin_login_smoke <host> <auth_port> <channel_port> <login> <password>\n"
|
||||||
|
" or: metin_login_smoke <host> <auth_port> <channel_port> <login> --password-env=ENV_NAME");
|
||||||
|
|
||||||
const std::string host = argv[1];
|
const std::string host = argv[1];
|
||||||
const uint16_t auth_port = static_cast<uint16_t>(std::stoi(argv[2]));
|
const uint16_t auth_port = static_cast<uint16_t>(std::stoi(argv[2]));
|
||||||
const uint16_t channel_port = static_cast<uint16_t>(std::stoi(argv[3]));
|
const uint16_t channel_port = static_cast<uint16_t>(std::stoi(argv[3]));
|
||||||
const std::string login = argv[4];
|
const std::string login = argv[4];
|
||||||
const std::string password = argv[5];
|
std::string password;
|
||||||
|
|
||||||
|
const std::string password_arg = argv[5];
|
||||||
|
const std::string prefix = "--password-env=";
|
||||||
|
if (password_arg.rfind(prefix, 0) == 0)
|
||||||
|
{
|
||||||
|
const char* value = std::getenv(password_arg.substr(prefix.size()).c_str());
|
||||||
|
Expect(value && *value, "password environment variable is empty");
|
||||||
|
password = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
password = password_arg;
|
||||||
|
}
|
||||||
|
|
||||||
Expect(login.size() <= LOGIN_MAX_LEN_LOCAL, "login too long");
|
Expect(login.size() <= LOGIN_MAX_LEN_LOCAL, "login too long");
|
||||||
Expect(password.size() <= PASSWD_MAX_LEN_LOCAL, "password too long");
|
Expect(password.size() <= PASSWD_MAX_LEN_LOCAL, "password too long");
|
||||||
|
|||||||
Reference in New Issue
Block a user