Initialer Laravel Commit für BetiX
This commit is contained in:
50
tests/Feature/Gateway/VaultPinControllerTest.php
Normal file
50
tests/Feature/Gateway/VaultPinControllerTest.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user