feat: validate credentials, persist them, and switch without rebooting
This commit is contained in:
+6
-2
@@ -1,7 +1,7 @@
|
||||
CC ?= cc
|
||||
CFLAGS ?= -std=c11 -Wall -Wextra -Werror -I../../include
|
||||
|
||||
all: test_command_queue test_game_domain test_bot_player test_game_lifecycle test_state_presenter test_http_api test_sync_service test_human_game_integration test_bot_game_integration test_robustness test_network_foundation
|
||||
all: test_command_queue test_game_domain test_bot_player test_game_lifecycle test_state_presenter test_http_api test_sync_service test_human_game_integration test_bot_game_integration test_robustness test_network_foundation test_captive_portal
|
||||
|
||||
test_command_queue: test_command_queue.c ../../src/command_queue.c
|
||||
$(CC) $(CFLAGS) $^ -o $@
|
||||
@@ -18,6 +18,7 @@ run: all
|
||||
./test_bot_game_integration
|
||||
./test_robustness
|
||||
./test_network_foundation
|
||||
./test_captive_portal
|
||||
|
||||
test_game_domain: test_game_domain.c ../../src/fleet_generator.c ../../src/game_engine.c
|
||||
$(CC) $(CFLAGS) $^ -o $@
|
||||
@@ -50,5 +51,8 @@ test_robustness: test_robustness.c ../../src/http_api.c ../../src/sync_service.c
|
||||
test_network_foundation: test_network_foundation.c ../../src/network_state.c ../../src/network_credentials.c
|
||||
$(CC) $(CFLAGS) $^ -o $@
|
||||
|
||||
test_captive_portal: test_captive_portal.c ../../src/captive_portal.c
|
||||
$(CC) $(CFLAGS) $^ -o $@
|
||||
|
||||
clean:
|
||||
rm -f test_command_queue test_game_domain test_bot_player test_game_lifecycle test_state_presenter test_http_api test_sync_service test_human_game_integration test_bot_game_integration test_robustness test_network_foundation
|
||||
rm -f test_command_queue test_game_domain test_bot_player test_game_lifecycle test_state_presenter test_http_api test_sync_service test_human_game_integration test_bot_game_integration test_robustness test_network_foundation test_captive_portal
|
||||
|
||||
@@ -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