<commit_before><?php

namespace Tests\App\Http\Controllers;

use App\User;
use Illuminate\Http\Response;
use Tests\BaseTestClass;

/**
 * @SuppressWarnings(PHPMD.TooManyPublicMethods)
 */
class AuthControllerTest extends BaseTestClass
{
    private $adminEmail = '<EMAIL>';
    private $adminPassword = '<PASSWORD>';
    private $adminName = 'admin';

    /** @var User $admin */
    private $admin;

    public function setUp()
    {
        parent::setUp();

        $this->admin = $this->createAdmin();
    }

    /**
     * @group auth
     * @group POST
     * @covers \App\Http\Controllers\AuthController::postLogin
     */
    public function testLoginEmptyBody()
    {
        $this->postJson($this->baseUrl . 'api/auth/login')->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
    }

    /**
     * @group auth
     * @group POST
     * @covers \App\Http\Controllers\AuthController::postLogin
     * @covers \App\Http\Controllers\AuthController::__construct
     */
    public function testLoginInvalidEmail()
    {
        $this->postJson($this->baseUrl . 'api/auth/login', [
            'email' => 'd<PASSWORD>',
            'password' => '<PASSWORD>'
        ])->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
    }

    /**
     * @group auth
     * @group POST
     * @covers \App\Http\Controllers\AuthController::postLogin
     */
    public function testLoginBadEmailBadPassword()
    {
        $this->postJson($this->baseUrl . 'api/auth/login', [
            'email' => '<EMAIL>',
            'password' => '<PASSWORD>'
        ])->assertStatus(Response::HTTP_UNAUTHORIZED);
    }

    /**
     * @group auth
     * @group POST
     * @covers \App\Http\Controllers\AuthController::postLogin
     */
    public function testLoginGoodEmailBadPassword()
    {
        $this->postJson($this->baseUrl . 'api/auth/login', [
            'email' => $this->adminEmail,
            'password' => '<PASSWORD>'
        ])->assertStatus(Response::HTTP_UNAUTHORIZED);
    }

    /**
     * @group auth
     * @group POST
     * @covers \App\Http\Controllers\AuthController::postLogin
     */
    public function testLoginGoodEmailGoodPassword()
    {
        $response = $this->postJson($this->baseUrl . 'api/auth/login', [
            'email' => $this->adminEmail,
            'password' => $this->adminPassword
        ])->assertStatus(Response::HTTP_OK);
        $this->assertNotEmpty(json_decode($response->getContent(), true)['token']);
    }

    /**
     * @group auth
     * @group perMe
     * @group GET
     * @covers \App\Http\Controllers\AuthController::getAuthenticatedUser
     */
    public function testGetUserNoToken()
    {
        $this->getJson($this->baseUrl . 'api/users/me')->assertStatus(Response::HTTP_UNAUTHORIZED);
    }

    /**
     * @group auth
     * @group perMe
     * @group GET
     * @covers \App\Http\Controllers\AuthController::getAuthenticatedUser
     */
    public function testGetUserInvalidToken()
    {
        $this->getJson($this->baseUrl . 'api/users/me', [
            'Authorization' => 'Bearer fdgdhdsfhfsdhgd'
        ])->assertStatus(Response::HTTP_UNAUTHORIZED);
    }
<commit_msg>fix test<commit_after><?php

namespace Tests\App\Http\Controllers;

use App\User;
use Illuminate\Http\Response;
use Tests\BaseTestClass;

/**
 * @SuppressWarnings(PHPMD.TooManyPublicMethods)
 */
class AuthControllerTest extends BaseTestClass
{
    private $adminEmail = '<EMAIL>';
    private $adminPassword = '<PASSWORD>';
    private $adminName = 'admin';

    /** @var User $admin */
    private $admin;

    public function setUp()
    {
        parent::setUp();

        $this->admin = $this->createAdmin();
    }

    /**
     * @group auth
     * @group POST
     * @covers \App\Http\Controllers\AuthController::postLogin
     */
    public function testLoginEmptyBody()
    {
        $this->postJson($this->baseUrl . 'api/auth/login')->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
    }

    /**
     * @group auth
     * @group POST
     * @covers \App\Http\Controllers\AuthController::postLogin
     * @covers \App\Http\Controllers\AuthController::__construct
     */
    public function testLoginInvalidEmail()
    {
        $this->postJson($this->baseUrl . 'api/auth/login', [
            'email' => 'dsgfdg',
            'password' => '<PASSWORD>'
        ])->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
    }

    /**
     * @group auth
     * @group POST
     * @covers \App\Http\Controllers\AuthController::postLogin
     */
    public function testLoginBadEmailBadPassword()
    {
        $this->postJson($this->baseUrl . 'api/auth/login', [
            'email' => '<EMAIL>',
            'password' => '<PASSWORD>'
        ])->assertStatus(Response::HTTP_UNAUTHORIZED);
    }

    /**
     * @group auth
     * @group POST
     * @covers \App\Http\Controllers\AuthController::postLogin
     */
    public function testLoginGoodEmailBadPassword()
    {
        $this->postJson($this->baseUrl . 'api/auth/login', [
            'email' => $this->adminEmail,
            'password' => '<PASSWORD>'
        ])->assertStatus(Response::HTTP_UNAUTHORIZED);
    }

    /**
     * @group auth
     * @group POST
     * @covers \App\Http\Controllers\AuthController::postLogin
     */
    public function testLoginGoodEmailGoodPassword()
    {
        $response = $this->postJson($this->baseUrl . 'api/auth/login', [
            'email' => $this->adminEmail,
            'password' => $this->adminPassword
        ])->assertStatus(Response::HTTP_NO_CONTENT);
        $response->assertHeader('Authorization');
    }

    /**
     * @group auth
     * @group perMe
     * @group GET
     * @covers \App\Http\Controllers\AuthController::getAuthenticatedUser
     */
    public function testGetUserNoToken()
    {
        $this->getJson($this->baseUrl . 'api/users/me')->assertStatus(Response::HTTP_UNAUTHORIZED);
    }

    /**
     * @group auth
     * @group perMe
     * @group GET
     * @covers \App\Http\Controllers\AuthController::getAuthenticatedUser
     */
    public function testGetUserInvalidToken()
    {
        $this->getJson($this->baseUrl . 'api/users/me', [
            'Authorization' => 'Bearer fdgdhdsfhfsdhgd'
        ])->assertStatus(Response::HTTP_UNAUTHORIZED);
    }

{'fraction_non_alphanumeric': 0.15126319155740325, 'fraction_numerical': 0.0, 'mean_word_length': 2.5580204778157, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 89, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5319035', 'n_tokens_mistral': 1932, 'n_tokens_neox': 1939, 'n_words': 288}