Skip to content

Commit

Permalink
Merge pull request #339 from nanasess/fix-memberlogin
Browse files Browse the repository at this point in the history
管理画面ログインのバリデーションをインストーラに合わせる
  • Loading branch information
chihiro-adachi authored Nov 26, 2019
2 parents 30eb664 + a8673ad commit a12e34e
Show file tree
Hide file tree
Showing 16 changed files with 277 additions and 34 deletions.
160 changes: 159 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@master

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Setup PHP
uses: nanasess/setup-php@master
with:
Expand Down Expand Up @@ -93,10 +105,20 @@ jobs:
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
echo ">>> Started xvfb"
- name: Run to Codeception
env:
DB: ${{ matrix.db }}
USER: ${{ matrix.dbuser }}
DBUSER: ${{ matrix.dbuser }}
DBPASS: ${{ matrix.dbpass }}
DBNAME: myapp_test
DBPORT: ${{ matrix.dbport }}
DBSERVER: 127.0.0.1
HTTP_URL: http://localhost:8085/
HTTPS_URL: http://localhost:8085/
run: |
php data/vendor/bin/codecept build
php -S 0.0.0.0:8085 -t html/ &
php data/vendor/bin/codecept run --env chrome --steps
php data/vendor/bin/codecept run --env chrome --skip-group installer --steps
run-on-windows:
name: Run on Windows
runs-on: ${{ matrix.operating-system }}
Expand All @@ -117,6 +139,17 @@ jobs:
with:
php-version: ${{ matrix.php }}

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**\composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install to Composer
run: composer install --no-interaction -o

Expand Down Expand Up @@ -149,6 +182,118 @@ jobs:
- name: Run to PHPUnit
run: data/vendor/bin/phpunit --exclude-group classloader

install-to-linux:
name: Install to Linux
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ ubuntu-18.04 ]
php: [ 5.4, 5.5, 5.6, 7.1, 7.2, 7.3 ]
db: [ mysql, pgsql ]
include:
- db: mysql
dbport: '3306'
dbuser: 'root'
dbpass: 'root'
- db: pgsql
dbport: '5432'
dbuser: 'postgres'
dbpass: 'password'
services:
postgres:
image: postgres:11
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: postgres
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
mailcatcher:
image: schickling/mailcatcher
ports:
- 1080:1080
- 1025:1025
steps:
- name: Checkout
uses: actions/checkout@master

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Setup PHP
uses: nanasess/setup-php@master
with:
php-version: ${{ matrix.php }}

- name: Install to Composer
run: composer install --no-interaction -o

- name: setup-chromedriver
uses: nanasess/setup-chromedriver@master
with:
chromedriver-version: '77.0.3865.40'

- name: Run chromedriver
run: |
export DISPLAY=:99
chromedriver --url-base=/wd/hub &
echo ">>> Started chrome-driver"
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
echo ">>> Started xvfb"
- name: CREATE mysql DATABASE
if: matrix.db == 'mysql'
env:
DB: ${{ matrix.db }}
USER: ${{ matrix.dbuser }}
DBUSER: ${{ matrix.dbuser }}
DBPASS: ${{ matrix.dbpass }}
DBNAME: myapp_test
DBPORT: ${{ matrix.dbport }}
DBSERVER: 127.0.0.1
run: mysql --user=${DBUSER} --password=${DBPASS} -h ${DBSERVER} -P ${DBPORT} -e "CREATE DATABASE ${DBNAME} DEFAULT COLLATE=utf8_general_ci;"

