From 1461cf6d658250017d20bb8cc48536c187f63403 Mon Sep 17 00:00:00 2001 From: Midah Pasche Date: Thu, 6 Oct 2022 15:37:16 +0200 Subject: [PATCH 1/3] added Fallback driver --- lib/Horde/Auth/Fallback.php | 237 ++++++++++++++++++++++++++++++++++++ 1 file changed, 237 insertions(+) create mode 100644 lib/Horde/Auth/Fallback.php diff --git a/lib/Horde/Auth/Fallback.php b/lib/Horde/Auth/Fallback.php new file mode 100644 index 0000000..4609561 --- /dev/null +++ b/lib/Horde/Auth/Fallback.php @@ -0,0 +1,237 @@ + + * @category Horde + * @license http://www.horde.org/licenses/lgpl21 LGPL-2.1 + * @package Auth + */ +/** + * The Horde_Auth_Fallback class provides a way to combine two separate + * drivers for failover and legacy support cases, for example + * using ldap, but falling back to a local database + * To the user, this driver presents the combined, unique users of both backends + * Only the primary driver allows adding, editing and removing users. + * + * @author Ralf Lang + * @category Horde + * @license http://www.horde.org/licenses/lgpl21 LGPL-2.1 + * @package Auth + */ +class Horde_Auth_Fallback extends Horde_Auth_Base +{ + /** + * Constructor. + * + * @param array $params Required parameters: + *
+     * 'primary_driver' - (Horde_Auth_Base) The primary driver.
+     * 'fallback_driver' - (Horde_Auth_Base) The auth driver.
+     * 'capabilities' -  (array) Keys each 'adduser', 'removeuser', 'updateuser', 'listusers', 'resetpassword'
+     *                   Values "both", "primary", "fallback", "none"
+     *                   See method doc for "both" case on resetpassword and listusers
+     *                   Also overrides capabilities exposed
+     * 
+ * + * @throws InvalidArgumentException + */ + public function __construct(array $params = array()) + { + foreach (array('primary_driver', 'fallback_driver', 'capabilities') as $val) { + if (!isset($params[$val])) { + throw new InvalidArgumentException('Missing ' . $val . ' parameter.'); + } + } + parent::__construct($params); + } + /** + * Find out if a set of login credentials are valid. + * + * @param string $userId The userId to check. + * @param array $credentials The credentials to use. + * + * @throws Horde_Auth_Exception + */ + protected function _authenticate($userId, $credentials) + { + if (!$this->_params['primary_driver']->authenticate($userId, $credentials) && !$this->_params['fallback_driver']->authenticate($userId, $credentials)) { + throw new Horde_Auth_Exception($this->_params['primary_driver']->getError(true), $this->_params['primary_driver']->getError()); + } + } + /** + * Trust user-supplied capabilities for writing operations. Else, + * Query the primary Auth object to find out if it supports the given + * capability. + * + * @param string $capability The capability to test for. + * + * @return boolean Whether or not the capability is supported. + */ + public function hasCapability($capability) + { + $lcCapability = strtolower($capability); + switch ($lcCapability) { + case 'adduser': + case 'removeuser': + case 'updateuser': + case 'listusers': + case 'resetpassword': + if (!empty($this->_params['capabilities'][$lcCapability])) { + return ($this->_params['capabilities'][$lcCapability] == 'none') ? false : true; + } + break; + } + + try { + return $this->_params['primary_driver']->hasCapability($capability); + } catch (Horde_Auth_Exception $e) { + return false; + } + } + /** + * Automatic authentication. + * + * @return boolean Whether or not the client is allowed. + */ + public function transparent() + { + try { + return $this->_params['primary_driver']->transparent() || $this->_params['fallback_driver']->transparent(); + } catch (Horde_Auth_Exception $e) { + return false; + } + } + /** + * Add a set of authentication credentials. + * + * @param string $userId The userId to add. + * @param array $credentials The credentials to use. + * + * @throws Horde_Auth_Exception + */ + public function addUser($userId, $credentials) + { + if (($this->_params['capabilities']['adduser'] == 'both') || + ($this->_params['capabilities']['adduser'] == 'primary') + ) { + $this->_params['primary_driver']->addUser($userId, $credentials); + } + if (($this->_params['capabilities']['adduser'] == 'both') || + ($this->_params['capabilities']['adduser'] == 'fallback') + ) { + $this->_params['fallback_driver']->addUser($userId, $credentials); + } + } + /** + * Update a set of authentication credentials. + * + * @param string $oldID The old userId. + * @param string $newID The new userId. + * @param array $credentials The new credentials + * + * @throws Horde_Auth_Exception + */ + public function updateUser($oldID, $newID, $credentials) + { + if (($this->_params['capabilities']['updateuser'] == 'both') || + ($this->_params['capabilities']['updateuser'] == 'primary') + ) { + $this->_params['primary_driver']->updateUser($oldID, $newID, $credentials); + } + if (($this->_params['capabilities']['updateuser'] == 'both') || + ($this->_params['capabilities']['updateuser'] == 'fallback') + ) { + $this->_params['fallback_driver']->updateUser($oldID, $newID, $credentials); + } + } + /** + * Reset a user's password. Used for example when the user does not + * remember the existing password. + * For "both" mode, only the primary backend's generation method is used + * Secondary backend will perform an "update" instead with the password + * + * @param string $userId The user id for which to reset the password. + * + * @return string The new password on success. + * @throws Horde_Auth_Exception + */ + public function resetPassword($userId) + { + $password = null; + if (($this->_params['capabilities']['resetpassword'] == 'both') || + ($this->_params['capabilities']['resetpassword'] == 'primary') + ) { + $password = $this->_params['primary_driver']->resetPassword($userId); + } + if ($this->_params['capabilities']['resetpassword'] == 'both') { + $this->_params['fallback_driver']->updateUser($userId, $userId, array('password' => $password)); + } + if ($this->_params['capabilities']['resetpassword'] == 'fallback') { + $password = $this->_params['fallback_driver']->resetPassword($userId); + } + return $password; + } + /** + * Delete a set of authentication credentials. + * + * @param string $userId The userId to delete. + * + * @throws Horde_Auth_Exception + */ + public function removeUser($userId) + { + if (($this->_params['capabilities']['removeuser'] == 'both') || + ($this->_params['capabilities']['removeuser'] == 'primary') + ) { + $this->_params['primary_driver']->removeUser($userId); + } + if (($this->_params['capabilities']['removeuser'] == 'both') || + ($this->_params['capabilities']['removeuser'] == 'fallback') + ) { + $this->_params['fallback_driver']->removeUser($userId); + } + } + /** + * Lists all users in the system. + * + * @param boolean $sort Sort the users? + * + * @return array The array of userIds. + * @throws Horde_Auth_Exception + */ + public function listUsers($sort = false) + { + if ($this->_params['capabilities']['listusers'] == 'primary') { + return $this->_params['primary_driver']->listUsers($sort); + } + if ($this->_params['capabilities']['listusers'] == 'fallback') { + return $this->_params['fallback_driver']->listUsers($sort); + } + if ($this->_params['capabilities']['listusers'] == 'none') { + return array(); + } + // In most cases, having the driver's native sort before the composite sort should not hurt performance + $res = array_unique(array_merge($this->_params['primary_driver']->listUsers($sort), $this->_params['fallback_driver']->listUsers($sort))); + return ($sort) ? sort($res) : $res; + } + /** + * Checks if a userId exists in the system. + * + * @param string $userId User ID to check + * + * @return boolean Whether or not the userId already exists. + */ + public function exists($userId) + { + try { + return $this->_params['primary_driver']->exists($userId) || $this->_params['fallback_driver']->exists($userId); + } catch (Horde_Auth_Exception $e) { + return false; + } + } +} From 8acfafb07a70e0c1e37c1ba8ed10d9923b030f16 Mon Sep 17 00:00:00 2001 From: Midah Pasche Date: Mon, 3 Feb 2025 09:34:50 +0100 Subject: [PATCH 2/3] allow to use 'authenticate' without logging in --- lib/Horde/Auth/Base.php | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/Horde/Auth/Base.php b/lib/Horde/Auth/Base.php index 2bfe017..59e6b8e 100644 --- a/lib/Horde/Auth/Base.php +++ b/lib/Horde/Auth/Base.php @@ -148,8 +148,11 @@ public function authenticate($userId, $credentials, $login = true) try { $this->_credentials['userId'] = $userId; - if (($this->hasCapability('lock')) && - $this->isLocked($userId)) { + if ( + $login + && $this->hasCapability('lock') + && $this->isLocked($userId) + ) { $details = $this->isLocked($userId, true); if ($details['lock_timeout'] == Horde_Lock::PERMANENT) { $message = Horde_Auth_Translation::t("Your account has been permanently locked"); @@ -159,6 +162,10 @@ public function authenticate($userId, $credentials, $login = true) throw new Horde_Auth_Exception($message, Horde_Auth::REASON_LOCKED); } $this->_authenticate($userId, $credentials); + if (!$login) { + $this->_credentials['userId'] = null; + return true; + } $this->setCredential('userId', $this->_credentials['userId']); $this->setCredential('credentials', $credentials); if ($this->hasCapability('badlogincount')) { @@ -166,16 +173,15 @@ public function authenticate($userId, $credentials, $login = true) } return true; } catch (Horde_Auth_Exception $e) { - if (($code = $e->getCode()) && - $code != Horde_Auth::REASON_MESSAGE) { - if (($code == Horde_Auth::REASON_BADLOGIN) && - $this->hasCapability('badlogincount')) { - $this->_badLogin($userId); - } - $this->setError($code, $e->getMessage()); - } else { - $this->setError(Horde_Auth::REASON_MESSAGE, $e->getMessage()); + $code = $e->getCode() ?: Horde_Auth::REASON_MESSAGE; + if ( + $login + && $code == Horde_Auth::REASON_BADLOGIN + && $this->hasCapability('badlogincount') + ) { + $this->_badLogin($userId); } + $this->setError($code, $e->getMessage()); return false; } } From 9bfdfa0fc173b4e5a0ac598964ef0ececf8cb4a5 Mon Sep 17 00:00:00 2001 From: Midah Pasche Date: Mon, 3 Feb 2025 09:35:05 +0100 Subject: [PATCH 3/3] update unitest setup & github workflows --- .github/workflows/ci.yml | 11 +- .github/workflows/phpdoc.yml | 5 +- .github/workflows/release.yml | 65 +++++ .github/workflows/update-satis.yml | 2 +- .gitignore | 6 + .horde.yml | 4 +- composer.json | 7 +- doc/components.conf | 249 ++++++++++++++++++ phpunit.xml.dist | 21 +- test/AllTests.php | 6 + test/Horde/Auth/AllTests.php | 5 - test/Horde/Auth/Autoload.php | 15 -- test/Horde/Auth/bootstrap.php | 9 - test/{Horde/Auth => }/TestCase.php | 6 +- test/{Horde/Auth => }/Unit/AuthTest.php | 6 +- test/{Horde/Auth => }/Unit/KolabTest.php | 5 +- test/{Horde/Auth => }/Unit/PasswdTest.php | 4 +- test/{Horde/Auth => }/Unit/Sql/Base.php | 4 +- test/{Horde/Auth => }/Unit/Sql/Locks.php | 2 +- .../Auth => }/Unit/Sql/Pdo/SqliteLockTest.php | 4 +- .../Auth => }/Unit/Sql/Pdo/SqliteTest.php | 5 +- test/bootstrap.php | 14 + test/{Horde/Auth => }/fixtures/test.passwd | 0 23 files changed, 390 insertions(+), 65 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 doc/components.conf create mode 100644 test/AllTests.php delete mode 100644 test/Horde/Auth/AllTests.php delete mode 100644 test/Horde/Auth/Autoload.php delete mode 100644 test/Horde/Auth/bootstrap.php rename test/{Horde/Auth => }/TestCase.php (95%) rename test/{Horde/Auth => }/Unit/AuthTest.php (92%) rename test/{Horde/Auth => }/Unit/KolabTest.php (97%) rename test/{Horde/Auth => }/Unit/PasswdTest.php (93%) rename test/{Horde/Auth => }/Unit/Sql/Base.php (97%) rename test/{Horde/Auth => }/Unit/Sql/Locks.php (98%) rename test/{Horde/Auth => }/Unit/Sql/Pdo/SqliteLockTest.php (87%) rename test/{Horde/Auth => }/Unit/Sql/Pdo/SqliteTest.php (83%) create mode 100644 test/bootstrap.php rename test/{Horde/Auth => }/fixtures/test.passwd (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2ad7de3..f41e32e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,6 +29,11 @@ jobs: operating-system: ['ubuntu-20.04'] php-versions: ['7.4', '8.0', 'latest'] phpunit-versions: ['latest', '9.5'] + exclude: + - php-versions: '7.4' + phpunit-versions: 'latest' + - php-versions: '8.0' + phpunit-versions: 'latest' steps: - name: Setup github ssh key run: mkdir -p ~/.ssh/ && ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts @@ -48,9 +53,7 @@ jobs: - name: Install horde/test dependency and other dependencies run: | ## For unclear reasons, github action fails randomly if we do not install before we require. + COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer config minimum-stability dev COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer install - COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer require --dev horde/test dev-FRAMEWORK_6_0 horde/log dev-FRAMEWORK_6_0 - - name: install horde/db ^3 - run: composer require horde/db ^3 - name: run phpunit - run: phpunit --bootstrap test/Horde/Auth/bootstrap.php test/Horde/Auth/ + run: phpunit --bootstrap test/bootstrap.php diff --git a/.github/workflows/phpdoc.yml b/.github/workflows/phpdoc.yml index 365812f..14eee9d 100644 --- a/.github/workflows/phpdoc.yml +++ b/.github/workflows/phpdoc.yml @@ -40,7 +40,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 7.4 + php-version: '8.1' extensions: bcmath, ctype, curl, dom, gd, gettext, iconv, imagick, json, ldap, mbstring, mysql, opcache, openssl, pcntl, pdo, posix, redis, soap, sockets, sqlite, tokenizer, xmlwriter ini-values: post_max_size=512M, max_execution_time=360 coverage: xdebug @@ -60,7 +60,8 @@ jobs: echo "Creating UUT related dir in docu repo" mkdir -p $UUT_DIR/phpdoc-git/${GITHUB_REF##*/}/${REPO}/ ## Look into any of lib, src, app (if they exist) but not test, migration, bin, locale or script dirs - $BIN_DIR/phpdocumentor -d $UUT_DIR/lib/ -d $UUT_DIR/src/ -d $UUT_DIR/app/ -t "${UUT_DIR}/phpdoc-git/${GITHUB_REF##*/}/${REPO}/" + cd $UUT_DIR + $BIN_DIR/phpdocumentor -d lib/ -d src/ -d app/ -t "phpdoc-git/${GITHUB_REF##*/}/${REPO}/" cd ${UUT_DIR}/phpdoc-git git add "${GITHUB_REF##*/}/${REPO}" php indexer.php ${GITHUB_REF##*/} $REPO diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ee161f7 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,65 @@ +--- +name: make release + +# manual workflow to make a new release for the default branch +on: + workflow_dispatch: + branches: + - FRAMEWORK_6_0 +env: + components: "/home/runner/.composer/web/components/bin/horde-components -c /home/runner/.composer/web/components/config/maintaina.conf.dist" + COMPOSER_ALLOW_SUPERUSER: 1 + +jobs: + run: + runs-on: ${{ matrix.operating-system }} + strategy: + matrix: + operating-system: ['ubuntu-20.04'] + php-versions: ['8.1'] + steps: + - name: Setup git + run: | + mkdir -p ~/.ssh/ && ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts + git config --global user.name "Github CI Runner" + git config --global user.email "ci-job@maintaina.com" + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: gettext + ini-values: post_max_size=512M, max_execution_time=360 + tools: composer:v2 + - name: Setup composer + run: | + composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }} + composer global config repositories.0 composer https://horde-satis.maintaina.com + composer global config minimum-stability dev + composer config --no-plugins --global allow-plugins.horde/horde-installer-plugin true + composer global require horde/horde-installer-plugin "2.3.0" + composer global require horde/components "dev-FRAMEWORK_6_0" + - name: write changelog + run: | + entries_amount=0; max_entries=100 + PATTERN="^\[.*\] .*" + + for commit in $(git rev-list FRAMEWORK_6_0) + do + msg=$(git log --format=%B -n 1 $commit | head -n 1) + if [ $entries_amount -gt $max_entries ]; then break; fi + if [[ $msg == 'Released'* ]]; then break; fi + if [[ $msg == 'Development mode for'* ]]; then break; fi + if [[ $msg =~ $PATTERN ]]; then + $components changed "$msg" + let "entries_amount+=1" + fi + done + - name: make release and push + run: | + $components release for maintaina + git push + git push origin --tags diff --git a/.github/workflows/update-satis.yml b/.github/workflows/update-satis.yml index 5049bd0..41e78af 100644 --- a/.github/workflows/update-satis.yml +++ b/.github/workflows/update-satis.yml @@ -38,7 +38,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 7.4 + php-version: '8.2' extensions: bcmath, ctype, curl, dom, gd, gettext, iconv, imagick, json, ldap, mbstring, mysql, opcache, openssl, pcntl, pdo, posix, redis, soap, sockets, sqlite, tokenizer, xmlwriter ini-values: post_max_size=512M, max_execution_time=3600 coverage: xdebug diff --git a/.gitignore b/.gitignore index 4e78ae3..f98bbbb 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,9 @@ run-tests.log /test/*/*/*/*.log /test/*/*/*/*.out +/vendor +/composer.lock +/web +/.phpunit.cache +.phpunit.results.cache +.php-cs-fixer.cache diff --git a/.horde.yml b/.horde.yml index e076e7b..eea8029 100644 --- a/.horde.yml +++ b/.horde.yml @@ -55,9 +55,11 @@ dependencies: horde/ldap: ^3 horde/imsp: ^3 horde/http: ^3 - horde/test: ^3 ext: ctype: '*' ftp: '*' pam: '*' sasl: '*' + dev: + composer: + horde/test: ^3 diff --git a/composer.json b/composer.json index b25f2e1..7fc58ce 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,9 @@ "horde/util": "^3 || dev-FRAMEWORK_6_0", "ext-hash": "*" }, - "require-dev": {}, + "require-dev": { + "horde/test": "^3 || dev-FRAMEWORK_6_0" + }, "suggest": { "horde/db": "^3 || dev-FRAMEWORK_6_0", "horde/history": "^3 || dev-FRAMEWORK_6_0", @@ -46,7 +48,6 @@ "horde/ldap": "^3 || dev-FRAMEWORK_6_0", "horde/imsp": "^3 || dev-FRAMEWORK_6_0", "horde/http": "^3 || dev-FRAMEWORK_6_0", - "horde/test": "^3 || dev-FRAMEWORK_6_0", "ext-ctype": "*", "ext-ftp": "*", "ext-pam": "*", @@ -67,4 +68,4 @@ "horde/horde-installer-plugin": true } } -} \ No newline at end of file +} diff --git a/doc/components.conf b/doc/components.conf new file mode 100644 index 0000000..d091e35 --- /dev/null +++ b/doc/components.conf @@ -0,0 +1,249 @@ +'; + +/* Path to a checkout of the horde-web repository. */ +$conf['web_dir'] = '/var/www/horde-web'; + +/** + * Vendor: Used by the composer, packagist, satis and git-related tasks + * Defaults to 'horde' if unset + */ +// $conf['vendor'] = 'horde'; + +/** + * Git Repo Base: The base URL for your remote git repo + * Defaults to https://github.com/$vendor if unset + * If you configure this, $vendor will NOT be appended + */ +//$conf['git_repo_base'] = 'https://git.mycompany.com/level/nextlevel/'; + +/** composer_repo - Type of loader hints to generate + * Default is not to generate any hints. Dependencies will be from packagist + */ +// generate a vcs repo source per horde internal dependency +// $conf['composer_repo'] = 'vcs'; +// generate a satis source for all horde namespace +$conf['composer_repo'] = 'satis:https://horde-satis.maintaina.com'; + +/** + * composer_version - tweak all dependency versions + * to a common branch name or version + * This is used by the horde-components composer command and + * the composer release task unless overwritten there + * + * Default: Depend on versions from .horde.yml + */ +// depend on master branch +// $conf['composer_version'] = 'dev-master'; +// depend on a staging branch - components won't check if it even exists! +$conf['composer_version'] = 'dev-FRAMEWORK_6_0'; + + +/* Well known composer native substitutes for pear dependencies */ +$conf['composer_opts']['pear-substitutes'] = [ + ['pear.php.net/Archive_Tar' => + ['source' => 'Packagist', 'name' => 'pear/archive_tar']], + ['pear.php.net/Console_Color2' => + ['source' => 'Packagist', 'name' => 'pear/console_color2']], + ['pear.php.net/Net_DNS2' => + ['source' => 'Packagist', 'name' => 'pear/net_dns2']], + ['pear.php.net/Console_Table' => + ['source' => 'Packagist', 'name' => 'pear/console_table']], + ['pear.php.net/PHP_CodeSniffer' => + ['source' => 'Packagist', 'name' => 'squizlabs/php_codesniffer']], + ['pear.phpunit.de/phpcpd' => ['source' => 'Packagist', 'name' => 'sebastian/phpcpd']], + ['pear.phpunit.de/phpdcd' => ['source' => 'Packagist', 'name' => 'sebastian/phpdcd']], + ['pear.phpunit.de/phploc' => ['source' => 'Packagist', 'name' => 'phploc/phploc']] +]; + +/** + * Configure release pipelines + */ + +/** + * Upstream pipeline + * + * Usage: horde-components path/to/component release for upstream + * + * The upstream pipeline is similar to the original pipeline + * + * Added Steps: + * - checkout of the correct branch, prevent accidental release from master + * - writing an updated composer file + * - Pushing to github + * - Notifying to Packagist + * + * Removed Steps: + * - None + * + */ +$conf['pipeline']['release']['upstream'] = [ + // Checkout the FRAMEWORK_5_2 branch, don't accidentally release master + ['name' => 'GitBranch', 'options' => [ + 'git_branch' => 'FRAMEWORK_5_2', + 'git_branch_prereq' => false + ] + ], + ['name' => 'Unit'], + ['name' => 'Changelog'], + ['name' => 'Timestamp'], + ['name' => 'CurrentSentinel'], + // By default, upload to Pirum server after generating + ['name' => 'Package', 'options' => ['upload' => 'true']], + + // The composer task will use global options like composer_opts, + // composer_version, composer_repo unless explicitly overwritten here + ['name' => 'Composer'], + ['name' => 'CommitPreRelease'], + ['name' => 'TagRelease'], + ['name' => 'Announce'], + ['name' => 'Website'], + ['name' => 'Bugs'], + ['name' => 'NextVersion'], + ['name' => 'CommitPostRelease'], + ['name' => 'GitPush'], + // Nudge Packagist that we have an update + // Requires API key. Does not work for new packages not yet registered. + ['name' => 'Packagist', 'options' => [ + 'packagist_api_key' => '', + 'packagist_user' => 'horde', + 'vendor' => 'horde' + ] + ] + // Optional: A local Satis installation satis.horde.org + // satis_bin: path to satis cli + // satis_json: path to satis json file + // satis_outdir: path where satis should write the repository + // satis_push: If the output dir is a git checkout, try to commit and push? +/* ['name' => 'Satis', 'options' => [ + 'satis_bin' => '', + 'satis_json' => '', + 'satis_outdir' => '', + 'satis_push' => true + ] + ]*/ +]; + +/** + * Downstream pipeline + * + * Usage: horde-components path/to/component release for downstream + * + * The downstream pipeline is for developing horde based code in your own lab + * + * Added Steps: + * - checkout of the correct branch, prevent accidental release from master + * - writing an updated composer file + * - Pushing to github + * - Writing to a satis repository + * + * Removed Steps: + * - Package/Upload (Pear) + * - Announce + * - Website + * - Bugs + * + */ +$conf['pipeline']['release']['downstream'] = [ + // Ensure we create release from the staging branch. Break if not. + ['name' => 'GitBranch', 'options' => [ + 'git_branch' => 'staging', + 'git_branch_prereq' => true + ] + ], + ['name' => 'Unit'], + ['name' => 'Changelog'], + ['name' => 'Timestamp'], + ['name' => 'CurrentSentinel'], + // Pear related steps have been removed + // The composer task will use global options like composer_opts, + // composer_version, composer_repo unless explicitly overwritten here + ['name' => 'Composer', 'options' => ['composer_version' => '' ] ], + ['name' => 'CommitPreRelease'], + ['name' => 'TagRelease'], + // Increase version numbers for development mode + ['name' => 'NextVersion'], + // Force our component to require staging branch dependencies + // This is useful for development mode + ['name' => 'Composer', 'options' => ['composer_version' => 'dev-FRAMEWORK_6_0']], + ['name' => 'CommitPostRelease'], + ['name' => 'GitPush'], + // Our downstream pipeline uses satis rather than packagist + // satis_bin: path to satis cli + // satis_json: path to satis json file + // satis_outdir: path where satis should write the repository + // satis_push: If the output dir is a git checkout, try to commit and push? + ['name' => 'Satis', 'options' => [ + 'satis_bin' => '', + 'satis_json' => '', + 'satis_outdir' => '', + 'satis_push' => true + ] + ] + // TODO: Missing a step to update the release branch from the latest tag +]; + + +/** + * maintaina pipeline + * + * Added Steps: + * - checkout of the correct branch, prevent accidental release from master + * - writing an updated composer file + * - Pushing to github + * - Writing to a satis repository + * + * Removed Steps: + * - Package/Upload (Pear) + * - Announce + * - Website + * - Bugs + * + */ +$conf['pipeline']['release']['maintaina'] = [ + // Ensure we create release from the master branch. Break if not. + ['name' => 'GitBranch', 'options' => [ + 'git_branch' => 'FRAMEWORK_6_0', + 'git_branch_prereq' => true + ] + ], + // no unit tests for now + // ['name' => 'Unit'], + ['name' => 'Changelog'], + ['name' => 'Timestamp'], + ['name' => 'CurrentSentinel'], + ['name' => 'Composer'], + ['name' => 'CommitPreRelease'], + ['name' => 'TagRelease'], + // Increase version numbers for development mode + ['name' => 'NextVersion'], + ['name' => 'CommitPostRelease'], + // ['name' => 'GitPush'], +]; diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c920379..350251c 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,13 +1,20 @@ - - - - - lib - - + + test + + + lib + + diff --git a/test/AllTests.php b/test/AllTests.php new file mode 100644 index 0000000..ad725e6 --- /dev/null +++ b/test/AllTests.php @@ -0,0 +1,6 @@ +run(); diff --git a/test/Horde/Auth/AllTests.php b/test/Horde/Auth/AllTests.php deleted file mode 100644 index 79e2099..0000000 --- a/test/Horde/Auth/AllTests.php +++ /dev/null @@ -1,5 +0,0 @@ -run(); diff --git a/test/Horde/Auth/Autoload.php b/test/Horde/Auth/Autoload.php deleted file mode 100644 index 2714e97..0000000 --- a/test/Horde/Auth/Autoload.php +++ /dev/null @@ -1,15 +0,0 @@ - - * @license http://www.horde.org/licenses/lgpl21 LGPL-2.1 - */ - -/** Load the basic test definition */ -require_once __DIR__ . '/TestCase.php'; diff --git a/test/Horde/Auth/bootstrap.php b/test/Horde/Auth/bootstrap.php deleted file mode 100644 index bcf408d..0000000 --- a/test/Horde/Auth/bootstrap.php +++ /dev/null @@ -1,9 +0,0 @@ - * @license http://www.horde.org/licenses/lgpl21 LGPL-2.1 */ -namespace Horde\Auth\Unit; -use Horde\Auth\TestCase; -use \Horde_Auth; +namespace Horde\Auth\Test\Unit; +use Horde\Auth\Test\TestCase; +use Horde_Auth; class AuthTest extends TestCase { diff --git a/test/Horde/Auth/Unit/KolabTest.php b/test/Unit/KolabTest.php similarity index 97% rename from test/Horde/Auth/Unit/KolabTest.php rename to test/Unit/KolabTest.php index 6044aed..78978d9 100644 --- a/test/Horde/Auth/Unit/KolabTest.php +++ b/test/Unit/KolabTest.php @@ -13,8 +13,9 @@ * @author Gunnar Wrobel * @license http://www.horde.org/licenses/lgpl21 LGPL-2.1 */ -namespace Horde\Auth\Unit; -use Horde\Auth\TestCase; +namespace Horde\Auth\Test\Unit; +use Horde\Auth\Test\TestCase; +use Horde_Auth_Kolab; class KolabTest extends TestCase { diff --git a/test/Horde/Auth/Unit/PasswdTest.php b/test/Unit/PasswdTest.php similarity index 93% rename from test/Horde/Auth/Unit/PasswdTest.php rename to test/Unit/PasswdTest.php index ed612d1..b08ac93 100644 --- a/test/Horde/Auth/Unit/PasswdTest.php +++ b/test/Unit/PasswdTest.php @@ -14,8 +14,8 @@ * @author Gunnar Wrobel * @license http://www.horde.org/licenses/lgpl21 LGPL-2.1 */ -namespace Horde\Auth\Unit; -use Horde\Auth\TestCase; +namespace Horde\Auth\Test\Unit; +use Horde\Auth\Test\TestCase; use \Horde_Auth_Passwd; class PasswdTest extends TestCase diff --git a/test/Horde/Auth/Unit/Sql/Base.php b/test/Unit/Sql/Base.php similarity index 97% rename from test/Horde/Auth/Unit/Sql/Base.php rename to test/Unit/Sql/Base.php index 1272fa0..4fba896 100644 --- a/test/Horde/Auth/Unit/Sql/Base.php +++ b/test/Unit/Sql/Base.php @@ -4,8 +4,8 @@ * @package Auth * @subpackage UnitTests */ -namespace Horde\Auth\Unit\Sql; -use Horde\Auth\TestCase; +namespace Horde\Auth\Test\Unit\Sql; +use Horde\Auth\Test\TestCase; use \Horde_Db_Migration_Migrator; use \Horde_Auth_Sql; diff --git a/test/Horde/Auth/Unit/Sql/Locks.php b/test/Unit/Sql/Locks.php similarity index 98% rename from test/Horde/Auth/Unit/Sql/Locks.php rename to test/Unit/Sql/Locks.php index bf6456c..2becc8c 100644 --- a/test/Horde/Auth/Unit/Sql/Locks.php +++ b/test/Unit/Sql/Locks.php @@ -2,7 +2,7 @@ /** * Prepare the test setup. */ -namespace Horde\Auth\Unit\Sql; +namespace Horde\Auth\Test\Unit\Sql; /** * @category Horde diff --git a/test/Horde/Auth/Unit/Sql/Pdo/SqliteLockTest.php b/test/Unit/Sql/Pdo/SqliteLockTest.php similarity index 87% rename from test/Horde/Auth/Unit/Sql/Pdo/SqliteLockTest.php rename to test/Unit/Sql/Pdo/SqliteLockTest.php index 674e442..be63957 100644 --- a/test/Horde/Auth/Unit/Sql/Pdo/SqliteLockTest.php +++ b/test/Unit/Sql/Pdo/SqliteLockTest.php @@ -2,8 +2,8 @@ /** * Prepare the test setup. */ -namespace Horde\Auth\Unit\Sql\Pdo; -use Horde\Auth\Unit\Sql\Locks; +namespace Horde\Auth\Test\Unit\Sql\Pdo; +use Horde\Auth\Test\Unit\Sql\Locks; use \Horde_Test_Factory_Db; /** diff --git a/test/Horde/Auth/Unit/Sql/Pdo/SqliteTest.php b/test/Unit/Sql/Pdo/SqliteTest.php similarity index 83% rename from test/Horde/Auth/Unit/Sql/Pdo/SqliteTest.php rename to test/Unit/Sql/Pdo/SqliteTest.php index d16eb44..9be26ca 100644 --- a/test/Horde/Auth/Unit/Sql/Pdo/SqliteTest.php +++ b/test/Unit/Sql/Pdo/SqliteTest.php @@ -2,10 +2,9 @@ /** * Prepare the test setup. */ -namespace Horde\Auth\Unit\Sql\Pdo; -use Horde\Auth\Unit\Sql\Base; +namespace Horde\Auth\Test\Unit\Sql\Pdo; +use Horde\Auth\Test\Unit\Sql\Base; use \Horde_Test_Factory_Db; -use \Horde_Db_Migration_Migrator; /** * @category Horde diff --git a/test/bootstrap.php b/test/bootstrap.php new file mode 100644 index 0000000..c92c4e9 --- /dev/null +++ b/test/bootstrap.php @@ -0,0 +1,14 @@ +