51 lines
1.3 KiB
PHP
51 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Gateway;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Tests\TestCase;
|
|
|
|
class VaultPinControllerTest extends TestCase
|
|
{
|
|
private function base(): string
|
|
{
|
|
return rtrim((string) config('services.backend.base'), '/');
|
|
}
|
|
|
|
private function actingUser()
|
|
{
|
|
return User::factory()->create([
|
|
'username' => 'pinuser',
|
|
'email_verified_at' => now(),
|
|
'vault_pin_hash' => \Illuminate\Support\Facades\Hash::make('4321'),
|
|
]);
|
|
}
|
|
|
|
public function test_set_success()
|
|
{
|
|
$user = $this->actingUser();
|
|
// Da ein PIN gesetzt ist, müssen wir current_pin mitsenden
|
|
$res = $this->actingAs($user, 'web')
|
|
->postJson('/api/wallet/vault/pin/set', [ 'pin' => '1234', 'current_pin' => '4321' ]);
|
|
|
|
$res->assertStatus(200)
|
|
->assertJson([
|
|
'success' => true,
|
|
]);
|
|
}
|
|
|
|
public function test_verify_success()
|
|
{
|
|
$user = $this->actingUser();
|
|
// Der actingUser() hat PIN 4321
|
|
$res = $this->actingAs($user, 'web')
|
|
->postJson('/api/wallet/vault/pin/verify', [ 'pin' => '4321' ]);
|
|
|
|
$res->assertStatus(200)
|
|
->assertJson([
|
|
'success' => true,
|
|
]);
|
|
}
|
|
}
|