9, 'is_admin' => false, 'is_super_admin' => false, 'can_manage' => true, 'session_id' => str_repeat('a', 64)]; $body = '{"session_id":"example"}'; $path = '/api/internal/cloud/session-introspection?a=1%2F2'; $headers = CloudEngineClient::headers('POST', $path, $body, $actor, 1800000000, 'PythonUrlSafeNonce_ab-CD_123456789'); $named = ['timestamp' => $headers['X-Cloud-Timestamp'], 'nonce' => $headers['X-Cloud-Nonce'], 'actor' => $headers['X-Cloud-Actor'], 'signature' => $headers['X-Cloud-Signature']]; $assert(CloudInternalController::validSignature('POST', $path, $body, $named, str_repeat('k', 32), 1800000000), 'Signed request rejected.'); foreach ([['POST', $path . '0', $body, 1800000000], ['GET', $path, $body, 1800000000], ['POST', $path, $body . ' ', 1800000000], ['POST', $path, $body, 1800000061]] as [$method, $target, $raw, $now]) { $assert(!CloudInternalController::validSignature($method, $target, $raw, $named, str_repeat('k', 32), $now), 'Tampered or stale signature accepted.'); } $digest = hash('sha256', $body); $assert(CloudEngineClient::canonicalDigest('POST', $path, $digest, '1800000000', $named['nonce'], $named['actor']) === CloudEngineClient::canonical('POST', $path, $body, '1800000000', $named['nonce'], $named['actor']), 'Upload digest contract differs.'); $assert(CloudWorkerService::disposition(['status' => 'failed'], true) === 'uncertain', 'Unknown creation failure must not refund.'); $assert(CloudWorkerService::disposition(['status' => 'failed', 'safe_to_refund' => false], true) === 'uncertain', 'Explicitly unsafe creation failure must not refund.'); $assert(CloudWorkerService::disposition(['status' => 'failed', 'safe_to_refund' => true], true) === 'failed', 'Confirmed absent creation must refund.'); foreach (['shortA1!', 'longwithoutupper1!', 'LongWithoutSymbol123', "StrongPassword!1\n", str_repeat('a', 254) . 'A1!'] as $bad) { try { CloudInput::password($bad); throw new RuntimeException('Weak guest password accepted.'); } catch (CloudError $expected) {} } $assert(strlen(CloudInput::password(null)) >= 12 && strlen(CloudInput::password('Aa1!' . str_repeat('x', 252))) === 256, 'Guest password bounds wrong.'); $safe = CloudInput::safeResult(['uuid' => 'test', 'generated_password' => 'never-save', 'nested' => ['private_key' => 'secret', 'name' => 'safe']]); $assert($safe === ['uuid' => 'test', 'nested' => ['name' => 'safe']], 'Secret entered durable job output.'); echo "Cloud money, password, HMAC and ambiguity checks passed.\n"; }