diff --git a/app/TwoFAccount.php b/app/TwoFAccount.php index 3d31d2a0..087468f5 100644 --- a/app/TwoFAccount.php +++ b/app/TwoFAccount.php @@ -43,7 +43,7 @@ class TwoFAccount extends Model public function getIconAttribute($value) { if (\App::environment('testing') == false) { - if( !Storage::exists('public/icons/' . pathinfo($value)['basename']) ) { + if( !Storage::exists('public/icons/' . $value) ) { return ''; } @@ -62,7 +62,7 @@ public function getIconAttribute($value) public function setIconAttribute($value) { - if( !Storage::exists('public/icons/' . pathinfo($value)['basename']) ) { + if( !Storage::exists('public/icons/' . $value) && \App::environment('testing') == false ) { $this->attributes['icon'] = ''; } diff --git a/tests/Unit/TwoFAccountTest.php b/tests/Unit/TwoFAccountTest.php index e8adc85f..7f346762 100644 --- a/tests/Unit/TwoFAccountTest.php +++ b/tests/Unit/TwoFAccountTest.php @@ -140,10 +140,10 @@ public function testTOTPgeneration() ]); $response = $this->actingAs($this->user, 'api') - ->json('GET', '/api/twofaccounts/' . $twofaccount->id . '/totp') + ->json('GET', '/api/twofaccounts/' . $twofaccount->id . '/otp') ->assertStatus(200) ->assertJsonStructure([ - 'totp', + 'otp', ]); } @@ -161,7 +161,6 @@ public function testTwoFAccountUpdate() ->json('PUT', '/api/twofaccounts/' . $twofaccount->id, [ 'service' => 'testUpdate', 'account' => 'testUpdate@test.com', - 'uri' => 'testUpdate', 'icon' => 'testUpdate.png', ]) ->assertStatus(200) @@ -169,7 +168,7 @@ public function testTwoFAccountUpdate() 'id' => 1, 'service' => 'testUpdate', 'account' => 'testUpdate@test.com', - 'uri' => 'testUpdate', + 'uri' => $twofaccount->uri, 'icon' => 'testUpdate.png', ]); }