@@ -20,9 +20,9 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | namespace OCA\Security\Tests\Controller; |
| 22 | 22 | |
| 23 | -use OCA\Security\Controller\SettingsController; |
|
| 24 | -use OCA\Security\SecurityConfig; |
|
| 25 | -use OCP\IRequest; |
|
| 23 | +use OCA\Security\Controller\SettingsController; |
|
| 24 | +use OCA\Security\SecurityConfig; |
|
| 25 | +use OCP\IRequest; |
|
| 26 | 26 | use Test\TestCase; |
| 27 | 27 | |
| 28 | 28 | class SettingsControllerTest extends TestCase {
|
@@ -19,10 +19,10 @@ |
||
| 19 | 19 | * |
| 20 | 20 | */ |
| 21 | 21 | namespace OCA\Password_Policy\Tests; |
| 22 | -use OC\HintException; |
|
| 23 | -use OCA\Security\SecurityConfig; |
|
| 24 | -use OCA\Security\PasswordValidator; |
|
| 25 | -use OCP\IL10N; |
|
| 22 | +use OC\HintException; |
|
| 23 | +use OCA\Security\SecurityConfig; |
|
| 24 | +use OCA\Security\PasswordValidator; |
|
| 25 | +use OCP\IL10N; |
|
| 26 | 26 | use Test\TestCase; |
| 27 | 27 | class PasswordValidatorTest extends TestCase {
|
| 28 | 28 | |
@@ -23,9 +23,9 @@ |
||
| 23 | 23 | } |
| 24 | 24 | require_once __DIR__.'/../../../lib/base.php'; |
| 25 | 25 | |
| 26 | -OC::$composerAutoloader->addPsr4('Test\\', OC::$SERVERROOT . '/tests/lib', true);
|
|
| 26 | +OC::$composerAutoloader->addPsr4('Test\\', OC::$SERVERROOT.'/tests/lib', true);
|
|
| 27 | 27 | |
| 28 | -if(!class_exists('PHPUnit_Framework_TestCase')) {
|
|
| 28 | +if (!class_exists('PHPUnit_Framework_TestCase')) {
|
|
| 29 | 29 | require_once('PHPUnit/Autoload.php');
|
| 30 | 30 | } |
| 31 | 31 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | use OC\HintException; |
| 23 | 23 | use OCP\IL10N; |
| 24 | 24 | |
| 25 | -class PasswordValidator {
|
|
| 25 | +class PasswordValidator {
|
|
| 26 | 26 | |
| 27 | 27 | /** @var SecurityConfig */ |
| 28 | 28 | protected $config; |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function checkPasswordLength($password) {
|
| 64 | 64 | $minPassLength = $this->config->getMinPasswordLength(); |
| 65 | - if(strlen($password) < $minPassLength) {
|
|
| 66 | - $message = 'Password needs to be at least ' . $minPassLength . ' characters long'; |
|
| 65 | + if (strlen($password) < $minPassLength) {
|
|
| 66 | + $message = 'Password needs to be at least '.$minPassLength.' characters long'; |
|
| 67 | 67 | $hint = $this->l->t( |
| 68 | 68 | 'Password needs to be at least %s characters long', [$minPassLength] |
| 69 | 69 | ); |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | * @throws HintException |
| 79 | 79 | */ |
| 80 | 80 | public function checkUpperLowerCase($password) {
|
| 81 | - $enforceUpperLowerCase= $this->config->getIsUpperLowerCaseEnforced(); |
|
| 82 | - if($enforceUpperLowerCase === true && $this->hasUpperAndLowerCase($password) === false) {
|
|
| 81 | + $enforceUpperLowerCase = $this->config->getIsUpperLowerCaseEnforced(); |
|
| 82 | + if ($enforceUpperLowerCase === true && $this->hasUpperAndLowerCase($password) === false) {
|
|
| 83 | 83 | $message = 'Password should contain at least one upper and one lower case character.'; |
| 84 | 84 | $hint = $this->l->t( |
| 85 | 85 | 'Password should contain at least one upper and one lower case character.' |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | public function checkNumericCharacters($password) {
|
| 98 | 98 | $enforceNumericCharacters = $this->config->getIsNumericCharactersEnforced(); |
| 99 | - if($enforceNumericCharacters === true && $this->hasNumericalCharacters($password) === false) {
|
|
| 99 | + if ($enforceNumericCharacters === true && $this->hasNumericalCharacters($password) === false) {
|
|
| 100 | 100 | $message = 'Password should contain at least one numerical character.'; |
| 101 | 101 | $hint = $this->l->t( |
| 102 | 102 | 'Password should contain at least one numerical character.' |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function checkSpecialCharacters($password) {
|
| 115 | 115 | $enforceSpecialCharacters = $this->config->getIsSpecialCharactersEnforced(); |
| 116 | - if($enforceSpecialCharacters === true && $this->hasSpecialCharacter($password) === false) {
|
|
| 116 | + if ($enforceSpecialCharacters === true && $this->hasSpecialCharacter($password) === false) {
|
|
| 117 | 117 | $message = 'Password should contain at least one special character.'; |
| 118 | 118 | $hint = $this->l->t( |
| 119 | 119 | 'Password should contain at least one special character.' |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | |
| 32 | 32 | class Application extends App {
|
| 33 | 33 | |
| 34 | - public function __construct(array $urlParams=array()){
|
|
| 34 | + public function __construct(array $urlParams = array()) {
|
|
| 35 | 35 | parent::__construct('security', $urlParams);
|
| 36 | 36 | |
| 37 | 37 | $container = $this->getContainer(); |
@@ -20,8 +20,8 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | namespace OCA\Security\Tests; |
| 22 | 22 | |
| 23 | -use OCA\Security\SecurityConfig; |
|
| 24 | -use OCP\IConfig; |
|
| 23 | +use OCA\Security\SecurityConfig; |
|
| 24 | +use OCP\IConfig; |
|
| 25 | 25 | use Test\TestCase; |
| 26 | 26 | class SecurityConfigTest extends TestCase {
|
| 27 | 27 | /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */ |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | * @param PasswordValidator $passValidator |
| 56 | 56 | * @param EventDispatcherInterface $dispatcher |
| 57 | 57 | */ |
| 58 | - public function __construct($userManager, $throttle, $request, $passValidator, $dispatcher){ |
|
| 58 | + public function __construct($userManager, $throttle, $request, $passValidator, $dispatcher) { |
|
| 59 | 59 | $this->userManager = $userManager; |
| 60 | 60 | $this->throttle = $throttle; |
| 61 | 61 | $this->request = $request; |
@@ -25,15 +25,15 @@ |
||
| 25 | 25 | ?> |
| 26 | 26 | <div id="password-policies" class="hidden"> |
| 27 | 27 | <?php print_unescaped( |
| 28 | - "<p>". $l->t('Passwords must:'). "</p>");?>
|
|
| 28 | + "<p>".$l->t('Passwords must:')."</p>"); ?>
|
|
| 29 | 29 | <ul class="pass-info"> |
| 30 | 30 | <?php print_unescaped( |
| 31 | - "<li class='pass-info-element'>". $l->t('be at least %s characters long ', $_['minPasswordLength']). "</li>");?>
|
|
| 31 | + "<li class='pass-info-element'>".$l->t('be at least %s characters long ', $_['minPasswordLength'])."</li>"); ?>
|
|
| 32 | 32 | <?php if ($_['isUpperLowerCaseEnforced']) print_unescaped( |
| 33 | - "<li class='pass-info-element'>". $l->t('contain at least one uppercase letter and at least one lowercase letter '). "</li>");?>
|
|
| 33 | + "<li class='pass-info-element'>".$l->t('contain at least one uppercase letter and at least one lowercase letter ')."</li>"); ?>
|
|
| 34 | 34 | <?php if ($_['isNumericalCharsEnforced']) print_unescaped( |
| 35 | - "<li class='pass-info-element'>". $l->t('contain at least one numerical character'). "</li>");?>
|
|
| 35 | + "<li class='pass-info-element'>".$l->t('contain at least one numerical character')."</li>"); ?>
|
|
| 36 | 36 | <?php if ($_['isSpecialCharsEnforced']) print_unescaped( |
| 37 | - "<li class='pass-info-element'>". $l->t('contain at least one special character'). "</li>");?>
|
|
| 37 | + "<li class='pass-info-element'>".$l->t('contain at least one special character')."</li>"); ?>
|
|
| 38 | 38 | </ul> |
| 39 | 39 | </div> |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | <input type="number" id="security-bfp-fail-tolerance" value="<?php p($_['bruteForceProtectionFailTolerance']) ?>"><br> |
| 33 | 33 | <label for="security-bfp-ban-period"><?php p($l->t('Ban for how many seconds?')) ?></label><br>
|
| 34 | 34 | <input type="number" id="security-bfp-ban-period" value="<?php p($_['bruteForceProtectionBanPeriod']) ?>"><br> |
| 35 | - <button id="save-bfp-settings" class="save"><?php p($l->t('Save settings'));?></button>
|
|
| 35 | + <button id="save-bfp-settings" class="save"><?php p($l->t('Save settings')); ?></button>
|
|
| 36 | 36 | </div> |
| 37 | 37 | </div> |
| 38 | 38 | <div id="security-password-policy" class="section"> |
@@ -40,22 +40,22 @@ discard block |
||
| 40 | 40 | <div> |
| 41 | 41 | <label for="security-min-password-length"><?php p($l->t('Determine minimum password length')) ?></label>
|
| 42 | 42 | <input type="number" id="security-min-password-length" min="6" value="<?php p($_['minPasswordLength']) ?>"> |
| 43 | - <button id="save-pass-length" class="save"><?php p($l->t('Save length'));?></button>
|
|
| 43 | + <button id="save-pass-length" class="save"><?php p($l->t('Save length')); ?></button>
|
|
| 44 | 44 | <span id="security-min-password-length-message" class="msg"></span> |
| 45 | 45 | </div> |
| 46 | 46 | <div> |
| 47 | 47 | <input type="checkbox" class="checkbox" id="security-enforce-upper-lower-case" |
| 48 | - <?php if ($_['isUpperLowerCaseEnforced']) p("checked");?> >
|
|
| 48 | + <?php if ($_['isUpperLowerCaseEnforced']) p("checked"); ?> >
|
|
| 49 | 49 | <label for="security-enforce-upper-lower-case"><?php p($l->t('Enforce at least one upper and one lower case character on passwords')) ?></label>
|
| 50 | 50 | </div> |
| 51 | 51 | <div> |
| 52 | 52 | <input type="checkbox" class="checkbox" id="security-enforce-numerical-characters" |
| 53 | - <?php if ($_['isNumericalCharsEnforced']) p("checked");?> >
|
|
| 53 | + <?php if ($_['isNumericalCharsEnforced']) p("checked"); ?> >
|
|
| 54 | 54 | <label for="security-enforce-numerical-characters"><?php p($l->t('Enforce at least one numerical characters on passwords')) ?></label>
|
| 55 | 55 | </div> |
| 56 | 56 | <div> |
| 57 | 57 | <input type="checkbox" class="checkbox" id="security-enforce-special-characters" |
| 58 | - <?php if ($_['isSpecialCharsEnforced']) p("checked");?> >
|
|
| 58 | + <?php if ($_['isSpecialCharsEnforced']) p("checked"); ?> >
|
|
| 59 | 59 | <label for="security-enforce-special-characters"><?php p($l->t('Enforce at least one special characters on passwords')) ?></label>
|
| 60 | 60 | </div> |
| 61 | 61 | </div> |
| 62 | 62 | \ No newline at end of file |