由于身份验证失败,无法在登录代码后登录后执行操作[无法发送令牌]

时间:2019-01-18 07:07:01

标签: laravel-5 codeception

我正在使用代码接收来自动化测试。登录后如何执行操作。

为了更好地理解,我在下面发布了我的代码。

    $I->amOnRoute('login');;
    $I->sendPOST('/login', ['email' => 'un', 'password' => `enter 
    code here`'pwd']);
    $I->seeResponseCodeIs(200);

上面的代码行工作正常,但是当我继续下面的代码时,我得到401认证错误

        $I->sendAjaxPostRequest('/adminproxy/create-entity',[ 
         "name" => 123123123123,
        "title" =>  123123123,
        "realm_id" =>  1,
        "description" =>  123123123123,
        "status" =>  'ACTIVE',
        "entity_type" => 'Workspace' ]);

1 个答案:

答案 0 :(得分:0)

混合使用Laravel5模块和REST模块的动作可能是一个问题。
与其使用sendPOST,不如使用submit a form

$I->amOnRoute('login');
$I->submitForm('#login-form', ['email' => 'un', 'password' => 'pwd']);
$I->seeResponseCodeIs(200);