Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/account/credentials.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "account/credentials.h"

#include "account/baked_endpoints.h"
#include "config/cli_paths.h"

#include <algorithm>
#include <cctype>
Expand Down Expand Up @@ -669,7 +670,9 @@ std::string ProfileDirectory() {
return override_dir;
}
#if defined(_WIN32)
const std::string home = HomeDirectory();
// LOCALAPPDATA is backslash-separated and the suffix is not; fold it the way
// paths::normalize_dir does so `wally account login` prints one style.
const std::string home = paths::normalize_dir(HomeDirectory());
return home.empty() ? std::string() : home + "/RunAnywhere/Wally";
#else
const std::string xdg = Env("XDG_CONFIG_HOME");
Expand Down
22 changes: 22 additions & 0 deletions tests/test_wally_account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,26 @@ TestResult test_credentials_reject_a_document_they_cannot_unlock() {
result.passed = true;
return result;
}

// A real LOCALAPPDATA is backslash-separated while the suffix appended to it is
// not. `wally account login` prints this directory, so the join must not mix them.
TestResult test_profile_directory_uses_one_separator_style() {
TestResult result;
result.test_name = "profile_directory_uses_one_separator_style";
EnvVar profile("WALLY_PROFILE_DIR", nullptr);
EnvVar legacy("RCLI_PROFILE_DIR", nullptr);
EnvVar local("LOCALAPPDATA", "C:\\wally-local");

const std::string directory = wally::account::ProfileDirectory();
if (directory != "C:/wally-local/RunAnywhere/Wally") {
result.expected = "C:/wally-local/RunAnywhere/Wally";
result.actual = directory;
result.details = "the profile directory must not mix separators";
return result;
}
result.passed = true;
return result;
}
#endif

#if !defined(_WIN32)
Expand Down Expand Up @@ -1190,6 +1210,8 @@ int main(int argc, char** argv) {
#else
suite.add("credentials_reject_a_document_they_cannot_unlock",
test_credentials_reject_a_document_they_cannot_unlock);
suite.add("profile_directory_uses_one_separator_style",
test_profile_directory_uses_one_separator_style);
#endif
suite.add("console_client_contract", test_console_client_contract);
suite.add("console_errors_do_not_echo_secrets", test_console_errors_do_not_echo_secrets);
Expand Down
Loading