- name: CREATE pgsql DATABASE
if: matrix.db == 'pgsql'
env:
DB: ${{ matrix.db }}
USER: ${{ matrix.dbuser }}
DBUSER: ${{ matrix.dbuser }}
DBPASS: ${{ matrix.dbpass }}
DBNAME: myapp_test
DBPORT: ${{ matrix.dbport }}
DBSERVER: 127.0.0.1
run: |
sudo apt-fast install -y postgresql-client
export PGPASSWORD=${DBPASS}
psql -h ${DBSERVER} -U ${DBUSER} -p ${DBPORT} -c "CREATE DATABASE ${DBNAME};"
- name: Run to Codeception
env:
DB: ${{ matrix.db }}
USER: ${{ matrix.dbuser }}
DBUSER: ${{ matrix.dbuser }}
DBPASS: ${{ matrix.dbpass }}
DBNAME: myapp_test
DBPORT: ${{ matrix.dbport }}
DBSERVER: 127.0.0.1
HTTP_URL: http://localhost:8085/
HTTPS_URL: http://localhost:8085/
run: |
php data/vendor/bin/codecept build
php -S 0.0.0.0:8085 -t html/ &
php data/vendor/bin/codecept run --env chrome --group installer --steps acceptance InstallerCept
deploy:
name: Deploy
runs-on: ubuntu-18.04
Expand All @@ -158,6 +303,19 @@ jobs:
if: github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'prereleased' )
uses: actions/checkout@master

- name: Get Composer Cache Directory
if: github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'prereleased' )
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v1
if: github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'prereleased' )
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install to Composer
if: github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'prereleased' )
run: composer install --no-scripts --no-dev --no-interaction --optimize-autoloader
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ addons:

env:
global:
- DBNAME=myapp_test HTTP_URL=http://localhost:8085/ HTTPS_URL=http://localhost:8085/
- DBNAME=myapp_test DBSERVER=127.0.0.1 HTTP_URL=http://localhost:8085/ HTTPS_URL=http://localhost:8085/
matrix:
- DB=mysql USER=root DBPASS=' ' DBUSER=root
- DB=pgsql USER=postgres DBPASS=password DBUSER=postgres
Expand Down Expand Up @@ -93,7 +93,7 @@ script:
- if [ ! $COVERAGE ] ; then php data/vendor/bin/phpunit -c phpunit.xml.dist --exclude-group classloader ; fi
- if [ ! $COVERAGE ] ; then php data/vendor/bin/phpunit -c phpunit.xml.dist --group classloader ; fi
- if [ $COVERAGE ] ; then phpdbg -qrr data/vendor/bin/phpunit -c phpunit.xml.dist --exclude-group classloader ; fi
- if [ ! $COVERAGE ] ; then php data/vendor/bin/codecept run --env chrome --steps ; fi
- if [ ! $COVERAGE ] ; then php data/vendor/bin/codecept run --env chrome --skip-group installer --steps ; fi

after_script:
- if [ $COVERAGE ] ; then php data/vendor/bin/coveralls -v ; fi
Expand Down
2 changes: 2 additions & 0 deletions codeception.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ modules:
user: ''
password: ''
dump: ctests/_data/dump.sql
params:
- env
5 changes: 5 additions & 0 deletions ctests/acceptance.suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ modules:
- WebDriver
- Asserts
- MailCatcherGuzzle5
- Db
config:
PhpBrowser:
url: 'http://localhost:8085/'
Expand All @@ -29,6 +30,10 @@ modules:
MailCatcherGuzzle5:
url: 'http://127.0.0.1'
port: '1080'
Db:
dsn: %DB%:host=%DBSERVER%;dbname=%DBNAME%
user: %DBUSER%
password: %DBPASS%

env:
travis:
Expand Down
78 changes: 78 additions & 0 deletions ctests/acceptance/InstallerCept.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
/**
* @group installer
*/
$I = new AcceptanceTester($scenario);
$faker = Codeception\Util\Fixtures::get('faker');
$I->wantTo('正常にインストール可能か検証する');
// $I->amOnPage('/');
$I->amOnPage('/install/');
$I->seeInCurrentUrl('/install/');
$I->see('EC-CUBEのインストールを開始します。');
$I->click('次へ進む');

$I->expect('パーミッションのチェックをします');
$I->see('チェック結果');
$I->see('>> ○:アクセス権限は正常です。', ['css' => 'textarea[name=disp_area]']);
$I->click('次へ進む');

$I->expect('必要なファイルのコピーをします');
$I->see('ice130.jpg', ['css' => 'textarea[name=disp_area]']);
$I->click('次へ進む');

