Public Access
S1 #7 steps 1-2: IPv4 checks, the IP setting per Saved Network, DNS and NTP settings
The plan and decisions Q105 to Q116 (docs/milestones/S1.md). lib/net: strict IPv4 parsing, prefix and mask, and the checks a Fixed setting must pass, each refusal with its reason. A Saved Network is Automatic or Fixed (address/prefix and an optional gateway), kept with it in flash. Settings: two DNS servers (9.9.9.9, 1.1.1.1), "Always use my DNS", two NTP servers (pool.ntp.org, time.cloudflare.com). Host-tested: 383 tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
@@ -154,6 +154,37 @@ void test_storage_keys_fit_nvs_limit() {
|
||||
TEST_ASSERT_TRUE(std::strlen(Settings::key(static_cast<Setting>(i))) <= 15);
|
||||
}
|
||||
|
||||
// S1, Q108 to Q110: DNS and NTP servers, with public defaults.
|
||||
void test_dns_and_ntp_defaults() {
|
||||
MemoryStore store;
|
||||
EventBus bus;
|
||||
Settings s(store, bus);
|
||||
s.load();
|
||||
TEST_ASSERT_EQUAL_STRING("9.9.9.9", s.getString(Setting::Dns1).c_str());
|
||||
TEST_ASSERT_EQUAL_STRING("1.1.1.1", s.getString(Setting::Dns2).c_str());
|
||||
TEST_ASSERT_FALSE(s.getBool(Setting::DnsAlways));
|
||||
TEST_ASSERT_EQUAL_STRING("pool.ntp.org", s.getString(Setting::Ntp1).c_str());
|
||||
TEST_ASSERT_EQUAL_STRING("time.cloudflare.com", s.getString(Setting::Ntp2).c_str());
|
||||
}
|
||||
|
||||
void test_dns_and_ntp_are_checked() {
|
||||
MemoryStore store;
|
||||
EventBus bus;
|
||||
Settings s(store, bus);
|
||||
s.load();
|
||||
TEST_ASSERT_TRUE(s.setString(Setting::Dns1, "10.39.39.1"));
|
||||
TEST_ASSERT_FALSE(s.setString(Setting::Dns1, "dns.example")); // an address, not a name
|
||||
TEST_ASSERT_FALSE(s.setString(Setting::Dns1, "")); // the first one is required
|
||||
TEST_ASSERT_EQUAL_STRING("10.39.39.1", s.getString(Setting::Dns1).c_str());
|
||||
TEST_ASSERT_TRUE(s.setString(Setting::Dns2, "")); // the second is optional
|
||||
TEST_ASSERT_FALSE(s.setString(Setting::Dns2, "1.1.1"));
|
||||
TEST_ASSERT_TRUE(s.setString(Setting::Ntp1, "10.39.39.1"));
|
||||
TEST_ASSERT_TRUE(s.setString(Setting::Ntp1, "0.be.pool.ntp.org"));
|
||||
TEST_ASSERT_FALSE(s.setString(Setting::Ntp1, "time server"));
|
||||
TEST_ASSERT_FALSE(s.setString(Setting::Ntp1, ""));
|
||||
TEST_ASSERT_TRUE(s.setString(Setting::Ntp2, ""));
|
||||
}
|
||||
|
||||
int main() {
|
||||
UNITY_BEGIN();
|
||||
RUN_TEST(test_defaults_when_store_is_empty);
|
||||
@@ -168,5 +199,7 @@ int main() {
|
||||
RUN_TEST(test_change_publishes_setting_changed_once);
|
||||
RUN_TEST(test_transmit_requires_confirmed_region);
|
||||
RUN_TEST(test_storage_keys_fit_nvs_limit);
|
||||
RUN_TEST(test_dns_and_ntp_defaults);
|
||||
RUN_TEST(test_dns_and_ntp_are_checked);
|
||||
return UNITY_END();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user