user-management icon indicating copy to clipboard operation
user-management copied to clipboard

Failed to stay loggedin with phpbrowser

Open vl-ivanov opened this issue 8 years ago • 0 comments

Hello!

I have installed user-management module on top of Yii2 advaced template and I am trying to write codeception functional test about the login form. That's the test verbose log:

codecept run backend/tests/ -vvv
Codeception PHP Testing Framework v2.3.5
Powered by PHPUnit 6.2.4 by Sebastian Bergmann and contributors.

Backend\tests.functional Tests (1) -------------------------------------------------------------------------------------------------------------------------------------------------------------------
Modules: Yii2
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
LoginCest: Login user
Signature: backend\tests\functional\LoginCest:loginUser
Test: tests/functional/LoginCest.php:loginUser
Scenario --
  [yii\db\Connection::open] 'Opening DB connection: mysql:host=localhost;dbname=everest_test'
  [Database] Transaction started
 I have fixtures {"user":{"class":"backend\\tests\\fixtures\\UserFixture","dataFile":"\/var\/www\/everest\/backend\/tests\/_data\/login_data.php"}}
 I am on page "/user-management/auth/login"
  [Request Headers] []
  [Page] /user-management/auth/login
  [Response] 200
  [Request Cookies] []
  [Response Headers] {"content-type":["text/html; charset=UTF-8"]}
 I fill field "LoginForm[username]","erau"
 I fill field "LoginForm[password]","password_0"
 I click "form button[type=submit]"
  [Uri] http://localhost/user-management/auth/login
  [Method] POST
  [Parameters] {"_csrf-backend":"RIP3YzwixnTr47BUxHbQfi-RFu-D0f7Ym9fZolddA6tmYND7bd2puYXWJpJWkxnocXBPlf4qHaiojn_KQPx3-w==","LoginForm[username]":"erau","LoginForm[password]":"password_0"}
  [Request Headers] []
  [yii\web\Session::open] 'Session started'
  [yii\web\User::login] 'User \'1\' logged in from  with duration 0.'
  [Headers] {"location":["http://localhost/index-test.php"],"content-type":["text/html; charset=UTF-8"]}
  [Page] http://localhost/user-management/auth/login
  [Response] 302
  [Request Cookies] 
  [Response Headers] {"location":["http://localhost/index-test.php"],"content-type":["text/html; charset=UTF-8"]}
  [Redirecting to] http://localhost/index-test.php
  [yii\web\Session::init] 'Session is already started'
  [Headers] {"location":["http://localhost/index-test.php/user-management/auth/login"],"content-type":["text/html; charset=UTF-8"]}
  [Page] http://localhost/index-test.php
  [Response] 302
  [Request Cookies] 
  [Response Headers] {"location":["http://localhost/index-test.php/user-management/auth/login"],"content-type":["text/html; charset=UTF-8"]}
  [Redirecting to] http://localhost/index-test.php/user-management/auth/login
  [yii\web\Session::init] 'Session is already started'
  [Page] http://localhost/index-test.php/user-management/auth/login
  [Response] 200
  [Request Cookies] 
  [Response Headers] {"content-type":["text/html; charset=UTF-8"]}
 I see "User Management"
 FAIL 

  [Database] Transaction cancelled; all changes reverted.

There seem to be a problem maintaining session because it's clear by the log that user 1 is logged in successfully and right after that is redirected to http://localhost/index-test.php. Fair enough, but no session cookie is passed and so http://localhost/index-test.php redirects user again to the login form on http://localhost/index-test.php/user-management.

Any ideas what's wrong? Already tried to login via normal web browser using the test configuration and there is no problem.

vl-ivanov avatar Oct 03 '17 15:10 vl-ivanov