Skip to content

Commit 6e9e4bf

Browse files
committed
Quality of life
1 parent c2f052b commit 6e9e4bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3720
-891
lines changed

.gitattributes

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
.gitignore export-ignore
22
.gitattributes export-ignore
33
.scrutinizer.yml export-ignore
4-
.travis.yml export-ignore
4+
.github/ export-ignore
55
/tests export-ignore
66
/Vagrantfile export-ignore
77
phpunit.xml.dist export-ignore
8-
behat.yml.dist export-ignore
8+
behat.yml export-ignore
99
composer.lock export-ignore
10+
docker-compose.yml export-ignore
11+
phpcs.xml export-ignore
12+
psalm.xml export-ignore

.github/workflows/behat.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Integration Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
pull_request:
8+
- '*'
9+
10+
jobs:
11+
integrationtest:
12+
runs-on: ubuntu-latest
13+
14+
name: Behat
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
19+
- name: Install PHP
20+
uses: shivammathur/setup-php@v2
21+
with:
22+
php-version: 8.1
23+
24+
- name: Cache Composer packages
25+
id: composer-cache
26+
uses: actions/cache@v2
27+
with:
28+
path: vendor
29+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
30+
restore-keys: |
31+
${{ runner.os }}-php-
32+
33+
- name: Install dependencies
34+
run: composer install --prefer-dist --no-progress
35+
36+
- name: Build the stack
37+
run: docker-compose up -d
38+
39+
- name: Sleep for 10 minutes
40+
run: sleep 10m
41+
shell: bash
42+
43+
- name: Run test suite
44+
run: ./vendor/bin/behat

.github/workflows/static.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Static Code Analysis
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
psalm:
7+
name: Psalm
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v2
12+
13+
- name: Psalm
14+
uses: docker://vimeo/psalm-github-actions
15+
with:
16+
security_analysis: true
17+
report_file: results.sarif
18+
composer_ignore_platform_reqs: true
19+
20+
- name: Upload Security Analysis results to GitHub
21+
uses: github/codeql-action/upload-sarif@v1
22+
with:
23+
sarif_file: results.sarif
24+
25+
# we may use whatever way to install phpcs, just specify the path on the next step
26+
# however, curl seems to be the fastest
27+
- name: Install PHP_CodeSniffer
28+
run: |
29+
curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
30+
php phpcs.phar --version
31+
32+
- uses: tinovyatkin/action-php-codesniffer@v1
33+
with:
34+
files: "**.php" # you may customize glob as needed
35+
phpcs_path: php phpcs.phar
36+
standard: phpcs.xml

.github/workflows/unit.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Unit Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
pull_request:
8+
- '*'
9+
10+
jobs:
11+
unittest:
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
php:
17+
- version: 5.3
18+
phpunit: 4.8
19+
compat: true
20+
coverage: false
21+
- version: 5.4
22+
phpunit: 4.8
23+
compat: true
24+
coverage: false
25+
- version: 5.5
26+
phpunit: 4.8
27+
compat: true
28+
coverage: false
29+
- version: 5.6
30+
phpunit: 5.7
31+
compat: true
32+
coverage: false
33+
- version: 7.0
34+
phpunit: 6.5
35+
compat: true
36+
coverage: false
37+
- version: 7.1
38+
phpunit: 7.5
39+
compat: true
40+
coverage: false
41+
- version: 7.2
42+
phpunit: 8.5
43+
coverage: false
44+
- version: 7.3
45+
phpunit: 9.5
46+
coverage: true
47+
- version: 7.4
48+
phpunit: 9.5
49+
coverage: false
50+
- version: 8.0
51+
phpunit: 9.5
52+
coverage: false
53+
- version: 8.1
54+
phpunit: 9.5
55+
coverage: false
56+
prefer-lowest: ['', '--prefer-lowest']
57+
58+
name: Unit Tests - PHP ${{ matrix.php.version }} ${{ matrix.prefer-lowest }}
59+
60+
steps:
61+
- uses: actions/checkout@v2
62+
63+
- name: Install PHP
64+
uses: shivammathur/setup-php@v2
65+
with:
66+
php-version: ${{ matrix.php.version }}
67+
extensions: mbstring
68+
69+
- name: Validate composer.json and composer.lock
70+
run: composer validate --strict
71+
72+
- name: Cache Composer packages
73+
id: composer-cache
74+
uses: actions/cache@v2
75+
with:
76+
path: vendor
77+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
78+
restore-keys: |
79+
${{ runner.os }}-php-
80+
81+
- name: Remove static analyse tools
82+
run: |
83+
composer remove --dev --with-all-dependencies --ignore-platform-reqs \
84+
squizlabs/php_codesniffer vimeo/psalm slevomat/coding-standard
85+
86+
- name: Update dependencies
87+
run: composer update --prefer-dist --no-progress --with-all-dependencies ${{ matrix.prefer-lowest }}
88+
89+
- name: Require compatible PHPUnit version
90+
run: composer require --dev --with-all-dependencies "phpunit/phpunit:^${{ matrix.php.phpunit }}"
91+
92+
- name: Make Unit tests compatible
93+
if: ${{ matrix.php.compat }}
94+
run: /bin/bash tests/compat.sh
95+
96+
- name: Run test suite
97+
if: ${{ ! matrix.php.coverage }}
98+
run: ./vendor/bin/phpunit --verbose
99+
100+
- name: Run test suite with code coverage
101+
if: ${{ matrix.php.coverage }}
102+
run: ./vendor/bin/phpunit --verbose --coverage-clover=build/logs/clover.xml
103+
env:
104+
XDEBUG_MODE: coverage
105+
106+
- name: Run Scrutinizer
107+
if: ${{ matrix.php.coverage }}
108+
run: |
109+
wget -q https://scrutinizer-ci.com/ocular.phar
110+
php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml || true

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/vendor/
22
.vagrant/
33
build/
4-
behat.yml
54
phpunit.xml
65
.phpunit.result.cache
6+
.phpcs-cache
77
*.log
88
codeclimate.json
99
ocular.phar
@@ -12,3 +12,4 @@ php-coveralls.phar
1212
php-coveralls.phar*
1313
codeclimate-test-reporter.phar
1414
codeclimate-test-reporter.phar*
15+
composer.phar

.scrutinizer.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,24 @@ tools:
1313
config:
1414
standard: PSR2
1515
php_sim: true
16-
php_cpd: false
16+
php_cpd: true
1717
php_loc: true
1818
php_hhvm: false
1919
php_mess_detector: true
2020
php_pdepend: true
21-
php_analyzer: false
21+
php_analyzer: true
2222
sensiolabs_security_checker: true
2323
php_changetracking: true
2424
external_code_coverage:
25-
runs: 1
26-
timeout: 1200
25+
runs: 2
26+
timeout: 120
27+
28+
build:
29+
environment:
30+
php: 7.3.0
31+
nodes:
32+
analysis:
33+
tests:
34+
override:
35+
# Add the respective Scrutinizer analysis for your language like
36+
- php-scrutinizer-run

.travis.yml

Lines changed: 0 additions & 54 deletions
This file was deleted.

README.md

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22

33
The PHP SASL Authentification Library.
44

5-
[![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)
6-
[![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)
5+
[![Latest Stable Version](https://poser.pugx.org/fabiang/sasl/v/stable.svg)](https://packagist.org/packages/fabiang/sasl)
6+
[![Total Downloads](https://poser.pugx.org/fabiang/sasl/downloads.svg)](https://packagist.org/packages/fabiang/sasl)
7+
[![License](https://poser.pugx.org/fabiang/sasl/license.svg)](https://packagist.org/packages/fabiang/sasl)
8+
[![Unit Tests](https://github.com/fabiang/sasl/actions/workflows/unit.yml/badge.svg?branch=develop)](https://github.com/fabiang/sasl/actions/workflows/unit.yml)
9+
[![Integration Tests](https://github.com/fabiang/sasl/actions/workflows/behat.yml/badge.svg?branch=develop)](https://github.com/fabiang/sasl/actions/workflows/behat.yml)
10+
[![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)
11+
[![Code Coverage](https://scrutinizer-ci.com/g/fabiang/sasl/badges/coverage.png?b=develop)](https://scrutinizer-ci.com/g/fabiang/sasl/?branch=develop)
712

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

83-
## Developing
88+
## Unit tests
8489

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

95100
```
96-
./vendor/bin/phpunit -c tests
101+
./vendor/bin/phpunit
97102
```
98103

104+
## Integration tests
105+
99106
The integration tests verify the authentication methods against an Ejabberd and Dovecot server.
107+
108+
### Docker Compose
109+
110+
To launch the servers you can use the provided Docker Compose file.
111+
Just [install Docker](https://www.docker.com/get-started/) and run:
112+
113+
```
114+
docker-compose up -d
115+
```
116+
117+
**Note:** ejabberd takes around *ten minutes* to start.
118+
119+
### Vagrant
120+
100121
To launch the servers you can use the provided Vagrant box.
101-
Just [install Vagrant](https://www.vagrantup.com/downloads.html) and run:
122+
Just [install Vagrant](https://www.vagrantup.com/downloads) and run:
102123

103124
```
104125
vagrant up
105126
```
106127

107128
After some minutes you'll have the runnig server instances inside of a virtual machine.
129+
130+
### RUN
131+
108132
Now you can run the integration tests:
109133

110134
```

Vagrantfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ MESSAGE
7878
# Install dovecot for integration tests by bash script
7979
config.vm.provision "shell" do |s|
8080
s.path = "tests/provisioner/install_dovecot.sh"
81-
s.args = ["testuser", "testpass"]
81+
s.args = ["vmail", "pass"]
8282
end
8383

8484
# Enable provisioning with CFEngine. CFEngine Community packages are

behat.yml.dist renamed to behat.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ default:
1313
- Fabiang\Sasl\Behat\Pop3Context:
1414
- localhost
1515
- 11110
16-
- testuser
17-
- testpass
16+
- vmail
17+
- pass
1818
- "%paths.base%/tests/log/features/"
1919
testers:
2020
strict: true

0 commit comments

Comments
 (0)