new email field in TwoFAccount entity

This commit is contained in:
Bubka 2019-06-10 23:42:13 +02:00
parent 99fb3b8c45
commit 8b5f5223c0
5 changed files with 10 additions and 1 deletions

View File

@ -31,6 +31,7 @@ public function store(Request $request)
{
$twofaccount = TwoFAccount::create([
'name' => $request->name,
'email' => $request->email,
'uri' => $request->uri
]);

View File

@ -9,7 +9,7 @@ class TwoFAccount extends Model
{
use SoftDeletes;
protected $fillable = ['name', 'uri', 'icon'];
protected $fillable = ['name', 'email', 'uri', 'icon'];
/**

View File

@ -20,6 +20,7 @@
$factory->define(TwoFAccount::class, function (Faker $faker) {
return [
'name' => $faker->unique()->domainName,
'email' => $faker->safeEmail,
'uri' => 'otpauth://totp/' . $faker->email . '?secret=' . $faker->regexify('[A-Z0-9]{16}') . '&issuer=test',
];
});

View File

@ -17,6 +17,7 @@ public function up()
$table->increments('id');
$table->string('name')->unique();
$table->string('uri');
$table->string('email');
$table->string('icon')->nullable();
$table->timestamps();
$table->softDeletes();

View File

@ -33,11 +33,13 @@ public function testTwoFAccountCreation()
$response = $this->actingAs($this->user, 'api')
->json('POST', '/api/twofaccounts', [
'name' => 'testCreation',
'email' => 'test@example.org',
'uri' => 'test',
])
->assertStatus(201)
->assertJson([
'name' => 'testCreation',
'email' => 'test@example.org',
'uri' => 'test',
]);
}
@ -52,6 +54,7 @@ public function testTOTPgeneration()
{
$twofaccount = factory(TwoFAccount::class)->create([
'name' => 'testTOTP',
'email' => 'test@test.com',
'uri' => 'otpauth://totp/test@test.com?secret=A4GRFHVVRBGY7UIW&issuer=test'
]);
@ -76,12 +79,14 @@ public function testTwoFAccountUpdate()
$response = $this->actingAs($this->user, 'api')
->json('PUT', '/api/twofaccounts/' . $twofaccount->id, [
'name' => 'testUpdate',
'email' => 'testUpdate@test.com',
'uri' => 'testUpdate',
])
->assertStatus(200)
->assertJson([
'id' => 1,
'name' => 'testUpdate',
'email' => 'testUpdate@test.com',
'uri' => 'testUpdate',
'icon' => null,
]);
@ -104,6 +109,7 @@ public function testTwoFAccountIndexListing()
'*' => [
'id',
'name',
'email',
'uri',
'icon',
'created_at',