Add uname, /uname and scp (key or masked password) in the Shell
CI / build (pull_request) Failing after 1m59s
Site / build (pull_request) Successful in 9s

- uname in the console and /uname in IRC: the firmware, its version and the chip
- scp: one file between the card and a trusted server, over SSH, with the
  device's key or a password asked (masked) in the Shell
- shared libssh helpers in src/platform/libssh_util
- README, user guide, command reference and a how-to updated

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0162FokPdvY2KsS4NBfwyWPk
This commit is contained in:
2026-10-09 19:01:36 +02:00
co-authored by Claude Sonnet 5.5
parent e707a5f2d4
commit 18285c3212
25 changed files with 730 additions and 34 deletions
@@ -330,6 +330,18 @@ void test_action_and_ctcp_version() {
TEST_ASSERT_TRUE(f.sent(std::string("NOTICE alice :\x01VERSION roro9stack ") + versionString() + "\x01"));
}
void test_uname_shows_the_firmware_here_and_sends_nothing() {
Fixture f;
f.registerNow();
f.recv(":roro!u@h JOIN #roro");
f.take();
f.session->input(f.buffer("#roro"), "/uname", 0);
const auto& line = f.session->buffer(f.buffer("#roro")).lines.back();
TEST_ASSERT_EQUAL(static_cast<int>(IrcLine::Kind::Info), static_cast<int>(line.kind));
TEST_ASSERT_EQUAL_STRING(unameString().c_str(), line.text.c_str());
TEST_ASSERT_EQUAL(0, f.take().send.size());
}
void test_topic_is_kept() {
Fixture f;
f.registerNow();
@@ -492,6 +504,7 @@ int main() {
RUN_TEST(test_private_message_opens_a_query_buffer_and_notifies);
RUN_TEST(test_no_notification_while_viewing_that_buffer);
RUN_TEST(test_action_and_ctcp_version);
RUN_TEST(test_uname_shows_the_firmware_here_and_sends_nothing);
RUN_TEST(test_topic_is_kept);
RUN_TEST(test_input_message_and_commands);
RUN_TEST(test_j_is_short_for_join);
+66
View File
@@ -0,0 +1,66 @@
#include <unity.h>
#include "scp_args.h"
using roro::term::ScpArgs;
using roro::term::parseScp;
void setUp() {}
void tearDown() {}
void test_upload() {
ScpArgs a;
TEST_ASSERT_EQUAL_STRING("", parseScp("/notes/a.txt bob@nas.lan:docs/a.txt", a).c_str());
TEST_ASSERT_TRUE(a.upload);
TEST_ASSERT_EQUAL_STRING("bob", a.target.user.c_str());
TEST_ASSERT_EQUAL_STRING("nas.lan", a.target.host.c_str());
TEST_ASSERT_EQUAL(22, a.target.port);
TEST_ASSERT_EQUAL_STRING("/notes/a.txt", a.local.c_str());
TEST_ASSERT_EQUAL_STRING("docs/a.txt", a.remote.c_str());
}
void test_download_and_port() {
ScpArgs a;
TEST_ASSERT_EQUAL_STRING("", parseScp("-P 2222 bob@10.9.0.1:/var/log/syslog /logs/syslog", a).c_str());
TEST_ASSERT_FALSE(a.upload);
TEST_ASSERT_EQUAL(2222, a.target.port);
TEST_ASSERT_EQUAL_STRING("/var/log/syslog", a.remote.c_str());
TEST_ASSERT_EQUAL_STRING("/logs/syslog", a.local.c_str());
}
void test_download_into_a_folder_takes_the_remote_name() {
ScpArgs a;
TEST_ASSERT_EQUAL_STRING("", parseScp("bob@h:/etc/motd /notes/", a).c_str());
TEST_ASSERT_EQUAL_STRING("/notes/motd", a.local.c_str());
}
void test_replace_flag() {
ScpArgs a;
TEST_ASSERT_EQUAL_STRING("", parseScp("-f -P 22 bob@h:x /a", a).c_str());
TEST_ASSERT_TRUE(a.replace);
TEST_ASSERT_EQUAL_STRING("", parseScp("bob@h:x /a", a).c_str());
TEST_ASSERT_FALSE(a.replace);
TEST_ASSERT_TRUE(parseScp("-r bob@h:x /a", a).size() > 0);
}
void test_refusals() {
ScpArgs a;
TEST_ASSERT_TRUE(parseScp("", a).size() > 0);
TEST_ASSERT_TRUE(parseScp("/a.txt /b.txt", a).size() > 0); // neither is a server
TEST_ASSERT_TRUE(parseScp("a@h:x b@h:y", a).size() > 0); // both are
TEST_ASSERT_TRUE(parseScp("a.txt bob@h:x", a).size() > 0); // not a card path
TEST_ASSERT_TRUE(parseScp("/a.txt bob@h:", a).size() > 0); // no remote path
TEST_ASSERT_TRUE(parseScp("/notes/ bob@h:x", a).size() > 0); // a folder
TEST_ASSERT_TRUE(parseScp("-P 0 /a bob@h:x", a).size() > 0);
TEST_ASSERT_TRUE(parseScp("/a bob@bad_host:x", a).size() > 0);
}
int main() {
UNITY_BEGIN();
RUN_TEST(test_upload);
RUN_TEST(test_download_and_port);
RUN_TEST(test_download_into_a_folder_takes_the_remote_name);
RUN_TEST(test_replace_flag);
RUN_TEST(test_refusals);
return UNITY_END();
}
+7
View File
@@ -14,9 +14,16 @@ void test_product_name() {
TEST_ASSERT_EQUAL_STRING("roro9stack", roro::kProductName);
}
void test_uname_has_name_version_and_architecture() {
std::string expected = std::string("roro9stack ") + roro::versionString() + " " + roro::architectureString();
TEST_ASSERT_EQUAL_STRING(expected.c_str(), roro::unameString().c_str());
TEST_ASSERT_TRUE(std::strlen(roro::architectureString()) > 0);
}
int main() {
UNITY_BEGIN();
RUN_TEST(test_version_is_never_empty);
RUN_TEST(test_product_name);
RUN_TEST(test_uname_has_name_version_and_architecture);
return UNITY_END();
}