feat: validate credentials, persist them, and switch without rebooting
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "captive_portal.h"
|
||||
|
||||
int main(void) {
|
||||
const uint8_t query[] = {0x12U, 0x34U, 0x01U, 0x00U, 0x00U, 0x01U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 3U, 'w', 'w', 'w', 7U, 'e', 'x', 'a', 'm', 'p', 'l', 'e', 3U, 'c', 'o', 'm', 0U, 0U, 1U, 0U, 1U};
|
||||
uint8_t response[80] = {0}; size_t response_length = 0U; const uint8_t address[] = {192U, 168U, 4U, 1U};
|
||||
assert(captive_portal_is_probe_path("/generate_204")); assert(captive_portal_is_probe_path("/hotspot-detect.html")); assert(!captive_portal_is_probe_path("/app.js"));
|
||||
assert(captive_portal_dns_response(query, sizeof(query), address, response, sizeof(response), &response_length));
|
||||
assert(response_length == sizeof(query) + 16U && response[0] == 0x12U && response[1] == 0x34U && response[2] == 0x81U && response[7] == 1U);
|
||||
assert(memcmp(response + response_length - 4U, address, sizeof(address)) == 0);
|
||||
assert(!captive_portal_dns_response(query, 12U, address, response, sizeof(response), &response_length));
|
||||
puts("captive portal tests passed"); return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user