I think nip42 is FINALLY working.
This commit is contained in:
@@ -407,12 +407,12 @@ test_nip42_authentication() {
|
||||
|
||||
# Test NIP-42 configuration modes
|
||||
test_nip42_configuration() {
|
||||
# Check NIP-42 mode in database using unified config table
|
||||
local nip42_mode=$(sqlite3 "$DB_PATH" "SELECT value FROM config WHERE key = 'require_nip42_auth';" 2>/dev/null || echo "")
|
||||
# Check NIP-42 mode in database using unified config table (updated key name)
|
||||
local nip42_mode=$(sqlite3 "$DB_PATH" "SELECT value FROM config WHERE key = 'nip42_require_auth';" 2>/dev/null || echo "")
|
||||
|
||||
if [[ -n "$nip42_mode" ]]; then
|
||||
case "$nip42_mode" in
|
||||
"true"|"false")
|
||||
"true"|"false"|"optional"|"required"|"disabled")
|
||||
record_test_result "NIP-42 Configuration Check" "VALID" "VALID" "true"
|
||||
;;
|
||||
*)
|
||||
@@ -422,6 +422,16 @@ test_nip42_configuration() {
|
||||
else
|
||||
record_test_result "NIP-42 Configuration Check" "VALID" "DEFAULT" "true"
|
||||
fi
|
||||
|
||||
# Also check that the other NIP-42 config keys exist
|
||||
local timeout=$(sqlite3 "$DB_PATH" "SELECT value FROM config WHERE key = 'nip42_challenge_timeout';" 2>/dev/null || echo "")
|
||||
local tolerance=$(sqlite3 "$DB_PATH" "SELECT value FROM config WHERE key = 'nip42_time_tolerance';" 2>/dev/null || echo "")
|
||||
|
||||
if [[ -n "$timeout" && -n "$tolerance" ]]; then
|
||||
record_test_result "NIP-42 Config Keys Check" "VALID" "VALID" "true"
|
||||
else
|
||||
record_test_result "NIP-42 Config Keys Check" "VALID" "PARTIAL" "true"
|
||||
fi
|
||||
}
|
||||
|
||||
# Test dual authentication capability
|
||||
|
||||
@@ -1 +1 @@
|
||||
NIP-42 authentication test content
|
||||
NIP-42 test content
|
||||
|
||||
@@ -1,17 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Mirror Test Script for BUD-04
|
||||
# Tests the PUT /mirror endpoint with a sample PNG file
|
||||
# Tests the PUT /mirror endpoint with a sample PNG file and NIP-42 authentication
|
||||
|
||||
# Test URL - PNG file with known SHA-256 hash
|
||||
TEST_URL="https://laantungir.github.io/img_repo/24308d48eb498b593e55a87b6300ccffdea8432babc0bb898b1eff21ebbb72de.png"
|
||||
EXPECTED_HASH="24308d48eb498b593e55a87b6300ccffdea8432babc0bb898b1eff21ebbb72de"
|
||||
|
||||
echo "=== BUD-04 Mirror Endpoint Test ==="
|
||||
echo "=== BUD-04 Mirror Endpoint Test with Authentication ==="
|
||||
echo "Target URL: $TEST_URL"
|
||||
echo "Expected Hash: $EXPECTED_HASH"
|
||||
echo ""
|
||||
|
||||
# Get a fresh challenge from the server
|
||||
echo "=== Getting Authentication Challenge ==="
|
||||
challenge=$(curl -s "http://localhost:9001/auth" | jq -r '.challenge')
|
||||
if [ "$challenge" = "null" ] || [ -z "$challenge" ]; then
|
||||
echo "❌ Failed to get challenge from server"
|
||||
exit 1
|
||||
fi
|
||||
echo "Challenge: $challenge"
|
||||
|
||||
# Create NIP-42 auth event (kind 22242) with challenge using hex private key
|
||||
TEST_USER_PRIVKEY="0000000000000000000000000000000000000000000000000000000000000001"
|
||||
expiration=$(date -d "+3600 seconds" +%s)
|
||||
event=$(nak event -k 22242 --tag "relay=ginxsom" --tag "challenge=$challenge" --tag "expiration=$expiration" --sec "$TEST_USER_PRIVKEY")
|
||||
auth_header="Nostr $(echo "$event" | base64 -w 0)"
|
||||
echo "Created NIP-42 auth event"
|
||||
echo ""
|
||||
|
||||
# Create JSON request body
|
||||
JSON_BODY=$(cat <<EOF
|
||||
{
|
||||
@@ -24,10 +41,11 @@ echo "Request Body:"
|
||||
echo "$JSON_BODY"
|
||||
echo ""
|
||||
|
||||
# Make the mirror request
|
||||
echo "=== Making Mirror Request ==="
|
||||
# Make the mirror request with authentication
|
||||
echo "=== Making Authenticated Mirror Request ==="
|
||||
RESPONSE=$(curl -s -w "\nHTTP_CODE:%{http_code}\n" \
|
||||
-X PUT \
|
||||
-H "Authorization: $auth_header" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$JSON_BODY" \
|
||||
http://localhost:9001/mirror)
|
||||
|
||||
Reference in New Issue
Block a user