lundi 27 juin 2016

Codeception Functional API tests with Laravel5 authentication

I'm trying to test an API that requires users to be logged in via Laravel through the web. Javascript will be accessing a REST API with a CSRF token. When I try to test this using Codeception it seems like the authentication is not being recognized with the sendPOST call.

I'm using the following Modules in my Api Suite:

modules:
    enabled:
        - Laravel5
        - \Helper\Api
        - REST:

Here is my test:

public function verifyFileIsRequired(ApiTester $I)
{
    $I->amLoggedAs($this->user);
    $I->sendPOST(self::URL_GOES_HERE);
    $I->seeResponseCodeIs(422);
}

I keep getting a 401 response code. I have a feeling that this is due to the sendPOST method not sending the Laravel session info. Is there a way to make this work?

Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire