Skip to content

Commit

Permalink
Test fetch of profile for bad wiki user name
Browse files Browse the repository at this point in the history
  • Loading branch information
edwh committed Aug 2, 2021
1 parent eb06d17 commit e3d305f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,10 @@ public static function getThumbnail(Request $request)
{
$user = User::where('mediawiki', $request->input('wiki_username'))->first();

if (!$user) {
abort('404', 'Wiki user not found');
}

if (isset($user->getProfile($user->id)->path) && ! is_null($user->getProfile($user->id)->path)) {
$thumbnailPath = config('app.url').'/uploads/thumbnail_'.$user->getProfile($user->id)->path;
} else {
Expand Down
6 changes: 6 additions & 0 deletions tests/Feature/Users/ProfileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Event;
use Illuminate\Validation\UnauthorizedException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Tests\TestCase;

class ProfileTest extends TestCase
Expand Down Expand Up @@ -120,4 +121,9 @@ public function testEditBadPassword()

$response->assertSee('The passwords are not identical!');
}

public function testBadMediaWikiId() {
$this->expectException(NotFoundHttpException::class);
$this->get('/user/thumbnail?wiki_username=invalid');
}
}

0 comments on commit e3d305f

Please sign in to comment.