Security review fixes: keep pending-capture ids, ship uninstall.php (+verify step), webhook guard, IPv6 /64 + global order throttle, token-safe redirects, honest refund wording, request-id and overlay-token hardening
Test and Release / test (push) Successful in 1m23s
Test and Release / release (push) Successful in 5s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
shadowdaoandClaude Sonnet 5.5 committed 2026-11-15 14:07:44 -08:00
1 parent 68bd917660
commit 473fe192cd
28 files changed
+747 -34

No files matched your search

+61
View File
@@ -0,0 +1,61 @@
<?php
declare( strict_types=1 );
namespace {
if ( ! function_exists( 'get_option' ) ) {
function get_option( $k, $d = false ) { return array_key_exists( $k, $GLOBALS['sg_test_opts'] ) ? $GLOBALS['sg_test_opts'][ $k ] : $d; }
}
if ( ! function_exists( 'update_option' ) ) {
function update_option( $k, $v, $a = null ) { $GLOBALS['sg_test_opts'][ $k ] = $v; $GLOBALS['sg_test_writes'] = ( $GLOBALS['sg_test_writes'] ?? 0 ) + 1; return true; }
}
if ( ! function_exists( 'current_user_can' ) ) {
function current_user_can( $cap ) { return (bool) ( $GLOBALS['sg_test_can'] ?? false ); }
}
}
namespace StreamGoals\Tests\Unit {
use PHPUnit\Framework\TestCase;
use StreamGoals\Core\Settings;
use StreamGoals\Rest\OverlayController;
/** L5: the overlay token is never created by an unauthenticated request. */
final class OverlayTokenTest extends TestCase {
protected function setUp(): void {
$GLOBALS['sg_test_opts'] = array();
$GLOBALS['sg_test_writes'] = 0;
$GLOBALS['sg_test_can'] = false;
}
public function test_public_verify_with_no_token_is_false_and_writes_nothing(): void {
$this->assertFalse( OverlayController::verify_token( 'anything' ) );
$this->assertFalse( OverlayController::verify_token( '' ) );
$this->assertSame( 0, $GLOBALS['sg_test_writes'], 'unauthenticated request must not write' );
$this->assertSame( '', OverlayController::current_token() );
}
public function test_ensure_token_refuses_without_capability(): void {
$this->assertSame( '', OverlayController::ensure_token() );
$this->assertSame( 0, $GLOBALS['sg_test_writes'] );
}
public function test_admin_generates_once_and_public_compare_then_works(): void {
$GLOBALS['sg_test_can'] = true;
$t = OverlayController::ensure_token();
$this->assertSame( 32, strlen( $t ) );
$this->assertSame( $t, OverlayController::ensure_token(), 'stable' );
$this->assertSame( 1, $GLOBALS['sg_test_writes'] );
$GLOBALS['sg_test_can'] = false;
$this->assertTrue( OverlayController::verify_token( $t ) );
$this->assertFalse( OverlayController::verify_token( str_repeat( 'a', 32 ) ) );
}
public function test_activation_helper_generates_when_missing_and_keeps_existing(): void {
$t = Settings::ensure_overlay_token();
$this->assertSame( 32, strlen( $t ) );
$this->assertSame( $t, Settings::ensure_overlay_token() );
$this->assertSame( 1, $GLOBALS['sg_test_writes'] );
}
}
}