Add admin firmware upload support
Implement authenticated HTTPS OTA uploads with bounded streaming, image validation, reboot coordination, and lifecycle exclusion. Add the admin UI, regression tests, and Phase 10 acceptance documentation.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <sys/socket.h>
|
||||
#include "admin_ssh_console.h"
|
||||
#include "web_admin_tickets.h"
|
||||
#include "web_firmware_update.h"
|
||||
#include "esp_timer.h"
|
||||
#include "esp_heap_caps.h"
|
||||
#include "freertos/task.h"
|
||||
@@ -14,7 +15,13 @@ static void (*timer_poll)(void *), (*pending_poll)(void *);
|
||||
static void *pending_argument;
|
||||
static httpd_req_t connected;
|
||||
static unsigned admin_closes;
|
||||
/* These endpoint tests never dispatch lifecycle commands. */
|
||||
static bool reboot_reservation_expected;
|
||||
esp_err_t web_firmware_update_reserve_reboot(void) {
|
||||
assert(reboot_reservation_expected);
|
||||
reboot_reservation_expected = false;
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
/* A rejected reboot reservation must never reach reset or other lifecycle effects. */
|
||||
void esp_restart(void) { assert(false); }
|
||||
esp_err_t web_server_stop(void) { assert(false); return ESP_FAIL; }
|
||||
esp_err_t web_server_start(void) { assert(false); return ESP_FAIL; }
|
||||
@@ -131,6 +138,11 @@ static void admin_tests(void) {
|
||||
assert(web_admin_transport_upgrade_handler(&req) == ESP_OK && upgrades == ++before);
|
||||
connected = req; assert(console_active && admin_owner->is_current(&admin_token, &administrator));
|
||||
if (mode == 0) {
|
||||
reboot_reservation_expected = true;
|
||||
assert(admin_owner->perform(&admin_token, ADMIN_SSH_DEFER_REBOOT, 0) == ESP_ERR_INVALID_STATE);
|
||||
assert(!reboot_reservation_expected && console_active && !admin_closes);
|
||||
assert(admin_owner->is_current(&admin_token, &administrator));
|
||||
puts("PASS: live admin deferred reboot propagates firmware reservation refusal without reset or session closure");
|
||||
admin_request(&admin, "/api/logout", true, true, true); expect("204 No Content");
|
||||
assert(!console_active); present(&other);
|
||||
} else if (mode == 1) stale_user = administrator.user_id;
|
||||
|
||||
Reference in New Issue
Block a user