mirror of
https://github.com/badaix/snapcast.git
synced 2025-06-23 04:57:05 +02:00
Fixes
This commit is contained in:
parent
81f849bea9
commit
c5ea25a5ea
5 changed files with 17 additions and 16 deletions
|
@ -55,6 +55,7 @@ public:
|
|||
/// Return value
|
||||
std::string result;
|
||||
|
||||
/// @return description as json
|
||||
Json toJson()
|
||||
{
|
||||
Json jres;
|
||||
|
|
|
@ -76,9 +76,11 @@ struct ServerSettings
|
|||
/// c'tor
|
||||
Authorization() = default;
|
||||
|
||||
/// c'tor
|
||||
Authorization(const std::vector<std::string>& conf_roles, const std::vector<std::string>& conf_users)
|
||||
void init(const std::vector<std::string>& conf_roles, const std::vector<std::string>& conf_users)
|
||||
{
|
||||
roles.clear();
|
||||
users.clear();
|
||||
|
||||
for (const auto& role : conf_roles)
|
||||
roles.emplace_back(std::make_shared<ServerSettings::Authorization::Role>(role));
|
||||
|
||||
|
|
|
@ -331,7 +331,7 @@ int main(int argc, char* argv[])
|
|||
for (size_t n = 0; n < users_value->count(); ++n)
|
||||
users.push_back(users_value->value(n));
|
||||
|
||||
settings.auth = ServerSettings::Authorization(roles, users);
|
||||
settings.auth.init(roles, users);
|
||||
|
||||
|
||||
for (const auto& role : settings.auth.roles)
|
||||
|
|
|
@ -64,14 +64,14 @@ std::string ProcessStream::findExe(const std::string& filename) const
|
|||
return which;
|
||||
|
||||
/// check in the same path as this binary
|
||||
char buff[PATH_MAX];
|
||||
char szTmp[32];
|
||||
sprintf(szTmp, "/proc/%d/exe", getpid());
|
||||
ssize_t len = readlink(szTmp, buff, sizeof(buff) - 1);
|
||||
std::array<char, PATH_MAX> buff;
|
||||
std::array<char, 32> szTmp;
|
||||
sprintf(szTmp.data(), "/proc/%d/exe", getpid());
|
||||
ssize_t len = readlink(szTmp.data(), buff.data(), buff.size() - 1);
|
||||
if (len != -1)
|
||||
{
|
||||
buff[len] = '\0';
|
||||
return string(buff) + "/" + exe;
|
||||
return string(buff.data()) + "/" + exe;
|
||||
}
|
||||
|
||||
return "";
|
||||
|
|
|
@ -724,9 +724,10 @@ TEST_CASE("WildcardMatch")
|
|||
|
||||
TEST_CASE("Auth")
|
||||
{
|
||||
ServerSettings::Authorization auth_settings;
|
||||
auth_settings.enabled = true;
|
||||
{
|
||||
ServerSettings::Authorization auth_settings({"admin:*"}, {"badaix:secret:admin"});
|
||||
auth_settings.enabled = true;
|
||||
auth_settings.init({"admin:*"}, {"badaix:secret:admin"});
|
||||
REQUIRE(auth_settings.users.size() == 1);
|
||||
REQUIRE(auth_settings.roles.size() == 1);
|
||||
REQUIRE(auth_settings.users.front().role->role == "admin");
|
||||
|
@ -741,8 +742,7 @@ TEST_CASE("Auth")
|
|||
}
|
||||
|
||||
{
|
||||
ServerSettings::Authorization auth_settings({"admin:"}, {"badaix:secret:admin"});
|
||||
auth_settings.enabled = true;
|
||||
auth_settings.init({"admin:"}, {"badaix:secret:admin"});
|
||||
REQUIRE(auth_settings.users.size() == 1);
|
||||
REQUIRE(auth_settings.roles.size() == 1);
|
||||
REQUIRE(auth_settings.users.front().role->role == "admin");
|
||||
|
@ -756,8 +756,7 @@ TEST_CASE("Auth")
|
|||
}
|
||||
|
||||
{
|
||||
ServerSettings::Authorization auth_settings({}, {"badaix:secret:"});
|
||||
auth_settings.enabled = true;
|
||||
auth_settings.init({}, {"badaix:secret:"});
|
||||
REQUIRE(auth_settings.users.size() == 1);
|
||||
REQUIRE(auth_settings.roles.empty());
|
||||
REQUIRE(auth_settings.users.front().role->permissions.empty());
|
||||
|
@ -770,8 +769,7 @@ TEST_CASE("Auth")
|
|||
}
|
||||
|
||||
{
|
||||
ServerSettings::Authorization auth_settings({"admin:xxx,stream"}, {"badaix:secret:admin"});
|
||||
auth_settings.enabled = true;
|
||||
auth_settings.init({"admin:xxx,stream"}, {"badaix:secret:admin"});
|
||||
REQUIRE(auth_settings.users.size() == 1);
|
||||
REQUIRE(auth_settings.roles.size() == 1);
|
||||
REQUIRE(auth_settings.users.front().role->permissions.size() == 2);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue