Remove user feature restrictions
parent
bc5d7ce263
commit
2e66371a1d
@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
class UserFeatureRestrictionService
|
||||
{
|
||||
public const RECHARGE_MESSAGE = '充值服务暂时无法使用,请稍后再试。';
|
||||
public const PURCHASE_MESSAGE = '套餐购买服务暂时无法使用,请稍后再试。';
|
||||
public const INVITE_MESSAGE = '邀请服务暂时无法使用,请稍后再试。';
|
||||
public const TICKET_MESSAGE = '工单服务暂时无法使用,请稍后再试。';
|
||||
|
||||
public static function isRechargeRestricted(User $user)
|
||||
{
|
||||
return (int) $user->restrict_recharge === 1;
|
||||
}
|
||||
|
||||
public static function isBalancePurchaseRestricted(User $user)
|
||||
{
|
||||
return (int) $user->restrict_balance_purchase === 1;
|
||||
}
|
||||
|
||||
public static function isInviteRestricted(User $user)
|
||||
{
|
||||
return (int) $user->restrict_invite === 1;
|
||||
}
|
||||
|
||||
public static function isTicketRestricted(User $user)
|
||||
{
|
||||
return (int) $user->restrict_ticket === 1;
|
||||
}
|
||||
|
||||
public static function isTransactionRecordsRestricted(User $user)
|
||||
{
|
||||
return (int) $user->restrict_transaction_records === 1;
|
||||
}
|
||||
|
||||
public static function hasManualRestrictions(User $user)
|
||||
{
|
||||
return in_array(true, self::status($user), true);
|
||||
}
|
||||
|
||||
public static function status(User $user)
|
||||
{
|
||||
return [
|
||||
'recharge' => self::isRechargeRestricted($user),
|
||||
'balance_purchase' => self::isBalancePurchaseRestricted($user),
|
||||
'invite' => self::isInviteRestricted($user),
|
||||
'ticket' => self::isTicketRestricted($user),
|
||||
'transaction_records' => self::isTransactionRecordsRestricted($user),
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -1,300 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Configurations;
|
||||
use App\Models\EmailVerify;
|
||||
use App\Models\User;
|
||||
|
||||
class UserRestrictionEnforcementService
|
||||
{
|
||||
private const EMAIL_BLACKLIST_KEY = 'email_blacklist';
|
||||
private const TRUSTED_LOGIN_DEVICE_PREFIX = 'trusted_login_device:';
|
||||
|
||||
public static function enforceUsers($users, ?RedisClient $redis = null)
|
||||
{
|
||||
$emails = [];
|
||||
$userIds = [];
|
||||
foreach ($users as $user) {
|
||||
if (!$user instanceof User || (bool) $user->is_admin) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$userId = (int) $user->id;
|
||||
$email = strtolower(trim((string) $user->email));
|
||||
if ($userId > 0) {
|
||||
$userIds[$userId] = $userId;
|
||||
}
|
||||
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
$emails[$email] = $email;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($userIds) && empty($emails)) {
|
||||
return self::emptyResult(false);
|
||||
}
|
||||
|
||||
$result = self::emptyResult(true);
|
||||
try {
|
||||
$result['emails_added'] = self::appendEmailsToBlacklist(array_values($emails));
|
||||
if (!empty($emails)) {
|
||||
EmailVerify::whereIn('email', array_values($emails))->delete();
|
||||
}
|
||||
} catch (\Throwable $exception) {
|
||||
$result['database_error'] = true;
|
||||
error_log('User restriction email blacklist update failed: ' . $exception->getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
if ($redis === null) {
|
||||
$redis = new RedisClient();
|
||||
}
|
||||
$redis->del(self::EMAIL_BLACKLIST_KEY);
|
||||
$result['trusted_devices_cleared'] = self::clearTrustedLoginDevices(array_values($userIds), $redis);
|
||||
} catch (\Throwable $exception) {
|
||||
$result['redis_error'] = true;
|
||||
error_log('User restriction trusted device cleanup failed: ' . $exception->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function releaseUsers($users, ?RedisClient $redis = null)
|
||||
{
|
||||
$emails = [];
|
||||
foreach ($users as $user) {
|
||||
if (!$user instanceof User || (bool) $user->is_admin) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$email = strtolower(trim((string) $user->email));
|
||||
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
$emails[$email] = $email;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($emails)) {
|
||||
return self::emptyResult(false);
|
||||
}
|
||||
|
||||
$result = self::emptyResult(false);
|
||||
try {
|
||||
$result['emails_removed'] = self::deleteEmailsFromBlacklist(array_values($emails));
|
||||
} catch (\Throwable $exception) {
|
||||
$result['database_error'] = true;
|
||||
error_log('User restriction email blacklist release failed: ' . $exception->getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
if ($redis === null) {
|
||||
$redis = new RedisClient();
|
||||
}
|
||||
$redis->del(self::EMAIL_BLACKLIST_KEY);
|
||||
} catch (\Throwable $exception) {
|
||||
$result['redis_error'] = true;
|
||||
error_log('User restriction email blacklist cache cleanup failed: ' . $exception->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function mergeEmailBlacklist($raw, array $emails)
|
||||
{
|
||||
$existing = [];
|
||||
foreach (preg_split('/\r\n|\r|\n|,|;/', (string) $raw) as $line) {
|
||||
$rule = strtolower(trim((string) $line));
|
||||
if (strpos($rule, '#') !== false) {
|
||||
$rule = trim(explode('#', $rule, 2)[0]);
|
||||
}
|
||||
if (filter_var($rule, FILTER_VALIDATE_EMAIL)) {
|
||||
$existing[$rule] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$added = [];
|
||||
foreach ($emails as $email) {
|
||||
$email = strtolower(trim((string) $email));
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL) || isset($existing[$email])) {
|
||||
continue;
|
||||
}
|
||||
$existing[$email] = true;
|
||||
$added[] = $email;
|
||||
}
|
||||
|
||||
if (empty($added)) {
|
||||
return ['value' => (string) $raw, 'added' => []];
|
||||
}
|
||||
|
||||
$value = rtrim((string) $raw);
|
||||
if ($value !== '') {
|
||||
$value .= "\n";
|
||||
}
|
||||
$value .= implode("\n", $added);
|
||||
|
||||
return ['value' => $value, 'added' => $added];
|
||||
}
|
||||
|
||||
public static function removeEmailsFromBlacklist($raw, array $emails)
|
||||
{
|
||||
$targets = [];
|
||||
foreach ($emails as $email) {
|
||||
$email = strtolower(trim((string) $email));
|
||||
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
$targets[$email] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($targets)) {
|
||||
return ['value' => (string) $raw, 'removed' => []];
|
||||
}
|
||||
|
||||
$kept = [];
|
||||
$removed = [];
|
||||
foreach (preg_split('/\r\n|\r|\n|,|;/', (string) $raw) as $entry) {
|
||||
$entry = trim((string) $entry);
|
||||
if ($entry === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$rule = strtolower($entry);
|
||||
if (strpos($rule, '#') !== false) {
|
||||
$rule = trim(explode('#', $rule, 2)[0]);
|
||||
}
|
||||
if (filter_var($rule, FILTER_VALIDATE_EMAIL) && isset($targets[$rule])) {
|
||||
$removed[$rule] = $rule;
|
||||
continue;
|
||||
}
|
||||
|
||||
$kept[] = $entry;
|
||||
}
|
||||
|
||||
if (empty($removed)) {
|
||||
return ['value' => (string) $raw, 'removed' => []];
|
||||
}
|
||||
|
||||
return [
|
||||
'value' => implode("\n", $kept),
|
||||
'removed' => array_values($removed),
|
||||
];
|
||||
}
|
||||
|
||||
private static function appendEmailsToBlacklist(array $emails)
|
||||
{
|
||||
if (empty($emails)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$connection = (new Configurations())->getConnection();
|
||||
return $connection->transaction(function () use ($emails) {
|
||||
$configuration = Configurations::where('name', self::EMAIL_BLACKLIST_KEY)
|
||||
->lockForUpdate()
|
||||
->first();
|
||||
if ($configuration === null) {
|
||||
$configuration = new Configurations();
|
||||
$configuration->name = self::EMAIL_BLACKLIST_KEY;
|
||||
$configuration->value = '';
|
||||
}
|
||||
|
||||
$merged = self::mergeEmailBlacklist((string) $configuration->value, $emails);
|
||||
if (empty($merged['added'])) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$configuration->value = $merged['value'];
|
||||
$configuration->save();
|
||||
|
||||
return count($merged['added']);
|
||||
});
|
||||
}
|
||||
|
||||
private static function deleteEmailsFromBlacklist(array $emails)
|
||||
{
|
||||
if (empty($emails)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$connection = (new Configurations())->getConnection();
|
||||
return $connection->transaction(function () use ($emails) {
|
||||
$configuration = Configurations::where('name', self::EMAIL_BLACKLIST_KEY)
|
||||
->lockForUpdate()
|
||||
->first();
|
||||
if ($configuration === null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$filtered = self::removeEmailsFromBlacklist((string) $configuration->value, $emails);
|
||||
if (empty($filtered['removed'])) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$configuration->value = $filtered['value'];
|
||||
$configuration->save();
|
||||
|
||||
return count($filtered['removed']);
|
||||
});
|
||||
}
|
||||
|
||||
private static function clearTrustedLoginDevices(array $userIds, RedisClient $redis)
|
||||
{
|
||||
if (empty($userIds)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$wanted = array_fill_keys(array_map('intval', $userIds), true);
|
||||
$client = $redis->getClient();
|
||||
$keys = [];
|
||||
try {
|
||||
$cursor = '0';
|
||||
do {
|
||||
$result = $client->executeRaw([
|
||||
'SCAN',
|
||||
$cursor,
|
||||
'MATCH',
|
||||
self::TRUSTED_LOGIN_DEVICE_PREFIX . '*',
|
||||
'COUNT',
|
||||
'500',
|
||||
]);
|
||||
if (!is_array($result) || count($result) < 2) {
|
||||
break;
|
||||
}
|
||||
|
||||
$cursor = (string) $result[0];
|
||||
$batch = is_array($result[1]) ? $result[1] : [];
|
||||
foreach ($batch as $key) {
|
||||
if (preg_match('/^trusted_login_device:(\d+):/', (string) $key, $matches)
|
||||
&& isset($wanted[(int) $matches[1]])) {
|
||||
$keys[(string) $key] = (string) $key;
|
||||
}
|
||||
}
|
||||
} while ($cursor !== '0');
|
||||
} catch (\Throwable $exception) {
|
||||
foreach ($userIds as $userId) {
|
||||
try {
|
||||
foreach ((array) $client->keys(self::TRUSTED_LOGIN_DEVICE_PREFIX . (int) $userId . ':*') as $key) {
|
||||
$keys[(string) $key] = (string) $key;
|
||||
}
|
||||
} catch (\Throwable $innerException) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($keys as $key) {
|
||||
$redis->del($key);
|
||||
}
|
||||
|
||||
return count($keys);
|
||||
}
|
||||
|
||||
private static function emptyResult($enforced)
|
||||
{
|
||||
return [
|
||||
'enforced' => (bool) $enforced,
|
||||
'emails_added' => 0,
|
||||
'emails_removed' => 0,
|
||||
'trusted_devices_cleared' => 0,
|
||||
'database_error' => false,
|
||||
'redis_error' => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
-- Import this file before deploying the user feature restriction code.
|
||||
ALTER TABLE `user`
|
||||
ADD COLUMN IF NOT EXISTS `restrict_recharge` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 AFTER `user_tcp_limit`,
|
||||
ADD COLUMN IF NOT EXISTS `restrict_balance_purchase` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 AFTER `restrict_recharge`,
|
||||
ADD COLUMN IF NOT EXISTS `restrict_subscription` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 AFTER `restrict_balance_purchase`,
|
||||
ADD COLUMN IF NOT EXISTS `restrict_invite` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 AFTER `restrict_subscription`,
|
||||
ADD COLUMN IF NOT EXISTS `restrict_ticket` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 AFTER `restrict_invite`,
|
||||
ADD COLUMN IF NOT EXISTS `restrict_transaction_records` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 AFTER `restrict_ticket`,
|
||||
ADD COLUMN IF NOT EXISTS `restriction_reason` varchar(255) NOT NULL DEFAULT '' AFTER `restrict_transaction_records`,
|
||||
ADD COLUMN IF NOT EXISTS `restriction_updated_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `restriction_reason`,
|
||||
ADD COLUMN IF NOT EXISTS `restriction_operator_id` int(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `restriction_updated_at`;
|
||||
@ -1,2 +0,0 @@
|
||||
ALTER TABLE `user`
|
||||
ADD COLUMN IF NOT EXISTS `restrict_ticket` tinyint(1) UNSIGNED NOT NULL DEFAULT 0;
|
||||
@ -1,2 +0,0 @@
|
||||
ALTER TABLE `user`
|
||||
ADD COLUMN IF NOT EXISTS `restrict_transaction_records` tinyint(1) UNSIGNED NOT NULL DEFAULT 0;
|
||||
@ -1,55 +0,0 @@
|
||||
<?php
|
||||
|
||||
// Pure field-contract fixture: no Eloquent bootstrap or database connection.
|
||||
namespace App\Models {
|
||||
class User
|
||||
{
|
||||
public int $id = 0;
|
||||
public int $is_admin = 0;
|
||||
public int $restrict_recharge = 0;
|
||||
public int $restrict_balance_purchase = 0;
|
||||
public int $restrict_invite = 0;
|
||||
public int $restrict_ticket = 0;
|
||||
public int $restrict_transaction_records = 0;
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
require dirname(__DIR__) . '/app/Services/UserFeatureRestrictionService.php';
|
||||
|
||||
use App\Models\User;
|
||||
use App\Services\UserFeatureRestrictionService;
|
||||
|
||||
$fields = [
|
||||
'restrict_recharge' => 'recharge',
|
||||
'restrict_balance_purchase' => 'balance_purchase',
|
||||
'restrict_invite' => 'invite',
|
||||
'restrict_ticket' => 'ticket',
|
||||
'restrict_transaction_records' => 'transaction_records',
|
||||
];
|
||||
foreach (array_merge([null], array_keys($fields)) as $restrictedField) {
|
||||
$user = new User();
|
||||
$user->id = 42;
|
||||
$user->is_admin = 0;
|
||||
foreach ($fields as $field => $statusKey) {
|
||||
$user->$field = $field === $restrictedField ? 1 : 0;
|
||||
}
|
||||
$status = UserFeatureRestrictionService::status($user);
|
||||
foreach ($fields as $field => $statusKey) {
|
||||
if ($status[$statusKey] !== ($field === $restrictedField)) {
|
||||
fwrite(STDERR, 'Manual restriction affected the wrong feature: ' . $statusKey . PHP_EOL);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
if (UserFeatureRestrictionService::hasManualRestrictions($user) !== ($restrictedField !== null)) {
|
||||
fwrite(STDERR, 'Manual restriction presence check failed.' . PHP_EOL);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
if (method_exists(UserFeatureRestrictionService::class, 'isAutomaticCommerceRestricted')
|
||||
|| method_exists(UserFeatureRestrictionService::class, 'isSubscriptionRestricted')) {
|
||||
fwrite(STDERR, 'Retired membership/subscription restrictions remain.' . PHP_EOL);
|
||||
exit(1);
|
||||
}
|
||||
echo 'Independent manual restrictions passed without membership or proxy fields.' . PHP_EOL;
|
||||
}
|
||||
@ -1,133 +0,0 @@
|
||||
<?php
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
use App\Models\Configurations;
|
||||
use App\Models\EmailVerify;
|
||||
use App\Models\User;
|
||||
use App\Services\Mail;
|
||||
use App\Services\RedisClient;
|
||||
use App\Services\UserRestrictionEnforcementService;
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
$raw = "existing@example.com\n*@blocked.example\ncommented@example.com # legacy";
|
||||
$merged = UserRestrictionEnforcementService::mergeEmailBlacklist($raw, [
|
||||
'NEW@example.com',
|
||||
'existing@example.com',
|
||||
'Commented@example.com',
|
||||
'not-an-email',
|
||||
]);
|
||||
|
||||
$cases = [
|
||||
'only new valid email is appended' => [$merged['added'], ['new@example.com']],
|
||||
'existing rules are preserved' => [strpos($merged['value'], '*@blocked.example') !== false, true],
|
||||
'new email is normalized' => [substr_count($merged['value'], 'new@example.com'), 1],
|
||||
];
|
||||
|
||||
$second = UserRestrictionEnforcementService::mergeEmailBlacklist($merged['value'], [
|
||||
'new@example.com',
|
||||
'EXISTING@example.com',
|
||||
]);
|
||||
$cases['repeated enforcement is idempotent'] = [$second['added'], []];
|
||||
$cases['idempotent merge keeps value unchanged'] = [$second['value'], $merged['value']];
|
||||
|
||||
$removed = UserRestrictionEnforcementService::removeEmailsFromBlacklist($merged['value'], [
|
||||
'EXISTING@example.com',
|
||||
'commented@example.com',
|
||||
]);
|
||||
$cases['exact emails are removed case-insensitively'] = [$removed['removed'], ['existing@example.com', 'commented@example.com']];
|
||||
$cases['wildcard blacklist rule is preserved on release'] = [strpos($removed['value'], '*@blocked.example') !== false, true];
|
||||
$cases['unrelated exact email is preserved on release'] = [strpos($removed['value'], 'new@example.com') !== false, true];
|
||||
|
||||
$repeatRemoval = UserRestrictionEnforcementService::removeEmailsFromBlacklist($removed['value'], [
|
||||
'existing@example.com',
|
||||
]);
|
||||
$cases['repeated release is idempotent'] = [$repeatRemoval['removed'], []];
|
||||
$cases['idempotent release keeps value unchanged'] = [$repeatRemoval['value'], $removed['value']];
|
||||
|
||||
$mailRules = Mail::parseEmailBlacklistRules("Exact@Example.com\n*@blocked.example\n@other.example\n# ignored");
|
||||
$cases['mail blacklist matches exact email'] = [Mail::isRecipientBlacklistedByRules('exact@example.com', $mailRules), true];
|
||||
$cases['mail blacklist matches wildcard domain'] = [Mail::isRecipientBlacklistedByRules('user@blocked.example', $mailRules), true];
|
||||
$cases['mail blacklist matches at-domain rule'] = [Mail::isRecipientBlacklistedByRules('user@other.example', $mailRules), true];
|
||||
$cases['mail blacklist leaves unrelated email available'] = [Mail::isRecipientBlacklistedByRules('user@allowed.example', $mailRules), false];
|
||||
|
||||
$capsule = new Capsule();
|
||||
$capsule->addConnection(['driver' => 'sqlite', 'database' => ':memory:'], 'default');
|
||||
$capsule->setAsGlobal();
|
||||
$capsule->bootEloquent();
|
||||
|
||||
$capsule->schema('default')->create('configurations', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name', 256)->nullable();
|
||||
$table->string('value', 512)->nullable();
|
||||
});
|
||||
$capsule->schema('default')->create('email_verify', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->text('email');
|
||||
$table->text('ip');
|
||||
$table->text('code');
|
||||
$table->bigInteger('expire_in');
|
||||
});
|
||||
|
||||
$email = 'restricted@example.com';
|
||||
$capsule->table('email_verify')->insert([
|
||||
'email' => $email,
|
||||
'ip' => '127.0.0.1',
|
||||
'code' => '123456',
|
||||
'expire_in' => time() + 600,
|
||||
]);
|
||||
|
||||
$user = new User();
|
||||
$user->id = 42;
|
||||
$user->email = $email;
|
||||
$user->is_admin = false;
|
||||
|
||||
$redis = new class extends RedisClient {
|
||||
private $fakeClient;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->fakeClient = new class {
|
||||
public function executeRaw($command)
|
||||
{
|
||||
return ['0', []];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public function getClient()
|
||||
{
|
||||
return $this->fakeClient;
|
||||
}
|
||||
|
||||
public function del($key)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
$enforcement = UserRestrictionEnforcementService::enforceUsers([$user], $redis);
|
||||
$cases['database-backed enforcement succeeds'] = [$enforcement['database_error'], false];
|
||||
$cases['database-backed enforcement appends email'] = [$enforcement['emails_added'], 1];
|
||||
$cases['database-backed enforcement stores email'] = [Configurations::where('name', 'email_blacklist')->value('value'), $email];
|
||||
$cases['database-backed enforcement invalidates verification codes'] = [EmailVerify::where('email', $email)->count(), 0];
|
||||
|
||||
$repeatEnforcement = UserRestrictionEnforcementService::enforceUsers([$user], $redis);
|
||||
$cases['database-backed enforcement stays idempotent'] = [$repeatEnforcement['emails_added'], 0];
|
||||
|
||||
$release = UserRestrictionEnforcementService::releaseUsers([$user], $redis);
|
||||
$cases['database-backed release succeeds'] = [$release['database_error'], false];
|
||||
$cases['database-backed release removes email'] = [$release['emails_removed'], 1];
|
||||
$cases['database-backed release updates stored blacklist'] = [Configurations::where('name', 'email_blacklist')->value('value'), ''];
|
||||
|
||||
$repeatRelease = UserRestrictionEnforcementService::releaseUsers([$user], $redis);
|
||||
$cases['database-backed release stays idempotent'] = [$repeatRelease['emails_removed'], 0];
|
||||
|
||||
foreach ($cases as $name => [$actual, $expected]) {
|
||||
if ($actual !== $expected) {
|
||||
fwrite(STDERR, sprintf("%s failed: expected %s, got %s\n", $name, var_export($expected, true), var_export($actual, true)));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
echo "User restriction enforcement tests passed.\n";
|
||||
Loading…
Reference in New Issue