Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
proyek_pswii_evoting
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
proyek_pswii_2020_kelompok_06
proyek_pswii_evoting
Commits
e5104d0e
Commit
e5104d0e
authored
Jun 06, 2020
by
henny flora panjaitan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
by artha
parent
1c61c501
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
712 additions
and
0 deletions
+712
-0
_bootstrap.php
online_voting_system_FINAL_06/tests/_bootstrap.php
+7
-0
.gitkeep
online_voting_system_FINAL_06/tests/_data/.gitkeep
+1
-0
.gitignore
online_voting_system_FINAL_06/tests/_output/.gitignore
+3
-0
AcceptanceTester.php
...oting_system_FINAL_06/tests/_support/AcceptanceTester.php
+26
-0
FunctionalTester.php
...oting_system_FINAL_06/tests/_support/FunctionalTester.php
+23
-0
UnitTester.php
online_voting_system_FINAL_06/tests/_support/UnitTester.php
+26
-0
acceptance.suite.yml.example
...voting_system_FINAL_06/tests/acceptance.suite.yml.example
+10
-0
AboutCest.php
online_voting_system_FINAL_06/tests/acceptance/AboutCest.php
+12
-0
ContactCest.php
...e_voting_system_FINAL_06/tests/acceptance/ContactCest.php
+34
-0
HomeCest.php
online_voting_system_FINAL_06/tests/acceptance/HomeCest.php
+18
-0
LoginCest.php
online_voting_system_FINAL_06/tests/acceptance/LoginCest.php
+21
-0
_bootstrap.php
...ne_voting_system_FINAL_06/tests/acceptance/_bootstrap.php
+1
-0
yii
online_voting_system_FINAL_06/tests/bin/yii
+29
-0
yii.bat
online_voting_system_FINAL_06/tests/bin/yii.bat
+20
-0
functional.suite.yml
online_voting_system_FINAL_06/tests/functional.suite.yml
+13
-0
ContactFormCest.php
...ting_system_FINAL_06/tests/functional/ContactFormCest.php
+57
-0
LoginFormCest.php
...voting_system_FINAL_06/tests/functional/LoginFormCest.php
+60
-0
_bootstrap.php
...ne_voting_system_FINAL_06/tests/functional/_bootstrap.php
+1
-0
unit.suite.yml
online_voting_system_FINAL_06/tests/unit.suite.yml
+11
-0
_bootstrap.php
online_voting_system_FINAL_06/tests/unit/_bootstrap.php
+3
-0
ContactFormTest.php
...ing_system_FINAL_06/tests/unit/models/ContactFormTest.php
+48
-0
LoginFormTest.php
...oting_system_FINAL_06/tests/unit/models/LoginFormTest.php
+51
-0
UserTest.php
online_voting_system_FINAL_06/tests/unit/models/UserTest.php
+44
-0
.gitignore
online_voting_system_FINAL_06/vagrant/config/.gitignore
+3
-0
vagrant-local.example.yml
..._system_FINAL_06/vagrant/config/vagrant-local.example.yml
+22
-0
app.conf
online_voting_system_FINAL_06/vagrant/nginx/app.conf
+38
-0
.gitignore
online_voting_system_FINAL_06/vagrant/nginx/log/.gitignore
+4
-0
always-as-root.sh
...oting_system_FINAL_06/vagrant/provision/always-as-root.sh
+19
-0
once-as-root.sh
..._voting_system_FINAL_06/vagrant/provision/once-as-root.sh
+76
-0
once-as-vagrant.sh
...ting_system_FINAL_06/vagrant/provision/once-as-vagrant.sh
+31
-0
No files found.
online_voting_system_FINAL_06/tests/_bootstrap.php
0 → 100644
View file @
e5104d0e
<?php
define
(
'YII_ENV'
,
'test'
);
defined
(
'YII_DEBUG'
)
or
define
(
'YII_DEBUG'
,
true
);
require_once
__DIR__
.
'/../vendor/yiisoft/yii2/Yii.php'
;
require
__DIR__
.
'/../vendor/autoload.php'
;
\ No newline at end of file
online_voting_system_FINAL_06/tests/_data/.gitkeep
0 → 100644
View file @
e5104d0e
online_voting_system_FINAL_06/tests/_output/.gitignore
0 → 100644
View file @
e5104d0e
*
!.gitignore
\ No newline at end of file
online_voting_system_FINAL_06/tests/_support/AcceptanceTester.php
0 → 100644
View file @
e5104d0e
<?php
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class
AcceptanceTester
extends
\Codeception\Actor
{
use
_generated\AcceptanceTesterActions
;
/**
* Define custom actions here
*/
}
online_voting_system_FINAL_06/tests/_support/FunctionalTester.php
0 → 100644
View file @
e5104d0e
<?php
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class
FunctionalTester
extends
\Codeception\Actor
{
use
_generated\FunctionalTesterActions
;
}
online_voting_system_FINAL_06/tests/_support/UnitTester.php
0 → 100644
View file @
e5104d0e
<?php
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class
UnitTester
extends
\Codeception\Actor
{
use
_generated\UnitTesterActions
;
/**
* Define custom actions here
*/
}
online_voting_system_FINAL_06/tests/acceptance.suite.yml.example
0 → 100644
View file @
e5104d0e
class_name: AcceptanceTester
modules:
enabled:
- WebDriver:
url: http://127.0.0.1:8080/
browser: firefox
- Yii2:
part: orm
entryScript: index-test.php
cleanup: false
online_voting_system_FINAL_06/tests/acceptance/AboutCest.php
0 → 100644
View file @
e5104d0e
<?php
use
yii\helpers\Url
;
class
AboutCest
{
public
function
ensureThatAboutWorks
(
AcceptanceTester
$I
)
{
$I
->
amOnPage
(
Url
::
toRoute
(
'/site/about'
));
$I
->
see
(
'About'
,
'h1'
);
}
}
online_voting_system_FINAL_06/tests/acceptance/ContactCest.php
0 → 100644
View file @
e5104d0e
<?php
use
yii\helpers\Url
;
class
ContactCest
{
public
function
_before
(
\AcceptanceTester
$I
)
{
$I
->
amOnPage
(
Url
::
toRoute
(
'/site/contact'
));
}
public
function
contactPageWorks
(
AcceptanceTester
$I
)
{
$I
->
wantTo
(
'ensure that contact page works'
);
$I
->
see
(
'Contact'
,
'h1'
);
}
public
function
contactFormCanBeSubmitted
(
AcceptanceTester
$I
)
{
$I
->
amGoingTo
(
'submit contact form with correct data'
);
$I
->
fillField
(
'#contactform-name'
,
'tester'
);
$I
->
fillField
(
'#contactform-email'
,
'tester@example.com'
);
$I
->
fillField
(
'#contactform-subject'
,
'test subject'
);
$I
->
fillField
(
'#contactform-body'
,
'test content'
);
$I
->
fillField
(
'#contactform-verifycode'
,
'testme'
);
$I
->
click
(
'contact-button'
);
$I
->
wait
(
2
);
// wait for button to be clicked
$I
->
dontSeeElement
(
'#contact-form'
);
$I
->
see
(
'Thank you for contacting us. We will respond to you as soon as possible.'
);
}
}
online_voting_system_FINAL_06/tests/acceptance/HomeCest.php
0 → 100644
View file @
e5104d0e
<?php
use
yii\helpers\Url
;
class
HomeCest
{
public
function
ensureThatHomePageWorks
(
AcceptanceTester
$I
)
{
$I
->
amOnPage
(
Url
::
toRoute
(
'/site/index'
));
$I
->
see
(
'My Company'
);
$I
->
seeLink
(
'About'
);
$I
->
click
(
'About'
);
$I
->
wait
(
2
);
// wait for page to be opened
$I
->
see
(
'This is the About page.'
);
}
}
online_voting_system_FINAL_06/tests/acceptance/LoginCest.php
0 → 100644
View file @
e5104d0e
<?php
use
yii\helpers\Url
;
class
LoginCest
{
public
function
ensureThatLoginWorks
(
AcceptanceTester
$I
)
{
$I
->
amOnPage
(
Url
::
toRoute
(
'/site/login'
));
$I
->
see
(
'Login'
,
'h1'
);
$I
->
amGoingTo
(
'try to login with correct credentials'
);
$I
->
fillField
(
'input[name="LoginForm[username]"]'
,
'admin'
);
$I
->
fillField
(
'input[name="LoginForm[password]"]'
,
'admin'
);
$I
->
click
(
'login-button'
);
$I
->
wait
(
2
);
// wait for button to be clicked
$I
->
expectTo
(
'see user info'
);
$I
->
see
(
'Logout'
);
}
}
online_voting_system_FINAL_06/tests/acceptance/_bootstrap.php
0 → 100644
View file @
e5104d0e
<?php
online_voting_system_FINAL_06/tests/bin/yii
0 → 100644
View file @
e5104d0e
#!/usr/bin/env php
<?php
/**
* Yii console bootstrap file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
defined
(
'YII_DEBUG'
)
or
define
(
'YII_DEBUG'
,
true
);
defined
(
'YII_ENV'
)
or
define
(
'YII_ENV'
,
'test'
);
require
__DIR__
.
'/../../vendor/autoload.php'
;
require
__DIR__
.
'/../../vendor/yiisoft/yii2/Yii.php'
;
$config
=
yii\helpers\ArrayHelper
::
merge
(
require
__DIR__
.
'/../../config/console.php'
,
[
'components'
=>
[
'db'
=>
require
__DIR__
.
'/../../config/test_db.php'
]
]
);
$application
=
new
yii\console\Application
(
$config
);
$exitCode
=
$application
->
run
();
exit
(
$exitCode
);
online_voting_system_FINAL_06/tests/bin/yii.bat
0 → 100644
View file @
e5104d0e
@echo off
rem -------------------------------------------------------------
rem Yii command line bootstrap script for Windows.
rem
rem @author Qiang Xue <qiang.xue@gmail.com>
rem @link http://www.yiiframework.com/
rem @copyright Copyright (c) 2008 Yii Software LLC
rem @license http://www.yiiframework.com/license/
rem -------------------------------------------------------------
@setlocal
set YII_PATH=%~dp0
if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe
"%PHP_COMMAND%" "%YII_PATH%yii" %*
@endlocal
online_voting_system_FINAL_06/tests/functional.suite.yml
0 → 100644
View file @
e5104d0e
# Codeception Test Suite Configuration
# suite for functional (integration) tests.
# emulate web requests and make application process them.
# (tip: better to use with frameworks).
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
#basic/web/index.php
class_name
:
FunctionalTester
modules
:
enabled
:
-
Filesystem
-
Yii2
online_voting_system_FINAL_06/tests/functional/ContactFormCest.php
0 → 100644
View file @
e5104d0e
<?php
class
ContactFormCest
{
public
function
_before
(
\FunctionalTester
$I
)
{
$I
->
amOnPage
([
'site/contact'
]);
}
public
function
openContactPage
(
\FunctionalTester
$I
)
{
$I
->
see
(
'Contact'
,
'h1'
);
}
public
function
submitEmptyForm
(
\FunctionalTester
$I
)
{
$I
->
submitForm
(
'#contact-form'
,
[]);
$I
->
expectTo
(
'see validations errors'
);
$I
->
see
(
'Contact'
,
'h1'
);
$I
->
see
(
'Name cannot be blank'
);
$I
->
see
(
'Email cannot be blank'
);
$I
->
see
(
'Subject cannot be blank'
);
$I
->
see
(
'Body cannot be blank'
);
$I
->
see
(
'The verification code is incorrect'
);
}
public
function
submitFormWithIncorrectEmail
(
\FunctionalTester
$I
)
{
$I
->
submitForm
(
'#contact-form'
,
[
'ContactForm[name]'
=>
'tester'
,
'ContactForm[email]'
=>
'tester.email'
,
'ContactForm[subject]'
=>
'test subject'
,
'ContactForm[body]'
=>
'test content'
,
'ContactForm[verifyCode]'
=>
'testme'
,
]);
$I
->
expectTo
(
'see that email address is wrong'
);
$I
->
dontSee
(
'Name cannot be blank'
,
'.help-inline'
);
$I
->
see
(
'Email is not a valid email address.'
);
$I
->
dontSee
(
'Subject cannot be blank'
,
'.help-inline'
);
$I
->
dontSee
(
'Body cannot be blank'
,
'.help-inline'
);
$I
->
dontSee
(
'The verification code is incorrect'
,
'.help-inline'
);
}
public
function
submitFormSuccessfully
(
\FunctionalTester
$I
)
{
$I
->
submitForm
(
'#contact-form'
,
[
'ContactForm[name]'
=>
'tester'
,
'ContactForm[email]'
=>
'tester@example.com'
,
'ContactForm[subject]'
=>
'test subject'
,
'ContactForm[body]'
=>
'test content'
,
'ContactForm[verifyCode]'
=>
'testme'
,
]);
$I
->
seeEmailIsSent
();
$I
->
dontSeeElement
(
'#contact-form'
);
$I
->
see
(
'Thank you for contacting us. We will respond to you as soon as possible.'
);
}
}
online_voting_system_FINAL_06/tests/functional/LoginFormCest.php
0 → 100644
View file @
e5104d0e
<?php
class
LoginFormCest
{
public
function
_before
(
\FunctionalTester
$I
)
{
$I
->
amOnRoute
(
'site/login'
);
}
public
function
openLoginPage
(
\FunctionalTester
$I
)
{
$I
->
see
(
'Login'
,
'h1'
);
}
// demonstrates `amLoggedInAs` method
public
function
internalLoginById
(
\FunctionalTester
$I
)
{
$I
->
amLoggedInAs
(
100
);
$I
->
amOnPage
(
'/'
);
$I
->
see
(
'Logout (admin)'
);
}
// demonstrates `amLoggedInAs` method
public
function
internalLoginByInstance
(
\FunctionalTester
$I
)
{
$I
->
amLoggedInAs
(
\app\models\User
::
findByUsername
(
'admin'
));
$I
->
amOnPage
(
'/'
);
$I
->
see
(
'Logout (admin)'
);
}
public
function
loginWithEmptyCredentials
(
\FunctionalTester
$I
)
{
$I
->
submitForm
(
'#login-form'
,
[]);
$I
->
expectTo
(
'see validations errors'
);
$I
->
see
(
'Username cannot be blank.'
);
$I
->
see
(
'Password cannot be blank.'
);
}
public
function
loginWithWrongCredentials
(
\FunctionalTester
$I
)
{
$I
->
submitForm
(
'#login-form'
,
[
'LoginForm[username]'
=>
'admin'
,
'LoginForm[password]'
=>
'wrong'
,
]);
$I
->
expectTo
(
'see validations errors'
);
$I
->
see
(
'Incorrect username or password.'
);
}
public
function
loginSuccessfully
(
\FunctionalTester
$I
)
{
$I
->
submitForm
(
'#login-form'
,
[
'LoginForm[username]'
=>
'admin'
,
'LoginForm[password]'
=>
'admin'
,
]);
$I
->
see
(
'Logout (admin)'
);
$I
->
dontSeeElement
(
'form#login-form'
);
}
}
\ No newline at end of file
online_voting_system_FINAL_06/tests/functional/_bootstrap.php
0 → 100644
View file @
e5104d0e
<?php
online_voting_system_FINAL_06/tests/unit.suite.yml
0 → 100644
View file @
e5104d0e
# Codeception Test Suite Configuration
# suite for unit (internal) tests.
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
class_name
:
UnitTester
modules
:
enabled
:
-
Asserts
-
Yii2
:
part
:
[
orm
,
email
,
fixtures
]
online_voting_system_FINAL_06/tests/unit/_bootstrap.php
0 → 100644
View file @
e5104d0e
<?php
// add unit testing specific bootstrap code here
online_voting_system_FINAL_06/tests/unit/models/ContactFormTest.php
0 → 100644
View file @
e5104d0e
<?php
namespace
tests\unit\models
;
use
app\models\ContactForm
;
use
yii\mail\MessageInterface
;
class
ContactFormTest
extends
\Codeception\Test\Unit
{
private
$model
;
/**
* @var \UnitTester
*/
public
$tester
;
public
function
testEmailIsSentOnContact
()
{
/** @var ContactForm $model */
$this
->
model
=
$this
->
getMockBuilder
(
'app\models\ContactForm'
)
->
setMethods
([
'validate'
])
->
getMock
();
$this
->
model
->
expects
(
$this
->
once
())
->
method
(
'validate'
)
->
willReturn
(
true
);
$this
->
model
->
attributes
=
[
'name'
=>
'Tester'
,
'email'
=>
'tester@example.com'
,
'subject'
=>
'very important letter subject'
,
'body'
=>
'body of current message'
,
];
expect_that
(
$this
->
model
->
contact
(
'admin@example.com'
));
// using Yii2 module actions to check email was sent
$this
->
tester
->
seeEmailIsSent
();
/** @var MessageInterface $emailMessage */
$emailMessage
=
$this
->
tester
->
grabLastSentEmail
();
expect
(
'valid email is sent'
,
$emailMessage
)
->
isInstanceOf
(
'yii\mail\MessageInterface'
);
expect
(
$emailMessage
->
getTo
())
->
hasKey
(
'admin@example.com'
);
expect
(
$emailMessage
->
getFrom
())
->
hasKey
(
'noreply@example.com'
);
expect
(
$emailMessage
->
getReplyTo
())
->
hasKey
(
'tester@example.com'
);
expect
(
$emailMessage
->
getSubject
())
->
equals
(
'very important letter subject'
);
expect
(
$emailMessage
->
toString
())
->
stringContainsString
(
'body of current message'
);
}
}
online_voting_system_FINAL_06/tests/unit/models/LoginFormTest.php
0 → 100644
View file @
e5104d0e
<?php
namespace
tests\unit\models
;
use
app\models\LoginForm
;
class
LoginFormTest
extends
\Codeception\Test\Unit
{
private
$model
;
protected
function
_after
()
{
\Yii
::
$app
->
user
->
logout
();
}
public
function
testLoginNoUser
()
{
$this
->
model
=
new
LoginForm
([
'username'
=>
'not_existing_username'
,
'password'
=>
'not_existing_password'
,
]);
expect_not
(
$this
->
model
->
login
());
expect_that
(
\Yii
::
$app
->
user
->
isGuest
);
}
public
function
testLoginWrongPassword
()
{
$this
->
model
=
new
LoginForm
([
'username'
=>
'demo'
,
'password'
=>
'wrong_password'
,
]);
expect_not
(
$this
->
model
->
login
());
expect_that
(
\Yii
::
$app
->
user
->
isGuest
);
expect
(
$this
->
model
->
errors
)
->
hasKey
(
'password'
);
}
public
function
testLoginCorrect
()
{
$this
->
model
=
new
LoginForm
([
'username'
=>
'demo'
,
'password'
=>
'demo'
,
]);
expect_that
(
$this
->
model
->
login
());
expect_not
(
\Yii
::
$app
->
user
->
isGuest
);
expect
(
$this
->
model
->
errors
)
->
hasntKey
(
'password'
);
}
}
online_voting_system_FINAL_06/tests/unit/models/UserTest.php
0 → 100644
View file @
e5104d0e
<?php
namespace
tests\unit\models
;
use
app\models\User
;
class
UserTest
extends
\Codeception\Test\Unit
{
public
function
testFindUserById
()
{
expect_that
(
$user
=
User
::
findIdentity
(
100
));
expect
(
$user
->
username
)
->
equals
(
'admin'
);
expect_not
(
User
::
findIdentity
(
999
));
}
public
function
testFindUserByAccessToken
()
{
expect_that
(
$user
=
User
::
findIdentityByAccessToken
(
'100-token'
));
expect
(
$user
->
username
)
->
equals
(
'admin'
);
expect_not
(
User
::
findIdentityByAccessToken
(
'non-existing'
));
}
public
function
testFindUserByUsername
()
{
expect_that
(
$user
=
User
::
findByUsername
(
'admin'
));
expect_not
(
User
::
findByUsername
(
'not-admin'
));
}
/**
* @depends testFindUserByUsername
*/
public
function
testValidateUser
(
$user
)
{
$user
=
User
::
findByUsername
(
'admin'
);
expect_that
(
$user
->
validateAuthKey
(
'test100key'
));
expect_not
(
$user
->
validateAuthKey
(
'test102key'
));
expect_that
(
$user
->
validatePassword
(
'admin'
));
expect_not
(
$user
->
validatePassword
(
'123456'
));
}
}
online_voting_system_FINAL_06/vagrant/config/.gitignore
0 → 100644
View file @
e5104d0e
# local configuration
vagrant-local.yml
\ No newline at end of file
online_voting_system_FINAL_06/vagrant/config/vagrant-local.example.yml
0 → 100644
View file @
e5104d0e
# Your personal GitHub token
github_token
:
<your-personal-github-token>
# Read more: https://github.com/blog/1509-personal-api-tokens
# You can generate it here: https://github.com/settings/tokens
# Guest OS timezone
timezone
:
Europe/London
# Are we need check box updates for every 'vagrant up'?
box_check_update
:
false
# Virtual machine name
machine_name
:
yii2basic
# Virtual machine IP
ip
:
192.168.83.137
# Virtual machine CPU cores number
cpus
:
1
# Virtual machine RAM
memory
:
1024
online_voting_system_FINAL_06/vagrant/nginx/app.conf
0 → 100644
View file @
e5104d0e
server
{
charset
utf
-
8
;
client_max_body_size
128
M
;
sendfile
off
;
listen
80
;
## listen for ipv4
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
server_name
yii2basic
.
test
;
root
/
app
/
web
/;
index
index
.
php
;
access_log
/
app
/
vagrant
/
nginx
/
log
/
yii2basic
.
access
.
log
;
error_log
/
app
/
vagrant
/
nginx
/
log
/
yii2basic
.
error
.
log
;
location
/ {
# Redirect everything that isn't a real file to index.php
try_files
$
uri
$
uri
/ /
index
.
php
$
is_args
$
args
;
}
# uncomment to avoid processing of calls to non-existing static files by Yii
#location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
# try_files $uri =404;
#}
#error_page 404 /404.html;
location
~ \.
php
$ {
include
fastcgi_params
;
fastcgi_param
SCRIPT_FILENAME
$
document_root
$
fastcgi_script_name
;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass
unix
:/
var
/
run
/
php
/
php7
.
0
-
fpm
.
sock
;
try_files
$
uri
=
404
;
}
location
~ /\.(
ht
|
svn
|
git
) {
deny
all
;
}
}
online_voting_system_FINAL_06/vagrant/nginx/log/.gitignore
0 → 100644
View file @
e5104d0e
#nginx logs
yii2basic.access.log
yii2basic.error.log
\ No newline at end of file
online_voting_system_FINAL_06/vagrant/provision/always-as-root.sh
0 → 100644
View file @
e5104d0e
#!/usr/bin/env bash
#== Bash helpers ==
function
info
{
echo
" "
echo
"-->
$1
"
echo
" "
}
#== Provision script ==
info
"Provision-script user:
`
whoami
`
"
info
"Restart web-stack"
service php7.0-fpm restart
service nginx restart
service mysql restart
\ No newline at end of file
online_voting_system_FINAL_06/vagrant/provision/once-as-root.sh
0 → 100644
View file @
e5104d0e
#!/usr/bin/env bash
#== Import script args ==
timezone
=
$(
echo
"
$1
"
)
#== Bash helpers ==
function
info
{
echo
" "
echo
"-->
$1
"
echo
" "
}
#== Provision script ==
info
"Provision-script user:
`
whoami
`
"
export
DEBIAN_FRONTEND
=
noninteractive
info
"Configure timezone"
timedatectl set-timezone
${
timezone
}
--no-ask-password
info
"Prepare root password for MySQL"
debconf-set-selections
<<<
"mariadb-server-10.0 mysql-server/root_password password
\"
''
\"
"
debconf-set-selections
<<<
"mariadb-server-10.0 mysql-server/root_password_again password
\"
''
\"
"
echo
"Done!"
info
"Update OS software"
apt-get update
apt-get upgrade
-y
info
"Install additional software"
apt-get
install
-y
php7.0-curl php7.0-cli php7.0-intl php7.0-mysqlnd php7.0-gd php7.0-fpm php7.0-mbstring php7.0-xml unzip nginx mariadb-server-10.0 php.xdebug
info
"Configure MySQL"
sed
-i
"s/.*bind-address.*/bind-address = 0.0.0.0/"
/etc/mysql/mariadb.conf.d/50-server.cnf
mysql
-uroot
<<<
"CREATE USER 'root'@'%' IDENTIFIED BY ''"
mysql
-uroot
<<<
"GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'"
mysql
-uroot
<<<
"DROP USER 'root'@'localhost'"
mysql
-uroot
<<<
"FLUSH PRIVILEGES"
echo
"Done!"
info
"Configure PHP-FPM"
sed
-i
's/user = www-data/user = vagrant/g'
/etc/php/7.0/fpm/pool.d/www.conf
sed
-i
's/group = www-data/group = vagrant/g'
/etc/php/7.0/fpm/pool.d/www.conf
sed
-i
's/owner = www-data/owner = vagrant/g'
/etc/php/7.0/fpm/pool.d/www.conf
cat
<<
EOF
> /etc/php/7.0/mods-available/xdebug.ini
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_connect_back=1
xdebug.remote_port=9000
xdebug.remote_autostart=1
EOF
echo
"Done!"
info
"Configure NGINX"
sed
-i
's/user www-data/user vagrant/g'
/etc/nginx/nginx.conf
echo
"Done!"
info
"Enabling site configuration"
ln
-s
/app/vagrant/nginx/app.conf /etc/nginx/sites-enabled/app.conf
echo
"Done!"
info
"Removing default site configuration"
rm
/etc/nginx/sites-enabled/default
echo
"Done!"
info
"Initailize databases for MySQL"
mysql
-uroot
<<<
"CREATE DATABASE yii2basic"
mysql
-uroot
<<<
"CREATE DATABASE yii2basic_test"
echo
"Done!"
info
"Install composer"
curl
-sS
https://getcomposer.org/installer | php
--
--install-dir
=
/usr/local/bin
--filename
=
composer
\ No newline at end of file
online_voting_system_FINAL_06/vagrant/provision/once-as-vagrant.sh
0 → 100644
View file @
e5104d0e
#!/usr/bin/env bash
#== Import script args ==
github_token
=
$(
echo
"
$1
"
)
#== Bash helpers ==
function
info
{
echo
" "
echo
"-->
$1
"
echo
" "
}
#== Provision script ==
info
"Provision-script user:
`
whoami
`
"
info
"Configure composer"
composer config
--global
github-oauth.github.com
${
github_token
}
echo
"Done!"
info
"Install project dependencies"
cd
/app
composer
--no-progress
--prefer-dist
install
info
"Create bash-alias 'app' for vagrant user"
echo
'alias app="cd /app"'
|
tee
/home/vagrant/.bash_aliases
info
"Enabling colorized prompt for guest console"
sed
-i
"s/#force_color_prompt=yes/force_color_prompt=yes/"
/home/vagrant/.bashrc
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment