Skip to content

Commit

Permalink
Quality of life
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiang committed Apr 21, 2022
1 parent c2f052b commit 6e9e4bf
Show file tree
Hide file tree
Showing 54 changed files with 3,720 additions and 891 deletions.
7 changes: 5 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
.gitignore export-ignore
.gitattributes export-ignore
.scrutinizer.yml export-ignore
.travis.yml export-ignore
.github/ export-ignore
/tests export-ignore
/Vagrantfile export-ignore
phpunit.xml.dist export-ignore
behat.yml.dist export-ignore
behat.yml export-ignore
composer.lock export-ignore
docker-compose.yml export-ignore
phpcs.xml export-ignore
psalm.xml export-ignore
44 changes: 44 additions & 0 deletions .github/workflows/behat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Integration Tests

on:
push:
branches:
- '*'
pull_request:
- '*'

jobs:
integrationtest:
runs-on: ubuntu-latest

name: Behat

steps:
- uses: actions/checkout@v2

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Build the stack
run: docker-compose up -d

- name: Sleep for 10 minutes
run: sleep 10m
shell: bash

- name: Run test suite
run: ./vendor/bin/behat
36 changes: 36 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Static Code Analysis

on: [push, pull_request]

jobs:
psalm:
name: Psalm
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Psalm
uses: docker://vimeo/psalm-github-actions
with:
security_analysis: true
report_file: results.sarif
composer_ignore_platform_reqs: true

- name: Upload Security Analysis results to GitHub
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: results.sarif

# we may use whatever way to install phpcs, just specify the path on the next step
# however, curl seems to be the fastest
- name: Install PHP_CodeSniffer
run: |
curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
php phpcs.phar --version
- uses: tinovyatkin/action-php-codesniffer@v1
with:
files: "**.php" # you may customize glob as needed
phpcs_path: php phpcs.phar
standard: phpcs.xml
110 changes: 110 additions & 0 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Unit Tests

on:
push:
branches:
- '*'
pull_request:
- '*'

jobs:
unittest:
runs-on: ubuntu-latest

strategy:
matrix:
php:
- version: 5.3
phpunit: 4.8
compat: true
coverage: false
- version: 5.4
phpunit: 4.8
compat: true
coverage: false
- version: 5.5
phpunit: 4.8
compat: true
coverage: false
- version: 5.6
phpunit: 5.7
compat: true
coverage: false
- version: 7.0
phpunit: 6.5
compat: true
coverage: false
- version: 7.1
phpunit: 7.5
compat: true
coverage: false
- version: 7.2
phpunit: 8.5
coverage: false
- version: 7.3
phpunit: 9.5
coverage: true
- version: 7.4
phpunit: 9.5
coverage: false
- version: 8.0
phpunit: 9.5
coverage: false
- version: 8.1
phpunit: 9.5
coverage: false
prefer-lowest: ['', '--prefer-lowest']

name: Unit Tests - PHP ${{ matrix.php.version }} ${{ matrix.prefer-lowest }}

steps:
- uses: actions/checkout@v2

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php.version }}
extensions: mbstring

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Remove static analyse tools
run: |
composer remove --dev --with-all-dependencies --ignore-platform-reqs \
squizlabs/php_codesniffer vimeo/psalm slevomat/coding-standard
- name: Update dependencies
run: composer update --prefer-dist --no-progress --with-all-dependencies ${{ matrix.prefer-lowest }}

- name: Require compatible PHPUnit version
run: composer require --dev --with-all-dependencies "phpunit/phpunit:^${{ matrix.php.phpunit }}"

- name: Make Unit tests compatible
if: ${{ matrix.php.compat }}
run: /bin/bash tests/compat.sh

- name: Run test suite
if: ${{ ! matrix.php.coverage }}
run: ./vendor/bin/phpunit --verbose

- name: Run test suite with code coverage
if: ${{ matrix.php.coverage }}
run: ./vendor/bin/phpunit --verbose --coverage-clover=build/logs/clover.xml
env:
XDEBUG_MODE: coverage

- name: Run Scrutinizer
if: ${{ matrix.php.coverage }}
run: |
wget -q https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml || true
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/vendor/
.vagrant/
build/
behat.yml
phpunit.xml
.phpunit.result.cache
.phpcs-cache
*.log
codeclimate.json
ocular.phar
Expand All @@ -12,3 +12,4 @@ php-coveralls.phar
php-coveralls.phar*
codeclimate-test-reporter.phar
codeclimate-test-reporter.phar*
composer.phar
18 changes: 14 additions & 4 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,24 @@ tools:
config:
standard: PSR2
php_sim: true
php_cpd: false
php_cpd: true
php_loc: true
php_hhvm: false
php_mess_detector: true
php_pdepend: true
php_analyzer: false
php_analyzer: true
sensiolabs_security_checker: true
php_changetracking: true
external_code_coverage:
runs: 1
timeout: 1200
runs: 2
timeout: 120

build:
environment:
php: 7.3.0
nodes:
analysis:
tests:
override:
# Add the respective Scrutinizer analysis for your language like
- php-scrutinizer-run
54 changes: 0 additions & 54 deletions .travis.yml

This file was deleted.

34 changes: 29 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

The PHP SASL Authentification Library.

[![Latest Stable Version](https://poser.pugx.org/fabiang/sasl/v/stable.svg)](https://packagist.org/packages/fabiang/sasl) [![Total Downloads](https://poser.pugx.org/fabiang/sasl/downloads.svg)](https://packagist.org/packages/fabiang/sasl) [![License](https://poser.pugx.org/fabiang/sasl/license.svg)](https://packagist.org/packages/fabiang/sasl)
[![Build Status](https://travis-ci.com/fabiang/sasl.svg?branch=master)](https://travis-ci.com/fabiang/sasl) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/fabiang/sasl/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/fabiang/sasl/?branch=master) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/e81e1e30-c545-420a-8a0c-59b60976f54b/mini.png)](https://insight.sensiolabs.com/projects/e81e1e30-c545-420a-8a0c-59b60976f54b) [![Coverage Status](https://img.shields.io/coveralls/fabiang/sasl.svg)](https://coveralls.io/r/fabiang/sasl)
[![Latest Stable Version](https://poser.pugx.org/fabiang/sasl/v/stable.svg)](https://packagist.org/packages/fabiang/sasl)
[![Total Downloads](https://poser.pugx.org/fabiang/sasl/downloads.svg)](https://packagist.org/packages/fabiang/sasl)
[![License](https://poser.pugx.org/fabiang/sasl/license.svg)](https://packagist.org/packages/fabiang/sasl)
[![Unit Tests](https://github.com/fabiang/sasl/actions/workflows/unit.yml/badge.svg?branch=develop)](https://github.com/fabiang/sasl/actions/workflows/unit.yml)
[![Integration Tests](https://github.com/fabiang/sasl/actions/workflows/behat.yml/badge.svg?branch=develop)](https://github.com/fabiang/sasl/actions/workflows/behat.yml)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/fabiang/sasl/badges/quality-score.png?b=develop)](https://scrutinizer-ci.com/g/fabiang/sasl/?branch=develop)
[![Code Coverage](https://scrutinizer-ci.com/g/fabiang/sasl/badges/coverage.png?b=develop)](https://scrutinizer-ci.com/g/fabiang/sasl/?branch=develop)

Provides code to generate responses to common SASL mechanisms, including:
* Digest-MD5
Expand Down Expand Up @@ -80,7 +85,7 @@ again and send the returned value to the server.
| Plain | yes | yes | optional | no | no | no |
| SCRAM-* | yes | yes | optional | no | no | yes |

## Developing
## Unit tests

If you like this library and you want to contribute, make sure the unit tests
and integration tests are running. Composer will help you to install the right
Expand All @@ -93,18 +98,37 @@ composer install --dev
After that run the unit tests:

```
./vendor/bin/phpunit -c tests
./vendor/bin/phpunit
```

## Integration tests

The integration tests verify the authentication methods against an Ejabberd and Dovecot server.

### Docker Compose

To launch the servers you can use the provided Docker Compose file.
Just [install Docker](https://www.docker.com/get-started/) and run:

```
docker-compose up -d
```

**Note:** ejabberd takes around *ten minutes* to start.

### Vagrant

To launch the servers you can use the provided Vagrant box.
Just [install Vagrant](https://www.vagrantup.com/downloads.html) and run:
Just [install Vagrant](https://www.vagrantup.com/downloads) and run:

```
vagrant up
```

After some minutes you'll have the runnig server instances inside of a virtual machine.

### RUN

Now you can run the integration tests:

```
Expand Down
2 changes: 1 addition & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ MESSAGE
# Install dovecot for integration tests by bash script
config.vm.provision "shell" do |s|
s.path = "tests/provisioner/install_dovecot.sh"
s.args = ["testuser", "testpass"]
s.args = ["vmail", "pass"]
end

# Enable provisioning with CFEngine. CFEngine Community packages are
Expand Down
4 changes: 2 additions & 2 deletions behat.yml.dist → behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ default:
- Fabiang\Sasl\Behat\Pop3Context:
- localhost
- 11110
- testuser
- testpass
- vmail
- pass
- "%paths.base%/tests/log/features/"
testers:
strict: true
Loading

0 comments on commit 6e9e4bf

Please sign in to comment.