feat: ds
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\Admin;
|
||||
use App\Models\Device;
|
||||
use App\Models\TokenviewEvent;
|
||||
use App\Models\WalletAddress;
|
||||
@@ -39,10 +40,27 @@ class TokenviewWebhookTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function webhook_rejects_bad_signature_when_sign_key_configured(): void
|
||||
public function webhook_acks_unsigned_probe_with_200(): void
|
||||
{
|
||||
config(['coruna.tokenview.sign_key' => 'secret-sign']);
|
||||
$body = json_encode(['address' => '0xabc', 'txid' => '0x1', 'coin' => 'ETH', 'value' => '1']);
|
||||
|
||||
$this->get('/hooks/tokenview')->assertOk()->assertSee('ok');
|
||||
$this->get('/hook/tokenview')->assertOk()->assertSee('ok');
|
||||
$this->postJson('/hooks/tokenview', [])->assertOk()->assertSee('ok');
|
||||
$this->postJson('/hook/tokenview', [])->assertOk()->assertSee('ok');
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function webhook_acks_bad_signature_without_ingesting(): void
|
||||
{
|
||||
config(['coruna.tokenview.sign_key' => 'secret-sign']);
|
||||
$addr = $this->seedMonitoredAddress();
|
||||
$body = json_encode([
|
||||
'address' => $addr->address,
|
||||
'txid' => '0xbad-sig-1',
|
||||
'coin' => 'ETH',
|
||||
'value' => '9',
|
||||
]);
|
||||
|
||||
$this->call(
|
||||
'POST',
|
||||
@@ -55,7 +73,11 @@ class TokenviewWebhookTest extends TestCase
|
||||
'HTTP_X_TOKENVIEW_SIGNATURE' => 'deadbeef',
|
||||
],
|
||||
$body
|
||||
)->assertStatus(401);
|
||||
)->assertOk()->assertSee('ok');
|
||||
|
||||
$addr->refresh();
|
||||
$this->assertEqualsWithDelta(1.0, (float) $addr->eth, 0.0000001);
|
||||
$this->assertSame(0, TokenviewEvent::query()->count());
|
||||
}
|
||||
|
||||
#[Test]
|
||||
@@ -155,9 +177,9 @@ class TokenviewWebhookTest extends TestCase
|
||||
}
|
||||
$text = (string) ($request->data()['text'] ?? '');
|
||||
|
||||
return str_contains($text, 'Balance Inbound')
|
||||
return str_contains($text, '余额入账')
|
||||
&& str_contains($text, '+5 USDT')
|
||||
&& str_contains($text, 'Balance')
|
||||
&& str_contains($text, '余额')
|
||||
&& str_contains($text, 'USDT');
|
||||
});
|
||||
}
|
||||
@@ -190,7 +212,7 @@ class TokenviewWebhookTest extends TestCase
|
||||
'services.tokenview.io/*' => Http::response(['code' => 1, 'msg' => 'success', 'data' => null], 200),
|
||||
]);
|
||||
|
||||
$admin = \App\Models\Admin::query()->create(['username' => 'admin', 'password' => 'admin123']);
|
||||
$admin = Admin::query()->create(['username' => 'admin', 'password' => 'admin123']);
|
||||
$addr = $this->seedMonitoredAddress(['monitor' => 0]);
|
||||
|
||||
$this->actingAs($admin, 'admin')
|
||||
|
||||
Reference in New Issue
Block a user