$I->see('ECサイトの設定');
$I->expect('STEP1');
$admindirectory = $faker->regexify('[A-Za-z0-9]{8,10}');
$user = $faker->userName;
$password = $faker->regexify('[A-Za-z]{8,10}').$faker->regexify('[0-9]{3,5}');
$I->fillField('input[name=shop_name]', $faker->name);
$I->fillField('input[name=admin_mail]', $faker->safeEmail);
$I->fillField('input[name=login_id]', $user);
$I->fillField('input[name=login_pass]', $password);
$I->fillField('input[name=admin_dir]', $admindirectory);

$I->click('>> オプション設定');
$I->selectOption('input[name=mail_backend]', 'smtp');
$I->fillField('input[name=smtp_host]', '127.0.0.1');
$I->fillField('input[name=smtp_port]', '1025');
$I->click('次へ進む');

$I->expect('STEP2');
defined('DB_TYPE') or define('DB_TYPE', getenv('DB') == 'mysql' ? 'mysqli' : getenv('DB'));
defined('DB_USER') or define('DB_USER', getenv('DBUSER'));
defined('DB_NAME') or define('DB_NAME', getenv('DBNAME'));
defined('DB_PASSWORD') or define('DB_PASSWORD', getenv('DBPASS') );
defined('DB_PORT') or define('DB_PORT', getenv('DBPORT'));
defined('DB_SERVER') or define('DB_SERVER', getenv('DBSERVER'));

$I->selectOption('select[name=db_type]', DB_TYPE);
$I->fillField('input[name=db_server]', DB_SERVER);
$I->fillField('input[name=db_port]', DB_PORT);
$I->fillField('input[name=db_name]', DB_NAME);
$I->fillField('input[name=db_user]', DB_USER);
$I->fillField('input[name=db_password]', DB_PASSWORD);
$I->click('次へ進む');

$I->expect('STEP3');
$I->see('データベースの初期化');
$I->click('次へ進む');

$I->see('データベースの初期化');
$I->waitForText('○:テーブルの作成に成功しました。', 30);
$I->waitForText('○:シーケンスの作成に成功しました。', 30);
$I->click('次へ進む');

$I->expect('STEP4');
$I->see('サイト情報について');
$I->click('次へ進む');

$I->see('インストールが完了しました。');
$I->seeInDatabase('dtb_member', ['login_id' => $user]);
$I->click('管理画面へログインする');

$I->seeInCurrentUrl('/'.$admindirectory);
$I->fillField('input[name=login_id]', $user);
$I->fillField('input[name=password]', $password);
$I->click(['css' => '.btn-tool-format']);

$I->see('ログイン : 管理者 様');
6 changes: 6 additions & 0 deletions ctests/acceptance/_bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
$faker = Faker\Factory::create('ja_JP');
Codeception\Util\Fixtures::add('faker', $faker);

if (!file_exists(__DIR__.'/../../data/config/config.php')
|| !defined('ECCUBE_INSTALL') || ECCUBE_INSTALL != 'ON') {
echo 'EC-CUBE is not yet installed.';
return;
}

/** @var SC_Query $objQuery */
$objQuery = SC_Query_Ex::getSingletonInstance();

Expand Down
3 changes: 2 additions & 1 deletion data/class/pages/admin/LC_Page_Admin_Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public function action()
//ログイン処理
$this->lfInitParam($objFormParam);
$objFormParam->setParam($_POST);
$objFormParam->trimParam();
$this->arrErr = $this->lfCheckError($objFormParam);
if (SC_Utils_Ex::isBlank($this->arrErr)) {
$this->lfDoLogin($objFormParam->getValue('login_id'));
Expand Down Expand Up @@ -99,7 +100,7 @@ public function action()
*/
public function lfInitParam(&$objFormParam)
{
$objFormParam->addParam('ID', 'login_id', ID_MAX_LEN, '', array('EXIST_CHECK', 'ALNUM_CHECK' ,'MAX_LENGTH_CHECK'));
$objFormParam->addParam('ID', 'login_id', ID_MAX_LEN, '', array('EXIST_CHECK', 'GRAPH_CHECK' ,'MAX_LENGTH_CHECK'));
$objFormParam->addParam('PASSWORD', 'password', PASSWORD_MAX_LEN, '', array('EXIST_CHECK', 'GRAPH_CHECK', 'MAX_LENGTH_CHECK'));
}

Expand Down
Loading

0 comments on commit a12e34e

Please sign in to comment.