Repository: j0k3r/banditore Branch: master Commit: aa0cb944a8c2 Files: 120 Total size: 469.1 KB Directory structure: gitextract_xx2gl39y/ ├── .editorconfig ├── .github/ │ ├── FUNDING.yml │ ├── dependabot.yml │ ├── release.yml │ └── workflows/ │ ├── coding-standards.yml │ ├── continuous-integration.yml │ └── coverage.yml ├── .gitignore ├── .nvmrc ├── .php-cs-fixer.dist.php ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── README.md ├── bin/ │ └── console ├── composer.json ├── config/ │ ├── bundles.php │ ├── packages/ │ │ ├── cache.yaml │ │ ├── debug.yaml │ │ ├── doctrine.yaml │ │ ├── doctrine_migrations.yaml │ │ ├── framework.yaml │ │ ├── github_api.yaml │ │ ├── http_discovery.yaml │ │ ├── knpu_oauth2_client.yaml │ │ ├── messenger.yaml │ │ ├── monolog.yaml │ │ ├── routing.yaml │ │ ├── security.yaml │ │ ├── sentry.yaml │ │ ├── snc_redis.yaml │ │ ├── twig.yaml │ │ ├── validator.yaml │ │ └── web_profiler.yaml │ ├── preload.php │ ├── reference.php │ ├── routes/ │ │ ├── framework.yaml │ │ ├── security.yaml │ │ └── web_profiler.yaml │ ├── routes.yaml │ ├── services.yaml │ └── services_test.yaml ├── data/ │ └── supervisor.conf ├── migrations/ │ ├── .gitignore │ ├── Version20170222055642.php │ ├── Version20170329095349.php │ ├── Version20180827105910.php │ ├── Version20200511062812.php │ ├── Version20200613153754.php │ └── Version20260408120000.php ├── phpstan.dist.neon ├── phpunit.xml.dist ├── public/ │ ├── css/ │ │ ├── banditore.css │ │ ├── grids-responsive-min.css │ │ └── pure-min.css │ ├── fonts/ │ │ ├── .gitkeep │ │ └── FontAwesome.otf │ ├── index.php │ ├── js/ │ │ └── banditore.js │ └── robots.txt ├── rector.php ├── src/ │ ├── Cache/ │ │ ├── CustomRedisCachePool.php │ │ ├── HierarchicalCachePoolTrait.php │ │ └── PredisCachePool.php │ ├── Command/ │ │ ├── SyncStarredReposCommand.php │ │ └── SyncVersionsCommand.php │ ├── Controller/ │ │ └── DefaultController.php │ ├── DataFixtures/ │ │ └── AppFixtures.php │ ├── Entity/ │ │ ├── Repo.php │ │ ├── Star.php │ │ ├── User.php │ │ └── Version.php │ ├── Github/ │ │ ├── ClientDiscovery.php │ │ └── RateLimitTrait.php │ ├── Kernel.php │ ├── Message/ │ │ ├── StarredReposSync.php │ │ └── VersionsSync.php │ ├── MessageHandler/ │ │ ├── StarredReposSyncHandler.php │ │ └── VersionsSyncHandler.php │ ├── Pagination/ │ │ ├── Exception/ │ │ │ ├── CallbackNotFoundException.php │ │ │ └── InvalidPageNumberException.php │ │ ├── Pagination.php │ │ ├── Paginator.php │ │ └── PaginatorInterface.php │ ├── PubSubHubbub/ │ │ └── Publisher.php │ ├── Repository/ │ │ ├── RepoRepository.php │ │ ├── StarRepository.php │ │ ├── UserRepository.php │ │ └── VersionRepository.php │ ├── Rss/ │ │ └── Generator.php │ ├── Security/ │ │ └── GithubAuthenticator.php │ ├── Twig/ │ │ ├── PaginationExtension.php │ │ └── RepoVersionExtension.php │ └── Webfeeds/ │ ├── Webfeeds.php │ └── WebfeedsWriter.php ├── templates/ │ ├── base.html.twig │ ├── bundles/ │ │ └── TwigBundle/ │ │ └── Exception/ │ │ └── error.html.twig │ └── default/ │ ├── _line_version.html.twig │ ├── _pagination.html.twig │ ├── dashboard.html.twig │ ├── index.html.twig │ └── stats.html.twig └── tests/ ├── Cache/ │ └── CustomRedisCachePoolTest.php ├── Command/ │ ├── SyncStarredReposCommandTest.php │ └── SyncVersionsCommandTest.php ├── Controller/ │ └── DefaultControllerTest.php ├── Github/ │ └── ClientDiscoveryTest.php ├── MessageHandler/ │ ├── StarredReposSyncHandlerTest.php │ └── VersionsSyncHandlerTest.php ├── PubSubHubbub/ │ └── PublisherTest.php ├── Repository/ │ ├── UserRepositoryTest.php │ └── VersionRepositoryTest.php ├── Rss/ │ └── GeneratorTest.php ├── Security/ │ └── GithubAuthenticatorTest.php ├── Twig/ │ └── RepoVersionExtensionTest.php ├── Webfeeds/ │ ├── WebfeedsTest.php │ └── WebfeedsWriterTest.php ├── bootstrap.php ├── console-application.php └── object-manager.php ================================================ FILE CONTENTS ================================================ ================================================ FILE: .editorconfig ================================================ # editorconfig.org root = true [*] charset = utf-8 end_of_line = lf indent_size = 4 indent_style = space insert_final_newline = true trim_trailing_whitespace = true [{compose.yaml,compose.*.yaml}] indent_size = 2 [.github/**.yml] indent_size = 2 [*.md] trim_trailing_whitespace = false [Makefile] indent_style = tab ================================================ FILE: .github/FUNDING.yml ================================================ github: j0k3r ================================================ FILE: .github/dependabot.yml ================================================ version: 2 updates: - package-ecosystem: composer directory: "/" schedule: interval: weekly open-pull-requests-limit: 10 groups: symfony-dependencies: patterns: - "symfony/*" twig-dependencies: patterns: - "twig/*" phpstan-dependencies: patterns: - "phpstan/*" - package-ecosystem: github-actions directory: "/" schedule: interval: weekly open-pull-requests-limit: 10 ================================================ FILE: .github/release.yml ================================================ changelog: exclude: labels: - dependencies authors: - dependabot ================================================ FILE: .github/workflows/coding-standards.yml ================================================ name: CS on: pull_request: branches: - master push: branches: - master jobs: coding-standards: name: CS Fixer & PHPStan runs-on: "ubuntu-latest" strategy: matrix: php: - "8.2" steps: - name: Checkout uses: actions/checkout@v6 - name: Install PHP uses: shivammathur/setup-php@v2 with: coverage: "none" php-version: "${{ matrix.php }}" tools: composer:v2 ini-values: "date.timezone=Europe/Paris" env: COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Install dependencies with Composer uses: ramsey/composer-install@v4 - name: Run PHP CS Fixer run: bin/php-cs-fixer fix --verbose --dry-run - name: Generate test cache for PHPStan run: php bin/console cache:clear --env=test - name: Install PHPUnit for PHPStan run: php bin/simple-phpunit install - name: Run PHPStan run: php bin/phpstan analyse --no-progress ================================================ FILE: .github/workflows/continuous-integration.yml ================================================ name: CI on: pull_request: branches: - "master" push: branches: - "master" env: fail-fast: true APP_ENV: test jobs: phpunit: name: PHPUnit (PHP ${{ matrix.php }}) runs-on: "ubuntu-latest" services: mysql: image: mysql:5.7 env: MYSQL_ALLOW_EMPTY_PASSWORD: yes ports: - 3306:3306 rabbitmq: image: rabbitmq:3-alpine ports: - 5672:5672 redis: image: redis:6-alpine ports: - 6379:6379 strategy: matrix: php: - "8.2" - "8.3" - "8.4" - "8.5" steps: - name: Checkout uses: actions/checkout@v6 with: fetch-depth: 2 - name: Install PHP uses: shivammathur/setup-php@v2 with: php-version: "${{ matrix.php }}" coverage: "none" tools: composer:v2 extensions: pdo, pdo_mysql, curl, redis, amqp ini-values: "date.timezone=Europe/Paris" env: COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Install dependencies with Composer uses: ramsey/composer-install@v4 - name: Create database run: php bin/console doctrine:database:create --env=test - name: Create schema run: php bin/console doctrine:schema:create --env=test - name: Load fixtures run: php bin/console doctrine:fixtures:load --env=test -n - name: Setup messenger queue run: php bin/console messenger:setup-transports --env=dev - name: Run PHPUnit run: php bin/phpunit ================================================ FILE: .github/workflows/coverage.yml ================================================ name: Coverage on: pull_request: branches: - "master" push: branches: - "master" env: APP_ENV: test jobs: phpunit: name: PHPUnit runs-on: "ubuntu-latest" services: mysql: image: mysql:5.7 env: MYSQL_ALLOW_EMPTY_PASSWORD: yes ports: - 3306:3306 rabbitmq: image: rabbitmq:3-alpine ports: - 5672:5672 redis: image: redis:6-alpine ports: - 6379:6379 strategy: matrix: php: - "8.2" steps: - name: Checkout uses: actions/checkout@v6 with: fetch-depth: 2 - name: Install PHP with PCOV uses: shivammathur/setup-php@v2 with: php-version: "${{ matrix.php }}" coverage: "pcov" tools: composer:v2 extensions: pdo, pdo_mysql, curl, redis, amqp ini-values: "date.timezone=Europe/Paris" env: COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Install dependencies with Composer uses: ramsey/composer-install@v4 - name: Create database run: php bin/console doctrine:database:create --env=test - name: Create schema run: php bin/console doctrine:schema:create --env=test - name: Load fixtures run: php bin/console doctrine:fixtures:load --env=test -n - name: Setup messenger queue run: php bin/console messenger:setup-transports --env=dev - name: Run PHPUnit (with coverage) run: php bin/phpunit --coverage-clover=coverage.xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v6 with: files: ./coverage.xml token: ${{ secrets.CODECOV_TOKEN }} ================================================ FILE: .gitignore ================================================ /build/ /coverage/ /var/* !/var/cache /var/cache/* !var/cache/.gitkeep !/var/log /var/log/* !var/log/.gitkeep !/var/sessions /var/sessions/* !var/sessions/.gitkeep /bin/* !/bin/console ###> symfony/framework-bundle ### /.env.local /.env.local.php /.env.*.local /config/secrets/prod/prod.decrypt.private.php /public/bundles/ /var/ /vendor/ ###< symfony/framework-bundle ### ###> friendsofphp/php-cs-fixer ### /.php-cs-fixer.php /.php-cs-fixer.cache ###< friendsofphp/php-cs-fixer ### ###> symfony/phpunit-bridge ### .phpunit .phpunit.result.cache /.phpunit.cache /phpunit.xml ###< symfony/phpunit-bridge ### ###> phpunit/phpunit ### /phpunit.xml .phpunit.result.cache ###< phpunit/phpunit ### ###> phpstan/phpstan ### phpstan.neon ###< phpstan/phpstan ### ================================================ FILE: .nvmrc ================================================ 22 ================================================ FILE: .php-cs-fixer.dist.php ================================================ in(__DIR__) ->exclude(['vendor', 'var', 'web']) ->notPath([ 'config/reference.php', ]) ; return (new Config()) ->setRiskyAllowed(true) ->setRules([ '@Symfony' => true, '@Symfony:risky' => true, 'array_syntax' => ['syntax' => 'short'], 'combine_consecutive_unsets' => true, 'heredoc_to_nowdoc' => true, 'no_extra_blank_lines' => ['tokens' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']], 'no_unreachable_default_argument_value' => true, 'no_useless_else' => true, 'no_useless_return' => true, 'ordered_class_elements' => true, 'ordered_imports' => true, 'php_unit_strict' => true, 'phpdoc_order' => true, // 'psr4' => true, 'strict_comparison' => true, 'strict_param' => true, 'concat_space' => ['spacing' => 'one'], ]) ->setFinder($finder) ; ================================================ FILE: CONTRIBUTING.md ================================================ # Contributing Contributions are welcome, of course. ## Setting up an Environment You locally need: - PHP >= 8.2 (with `pdo_mysql`) with [Composer](https://getcomposer.org/) installed - Docker Install deps: ``` composer i ``` The application serves its frontend assets directly from `public/`, so there is no Node/Yarn setup step. Then you can use Docker (used for test or dev): ``` docker run -d --name banditore-mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -p 3306:3306 mysql:latest docker run -d --name banditore-redis -p 6379:6379 redis:latest docker run -d --name banditore-rabbit -p 5672:5672 -p 15672:15672 rabbitmq:4-management ``` ## Running Tests You can setup the database and the project using: ``` make prepare ``` Once it's ok, launch tests: ``` php bin/phpunit ``` Test environment defaults live in `.env.test`. ## Linting Linter is used only on PHP files: ``` php bin/php-cs-fixer fix php bin/phpstan analyse ``` ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2017-present Jérémy Benoist Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: Makefile ================================================ .PHONY: build local prepare test build: prepare test local: php bin/console doctrine:database:create --if-not-exists --env=test php bin/console doctrine:schema:create --env=test php bin/console doctrine:fixtures:load --env=test -n php bin/console cache:clear --env=test prepare: composer install --no-interaction -o --prefer-dist php bin/console doctrine:database:create --if-not-exists --env=test php bin/console doctrine:schema:drop --force --env=test php bin/console doctrine:schema:create --env=test php bin/console doctrine:fixtures:load --env=test -n php bin/console cache:clear --env=test test: php bin/phpunit --coverage-html build/coverage reset: php bin/console doctrine:schema:drop --force --env=test php bin/console doctrine:schema:create --env=test php bin/console doctrine:fixtures:load --env=test -n ================================================ FILE: README.md ================================================ # Banditore ![CI](https://github.com/j0k3r/banditore/workflows/CI/badge.svg) [![codecov](https://codecov.io/github/j0k3r/banditore/graph/badge.svg?token=vGOatWHRG8)](https://codecov.io/github/j0k3r/banditore) ![PHPStan level max](https://img.shields.io/badge/PHPStan-level%20max-brightgreen.svg?style=flat) Banditore retrieves new releases from your GitHub starred repositories and put them in a RSS feed, just for you. ![](https://i.imgur.com/XDCWLJV.png) ## Requirements - PHP >= 8.2 (with `pdo_mysql`) - MySQL >= 5.7 - Redis (to cache requests to the GitHub API) - [RabbitMQ](https://www.rabbitmq.com/), which is optional (see below) - [Supervisor](http://supervisord.org/) (only if you use RabbitMQ) ## Installation 1. Clone the project ```bash git clone https://github.com/j0k3r/banditore.git ``` 2. [Register a new OAuth GitHub application](https://github.com/settings/applications/new) and get the _Client ID_ & _Client Secret_ for the next step (for the _Authorization callback URL_ put `http://127.0.0.1:8000/callback`) 3. Install dependencies using [Composer](https://getcomposer.org/download/) and define your parameter during the installation ```bash APP_ENV=prod composer install -o --no-dev ``` If you want to use: - **Sentry** to retrieve all errors, [register here](https://sentry.io/signup/) and get your dsn (in Project Settings > DSN). 4. Setup the database ```bash php bin/console doctrine:database:create -e prod php bin/console doctrine:schema:create -e prod ``` 5. The application serves its frontend assets directly from `public/`, so no Node/Yarn install step is required (it's locked on `font-awesome@4.7.0` & `purecss@3.0.0`). 6. You can now launch the website: ```bash php -S localhost:8000 -t public/ ``` And access it at this address: `http://127.0.0.1:8000` ## Running the instance Once the website is up, you now have to setup few things to retrieve new releases. You have two choices: - using crontab command (very simple and ok if you are alone) - using RabbitMQ (might be better if you plan to have more than few persons but it's more complex) :call_me_hand: ### Without RabbitMQ You just need to define these 2 cronjobs (replace all `/path/to/banditore` with real value): ```bash # retrieve new release of each repo every 10 minutes */10 * * * * php /path/to/banditore/bin/console -e prod banditore:sync:versions >> /path/to/banditore/var/logs/command-sync-versions.log 2>&1 # sync starred repos of each user every 5 minutes */5 * * * * php /path/to/banditore/bin/console -e prod banditore:sync:starred-repos >> /path/banditore/to/var/logs/command-sync-repos.log 2>&1 ``` ### With RabbitMQ 1. You'll need to declare exchanges and queues. Replace `guest` by the user of your RabbitMQ instance (`guest` is the default one): ```bash php bin/console messenger:setup-transports -vvv sync_starred_repos php bin/console messenger:setup-transports -vvv sync_versions ``` 2. You now have two queues and two exchanges defined: - `banditore.sync_starred_repos`: will receive messages to sync starred repos of all users - `banditore.sync_versions`: will receive message to retrieve new release for repos 3. Enable these 2 cronjobs which will periodically push messages in queues (replace all `/path/to/banditore` with real value): ```bash # retrieve new release of each repo every 10 minutes */10 * * * * php /path/to/banditore/bin/console -e prod banditore:sync:versions --use_queue >> /path/to/banditore/var/logs/command-sync-versions.log 2>&1 # sync starred repos of each user every 5 minutes */5 * * * * php /path/to/banditore/bin/console -e prod banditore:sync:starred-repos --use_queue >> /path/banditore/to/var/logs/command-sync-repos.log 2>&1 ``` 4. Setup Supervisor using the [sample file](data/supervisor.conf) from the repo. You can copy/paste it into `/etc/supervisor/conf.d/` and adjust path. The default file will launch: - 2 workers for sync starred repos - 4 workers to fetch new releases Once you've put the file in the supervisor conf repo, run `supervisorctl update && supervisorctl start all` (`update` will read your conf, `start all` will start all workers) ### Monitoring There is a status page available at `/status`, it returns a json with some information about the freshness of fetched versions: ```json { "latest": { "date": "2019-09-17 19:50:50.000000", "timezone_type": 3, "timezone": "Europe\/Berlin" }, "diff": 1736, "is_fresh": true } ``` - `latest`: the latest created version as a DateTime - `diff`: the difference between now and the latest created version (in seconds) - `is_fresh`: indicate if everything is fine by comparing the `diff` above with the `status_minute_interval_before_alert` parameter For example, I've setup a check on [updown.io](https://updown.io/r/P7qer) to check that status page and if the page contains `"is_fresh":true`. So I receive an alert when `is_fresh` is false: which means there is a potential issue on the server. ## Running the test suite If you plan to contribute (you're awesome, I know that :v:), you'll need to install the project in a different way (for example, to retrieve dev packages): ```bash git clone https://github.com/j0k3r/banditore.git composer install -o php bin/console doctrine:database:create -e=test php bin/console doctrine:schema:create -e=test php bin/console doctrine:fixtures:load --env=test -n php bin/phpunit ``` Test environment defaults, including the database connection, are defined in `.env.test`. ## How it works Ok, if you goes that deeper in the readme, it means you're a bit more than interested, I like that. ### Retrieving new release / tag This is the complex part of the app. Here is a simplified solution to achieve it. #### New release It's not as easy as using the `/repos/:owner/:repo/releases` API endpoint to retrieve latest release for a given repo. Because not all repo owner use that feature (which is a shame in my case). All information for a release are available on that endpoint: - name of the tag (ie: v1.0.0) - name of the release (ie: yay first release) - published date - description of the release > Check a new release of that repo as example: https://api.github.com/repos/j0k3r/banditore/releases/5770680 #### New tag Some owners also use tag which is a bit more complex to retrieve all information because a tag only contains information about the SHA-1 of the commit which was used to make the tag. We only have these information: - name of the tag (ie: v1.4.2) - name of the release will be the name of the tag, in that case > Check tag list of swarrot/SwarrotBundle as example: https://api.github.com/repos/swarrot/SwarrotBundle/tags After retrieving the tag, we need to retrieve the commit to get these information: - date of the commit - message of the commit > Check a commit from the previous tag list as example: https://api.github.com/repos/swarrot/SwarrotBundle/commits/84c7c57622e4666ae5706f33cd71842639b78755 ### GitHub Client Discovery This is the most important piece of the app. One thing that I ran though is hitting the rate limit on GitHub. The rate limit for a given authenticated client is 5.000 calls per hour. This limit is **never** reached when looking for new release (thanks to the [conditional requests](https://developer.github.com/v3/#conditional-requests) of the GitHub API) on a daily basis. But when new user sign in, we need to sync all its starred repositories and also all their releases / tags. And here come the gourmand part: - one call for the list of release - one call to retrieve information of each tag (if the repo doesn't have release) - one call for each release to convert markdown text to html Let's say the repo: - has 50 tags: 1 (get tag list) + 50 (get commit information) + 50 (convert markdown) = 101 calls. - has 50 releases: 1 (get tag list) + 50 (get each release) + 50 (convert markdown) = 101 calls. And keep in mind that some repos got also 1.000+ tags (!!). To avoid hitting the limit in such case and wait 1 hour to be able to make requests again I created the [GitHub Client Discovery class](src/AppBundle/Github/ClientDiscovery.php). It aims to find the best client with enough rate limit remain (defined as 50). - it first checks using the GitHub OAuth app - then it checks using all user GitHub token Which means, if you have 5 users on the app, you'll be able to make (1 + 5) x 5.000 = 30.000 calls per hour ================================================ FILE: bin/console ================================================ #!/usr/bin/env php =8.2", "cache/adapter-common": "dev-psr-cache-v3", "cache/tag-interop": "dev-psr-cache-v3", "doctrine/doctrine-bundle": "^2.0", "doctrine/doctrine-migrations-bundle": "^3.0", "doctrine/orm": "^3.5", "knplabs/github-api": "^3.0", "knplabs/knp-time-bundle": "^2.4", "knpuniversity/oauth2-client-bundle": "^2.1", "laminas/laminas-code": "^4.5", "league/oauth2-github": "^3.0", "marcw/rss-writer": "dev-fix/symfony-6", "php-http/guzzle7-adapter": "^1.1", "predis/predis": "^3.2", "ramsey/uuid": "^4.0", "sentry/sentry-symfony": "^5.0", "snc/redis-bundle": "^4.10", "symfony/amqp-messenger": "*", "symfony/asset": "*", "symfony/dotenv": "*", "symfony/expression-language": "*", "symfony/flex": "^2.5", "symfony/monolog-bundle": "^4.0", "symfony/polyfill-apcu": "^1.0", "symfony/polyfill-php80": "^1.27", "symfony/runtime": "*", "symfony/security-bundle": "*", "symfony/translation": "*", "symfony/twig-bundle": "*", "symfony/validator": "*", "symfony/yaml": "*", "twig/extra-bundle": "^2.12|^3.0", "twig/twig": "^2.0|^3.0" }, "require-dev": { "doctrine/doctrine-fixtures-bundle": "^4.1", "friendsofphp/php-cs-fixer": "~3.0", "phpstan/extension-installer": "^1.0", "phpstan/phpstan": "^2.0", "phpstan/phpstan-deprecation-rules": "^2.0", "phpstan/phpstan-doctrine": "^2.0", "phpstan/phpstan-phpunit": "^2.0", "phpstan/phpstan-symfony": "^2.0", "phpunit/phpunit": "^11", "rector/rector": "^2.1", "symfony/browser-kit": "*", "symfony/css-selector": "*", "symfony/debug-bundle": "*", "symfony/phpunit-bridge": "*", "symfony/web-profiler-bundle": "*" }, "conflict": { "symfony/symfony": "*" }, "scripts": { "auto-scripts": { "cache:clear": "symfony-cmd", "assets:install %PUBLIC_DIR%": "symfony-cmd" }, "post-install-cmd": [ "@auto-scripts" ], "post-update-cmd": [ "@auto-scripts" ] }, "config": { "bin-dir": "bin", "sort-packages": true, "allow-plugins": { "phpstan/extension-installer": true, "symfony/flex": true, "symfony/runtime": true, "php-http/discovery": true } }, "repositories": [ { "type": "vcs", "url": "https://github.com/j0k3r/rss-writer" }, { "type": "vcs", "url": "https://github.com/j0k3r/adapter-common" }, { "type": "vcs", "url": "https://github.com/j0k3r/tag-interop" } ], "extra": { "symfony": { "allow-contrib": true, "require": "7.4.*" } } } ================================================ FILE: config/bundles.php ================================================ ['all' => true], DoctrineBundle::class => ['all' => true], DoctrineMigrationsBundle::class => ['all' => true], KnpTimeBundle::class => ['all' => true], KnpUOAuth2ClientBundle::class => ['all' => true], SentryBundle::class => ['prod' => true], SncRedisBundle::class => ['all' => true], MonologBundle::class => ['all' => true], DoctrineFixturesBundle::class => ['dev' => true, 'test' => true], TwigBundle::class => ['all' => true], TwigExtraBundle::class => ['all' => true], SecurityBundle::class => ['all' => true], DebugBundle::class => ['dev' => true, 'test' => true], WebProfilerBundle::class => ['dev' => true, 'test' => true], ]; ================================================ FILE: config/packages/cache.yaml ================================================ framework: cache: # Unique name of your app: used to compute stable namespaces for cache keys. #prefix_seed: your_vendor_name/app_name # The "app" cache stores to the filesystem by default. # The data in this cache should persist between deploys. # Other options include: # Redis #app: cache.adapter.redis #default_redis_provider: redis://localhost # APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues) #app: cache.adapter.apcu # Namespaced pools use the above "app" backend by default #pools: #my.dedicated.cache: null ================================================ FILE: config/packages/debug.yaml ================================================ when@dev: debug: # Forwards VarDumper Data clones to a centralized server allowing to inspect dumps on CLI or in your browser. # See the "server:dump" command to start a new server. dump_destination: "tcp://%env(VAR_DUMPER_SERVER)%" ================================================ FILE: config/packages/doctrine.yaml ================================================ doctrine: dbal: url: '%env(resolve:DATABASE_URL)%' # driver: pdo_mysql # host: "%database_host%" # port: "%database_port%" # dbname: "%database_name%" # user: "%database_user%" # password: "%database_password%" charset: utf8mb4 server_version: 5.7 default_table_options: charset: utf8mb4 collate: utf8mb4_unicode_ci # backtrace queries in profiler (increases memory usage per request) profiling_collect_backtrace: '%kernel.debug%' use_savepoints: true orm: auto_generate_proxy_classes: true enable_lazy_ghost_objects: true report_fields_where_declared: true validate_xml_mapping: true naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware identity_generation_preferences: Doctrine\DBAL\Platforms\PostgreSQLPlatform: identity auto_mapping: true mappings: App: type: attribute is_bundle: false dir: '%kernel.project_dir%/src/Entity' prefix: 'App\Entity' alias: App controller_resolver: auto_mapping: false when@test: doctrine: dbal: logging: false # "TEST_TOKEN" is typically set by ParaTest # dbname_suffix: '_test%env(default::TEST_TOKEN)%' when@prod: doctrine: orm: auto_generate_proxy_classes: false proxy_dir: '%kernel.build_dir%/doctrine/orm/Proxies' metadata_cache_driver: type: pool pool: doctrine.system_cache_pool query_cache_driver: type: pool pool: doctrine.system_cache_pool result_cache_driver: type: pool pool: doctrine.result_cache_pool framework: cache: pools: doctrine.result_cache_pool: adapter: cache.app doctrine.system_cache_pool: adapter: cache.system ================================================ FILE: config/packages/doctrine_migrations.yaml ================================================ doctrine_migrations: migrations_paths: # namespace is arbitrary but should be different from App\Migrations # as migrations classes should NOT be autoloaded 'DoctrineMigrations': '%kernel.project_dir%/migrations' enable_profiler: false ================================================ FILE: config/packages/framework.yaml ================================================ # see https://symfony.com/doc/current/reference/configuration/framework.html framework: secret: '%env(APP_SECRET)%' annotations: false http_method_override: true handle_all_throwables: true # Enables session support. Note that the session will ONLY be started if you read or write from it. # Remove or comment this section to explicitly disable session support. session: name: banditore storage_factory_id: session.storage.factory.native save_path: "%kernel.project_dir%/var/sessions/%kernel.environment%" cookie_secure: auto cookie_samesite: lax #esi: true #fragments: true when@test: framework: test: true session: storage_factory_id: session.storage.factory.mock_file ================================================ FILE: config/packages/github_api.yaml ================================================ services: Github\Client: arguments: - '@Github\HttpClient\Builder' # Uncomment to enable authentication #calls: # - ['authenticate', ['%env(GITHUB_USERNAME)%', '%env(GITHUB_SECRET)%', '%env(GITHUB_AUTH_METHOD)%']] Github\HttpClient\Builder: arguments: - '@?Http\Client\HttpClient' - '@?Http\Message\RequestFactory' - '@?Http\Message\StreamFactory' ================================================ FILE: config/packages/http_discovery.yaml ================================================ services: Psr\Http\Message\RequestFactoryInterface: '@http_discovery.psr17_factory' Psr\Http\Message\ResponseFactoryInterface: '@http_discovery.psr17_factory' Psr\Http\Message\ServerRequestFactoryInterface: '@http_discovery.psr17_factory' Psr\Http\Message\StreamFactoryInterface: '@http_discovery.psr17_factory' Psr\Http\Message\UploadedFileFactoryInterface: '@http_discovery.psr17_factory' Psr\Http\Message\UriFactoryInterface: '@http_discovery.psr17_factory' http_discovery.psr17_factory: class: Http\Discovery\Psr17Factory ================================================ FILE: config/packages/knpu_oauth2_client.yaml ================================================ knpu_oauth2_client: clients: # will create service: "knpu.oauth2.client.github" # an instance of: KnpU\OAuth2ClientBundle\Client\Provider\GithubClient github: type: github client_id: "%env(GITHUB_CLIENT_ID)%" client_secret: "%env(GITHUB_CLIENT_SECRET)%" # a route name you'll create redirect_route: github_callback redirect_params: {} ================================================ FILE: config/packages/messenger.yaml ================================================ framework: messenger: # Uncomment this (and the failed transport below) to send failed messages to this transport for later handling. # failure_transport: failed transports: sync_starred_repos: dsn: '%env(MESSENGER_TRANSPORT_DSN)%/sync_starred_repos' options: exchange: name: banditore.sync_starred_repos type: direct queues: banditore.sync_starred_repos: ~ sync_versions: dsn: '%env(MESSENGER_TRANSPORT_DSN)%/sync_versions' options: exchange: name: banditore.sync_versions type: direct queues: banditore.sync_versions: ~ # https://symfony.com/doc/current/messenger.html#transport-configuration # async: '%env(MESSENGER_TRANSPORT_DSN)%' # failed: 'doctrine://default?queue_name=failed' # sync: 'sync://' routing: 'App\Message\StarredReposSync': sync_starred_repos 'App\Message\VersionsSync': sync_versions buses: command_bus: middleware: - doctrine_ping_connection - doctrine_close_connection when@test: framework: messenger: transports: sync_starred_repos: 'in-memory://' sync_versions: 'in-memory://' ================================================ FILE: config/packages/monolog.yaml ================================================ monolog: channels: - deprecation # Deprecations are logged in the dedicated "deprecation" channel when it exists when@dev: monolog: handlers: main: type: stream path: "%kernel.logs_dir%/%kernel.environment%.log" level: debug channels: ["!event"] console: type: console process_psr_3_messages: false channels: ["!event", "!doctrine", "!console"] when@test: monolog: handlers: main: type: fingers_crossed action_level: error handler: nested excluded_http_codes: [404, 405] channels: ["!event"] nested: type: stream path: "%kernel.logs_dir%/%kernel.environment%.log" level: debug when@prod: monolog: handlers: main: type: fingers_crossed action_level: error handler: nested excluded_http_codes: [404, 405] channels: ["!deprecation"] buffer_size: 50 # How many messages should be saved? Prevent memory leaks nested: type: rotating_file path: "%kernel.logs_dir%/%kernel.environment%.log" level: debug max_files: 10 console: type: console process_psr_3_messages: false channels: ["!event", "!doctrine"] deprecation: type: stream channels: [deprecation] path: "%kernel.logs_dir%/deprecation.log" ================================================ FILE: config/packages/routing.yaml ================================================ framework: router: # Configure how to generate URLs in non-HTTP contexts, such as CLI commands. # See https://symfony.com/doc/current/routing.html#generating-urls-in-commands default_uri: '%env(DEFAULT_URI)%' when@prod: framework: router: strict_requirements: null ================================================ FILE: config/packages/security.yaml ================================================ security: # https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords password_hashers: Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto' # https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider providers: github_provider: entity: class: App\Entity\User property: githubId firewalls: dev: # Ensure dev tools and static assets are always allowed pattern: ^/(_profiler|_wdt|assets|build|css|images|js)/ security: false main: lazy: true custom_authenticators: - App\Security\GithubAuthenticator logout: path: logout # Activate different ways to authenticate: # https://symfony.com/doc/current/security.html#the-firewall # https://symfony.com/doc/current/security/impersonating_user.html # switch_user: true # Note: Only the *first* matching rule is applied access_control: # - { path: ^/admin, roles: ROLE_ADMIN } # - { path: ^/profile, roles: ROLE_USER } when@test: security: password_hashers: # Password hashers are resource-intensive by design to ensure security. # In tests, it's safe to reduce their cost to improve performance. Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: algorithm: auto cost: 4 # Lowest possible value for bcrypt time_cost: 3 # Lowest possible value for argon memory_cost: 10 # Lowest possible value for argon ================================================ FILE: config/packages/sentry.yaml ================================================ when@prod: sentry: dsn: '%env(SENTRY_DSN)%' options: integrations: - 'Sentry\Integration\IgnoreErrorsIntegration' - 'Symfony\Component\ErrorHandler\Error\FatalError' - 'Symfony\Component\Debug\Exception\FatalErrorException' # If you are using Monolog, you also need these additional configuration and services to log the errors correctly: # https://docs.sentry.io/platforms/php/guides/symfony/#monolog-integration register_error_listener: false register_error_handler: false # this hooks into critical paths of the framework (and vendors) to perform # automatic instrumentation (there might be some performance penalty) # https://docs.sentry.io/platforms/php/guides/symfony/performance/instrumentation/automatic-instrumentation/ tracing: enabled: false monolog: handlers: sentry: type: service id: Sentry\Monolog\Handler level: !php/const Monolog\Logger::ERROR services: Sentry\Integration\IgnoreErrorsIntegration: arguments: $options: ignore_exceptions: - Symfony\Component\HttpKernel\Exception\NotFoundHttpException Sentry\Monolog\Handler: arguments: $hub: '@Sentry\State\HubInterface' $level: !php/const Monolog\Logger::ERROR $bubble: false ================================================ FILE: config/packages/snc_redis.yaml ================================================ # Define your clients here. The example below connects to database 0 of the default Redis server. # # See https://github.com/snc/SncRedisBundle/blob/master/docs/README.md for instructions on # how to configure the bundle. snc_redis: clients: guzzle_cache: type: predis alias: guzzle_cache dsn: "%env(REDIS_URL_GUZZLE_CACHE)%" app_cache: type: predis alias: app_cache dsn: "%env(REDIS_URL_APP_CACHE)%" ================================================ FILE: config/packages/twig.yaml ================================================ twig: file_name_pattern: '*.twig' when@test: twig: strict_variables: true ================================================ FILE: config/packages/validator.yaml ================================================ framework: validation: enable_attributes: true email_validation_mode: html5 # Enables validator auto-mapping support. # For instance, basic validation constraints will be inferred from Doctrine's metadata. auto_mapping: App\Entity\: [] when@test: framework: validation: not_compromised_password: false ================================================ FILE: config/packages/web_profiler.yaml ================================================ when@dev: web_profiler: toolbar: true framework: profiler: collect_serializer_data: true when@test: web_profiler: toolbar: false intercept_redirects: false framework: profiler: enabled: false collect: false collect_serializer_data: true ================================================ FILE: config/preload.php ================================================ [ * 'App\\' => [ * 'resource' => '../src/', * ], * ], * ]); * ``` * * @psalm-type ImportsConfig = list * @psalm-type ParametersConfig = array|Param|null>|Param|null> * @psalm-type ArgumentsType = list|array * @psalm-type CallType = array|array{0:string, 1?:ArgumentsType, 2?:bool}|array{method:string, arguments?:ArgumentsType, returns_clone?:bool} * @psalm-type TagsType = list>> // arrays inside the list must have only one element, with the tag name as the key * @psalm-type CallbackType = string|array{0:string|ReferenceConfigurator,1:string}|\Closure|ReferenceConfigurator|ExpressionConfigurator * @psalm-type DeprecationType = array{package: string, version: string, message?: string} * @psalm-type DefaultsType = array{ * public?: bool, * tags?: TagsType, * resource_tags?: TagsType, * autowire?: bool, * autoconfigure?: bool, * bind?: array, * } * @psalm-type InstanceofType = array{ * shared?: bool, * lazy?: bool|string, * public?: bool, * properties?: array, * configurator?: CallbackType, * calls?: list, * tags?: TagsType, * resource_tags?: TagsType, * autowire?: bool, * bind?: array, * constructor?: string, * } * @psalm-type DefinitionType = array{ * class?: string, * file?: string, * parent?: string, * shared?: bool, * synthetic?: bool, * lazy?: bool|string, * public?: bool, * abstract?: bool, * deprecated?: DeprecationType, * factory?: CallbackType, * configurator?: CallbackType, * arguments?: ArgumentsType, * properties?: array, * calls?: list, * tags?: TagsType, * resource_tags?: TagsType, * decorates?: string, * decoration_inner_name?: string, * decoration_priority?: int, * decoration_on_invalid?: 'exception'|'ignore'|null, * autowire?: bool, * autoconfigure?: bool, * bind?: array, * constructor?: string, * from_callable?: CallbackType, * } * @psalm-type AliasType = string|array{ * alias: string, * public?: bool, * deprecated?: DeprecationType, * } * @psalm-type PrototypeType = array{ * resource: string, * namespace?: string, * exclude?: string|list, * parent?: string, * shared?: bool, * lazy?: bool|string, * public?: bool, * abstract?: bool, * deprecated?: DeprecationType, * factory?: CallbackType, * arguments?: ArgumentsType, * properties?: array, * configurator?: CallbackType, * calls?: list, * tags?: TagsType, * resource_tags?: TagsType, * autowire?: bool, * autoconfigure?: bool, * bind?: array, * constructor?: string, * } * @psalm-type StackType = array{ * stack: list>, * public?: bool, * deprecated?: DeprecationType, * } * @psalm-type ServicesConfig = array{ * _defaults?: DefaultsType, * _instanceof?: InstanceofType, * ... * } * @psalm-type ExtensionType = array * @psalm-type FrameworkConfig = array{ * secret?: scalar|Param|null, * http_method_override?: bool|Param, // Set true to enable support for the '_method' request parameter to determine the intended HTTP method on POST requests. // Default: false * allowed_http_method_override?: list|null, * trust_x_sendfile_type_header?: scalar|Param|null, // Set true to enable support for xsendfile in binary file responses. // Default: "%env(bool:default::SYMFONY_TRUST_X_SENDFILE_TYPE_HEADER)%" * ide?: scalar|Param|null, // Default: "%env(default::SYMFONY_IDE)%" * test?: bool|Param, * default_locale?: scalar|Param|null, // Default: "en" * set_locale_from_accept_language?: bool|Param, // Whether to use the Accept-Language HTTP header to set the Request locale (only when the "_locale" request attribute is not passed). // Default: false * set_content_language_from_locale?: bool|Param, // Whether to set the Content-Language HTTP header on the Response using the Request locale. // Default: false * enabled_locales?: list, * trusted_hosts?: list, * trusted_proxies?: mixed, // Default: ["%env(default::SYMFONY_TRUSTED_PROXIES)%"] * trusted_headers?: list, * error_controller?: scalar|Param|null, // Default: "error_controller" * handle_all_throwables?: bool|Param, // HttpKernel will handle all kinds of \Throwable. // Default: true * csrf_protection?: bool|array{ * enabled?: scalar|Param|null, // Default: null * stateless_token_ids?: list, * check_header?: scalar|Param|null, // Whether to check the CSRF token in a header in addition to a cookie when using stateless protection. // Default: false * cookie_name?: scalar|Param|null, // The name of the cookie to use when using stateless protection. // Default: "csrf-token" * }, * form?: bool|array{ // Form configuration * enabled?: bool|Param, // Default: false * csrf_protection?: bool|array{ * enabled?: scalar|Param|null, // Default: null * token_id?: scalar|Param|null, // Default: null * field_name?: scalar|Param|null, // Default: "_token" * field_attr?: array, * }, * }, * http_cache?: bool|array{ // HTTP cache configuration * enabled?: bool|Param, // Default: false * debug?: bool|Param, // Default: "%kernel.debug%" * trace_level?: "none"|"short"|"full"|Param, * trace_header?: scalar|Param|null, * default_ttl?: int|Param, * private_headers?: list, * skip_response_headers?: list, * allow_reload?: bool|Param, * allow_revalidate?: bool|Param, * stale_while_revalidate?: int|Param, * stale_if_error?: int|Param, * terminate_on_cache_hit?: bool|Param, * }, * esi?: bool|array{ // ESI configuration * enabled?: bool|Param, // Default: false * }, * ssi?: bool|array{ // SSI configuration * enabled?: bool|Param, // Default: false * }, * fragments?: bool|array{ // Fragments configuration * enabled?: bool|Param, // Default: false * hinclude_default_template?: scalar|Param|null, // Default: null * path?: scalar|Param|null, // Default: "/_fragment" * }, * profiler?: bool|array{ // Profiler configuration * enabled?: bool|Param, // Default: false * collect?: bool|Param, // Default: true * collect_parameter?: scalar|Param|null, // The name of the parameter to use to enable or disable collection on a per request basis. // Default: null * only_exceptions?: bool|Param, // Default: false * only_main_requests?: bool|Param, // Default: false * dsn?: scalar|Param|null, // Default: "file:%kernel.cache_dir%/profiler" * collect_serializer_data?: bool|Param, // Enables the serializer data collector and profiler panel. // Default: false * }, * workflows?: bool|array{ * enabled?: bool|Param, // Default: false * workflows?: array, * definition_validators?: list, * support_strategy?: scalar|Param|null, * initial_marking?: list, * events_to_dispatch?: list|null, * places?: list, * }>, * transitions?: list, * to?: list, * weight?: int|Param, // Default: 1 * metadata?: array, * }>, * metadata?: array, * }>, * }, * router?: bool|array{ // Router configuration * enabled?: bool|Param, // Default: false * resource?: scalar|Param|null, * type?: scalar|Param|null, * cache_dir?: scalar|Param|null, // Deprecated: Setting the "framework.router.cache_dir.cache_dir" configuration option is deprecated. It will be removed in version 8.0. // Default: "%kernel.build_dir%" * default_uri?: scalar|Param|null, // The default URI used to generate URLs in a non-HTTP context. // Default: null * http_port?: scalar|Param|null, // Default: 80 * https_port?: scalar|Param|null, // Default: 443 * strict_requirements?: scalar|Param|null, // set to true to throw an exception when a parameter does not match the requirements set to false to disable exceptions when a parameter does not match the requirements (and return null instead) set to null to disable parameter checks against requirements 'true' is the preferred configuration in development mode, while 'false' or 'null' might be preferred in production // Default: true * utf8?: bool|Param, // Default: true * }, * session?: bool|array{ // Session configuration * enabled?: bool|Param, // Default: false * storage_factory_id?: scalar|Param|null, // Default: "session.storage.factory.native" * handler_id?: scalar|Param|null, // Defaults to using the native session handler, or to the native *file* session handler if "save_path" is not null. * name?: scalar|Param|null, * cookie_lifetime?: scalar|Param|null, * cookie_path?: scalar|Param|null, * cookie_domain?: scalar|Param|null, * cookie_secure?: true|false|"auto"|Param, // Default: "auto" * cookie_httponly?: bool|Param, // Default: true * cookie_samesite?: null|"lax"|"strict"|"none"|Param, // Default: "lax" * use_cookies?: bool|Param, * gc_divisor?: scalar|Param|null, * gc_probability?: scalar|Param|null, * gc_maxlifetime?: scalar|Param|null, * save_path?: scalar|Param|null, // Defaults to "%kernel.cache_dir%/sessions" if the "handler_id" option is not null. * metadata_update_threshold?: int|Param, // Seconds to wait between 2 session metadata updates. // Default: 0 * sid_length?: int|Param, // Deprecated: Setting the "framework.session.sid_length.sid_length" configuration option is deprecated. It will be removed in version 8.0. No alternative is provided as PHP 8.4 has deprecated the related option. * sid_bits_per_character?: int|Param, // Deprecated: Setting the "framework.session.sid_bits_per_character.sid_bits_per_character" configuration option is deprecated. It will be removed in version 8.0. No alternative is provided as PHP 8.4 has deprecated the related option. * }, * request?: bool|array{ // Request configuration * enabled?: bool|Param, // Default: false * formats?: array>, * }, * assets?: bool|array{ // Assets configuration * enabled?: bool|Param, // Default: true * strict_mode?: bool|Param, // Throw an exception if an entry is missing from the manifest.json. // Default: false * version_strategy?: scalar|Param|null, // Default: null * version?: scalar|Param|null, // Default: null * version_format?: scalar|Param|null, // Default: "%%s?%%s" * json_manifest_path?: scalar|Param|null, // Default: null * base_path?: scalar|Param|null, // Default: "" * base_urls?: list, * packages?: array, * }>, * }, * asset_mapper?: bool|array{ // Asset Mapper configuration * enabled?: bool|Param, // Default: false * paths?: array, * excluded_patterns?: list, * exclude_dotfiles?: bool|Param, // If true, any files starting with "." will be excluded from the asset mapper. // Default: true * server?: bool|Param, // If true, a "dev server" will return the assets from the public directory (true in "debug" mode only by default). // Default: true * public_prefix?: scalar|Param|null, // The public path where the assets will be written to (and served from when "server" is true). // Default: "/assets/" * missing_import_mode?: "strict"|"warn"|"ignore"|Param, // Behavior if an asset cannot be found when imported from JavaScript or CSS files - e.g. "import './non-existent.js'". "strict" means an exception is thrown, "warn" means a warning is logged, "ignore" means the import is left as-is. // Default: "warn" * extensions?: array, * importmap_path?: scalar|Param|null, // The path of the importmap.php file. // Default: "%kernel.project_dir%/importmap.php" * importmap_polyfill?: scalar|Param|null, // The importmap name that will be used to load the polyfill. Set to false to disable. // Default: "es-module-shims" * importmap_script_attributes?: array, * vendor_dir?: scalar|Param|null, // The directory to store JavaScript vendors. // Default: "%kernel.project_dir%/assets/vendor" * precompress?: bool|array{ // Precompress assets with Brotli, Zstandard and gzip. * enabled?: bool|Param, // Default: false * formats?: list, * extensions?: list, * }, * }, * translator?: bool|array{ // Translator configuration * enabled?: bool|Param, // Default: true * fallbacks?: list, * logging?: bool|Param, // Default: false * formatter?: scalar|Param|null, // Default: "translator.formatter.default" * cache_dir?: scalar|Param|null, // Default: "%kernel.cache_dir%/translations" * default_path?: scalar|Param|null, // The default path used to load translations. // Default: "%kernel.project_dir%/translations" * paths?: list, * pseudo_localization?: bool|array{ * enabled?: bool|Param, // Default: false * accents?: bool|Param, // Default: true * expansion_factor?: float|Param, // Default: 1.0 * brackets?: bool|Param, // Default: true * parse_html?: bool|Param, // Default: false * localizable_html_attributes?: list, * }, * providers?: array, * locales?: list, * }>, * globals?: array, * domain?: string|Param, * }>, * }, * validation?: bool|array{ // Validation configuration * enabled?: bool|Param, // Default: true * cache?: scalar|Param|null, // Deprecated: Setting the "framework.validation.cache.cache" configuration option is deprecated. It will be removed in version 8.0. * enable_attributes?: bool|Param, // Default: true * static_method?: list, * translation_domain?: scalar|Param|null, // Default: "validators" * email_validation_mode?: "html5"|"html5-allow-no-tld"|"strict"|"loose"|Param, // Default: "html5" * mapping?: array{ * paths?: list, * }, * not_compromised_password?: bool|array{ * enabled?: bool|Param, // When disabled, compromised passwords will be accepted as valid. // Default: true * endpoint?: scalar|Param|null, // API endpoint for the NotCompromisedPassword Validator. // Default: null * }, * disable_translation?: bool|Param, // Default: false * auto_mapping?: array, * }>, * }, * annotations?: bool|array{ * enabled?: bool|Param, // Default: false * }, * serializer?: bool|array{ // Serializer configuration * enabled?: bool|Param, // Default: false * enable_attributes?: bool|Param, // Default: true * name_converter?: scalar|Param|null, * circular_reference_handler?: scalar|Param|null, * max_depth_handler?: scalar|Param|null, * mapping?: array{ * paths?: list, * }, * default_context?: array, * named_serializers?: array, * include_built_in_normalizers?: bool|Param, // Whether to include the built-in normalizers // Default: true * include_built_in_encoders?: bool|Param, // Whether to include the built-in encoders // Default: true * }>, * }, * property_access?: bool|array{ // Property access configuration * enabled?: bool|Param, // Default: true * magic_call?: bool|Param, // Default: false * magic_get?: bool|Param, // Default: true * magic_set?: bool|Param, // Default: true * throw_exception_on_invalid_index?: bool|Param, // Default: false * throw_exception_on_invalid_property_path?: bool|Param, // Default: true * }, * type_info?: bool|array{ // Type info configuration * enabled?: bool|Param, // Default: true * aliases?: array, * }, * property_info?: bool|array{ // Property info configuration * enabled?: bool|Param, // Default: true * with_constructor_extractor?: bool|Param, // Registers the constructor extractor. * }, * cache?: array{ // Cache configuration * prefix_seed?: scalar|Param|null, // Used to namespace cache keys when using several apps with the same shared backend. // Default: "_%kernel.project_dir%.%kernel.container_class%" * app?: scalar|Param|null, // App related cache pools configuration. // Default: "cache.adapter.filesystem" * system?: scalar|Param|null, // System related cache pools configuration. // Default: "cache.adapter.system" * directory?: scalar|Param|null, // Default: "%kernel.share_dir%/pools/app" * default_psr6_provider?: scalar|Param|null, * default_redis_provider?: scalar|Param|null, // Default: "redis://localhost" * default_valkey_provider?: scalar|Param|null, // Default: "valkey://localhost" * default_memcached_provider?: scalar|Param|null, // Default: "memcached://localhost" * default_doctrine_dbal_provider?: scalar|Param|null, // Default: "database_connection" * default_pdo_provider?: scalar|Param|null, // Default: null * pools?: array, * tags?: scalar|Param|null, // Default: null * public?: bool|Param, // Default: false * default_lifetime?: scalar|Param|null, // Default lifetime of the pool. * provider?: scalar|Param|null, // Overwrite the setting from the default provider for this adapter. * early_expiration_message_bus?: scalar|Param|null, * clearer?: scalar|Param|null, * }>, * }, * php_errors?: array{ // PHP errors handling configuration * log?: mixed, // Use the application logger instead of the PHP logger for logging PHP errors. // Default: true * throw?: bool|Param, // Throw PHP errors as \ErrorException instances. // Default: true * }, * exceptions?: array, * web_link?: bool|array{ // Web links configuration * enabled?: bool|Param, // Default: false * }, * lock?: bool|string|array{ // Lock configuration * enabled?: bool|Param, // Default: false * resources?: array>, * }, * semaphore?: bool|string|array{ // Semaphore configuration * enabled?: bool|Param, // Default: false * resources?: array, * }, * messenger?: bool|array{ // Messenger configuration * enabled?: bool|Param, // Default: true * routing?: array, * }>, * serializer?: array{ * default_serializer?: scalar|Param|null, // Service id to use as the default serializer for the transports. // Default: "messenger.transport.native_php_serializer" * symfony_serializer?: array{ * format?: scalar|Param|null, // Serialization format for the messenger.transport.symfony_serializer service (which is not the serializer used by default). // Default: "json" * context?: array, * }, * }, * transports?: array, * failure_transport?: scalar|Param|null, // Transport name to send failed messages to (after all retries have failed). // Default: null * retry_strategy?: string|array{ * service?: scalar|Param|null, // Service id to override the retry strategy entirely. // Default: null * max_retries?: int|Param, // Default: 3 * delay?: int|Param, // Time in ms to delay (or the initial value when multiplier is used). // Default: 1000 * multiplier?: float|Param, // If greater than 1, delay will grow exponentially for each retry: this delay = (delay * (multiple ^ retries)). // Default: 2 * max_delay?: int|Param, // Max time in ms that a retry should ever be delayed (0 = infinite). // Default: 0 * jitter?: float|Param, // Randomness to apply to the delay (between 0 and 1). // Default: 0.1 * }, * rate_limiter?: scalar|Param|null, // Rate limiter name to use when processing messages. // Default: null * }>, * failure_transport?: scalar|Param|null, // Transport name to send failed messages to (after all retries have failed). // Default: null * stop_worker_on_signals?: list, * default_bus?: scalar|Param|null, // Default: null * buses?: array, * }>, * }>, * }, * scheduler?: bool|array{ // Scheduler configuration * enabled?: bool|Param, // Default: false * }, * disallow_search_engine_index?: bool|Param, // Enabled by default when debug is enabled. // Default: true * http_client?: bool|array{ // HTTP Client configuration * enabled?: bool|Param, // Default: false * max_host_connections?: int|Param, // The maximum number of connections to a single host. * default_options?: array{ * headers?: array, * vars?: array, * max_redirects?: int|Param, // The maximum number of redirects to follow. * http_version?: scalar|Param|null, // The default HTTP version, typically 1.1 or 2.0, leave to null for the best version. * resolve?: array, * proxy?: scalar|Param|null, // The URL of the proxy to pass requests through or null for automatic detection. * no_proxy?: scalar|Param|null, // A comma separated list of hosts that do not require a proxy to be reached. * timeout?: float|Param, // The idle timeout, defaults to the "default_socket_timeout" ini parameter. * max_duration?: float|Param, // The maximum execution time for the request+response as a whole. * bindto?: scalar|Param|null, // A network interface name, IP address, a host name or a UNIX socket to bind to. * verify_peer?: bool|Param, // Indicates if the peer should be verified in a TLS context. * verify_host?: bool|Param, // Indicates if the host should exist as a certificate common name. * cafile?: scalar|Param|null, // A certificate authority file. * capath?: scalar|Param|null, // A directory that contains multiple certificate authority files. * local_cert?: scalar|Param|null, // A PEM formatted certificate file. * local_pk?: scalar|Param|null, // A private key file. * passphrase?: scalar|Param|null, // The passphrase used to encrypt the "local_pk" file. * ciphers?: scalar|Param|null, // A list of TLS ciphers separated by colons, commas or spaces (e.g. "RC3-SHA:TLS13-AES-128-GCM-SHA256"...) * peer_fingerprint?: array{ // Associative array: hashing algorithm => hash(es). * sha1?: mixed, * pin-sha256?: mixed, * md5?: mixed, * }, * crypto_method?: scalar|Param|null, // The minimum version of TLS to accept; must be one of STREAM_CRYPTO_METHOD_TLSv*_CLIENT constants. * extra?: array, * rate_limiter?: scalar|Param|null, // Rate limiter name to use for throttling requests. // Default: null * caching?: bool|array{ // Caching configuration. * enabled?: bool|Param, // Default: false * cache_pool?: string|Param, // The taggable cache pool to use for storing the responses. // Default: "cache.http_client" * shared?: bool|Param, // Indicates whether the cache is shared (public) or private. // Default: true * max_ttl?: int|Param, // The maximum TTL (in seconds) allowed for cached responses. Null means no cap. // Default: null * }, * retry_failed?: bool|array{ * enabled?: bool|Param, // Default: false * retry_strategy?: scalar|Param|null, // service id to override the retry strategy. // Default: null * http_codes?: array, * }>, * max_retries?: int|Param, // Default: 3 * delay?: int|Param, // Time in ms to delay (or the initial value when multiplier is used). // Default: 1000 * multiplier?: float|Param, // If greater than 1, delay will grow exponentially for each retry: delay * (multiple ^ retries). // Default: 2 * max_delay?: int|Param, // Max time in ms that a retry should ever be delayed (0 = infinite). // Default: 0 * jitter?: float|Param, // Randomness in percent (between 0 and 1) to apply to the delay. // Default: 0.1 * }, * }, * mock_response_factory?: scalar|Param|null, // The id of the service that should generate mock responses. It should be either an invokable or an iterable. * scoped_clients?: array, * headers?: array, * max_redirects?: int|Param, // The maximum number of redirects to follow. * http_version?: scalar|Param|null, // The default HTTP version, typically 1.1 or 2.0, leave to null for the best version. * resolve?: array, * proxy?: scalar|Param|null, // The URL of the proxy to pass requests through or null for automatic detection. * no_proxy?: scalar|Param|null, // A comma separated list of hosts that do not require a proxy to be reached. * timeout?: float|Param, // The idle timeout, defaults to the "default_socket_timeout" ini parameter. * max_duration?: float|Param, // The maximum execution time for the request+response as a whole. * bindto?: scalar|Param|null, // A network interface name, IP address, a host name or a UNIX socket to bind to. * verify_peer?: bool|Param, // Indicates if the peer should be verified in a TLS context. * verify_host?: bool|Param, // Indicates if the host should exist as a certificate common name. * cafile?: scalar|Param|null, // A certificate authority file. * capath?: scalar|Param|null, // A directory that contains multiple certificate authority files. * local_cert?: scalar|Param|null, // A PEM formatted certificate file. * local_pk?: scalar|Param|null, // A private key file. * passphrase?: scalar|Param|null, // The passphrase used to encrypt the "local_pk" file. * ciphers?: scalar|Param|null, // A list of TLS ciphers separated by colons, commas or spaces (e.g. "RC3-SHA:TLS13-AES-128-GCM-SHA256"...). * peer_fingerprint?: array{ // Associative array: hashing algorithm => hash(es). * sha1?: mixed, * pin-sha256?: mixed, * md5?: mixed, * }, * crypto_method?: scalar|Param|null, // The minimum version of TLS to accept; must be one of STREAM_CRYPTO_METHOD_TLSv*_CLIENT constants. * extra?: array, * rate_limiter?: scalar|Param|null, // Rate limiter name to use for throttling requests. // Default: null * caching?: bool|array{ // Caching configuration. * enabled?: bool|Param, // Default: false * cache_pool?: string|Param, // The taggable cache pool to use for storing the responses. // Default: "cache.http_client" * shared?: bool|Param, // Indicates whether the cache is shared (public) or private. // Default: true * max_ttl?: int|Param, // The maximum TTL (in seconds) allowed for cached responses. Null means no cap. // Default: null * }, * retry_failed?: bool|array{ * enabled?: bool|Param, // Default: false * retry_strategy?: scalar|Param|null, // service id to override the retry strategy. // Default: null * http_codes?: array, * }>, * max_retries?: int|Param, // Default: 3 * delay?: int|Param, // Time in ms to delay (or the initial value when multiplier is used). // Default: 1000 * multiplier?: float|Param, // If greater than 1, delay will grow exponentially for each retry: delay * (multiple ^ retries). // Default: 2 * max_delay?: int|Param, // Max time in ms that a retry should ever be delayed (0 = infinite). // Default: 0 * jitter?: float|Param, // Randomness in percent (between 0 and 1) to apply to the delay. // Default: 0.1 * }, * }>, * }, * mailer?: bool|array{ // Mailer configuration * enabled?: bool|Param, // Default: false * message_bus?: scalar|Param|null, // The message bus to use. Defaults to the default bus if the Messenger component is installed. // Default: null * dsn?: scalar|Param|null, // Default: null * transports?: array, * envelope?: array{ // Mailer Envelope configuration * sender?: scalar|Param|null, * recipients?: list, * allowed_recipients?: list, * }, * headers?: array, * dkim_signer?: bool|array{ // DKIM signer configuration * enabled?: bool|Param, // Default: false * key?: scalar|Param|null, // Key content, or path to key (in PEM format with the `file://` prefix) // Default: "" * domain?: scalar|Param|null, // Default: "" * select?: scalar|Param|null, // Default: "" * passphrase?: scalar|Param|null, // The private key passphrase // Default: "" * options?: array, * }, * smime_signer?: bool|array{ // S/MIME signer configuration * enabled?: bool|Param, // Default: false * key?: scalar|Param|null, // Path to key (in PEM format) // Default: "" * certificate?: scalar|Param|null, // Path to certificate (in PEM format without the `file://` prefix) // Default: "" * passphrase?: scalar|Param|null, // The private key passphrase // Default: null * extra_certificates?: scalar|Param|null, // Default: null * sign_options?: int|Param, // Default: null * }, * smime_encrypter?: bool|array{ // S/MIME encrypter configuration * enabled?: bool|Param, // Default: false * repository?: scalar|Param|null, // S/MIME certificate repository service. This service shall implement the `Symfony\Component\Mailer\EventListener\SmimeCertificateRepositoryInterface`. // Default: "" * cipher?: int|Param, // A set of algorithms used to encrypt the message // Default: null * }, * }, * secrets?: bool|array{ * enabled?: bool|Param, // Default: true * vault_directory?: scalar|Param|null, // Default: "%kernel.project_dir%/config/secrets/%kernel.runtime_environment%" * local_dotenv_file?: scalar|Param|null, // Default: "%kernel.project_dir%/.env.%kernel.environment%.local" * decryption_env_var?: scalar|Param|null, // Default: "base64:default::SYMFONY_DECRYPTION_SECRET" * }, * notifier?: bool|array{ // Notifier configuration * enabled?: bool|Param, // Default: false * message_bus?: scalar|Param|null, // The message bus to use. Defaults to the default bus if the Messenger component is installed. // Default: null * chatter_transports?: array, * texter_transports?: array, * notification_on_failed_messages?: bool|Param, // Default: false * channel_policy?: array>, * admin_recipients?: list, * }, * rate_limiter?: bool|array{ // Rate limiter configuration * enabled?: bool|Param, // Default: false * limiters?: array, * limit?: int|Param, // The maximum allowed hits in a fixed interval or burst. * interval?: scalar|Param|null, // Configures the fixed interval if "policy" is set to "fixed_window" or "sliding_window". The value must be a number followed by "second", "minute", "hour", "day", "week" or "month" (or their plural equivalent). * rate?: array{ // Configures the fill rate if "policy" is set to "token_bucket". * interval?: scalar|Param|null, // Configures the rate interval. The value must be a number followed by "second", "minute", "hour", "day", "week" or "month" (or their plural equivalent). * amount?: int|Param, // Amount of tokens to add each interval. // Default: 1 * }, * }>, * }, * uid?: bool|array{ // Uid configuration * enabled?: bool|Param, // Default: false * default_uuid_version?: 7|6|4|1|Param, // Default: 7 * name_based_uuid_version?: 5|3|Param, // Default: 5 * name_based_uuid_namespace?: scalar|Param|null, * time_based_uuid_version?: 7|6|1|Param, // Default: 7 * time_based_uuid_node?: scalar|Param|null, * }, * html_sanitizer?: bool|array{ // HtmlSanitizer configuration * enabled?: bool|Param, // Default: false * sanitizers?: array, * block_elements?: list, * drop_elements?: list, * allow_attributes?: array, * drop_attributes?: array, * force_attributes?: array>, * force_https_urls?: bool|Param, // Transforms URLs using the HTTP scheme to use the HTTPS scheme instead. // Default: false * allowed_link_schemes?: list, * allowed_link_hosts?: list|null, * allow_relative_links?: bool|Param, // Allows relative URLs to be used in links href attributes. // Default: false * allowed_media_schemes?: list, * allowed_media_hosts?: list|null, * allow_relative_medias?: bool|Param, // Allows relative URLs to be used in media source attributes (img, audio, video, ...). // Default: false * with_attribute_sanitizers?: list, * without_attribute_sanitizers?: list, * max_input_length?: int|Param, // The maximum length allowed for the sanitized input. // Default: 0 * }>, * }, * webhook?: bool|array{ // Webhook configuration * enabled?: bool|Param, // Default: false * message_bus?: scalar|Param|null, // The message bus to use. // Default: "messenger.default_bus" * routing?: array, * }, * remote-event?: bool|array{ // RemoteEvent configuration * enabled?: bool|Param, // Default: false * }, * json_streamer?: bool|array{ // JSON streamer configuration * enabled?: bool|Param, // Default: false * }, * } * @psalm-type DoctrineConfig = array{ * dbal?: array{ * default_connection?: scalar|Param|null, * types?: array, * driver_schemes?: array, * connections?: array, * mapping_types?: array, * default_table_options?: array, * schema_manager_factory?: scalar|Param|null, // Default: "doctrine.dbal.default_schema_manager_factory" * result_cache?: scalar|Param|null, * slaves?: array, * replicas?: array, * }>, * }, * orm?: array{ * default_entity_manager?: scalar|Param|null, * auto_generate_proxy_classes?: scalar|Param|null, // Auto generate mode possible values are: "NEVER", "ALWAYS", "FILE_NOT_EXISTS", "EVAL", "FILE_NOT_EXISTS_OR_CHANGED", this option is ignored when the "enable_native_lazy_objects" option is true // Default: false * enable_lazy_ghost_objects?: bool|Param, // Enables the new implementation of proxies based on lazy ghosts instead of using the legacy implementation // Default: true * enable_native_lazy_objects?: bool|Param, // Enables the new native implementation of PHP lazy objects instead of generated proxies // Default: false * proxy_dir?: scalar|Param|null, // Configures the path where generated proxy classes are saved when using non-native lazy objects, this option is ignored when the "enable_native_lazy_objects" option is true // Default: "%kernel.build_dir%/doctrine/orm/Proxies" * proxy_namespace?: scalar|Param|null, // Defines the root namespace for generated proxy classes when using non-native lazy objects, this option is ignored when the "enable_native_lazy_objects" option is true // Default: "Proxies" * controller_resolver?: bool|array{ * enabled?: bool|Param, // Default: true * auto_mapping?: bool|Param|null, // Set to false to disable using route placeholders as lookup criteria when the primary key doesn't match the argument name // Default: null * evict_cache?: bool|Param, // Set to true to fetch the entity from the database instead of using the cache, if any // Default: false * }, * entity_managers?: array, * }>, * }>, * }, * connection?: scalar|Param|null, * class_metadata_factory_name?: scalar|Param|null, // Default: "Doctrine\\ORM\\Mapping\\ClassMetadataFactory" * default_repository_class?: scalar|Param|null, // Default: "Doctrine\\ORM\\EntityRepository" * auto_mapping?: scalar|Param|null, // Default: false * naming_strategy?: scalar|Param|null, // Default: "doctrine.orm.naming_strategy.default" * quote_strategy?: scalar|Param|null, // Default: "doctrine.orm.quote_strategy.default" * typed_field_mapper?: scalar|Param|null, // Default: "doctrine.orm.typed_field_mapper.default" * entity_listener_resolver?: scalar|Param|null, // Default: null * fetch_mode_subselect_batch_size?: scalar|Param|null, * repository_factory?: scalar|Param|null, // Default: "doctrine.orm.container_repository_factory" * schema_ignore_classes?: list, * report_fields_where_declared?: bool|Param, // Set to "true" to opt-in to the new mapping driver mode that was added in Doctrine ORM 2.16 and will be mandatory in ORM 3.0. See https://github.com/doctrine/orm/pull/10455. // Default: true * validate_xml_mapping?: bool|Param, // Set to "true" to opt-in to the new mapping driver mode that was added in Doctrine ORM 2.14. See https://github.com/doctrine/orm/pull/6728. // Default: false * second_level_cache?: array{ * region_cache_driver?: string|array{ * type?: scalar|Param|null, // Default: null * id?: scalar|Param|null, * pool?: scalar|Param|null, * }, * region_lock_lifetime?: scalar|Param|null, // Default: 60 * log_enabled?: bool|Param, // Default: true * region_lifetime?: scalar|Param|null, // Default: 3600 * enabled?: bool|Param, // Default: true * factory?: scalar|Param|null, * regions?: array, * loggers?: array, * }, * hydrators?: array, * mappings?: array, * dql?: array{ * string_functions?: array, * numeric_functions?: array, * datetime_functions?: array, * }, * filters?: array, * }>, * identity_generation_preferences?: array, * }>, * resolve_target_entities?: array, * }, * } * @psalm-type DoctrineMigrationsConfig = array{ * enable_service_migrations?: bool|Param, // Whether to enable fetching migrations from the service container. // Default: false * migrations_paths?: array, * services?: array, * factories?: array, * storage?: array{ // Storage to use for migration status metadata. * table_storage?: array{ // The default metadata storage, implemented as a table in the database. * table_name?: scalar|Param|null, // Default: null * version_column_name?: scalar|Param|null, // Default: null * version_column_length?: scalar|Param|null, // Default: null * executed_at_column_name?: scalar|Param|null, // Default: null * execution_time_column_name?: scalar|Param|null, // Default: null * }, * }, * migrations?: list, * connection?: scalar|Param|null, // Connection name to use for the migrations database. // Default: null * em?: scalar|Param|null, // Entity manager name to use for the migrations database (available when doctrine/orm is installed). // Default: null * all_or_nothing?: scalar|Param|null, // Run all migrations in a transaction. // Default: false * check_database_platform?: scalar|Param|null, // Adds an extra check in the generated migrations to allow execution only on the same platform as they were initially generated on. // Default: true * custom_template?: scalar|Param|null, // Custom template path for generated migration classes. // Default: null * organize_migrations?: scalar|Param|null, // Organize migrations mode. Possible values are: "BY_YEAR", "BY_YEAR_AND_MONTH", false // Default: false * enable_profiler?: bool|Param, // Whether or not to enable the profiler collector to calculate and visualize migration status. This adds some queries overhead. // Default: false * transactional?: bool|Param, // Whether or not to wrap migrations in a single transaction. // Default: true * } * @psalm-type KnpuOauth2ClientConfig = array{ * http_client?: scalar|Param|null, // Service id of HTTP client to use (must implement GuzzleHttp\ClientInterface) // Default: null * http_client_options?: array{ * timeout?: int|Param, * proxy?: scalar|Param|null, * verify?: bool|Param, // Use only with proxy option set * }, * clients?: array>, * } * @psalm-type SentryConfig = array{ * dsn?: scalar|Param|null, // If this value is not provided, the SDK will try to read it from the SENTRY_DSN environment variable. If that variable also does not exist, the SDK will not send any events. * register_error_listener?: bool|Param, // Default: true * register_error_handler?: bool|Param, // Default: true * logger?: scalar|Param|null, // The service ID of the PSR-3 logger used to log messages coming from the SDK client. Be aware that setting the same logger of the application may create a circular loop when an event fails to be sent. // Default: null * options?: array{ * integrations?: mixed, // Default: [] * default_integrations?: bool|Param, * prefixes?: list, * sample_rate?: float|Param, // The sampling factor to apply to events. A value of 0 will deny sending any event, and a value of 1 will send all events. * enable_tracing?: bool|Param, * traces_sample_rate?: float|Param, // The sampling factor to apply to transactions. A value of 0 will deny sending any transaction, and a value of 1 will send all transactions. * traces_sampler?: scalar|Param|null, * profiles_sample_rate?: float|Param, // The sampling factor to apply to profiles. A value of 0 will deny sending any profiles, and a value of 1 will send all profiles. Profiles are sampled in relation to traces_sample_rate * enable_logs?: bool|Param, * log_flush_threshold?: mixed, // Default: null * enable_metrics?: bool|Param, // Default: true * attach_stacktrace?: bool|Param, * attach_metric_code_locations?: bool|Param, * context_lines?: int|Param, * environment?: scalar|Param|null, // Default: "%kernel.environment%" * logger?: scalar|Param|null, * spotlight?: bool|Param, * spotlight_url?: scalar|Param|null, * release?: scalar|Param|null, // Default: "%env(default::SENTRY_RELEASE)%" * org_id?: int|Param, * server_name?: scalar|Param|null, * ignore_exceptions?: list, * ignore_transactions?: list, * before_send?: scalar|Param|null, * before_send_transaction?: scalar|Param|null, * before_send_check_in?: scalar|Param|null, * before_send_metrics?: scalar|Param|null, * before_send_log?: scalar|Param|null, * before_send_metric?: scalar|Param|null, * trace_propagation_targets?: mixed, * strict_trace_continuation?: bool|Param, * tags?: array, * error_types?: scalar|Param|null, * max_breadcrumbs?: int|Param, * before_breadcrumb?: mixed, * in_app_exclude?: list, * in_app_include?: list, * send_default_pii?: bool|Param, * max_value_length?: int|Param, * transport?: scalar|Param|null, * http_client?: scalar|Param|null, * http_proxy?: scalar|Param|null, * http_proxy_authentication?: scalar|Param|null, * http_connect_timeout?: float|Param, // The maximum number of seconds to wait while trying to connect to a server. It works only when using the default transport. * http_timeout?: float|Param, // The maximum execution time for the request+response as a whole. It works only when using the default transport. * http_ssl_verify_peer?: bool|Param, * http_compression?: bool|Param, * capture_silenced_errors?: bool|Param, * max_request_body_size?: "none"|"never"|"small"|"medium"|"always"|Param, * class_serializers?: array, * }, * messenger?: bool|array{ * enabled?: bool|Param, // Default: true * capture_soft_fails?: bool|Param, // Default: true * isolate_breadcrumbs_by_message?: bool|Param, // Default: false * isolate_context_by_message?: bool|Param, // Default: false * }, * tracing?: bool|array{ * enabled?: bool|Param, // Default: true * dbal?: bool|array{ * enabled?: bool|Param, // Default: true * ignore_prepare_spans?: bool|Param, // Default: false * connections?: list, * }, * twig?: bool|array{ * enabled?: bool|Param, // Default: true * }, * cache?: bool|array{ * enabled?: bool|Param, // Default: true * }, * http_client?: bool|array{ * enabled?: bool|Param, // Default: false * }, * console?: array{ * excluded_commands?: list, * }, * }, * } * @psalm-type SncRedisConfig = array{ * class?: array{ * client?: scalar|Param|null, // Default: "Predis\\Client" * client_options?: scalar|Param|null, // Default: "Predis\\Configuration\\Options" * connection_parameters?: scalar|Param|null, // Default: "Predis\\Connection\\Parameters" * connection_factory?: scalar|Param|null, // Default: "Snc\\RedisBundle\\Client\\Predis\\Connection\\ConnectionFactory" * connection_wrapper?: scalar|Param|null, // Default: "Snc\\RedisBundle\\Client\\Predis\\Connection\\ConnectionWrapper" * phpredis_client?: scalar|Param|null, // Default: "Redis" * relay_client?: scalar|Param|null, // Default: "Relay\\Relay" * phpredis_clusterclient?: scalar|Param|null, // Default: "RedisCluster" * logger?: scalar|Param|null, // Default: "Snc\\RedisBundle\\Logger\\RedisLogger" * data_collector?: scalar|Param|null, // Default: "Snc\\RedisBundle\\DataCollector\\RedisDataCollector" * monolog_handler?: scalar|Param|null, // Default: "Monolog\\Handler\\RedisHandler" * }, * clients?: array, * options?: array{ * commands?: array, * connection_async?: bool|Param, // Default: false * connection_persistent?: mixed, // Default: false * connection_timeout?: scalar|Param|null, // Default: 5 * scan?: int|Param, // Default: null * read_write_timeout?: scalar|Param|null, // Default: null * iterable_multibulk?: bool|Param, // Default: false * throw_errors?: bool|Param, // Default: true * serialization?: scalar|Param|null, // Default: "default" * cluster?: scalar|Param|null, // Default: null * prefix?: scalar|Param|null, // Default: null * replication?: true|"predis"|"sentinel"|Param, * service?: scalar|Param|null, // Default: null * slave_failover?: "none"|"error"|"distribute"|"distribute_slaves"|Param, * parameters?: array{ * database?: scalar|Param|null, // Default: null * username?: scalar|Param|null, // Default: null * password?: scalar|Param|null, // Default: null * sentinel_username?: scalar|Param|null, // Default: null * sentinel_password?: scalar|Param|null, // Default: null * logging?: bool|Param, // Default: true * ssl_context?: mixed, // Default: null * }, * }, * }>, * monolog?: array{ * client?: scalar|Param|null, * key?: scalar|Param|null, * formatter?: scalar|Param|null, * }, * } * @psalm-type MonologConfig = array{ * use_microseconds?: scalar|Param|null, // Default: true * channels?: list, * handlers?: array, * }>, * accepted_levels?: list, * min_level?: scalar|Param|null, // Default: "DEBUG" * max_level?: scalar|Param|null, // Default: "EMERGENCY" * buffer_size?: scalar|Param|null, // Default: 0 * flush_on_overflow?: bool|Param, // Default: false * handler?: scalar|Param|null, * url?: scalar|Param|null, * exchange?: scalar|Param|null, * exchange_name?: scalar|Param|null, // Default: "log" * channel?: scalar|Param|null, // Default: null * bot_name?: scalar|Param|null, // Default: "Monolog" * use_attachment?: scalar|Param|null, // Default: true * use_short_attachment?: scalar|Param|null, // Default: false * include_extra?: scalar|Param|null, // Default: false * icon_emoji?: scalar|Param|null, // Default: null * webhook_url?: scalar|Param|null, * exclude_fields?: list, * token?: scalar|Param|null, * region?: scalar|Param|null, * source?: scalar|Param|null, * use_ssl?: bool|Param, // Default: true * user?: mixed, * title?: scalar|Param|null, // Default: null * host?: scalar|Param|null, // Default: null * port?: scalar|Param|null, // Default: 514 * config?: list, * members?: list, * connection_string?: scalar|Param|null, * timeout?: scalar|Param|null, * time?: scalar|Param|null, // Default: 60 * deduplication_level?: scalar|Param|null, // Default: 400 * store?: scalar|Param|null, // Default: null * connection_timeout?: scalar|Param|null, * persistent?: bool|Param, * message_type?: scalar|Param|null, // Default: 0 * parse_mode?: scalar|Param|null, // Default: null * disable_webpage_preview?: bool|Param|null, // Default: null * disable_notification?: bool|Param|null, // Default: null * split_long_messages?: bool|Param, // Default: false * delay_between_messages?: bool|Param, // Default: false * topic?: int|Param, // Default: null * factor?: int|Param, // Default: 1 * tags?: list, * console_formatter_options?: mixed, // Default: [] * formatter?: scalar|Param|null, * nested?: bool|Param, // Default: false * publisher?: string|array{ * id?: scalar|Param|null, * hostname?: scalar|Param|null, * port?: scalar|Param|null, // Default: 12201 * chunk_size?: scalar|Param|null, // Default: 1420 * encoder?: "json"|"compressed_json"|Param, * }, * mongodb?: string|array{ * id?: scalar|Param|null, // ID of a MongoDB\Client service * uri?: scalar|Param|null, * username?: scalar|Param|null, * password?: scalar|Param|null, * database?: scalar|Param|null, // Default: "monolog" * collection?: scalar|Param|null, // Default: "logs" * }, * elasticsearch?: string|array{ * id?: scalar|Param|null, * hosts?: list, * host?: scalar|Param|null, * port?: scalar|Param|null, // Default: 9200 * transport?: scalar|Param|null, // Default: "Http" * user?: scalar|Param|null, // Default: null * password?: scalar|Param|null, // Default: null * }, * index?: scalar|Param|null, // Default: "monolog" * document_type?: scalar|Param|null, // Default: "logs" * ignore_error?: scalar|Param|null, // Default: false * redis?: string|array{ * id?: scalar|Param|null, * host?: scalar|Param|null, * password?: scalar|Param|null, // Default: null * port?: scalar|Param|null, // Default: 6379 * database?: scalar|Param|null, // Default: 0 * key_name?: scalar|Param|null, // Default: "monolog_redis" * }, * predis?: string|array{ * id?: scalar|Param|null, * host?: scalar|Param|null, * }, * from_email?: scalar|Param|null, * to_email?: list, * subject?: scalar|Param|null, * content_type?: scalar|Param|null, // Default: null * headers?: list, * mailer?: scalar|Param|null, // Default: null * email_prototype?: string|array{ * id?: scalar|Param|null, * method?: scalar|Param|null, // Default: null * }, * verbosity_levels?: array{ * VERBOSITY_QUIET?: scalar|Param|null, // Default: "ERROR" * VERBOSITY_NORMAL?: scalar|Param|null, // Default: "WARNING" * VERBOSITY_VERBOSE?: scalar|Param|null, // Default: "NOTICE" * VERBOSITY_VERY_VERBOSE?: scalar|Param|null, // Default: "INFO" * VERBOSITY_DEBUG?: scalar|Param|null, // Default: "DEBUG" * }, * channels?: string|array{ * type?: scalar|Param|null, * elements?: list, * }, * }>, * } * @psalm-type TwigConfig = array{ * form_themes?: list, * globals?: array, * autoescape_service?: scalar|Param|null, // Default: null * autoescape_service_method?: scalar|Param|null, // Default: null * base_template_class?: scalar|Param|null, // Deprecated: The child node "base_template_class" at path "twig.base_template_class" is deprecated. * cache?: scalar|Param|null, // Default: true * charset?: scalar|Param|null, // Default: "%kernel.charset%" * debug?: bool|Param, // Default: "%kernel.debug%" * strict_variables?: bool|Param, // Default: "%kernel.debug%" * auto_reload?: scalar|Param|null, * optimizations?: int|Param, * default_path?: scalar|Param|null, // The default path used to load templates. // Default: "%kernel.project_dir%/templates" * file_name_pattern?: list, * paths?: array, * date?: array{ // The default format options used by the date filter. * format?: scalar|Param|null, // Default: "F j, Y H:i" * interval_format?: scalar|Param|null, // Default: "%d days" * timezone?: scalar|Param|null, // The timezone used when formatting dates, when set to null, the timezone returned by date_default_timezone_get() is used. // Default: null * }, * number_format?: array{ // The default format options for the number_format filter. * decimals?: int|Param, // Default: 0 * decimal_point?: scalar|Param|null, // Default: "." * thousands_separator?: scalar|Param|null, // Default: "," * }, * mailer?: array{ * html_to_text_converter?: scalar|Param|null, // A service implementing the "Symfony\Component\Mime\HtmlToTextConverter\HtmlToTextConverterInterface". // Default: null * }, * } * @psalm-type TwigExtraConfig = array{ * cache?: bool|array{ * enabled?: bool|Param, // Default: false * }, * html?: bool|array{ * enabled?: bool|Param, // Default: false * }, * markdown?: bool|array{ * enabled?: bool|Param, // Default: false * }, * intl?: bool|array{ * enabled?: bool|Param, // Default: false * }, * cssinliner?: bool|array{ * enabled?: bool|Param, // Default: false * }, * inky?: bool|array{ * enabled?: bool|Param, // Default: false * }, * string?: bool|array{ * enabled?: bool|Param, // Default: false * }, * commonmark?: array{ * renderer?: array{ // Array of options for rendering HTML. * block_separator?: scalar|Param|null, * inner_separator?: scalar|Param|null, * soft_break?: scalar|Param|null, * }, * html_input?: "strip"|"allow"|"escape"|Param, // How to handle HTML input. * allow_unsafe_links?: bool|Param, // Remove risky link and image URLs by setting this to false. // Default: true * max_nesting_level?: int|Param, // The maximum nesting level for blocks. // Default: 9223372036854775807 * max_delimiters_per_line?: int|Param, // The maximum number of strong/emphasis delimiters per line. // Default: 9223372036854775807 * slug_normalizer?: array{ // Array of options for configuring how URL-safe slugs are created. * instance?: mixed, * max_length?: int|Param, // Default: 255 * unique?: mixed, * }, * commonmark?: array{ // Array of options for configuring the CommonMark core extension. * enable_em?: bool|Param, // Default: true * enable_strong?: bool|Param, // Default: true * use_asterisk?: bool|Param, // Default: true * use_underscore?: bool|Param, // Default: true * unordered_list_markers?: list, * }, * ... * }, * } * @psalm-type SecurityConfig = array{ * access_denied_url?: scalar|Param|null, // Default: null * session_fixation_strategy?: "none"|"migrate"|"invalidate"|Param, // Default: "migrate" * hide_user_not_found?: bool|Param, // Deprecated: The "hide_user_not_found" option is deprecated and will be removed in 8.0. Use the "expose_security_errors" option instead. * expose_security_errors?: \Symfony\Component\Security\Http\Authentication\ExposeSecurityLevel::None|\Symfony\Component\Security\Http\Authentication\ExposeSecurityLevel::AccountStatus|\Symfony\Component\Security\Http\Authentication\ExposeSecurityLevel::All|Param, // Default: "none" * erase_credentials?: bool|Param, // Default: true * access_decision_manager?: array{ * strategy?: "affirmative"|"consensus"|"unanimous"|"priority"|Param, * service?: scalar|Param|null, * strategy_service?: scalar|Param|null, * allow_if_all_abstain?: bool|Param, // Default: false * allow_if_equal_granted_denied?: bool|Param, // Default: true * }, * password_hashers?: array, * hash_algorithm?: scalar|Param|null, // Name of hashing algorithm for PBKDF2 (i.e. sha256, sha512, etc..) See hash_algos() for a list of supported algorithms. // Default: "sha512" * key_length?: scalar|Param|null, // Default: 40 * ignore_case?: bool|Param, // Default: false * encode_as_base64?: bool|Param, // Default: true * iterations?: scalar|Param|null, // Default: 5000 * cost?: int|Param, // Default: null * memory_cost?: scalar|Param|null, // Default: null * time_cost?: scalar|Param|null, // Default: null * id?: scalar|Param|null, * }>, * providers?: array, * }, * entity?: array{ * class?: scalar|Param|null, // The full entity class name of your user class. * property?: scalar|Param|null, // Default: null * manager_name?: scalar|Param|null, // Default: null * }, * memory?: array{ * users?: array, * }>, * }, * ldap?: array{ * service?: scalar|Param|null, * base_dn?: scalar|Param|null, * search_dn?: scalar|Param|null, // Default: null * search_password?: scalar|Param|null, // Default: null * extra_fields?: list, * default_roles?: list, * role_fetcher?: scalar|Param|null, // Default: null * uid_key?: scalar|Param|null, // Default: "sAMAccountName" * filter?: scalar|Param|null, // Default: "({uid_key}={user_identifier})" * password_attribute?: scalar|Param|null, // Default: null * }, * }>, * firewalls?: array, * security?: bool|Param, // Default: true * user_checker?: scalar|Param|null, // The UserChecker to use when authenticating users in this firewall. // Default: "security.user_checker" * request_matcher?: scalar|Param|null, * access_denied_url?: scalar|Param|null, * access_denied_handler?: scalar|Param|null, * entry_point?: scalar|Param|null, // An enabled authenticator name or a service id that implements "Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface". * provider?: scalar|Param|null, * stateless?: bool|Param, // Default: false * lazy?: bool|Param, // Default: false * context?: scalar|Param|null, * logout?: array{ * enable_csrf?: bool|Param|null, // Default: null * csrf_token_id?: scalar|Param|null, // Default: "logout" * csrf_parameter?: scalar|Param|null, // Default: "_csrf_token" * csrf_token_manager?: scalar|Param|null, * path?: scalar|Param|null, // Default: "/logout" * target?: scalar|Param|null, // Default: "/" * invalidate_session?: bool|Param, // Default: true * clear_site_data?: list<"*"|"cache"|"cookies"|"storage"|"executionContexts"|Param>, * delete_cookies?: array, * }, * switch_user?: array{ * provider?: scalar|Param|null, * parameter?: scalar|Param|null, // Default: "_switch_user" * role?: scalar|Param|null, // Default: "ROLE_ALLOWED_TO_SWITCH" * target_route?: scalar|Param|null, // Default: null * }, * required_badges?: list, * custom_authenticators?: list, * login_throttling?: array{ * limiter?: scalar|Param|null, // A service id implementing "Symfony\Component\HttpFoundation\RateLimiter\RequestRateLimiterInterface". * max_attempts?: int|Param, // Default: 5 * interval?: scalar|Param|null, // Default: "1 minute" * lock_factory?: scalar|Param|null, // The service ID of the lock factory used by the login rate limiter (or null to disable locking). // Default: null * cache_pool?: string|Param, // The cache pool to use for storing the limiter state // Default: "cache.rate_limiter" * storage_service?: string|Param, // The service ID of a custom storage implementation, this precedes any configured "cache_pool" // Default: null * }, * x509?: array{ * provider?: scalar|Param|null, * user?: scalar|Param|null, // Default: "SSL_CLIENT_S_DN_Email" * credentials?: scalar|Param|null, // Default: "SSL_CLIENT_S_DN" * user_identifier?: scalar|Param|null, // Default: "emailAddress" * }, * remote_user?: array{ * provider?: scalar|Param|null, * user?: scalar|Param|null, // Default: "REMOTE_USER" * }, * login_link?: array{ * check_route?: scalar|Param|null, // Route that will validate the login link - e.g. "app_login_link_verify". * check_post_only?: scalar|Param|null, // If true, only HTTP POST requests to "check_route" will be handled by the authenticator. // Default: false * signature_properties?: list, * lifetime?: int|Param, // The lifetime of the login link in seconds. // Default: 600 * max_uses?: int|Param, // Max number of times a login link can be used - null means unlimited within lifetime. // Default: null * used_link_cache?: scalar|Param|null, // Cache service id used to expired links of max_uses is set. * success_handler?: scalar|Param|null, // A service id that implements Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface. * failure_handler?: scalar|Param|null, // A service id that implements Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface. * provider?: scalar|Param|null, // The user provider to load users from. * secret?: scalar|Param|null, // Default: "%kernel.secret%" * always_use_default_target_path?: bool|Param, // Default: false * default_target_path?: scalar|Param|null, // Default: "/" * login_path?: scalar|Param|null, // Default: "/login" * target_path_parameter?: scalar|Param|null, // Default: "_target_path" * use_referer?: bool|Param, // Default: false * failure_path?: scalar|Param|null, // Default: null * failure_forward?: bool|Param, // Default: false * failure_path_parameter?: scalar|Param|null, // Default: "_failure_path" * }, * form_login?: array{ * provider?: scalar|Param|null, * remember_me?: bool|Param, // Default: true * success_handler?: scalar|Param|null, * failure_handler?: scalar|Param|null, * check_path?: scalar|Param|null, // Default: "/login_check" * use_forward?: bool|Param, // Default: false * login_path?: scalar|Param|null, // Default: "/login" * username_parameter?: scalar|Param|null, // Default: "_username" * password_parameter?: scalar|Param|null, // Default: "_password" * csrf_parameter?: scalar|Param|null, // Default: "_csrf_token" * csrf_token_id?: scalar|Param|null, // Default: "authenticate" * enable_csrf?: bool|Param, // Default: false * post_only?: bool|Param, // Default: true * form_only?: bool|Param, // Default: false * always_use_default_target_path?: bool|Param, // Default: false * default_target_path?: scalar|Param|null, // Default: "/" * target_path_parameter?: scalar|Param|null, // Default: "_target_path" * use_referer?: bool|Param, // Default: false * failure_path?: scalar|Param|null, // Default: null * failure_forward?: bool|Param, // Default: false * failure_path_parameter?: scalar|Param|null, // Default: "_failure_path" * }, * form_login_ldap?: array{ * provider?: scalar|Param|null, * remember_me?: bool|Param, // Default: true * success_handler?: scalar|Param|null, * failure_handler?: scalar|Param|null, * check_path?: scalar|Param|null, // Default: "/login_check" * use_forward?: bool|Param, // Default: false * login_path?: scalar|Param|null, // Default: "/login" * username_parameter?: scalar|Param|null, // Default: "_username" * password_parameter?: scalar|Param|null, // Default: "_password" * csrf_parameter?: scalar|Param|null, // Default: "_csrf_token" * csrf_token_id?: scalar|Param|null, // Default: "authenticate" * enable_csrf?: bool|Param, // Default: false * post_only?: bool|Param, // Default: true * form_only?: bool|Param, // Default: false * always_use_default_target_path?: bool|Param, // Default: false * default_target_path?: scalar|Param|null, // Default: "/" * target_path_parameter?: scalar|Param|null, // Default: "_target_path" * use_referer?: bool|Param, // Default: false * failure_path?: scalar|Param|null, // Default: null * failure_forward?: bool|Param, // Default: false * failure_path_parameter?: scalar|Param|null, // Default: "_failure_path" * service?: scalar|Param|null, // Default: "ldap" * dn_string?: scalar|Param|null, // Default: "{user_identifier}" * query_string?: scalar|Param|null, * search_dn?: scalar|Param|null, // Default: "" * search_password?: scalar|Param|null, // Default: "" * }, * json_login?: array{ * provider?: scalar|Param|null, * remember_me?: bool|Param, // Default: true * success_handler?: scalar|Param|null, * failure_handler?: scalar|Param|null, * check_path?: scalar|Param|null, // Default: "/login_check" * use_forward?: bool|Param, // Default: false * login_path?: scalar|Param|null, // Default: "/login" * username_path?: scalar|Param|null, // Default: "username" * password_path?: scalar|Param|null, // Default: "password" * }, * json_login_ldap?: array{ * provider?: scalar|Param|null, * remember_me?: bool|Param, // Default: true * success_handler?: scalar|Param|null, * failure_handler?: scalar|Param|null, * check_path?: scalar|Param|null, // Default: "/login_check" * use_forward?: bool|Param, // Default: false * login_path?: scalar|Param|null, // Default: "/login" * username_path?: scalar|Param|null, // Default: "username" * password_path?: scalar|Param|null, // Default: "password" * service?: scalar|Param|null, // Default: "ldap" * dn_string?: scalar|Param|null, // Default: "{user_identifier}" * query_string?: scalar|Param|null, * search_dn?: scalar|Param|null, // Default: "" * search_password?: scalar|Param|null, // Default: "" * }, * access_token?: array{ * provider?: scalar|Param|null, * remember_me?: bool|Param, // Default: true * success_handler?: scalar|Param|null, * failure_handler?: scalar|Param|null, * realm?: scalar|Param|null, // Default: null * token_extractors?: list, * token_handler?: string|array{ * id?: scalar|Param|null, * oidc_user_info?: string|array{ * base_uri?: scalar|Param|null, // Base URI of the userinfo endpoint on the OIDC server, or the OIDC server URI to use the discovery (require "discovery" to be configured). * discovery?: array{ // Enable the OIDC discovery. * cache?: array{ * id?: scalar|Param|null, // Cache service id to use to cache the OIDC discovery configuration. * }, * }, * claim?: scalar|Param|null, // Claim which contains the user identifier (e.g. sub, email, etc.). // Default: "sub" * client?: scalar|Param|null, // HttpClient service id to use to call the OIDC server. * }, * oidc?: array{ * discovery?: array{ // Enable the OIDC discovery. * base_uri?: list, * cache?: array{ * id?: scalar|Param|null, // Cache service id to use to cache the OIDC discovery configuration. * }, * }, * claim?: scalar|Param|null, // Claim which contains the user identifier (e.g.: sub, email..). // Default: "sub" * audience?: scalar|Param|null, // Audience set in the token, for validation purpose. * issuers?: list, * algorithm?: array, * algorithms?: list, * key?: scalar|Param|null, // Deprecated: The "key" option is deprecated and will be removed in 8.0. Use the "keyset" option instead. // JSON-encoded JWK used to sign the token (must contain a "kty" key). * keyset?: scalar|Param|null, // JSON-encoded JWKSet used to sign the token (must contain a list of valid public keys). * encryption?: bool|array{ * enabled?: bool|Param, // Default: false * enforce?: bool|Param, // When enabled, the token shall be encrypted. // Default: false * algorithms?: list, * keyset?: scalar|Param|null, // JSON-encoded JWKSet used to decrypt the token (must contain a list of valid private keys). * }, * }, * cas?: array{ * validation_url?: scalar|Param|null, // CAS server validation URL * prefix?: scalar|Param|null, // CAS prefix // Default: "cas" * http_client?: scalar|Param|null, // HTTP Client service // Default: null * }, * oauth2?: scalar|Param|null, * }, * }, * http_basic?: array{ * provider?: scalar|Param|null, * realm?: scalar|Param|null, // Default: "Secured Area" * }, * http_basic_ldap?: array{ * provider?: scalar|Param|null, * realm?: scalar|Param|null, // Default: "Secured Area" * service?: scalar|Param|null, // Default: "ldap" * dn_string?: scalar|Param|null, // Default: "{user_identifier}" * query_string?: scalar|Param|null, * search_dn?: scalar|Param|null, // Default: "" * search_password?: scalar|Param|null, // Default: "" * }, * remember_me?: array{ * secret?: scalar|Param|null, // Default: "%kernel.secret%" * service?: scalar|Param|null, * user_providers?: list, * catch_exceptions?: bool|Param, // Default: true * signature_properties?: list, * token_provider?: string|array{ * service?: scalar|Param|null, // The service ID of a custom remember-me token provider. * doctrine?: bool|array{ * enabled?: bool|Param, // Default: false * connection?: scalar|Param|null, // Default: null * }, * }, * token_verifier?: scalar|Param|null, // The service ID of a custom rememberme token verifier. * name?: scalar|Param|null, // Default: "REMEMBERME" * lifetime?: int|Param, // Default: 31536000 * path?: scalar|Param|null, // Default: "/" * domain?: scalar|Param|null, // Default: null * secure?: true|false|"auto"|Param, // Default: null * httponly?: bool|Param, // Default: true * samesite?: null|"lax"|"strict"|"none"|Param, // Default: "lax" * always_remember_me?: bool|Param, // Default: false * remember_me_parameter?: scalar|Param|null, // Default: "_remember_me" * }, * }>, * access_control?: list, * attributes?: array, * route?: scalar|Param|null, // Default: null * methods?: list, * allow_if?: scalar|Param|null, // Default: null * roles?: list, * }>, * role_hierarchy?: array>, * } * @psalm-type DebugConfig = array{ * max_items?: int|Param, // Max number of displayed items past the first level, -1 means no limit. // Default: 2500 * min_depth?: int|Param, // Minimum tree depth to clone all the items, 1 is default. // Default: 1 * max_string_length?: int|Param, // Max length of displayed strings, -1 means no limit. // Default: -1 * dump_destination?: scalar|Param|null, // A stream URL where dumps should be written to. // Default: null * theme?: "dark"|"light"|Param, // Changes the color of the dump() output when rendered directly on the templating. "dark" (default) or "light". // Default: "dark" * } * @psalm-type WebProfilerConfig = array{ * toolbar?: bool|array{ // Profiler toolbar configuration * enabled?: bool|Param, // Default: false * ajax_replace?: bool|Param, // Replace toolbar on AJAX requests // Default: false * }, * intercept_redirects?: bool|Param, // Default: false * excluded_ajax_paths?: scalar|Param|null, // Default: "^/((index|app(_[\\w]+)?)\\.php/)?_wdt" * } * @psalm-type ConfigType = array{ * imports?: ImportsConfig, * parameters?: ParametersConfig, * services?: ServicesConfig, * framework?: FrameworkConfig, * doctrine?: DoctrineConfig, * doctrine_migrations?: DoctrineMigrationsConfig, * knpu_oauth2_client?: KnpuOauth2ClientConfig, * snc_redis?: SncRedisConfig, * monolog?: MonologConfig, * twig?: TwigConfig, * twig_extra?: TwigExtraConfig, * security?: SecurityConfig, * "when@dev"?: array{ * imports?: ImportsConfig, * parameters?: ParametersConfig, * services?: ServicesConfig, * framework?: FrameworkConfig, * doctrine?: DoctrineConfig, * doctrine_migrations?: DoctrineMigrationsConfig, * knpu_oauth2_client?: KnpuOauth2ClientConfig, * snc_redis?: SncRedisConfig, * monolog?: MonologConfig, * twig?: TwigConfig, * twig_extra?: TwigExtraConfig, * security?: SecurityConfig, * debug?: DebugConfig, * web_profiler?: WebProfilerConfig, * }, * "when@prod"?: array{ * imports?: ImportsConfig, * parameters?: ParametersConfig, * services?: ServicesConfig, * framework?: FrameworkConfig, * doctrine?: DoctrineConfig, * doctrine_migrations?: DoctrineMigrationsConfig, * knpu_oauth2_client?: KnpuOauth2ClientConfig, * sentry?: SentryConfig, * snc_redis?: SncRedisConfig, * monolog?: MonologConfig, * twig?: TwigConfig, * twig_extra?: TwigExtraConfig, * security?: SecurityConfig, * }, * "when@test"?: array{ * imports?: ImportsConfig, * parameters?: ParametersConfig, * services?: ServicesConfig, * framework?: FrameworkConfig, * doctrine?: DoctrineConfig, * doctrine_migrations?: DoctrineMigrationsConfig, * knpu_oauth2_client?: KnpuOauth2ClientConfig, * snc_redis?: SncRedisConfig, * monolog?: MonologConfig, * twig?: TwigConfig, * twig_extra?: TwigExtraConfig, * security?: SecurityConfig, * debug?: DebugConfig, * web_profiler?: WebProfilerConfig, * }, * ..., * }> * } */ final class App { /** * @param ConfigType $config * * @psalm-return ConfigType */ public static function config(array $config): array { /** @var ConfigType $config */ $config = AppReference::config($config); return $config; } } namespace Symfony\Component\Routing\Loader\Configurator; /** * This class provides array-shapes for configuring the routes of an application. * * Example: * * ```php * // config/routes.php * namespace Symfony\Component\Routing\Loader\Configurator; * * return Routes::config([ * 'controllers' => [ * 'resource' => 'routing.controllers', * ], * ]); * ``` * * @psalm-type RouteConfig = array{ * path: string|array, * controller?: string, * methods?: string|list, * requirements?: array, * defaults?: array, * options?: array, * host?: string|array, * schemes?: string|list, * condition?: string, * locale?: string, * format?: string, * utf8?: bool, * stateless?: bool, * } * @psalm-type ImportConfig = array{ * resource: string, * type?: string, * exclude?: string|list, * prefix?: string|array, * name_prefix?: string, * trailing_slash_on_root?: bool, * controller?: string, * methods?: string|list, * requirements?: array, * defaults?: array, * options?: array, * host?: string|array, * schemes?: string|list, * condition?: string, * locale?: string, * format?: string, * utf8?: bool, * stateless?: bool, * } * @psalm-type AliasConfig = array{ * alias: string, * deprecated?: array{package:string, version:string, message?:string}, * } * @psalm-type RoutesConfig = array{ * "when@dev"?: array, * "when@prod"?: array, * "when@test"?: array, * ... * } */ final class Routes { /** * @param RoutesConfig $config * * @psalm-return RoutesConfig */ public static function config(array $config): array { return $config; } } ================================================ FILE: config/routes/framework.yaml ================================================ when@dev: _errors: resource: '@FrameworkBundle/Resources/config/routing/errors.php' prefix: /_error ================================================ FILE: config/routes/security.yaml ================================================ _security_logout: resource: security.route_loader.logout type: service ================================================ FILE: config/routes/web_profiler.yaml ================================================ when@dev: web_profiler_wdt: resource: '@WebProfilerBundle/Resources/config/routing/wdt.php' prefix: /_wdt web_profiler_profiler: resource: '@WebProfilerBundle/Resources/config/routing/profiler.php' prefix: /_profiler ================================================ FILE: config/routes.yaml ================================================ # yaml-language-server: $schema=../vendor/symfony/routing/Loader/schema/routing.schema.json # This file is the entry point to configure the routes of your app. # Methods with the #[Route] attribute are automatically imported. # See also https://symfony.com/doc/current/routing.html # To list all registered routes, run the following command: # bin/console debug:router logout: path: /logout controllers: resource: path: ../src/Controller/ namespace: App\Controller type: attribute ================================================ FILE: config/services.yaml ================================================ # yaml-language-server: $schema=../vendor/symfony/dependency-injection/Loader/schema/services.schema.json # This file is the entry point to configure your own services. # Files in the packages/ subdirectory configure your dependencies. # See also https://symfony.com/doc/current/service_container/import.html # Put parameters here that don't need to change on each machine where the app is deployed # https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration parameters: services: # default configuration for services in *this* file _defaults: autowire: true # Automatically injects dependencies in your services. autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. # makes classes in src/ available to be used as services # this creates a service per class whose id is the fully-qualified class name App\: resource: '../src/' exclude: - '../src/DependencyInjection/' - '../src/Kernel.php' # controllers are imported separately to make sure services can be injected # as action arguments even if you don't extend any base controller class App\Controller\: resource: '../src/Controller/' tags: ['controller.service_arguments'] # autorwire parameters App\Github\ClientDiscovery: arguments: $clientId: "%env(GITHUB_CLIENT_ID)%" $clientSecret: "%env(GITHUB_CLIENT_SECRET)%" App\Controller\DefaultController: arguments: $diffInterval: "%env(STATUS_MINUTE_INTERVAL_BEFORE_ALERT)%" $redis: "@snc_redis.app_cache" App\PubSubHubbub\Publisher: arguments: $hub: "http://pubsubhubbub.appspot.com" $host: "%env(PROJECT_HOST)%" $scheme: "%env(PROJECT_SCHEME)%" App\Command\SyncStarredReposCommand: arguments: $transport: "@messenger.transport.sync_starred_repos" App\Command\SyncVersionsCommand: arguments: $transport: "@messenger.transport.sync_versions" App\Webfeeds\WebfeedsWriter: tags: - { name: marcw_rss_writer.extension.writer } # lazy consumer # to avoid triggering Github Client Discovery # which will make a doctrine query on Travis because the default limit to Github will be reached App\MessageHandler\StarredReposSyncHandler: lazy: true arguments: $redis: "@snc_redis.app_cache" App\MessageHandler\VersionsSyncHandler: lazy: true # github stuff banditore.client.guzzle: class: GuzzleHttp\Client banditore.client.github: class: Github\Client factory: [ "@App\\Github\\ClientDiscovery", find ] # feed stuff banditore.writer.rss: class: MarcW\RssWriter\RssWriter arguments: - ~ - core: "@marcw_rss_writer.writer.core" webfeeds: "@App\\Webfeeds\\WebfeedsWriter" atom: "@marcw_rss_writer.writer.atom" - true - " " # force this service to be injected at first instead of the default one (from marcw) MarcW\RssWriter\RssWriter: '@banditore.writer.rss' App\Pagination\Paginator: arguments: - itemsPerPage: 30 pagesInRange: 5 Predis\Client: alias: snc_redis.guzzle_cache GuzzleHttp\Client: alias: banditore.client.guzzle Github\Client: alias: banditore.client.github # bundle not using recipe OR not compatible with Symfony > 3 marcw_rss_writer.rss_writer: class: MarcW\RssWriter\RssWriter marcw_rss_writer.writer.core: class: MarcW\RssWriter\Extension\Core\CoreWriter tags: - { name: marcw_rss_writer.extension.writer } marcw_rss_writer.writer.atom: class: MarcW\RssWriter\Extension\Atom\AtomWriter tags: - { name: marcw_rss_writer.extension.writer } ================================================ FILE: config/services_test.yaml ================================================ services: # see https://github.com/symfony/symfony/issues/24543 banditore.client.github.test: alias: banditore.client.github public: true banditore.client.guzzle.test: alias: banditore.client.guzzle public: true ================================================ FILE: data/supervisor.conf ================================================ [group:sync_repo] programs=sync_repo_1,sync_repo_2 [program:sync_repo_1] directory=/path/to/banditore command=/usr/bin/php bin/console messenger:consume --limit=5 sync_starred_repos -e prod autostart=true autorestart=true stderr_logfile=/path/to/banditore/var/log/sync_starred_repos_1.err stdout_logfile=/path/to/banditore/var/log/sync_starred_repos_1.log user=www-data environment = http_proxy="",https_proxy="" [program:sync_repo_2] directory=/path/to/banditore command=/usr/bin/php bin/console messenger:consume --limit=5 sync_starred_repos -e prod autostart=true autorestart=true stderr_logfile=/path/to/banditore/var/log/sync_starred_repos_2.err stdout_logfile=/path/to/banditore/var/log/sync_starred_repos_2.log user=www-data environment = http_proxy="",https_proxy="" [group:sync_version] programs=sync_version_1,sync_version_2,sync_version_3,sync_version_4 [program:sync_version_1] directory=/path/to/banditore command=/usr/bin/php php bin/console messenger:consume --limit=50 sync_versions -e prod autostart=true autorestart=true stderr_logfile=/path/to/banditore/var/log/sync_versions_1.err stdout_logfile=/path/to/banditore/var/log/sync_versions_1.log user=www-data environment = http_proxy="",https_proxy="" [program:sync_version_2] directory=/path/to/banditore command=/usr/bin/php php bin/console messenger:consume --limit=50 sync_versions -e prod autostart=true autorestart=true stderr_logfile=/path/to/banditore/var/log/sync_versions_2.err stdout_logfile=/path/to/banditore/var/log/sync_versions_2.log user=www-data environment = http_proxy="",https_proxy="" [program:sync_version_3] directory=/path/to/banditore command=/usr/bin/php php bin/console messenger:consume --limit=50 sync_versions -e prod autostart=true autorestart=true stderr_logfile=/path/to/banditore/var/log/sync_versions_3.err stdout_logfile=/path/to/banditore/var/log/sync_versions_3.log user=www-data environment = http_proxy="",https_proxy="" [program:sync_version_4] directory=/path/to/banditore command=/usr/bin/php php bin/console messenger:consume --limit=50 sync_versions -e prod autostart=true autorestart=true stderr_logfile=/path/to/banditore/var/log/sync_versions_4.err stdout_logfile=/path/to/banditore/var/log/sync_versions_4.log user=www-data environment = http_proxy="",https_proxy="" ================================================ FILE: migrations/.gitignore ================================================ ================================================ FILE: migrations/Version20170222055642.php ================================================ abortIf(!$this->connection->getDatabasePlatform() instanceof AbstractMySQLPlatform, 'Migration can only be executed safely on MySQL.'); $repoTable = $schema->getTable('repo'); $this->skipIf($repoTable->hasColumn('homepage') || $repoTable->hasColumn('language'), 'It seems that you already played this migration.'); $this->addSql('ALTER TABLE repo ADD homepage VARCHAR(255) DEFAULT NULL, ADD language VARCHAR(255) DEFAULT NULL'); } public function down(Schema $schema): void { $this->abortIf(!$this->connection->getDatabasePlatform() instanceof AbstractMySQLPlatform, 'Migration can only be executed safely on MySQL.'); $this->addSql('ALTER TABLE repo DROP homepage, DROP language'); } } ================================================ FILE: migrations/Version20170329095349.php ================================================ abortIf(!$this->connection->getDatabasePlatform() instanceof AbstractMySQLPlatform, 'Migration can only be executed safely on MySQL.'); $this->addSql('ALTER TABLE user CHANGE name name VARCHAR(191) DEFAULT NULL'); } public function down(Schema $schema): void { $this->abortIf(!$this->connection->getDatabasePlatform() instanceof AbstractMySQLPlatform, 'Migration can only be executed safely on MySQL.'); $this->addSql('ALTER TABLE user CHANGE name name VARCHAR(191) NOT NULL COLLATE utf8mb4_unicode_ci'); } } ================================================ FILE: migrations/Version20180827105910.php ================================================ abortIf(!$this->connection->getDatabasePlatform() instanceof AbstractMySQLPlatform, 'Migration can only be executed safely on MySQL.'); $this->addSql('ALTER TABLE repo ADD removed_at DATETIME DEFAULT NULL'); } public function down(Schema $schema): void { $this->abortIf(!$this->connection->getDatabasePlatform() instanceof AbstractMySQLPlatform, 'Migration can only be executed safely on MySQL.'); $this->addSql('ALTER TABLE repo DROP removed_at'); } } ================================================ FILE: migrations/Version20200511062812.php ================================================ abortIf(!$this->connection->getDatabasePlatform() instanceof AbstractMySQLPlatform, 'Migration can only be executed safely on MySQL.'); $this->addSql('ALTER TABLE user ADD removed_at DATETIME DEFAULT NULL'); } public function down(Schema $schema): void { $this->abortIf(!$this->connection->getDatabasePlatform() instanceof AbstractMySQLPlatform, 'Migration can only be executed safely on MySQL.'); $this->addSql('ALTER TABLE user DROP removed_at'); } } ================================================ FILE: migrations/Version20200613153754.php ================================================ abortIf(!$this->connection->getDatabasePlatform() instanceof AbstractMySQLPlatform, 'Migration can only be executed safely on MySQL.'); $this->addSql('ALTER TABLE star CHANGE user_id user_id INT NOT NULL, CHANGE repo_id repo_id INT NOT NULL'); $this->addSql('ALTER TABLE version CHANGE repo_id repo_id INT NOT NULL'); } public function down(Schema $schema): void { $this->abortIf(!$this->connection->getDatabasePlatform() instanceof AbstractMySQLPlatform, 'Migration can only be executed safely on MySQL.'); $this->addSql('ALTER TABLE star CHANGE user_id user_id INT DEFAULT NULL, CHANGE repo_id repo_id INT DEFAULT NULL'); $this->addSql('ALTER TABLE version CHANGE repo_id repo_id INT DEFAULT NULL'); } } ================================================ FILE: migrations/Version20260408120000.php ================================================ abortIf(!$this->connection->getDatabasePlatform() instanceof AbstractMySQLPlatform, 'Migration can only be executed safely on MySQL.'); $this->addSql('ALTER TABLE star ADD ignored_in_feed TINYINT(1) DEFAULT 0 NOT NULL'); } public function down(Schema $schema): void { $this->abortIf(!$this->connection->getDatabasePlatform() instanceof AbstractMySQLPlatform, 'Migration can only be executed safely on MySQL.'); $this->addSql('ALTER TABLE star DROP ignored_in_feed'); } } ================================================ FILE: phpstan.dist.neon ================================================ parameters: level: max paths: - src - tests symfony: containerXmlPath: %rootDir%/../../../var/cache/test/App_KernelTestDebugContainer.xml consoleApplicationLoader: tests/console-application.php doctrine: objectManagerLoader: tests/object-manager.php ignoreErrors: - identifier: missingType.iterableValue - identifier: offsetAccess.nonOffsetAccessible - identifier: argument.type - identifier: cast.int - identifier: cast.string - identifier: foreach.nonIterable - identifier: binaryOp.invalid - identifier: method.nonObject - path: src/Pagination/PaginatorInterface.php identifier: throws.notThrowable - path: src/Repository/VersionRepository.php identifier: return.type - path: tests/Security/GithubAuthenticatorTest.php identifier: deadCode.unreachable count: 2 - path: tests/bootstrap.php identifier: function.alreadyNarrowedType count: 1 - path: src/Cache/PredisCachePool.php identifier: return.type count: 2 - path: src/Entity/User.php identifier: return.type count: 1 inferPrivatePropertyTypeFromConstructor: true treatPhpDocTypesAsCertain: false ================================================ FILE: phpunit.xml.dist ================================================ tests src src/DataFixtures src/Migrations ================================================ FILE: public/css/banditore.css ================================================ * { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } /* * -- BASE STYLES -- * Most of these are inherited from Base, but I want to change a few. */ body { line-height: 1.7em; color: #7f8c8d; font-size: 13px; background: #10556B; } a { color: #7f8c8d; } h1, h2, h3, h4, h5, h6, label { color: #34495e; } .pure-img-responsive { max-width: 100%; height: auto; } /* * -- LAYOUT STYLES -- * These are some useful classes which I will need */ .l-box { padding: 0 1em; } .l-box-lrg { padding: 2em; border-bottom: 1px solid rgba(0,0,0,0.1); } .is-center { text-align: center; } /* * -- PURE FORM STYLES -- * Style the form inputs and labels */ .pure-form label { margin: 1em 0 0; font-weight: bold; font-size: 100%; } .pure-form input[type] { border: 2px solid #ddd; box-shadow: none; font-size: 100%; width: 100%; margin-bottom: 1em; } /* * -- PURE BUTTON STYLES -- * I want my pure-button elements to look a little different */ .pure-button { background-color: #2B687F; color: white; padding: 0.5em 2em; border-radius: 5px; } a.pure-button-primary { background: #FFAB80; color: white; border-radius: 5px; font-size: 120%; } a.pure-button-primary:hover { color: #2B687F; } /* * -- MENU STYLES -- * I want to customize how my .pure-menu looks at the top of the page */ .menu-wrapper { background-color: #10556B; /*margin-bottom: 1em;*/ /*-webkit-font-smoothing: antialiased;*/ height: 3.8em; padding: 8px 0; overflow: hidden; -webkit-transition: height 0.5s; -moz-transition: height 0.5s; -ms-transition: height 0.5s; transition: height 0.5s; /*box-shadow: 0 1px 1px rgba(0,0,0, 0.10);*/ } .pure-menu li a { color: #6FBEF3; } .pure-menu li a:hover, .pure-menu li a:focus { color: white; background-color: #10556B; } .pure-menu-heading { color: #FFAB80; font-weight: 400; font-size: 120%; } .menu-wrapper.open { height: 12.5em; } .menu-can-transform { text-align: left; } .menu-toggle { width: 34px; height: 34px; display: block; position: absolute; top: 0; right: 0; margin: 7px; } .menu-toggle .bar { background-color: #777; display: block; width: 20px; height: 2px; border-radius: 100px; position: absolute; top: 18px; right: 7px; -webkit-transition: all 0.5s; -moz-transition: all 0.5s; -ms-transition: all 0.5s; transition: all 0.5s; } .menu-toggle .bar:first-child { -webkit-transform: translateY(-6px); -moz-transform: translateY(-6px); -ms-transform: translateY(-6px); transform: translateY(-6px); } .menu-toggle.x .bar { -webkit-transform: rotate(45deg); -moz-transform: rotate(45deg); -ms-transform: rotate(45deg); transform: rotate(45deg); } .menu-toggle.x .bar:first-child { -webkit-transform: rotate(-45deg); -moz-transform: rotate(-45deg); -ms-transform: rotate(-45deg); transform: rotate(-45deg); } /* * -- SPLASH STYLES -- * This is the blue top section that appears on the page. */ .splash-container { background: #2B687F; padding: 80px 0 70px; } .splash { /* absolute center .splash within .splash-container */ width: 80%; height: 50%; margin: 0 auto; /*position: absolute;*/ top: 0; left: 0; bottom: 0; right: 0; text-align: center; text-transform: uppercase; } .splash p { color: #D5E1E5; letter-spacing: 0.05em; } /* This is the main heading that appears on the blue section */ .splash-head { font-size: 20px; color: white; border: 3px solid #FFAB80; padding: 1em 1.6em; font-weight: 100; border-radius: 5px; line-height: 1.3em; } /* * -- CONTENT STYLES -- * This represents the content area (everything below the blue section) */ .content-wrapper { /* These styles are required for the "scroll-over" effect */ /*position: absolute;*/ /*top: 69%;*/ /*width: 100%;*/ /*min-height: 12%;*/ /*z-index: 2;*/ background: #2B687F; margin: 0 auto; /*padding-top: 51px;*/ } /* We want to give the content area some more padding */ .content { padding: 1em; background: white; } /* This is the class used for the main content headers (

) */ .content-head { font-weight: 400; text-transform: uppercase; letter-spacing: 0.1em; margin: 2em 0 1em; } /* This is a modifier class used when the content-head is inside a ribbon */ .content-head-ribbon { color: white; } /* This is the class used for the content sub-headers (

) */ .content-subhead { color: #2B687F; } .content-subhead i { margin-right: 7px; } /* This is the class used for the dark-background areas. */ .ribbon { background: #10556B; color: #aaa; } img.repo-avatar { vertical-align: middle; width: 25px; } .image-productivity, .image-megaphone { display: none; } aside.feed { background: #2B687F; margin: 1em auto; padding: 0.3em 1em; border-radius: 3px; color: #fff; display: block; } aside.feed a { color: #FFAB80; text-decoration: none; } aside.feed a:hover { text-decoration: underline; } aside.feed b:after { content: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACGklEQVQ4T53TX0hTURzA8e/d3XbnxLUlpaOkFZW0IQqJkQ8t6GHuodAX3YOi/aGQeqgnrd4iCOrVpIdhovUWIiQsoX9oPkSFPdjIbGrDJ3Pq5pzc/bk3NuWWNkI7T4dzzu9zfr8f5wg/b5a6VUV4jMBBdjZmUWkV5jvs0/8RvH6Vyoww32lXs3PDgWr0ZcdRFn+QCn9EiS9sKx8NMJ++RqHn1oaskpoeIzH6iOTk639CGmAsP4Op2oe+pBxxz2EtKPn1JSvPbqCsRvJCGvDnrljsoKD2EgUnWkA0kFmeI+pvJBOZ/QvRAKmqAaniHOm5ceTxgVyQ3u7C0tKDaCsjsxRmucuLkljahOTvgZJmbcxPfPgeusLdWNufI1r3I38JEHtyMT8g7j2K8YgbyenBcKg2dyj57S3Rvlb0die29iHQiSz7G0mF3mlI3h5IzjqKmroQjGYSI92sBu5S1HAfU00zyclXRHtb8gCCgFRxFjJp5GAAyenF0uyHTIrIg5PoTEXYrr8BJc3CHReqvJJDfjexsh6Lrzu3GOs/jxwcxnplEIOjJpdBNpPijg/orPuI9vhITo1sAaoasDQ93AAuIAdfYHZfpbDuNvLEELGnl9nV1k/2vcQHO1l737cZIFtCZf16CRNDoKroS49hdHrILIaRPw8gubyIJeWkvo+SCn/SgBnAsa2Hv/WQIISyv/EU0LvjHykIIRTafgEZntfprlNojgAAAABJRU5ErkJggg=='); vertical-align: text-top; margin-left: 5px; } /* * -- DASHBOARD TABLE -- * * From https://codepen.io/geoffyuen/pen/FCBEg?editors=1100 */ .pure-table-rwd { margin: 0 auto; min-width: 300px; } .pure-table-rwd tr { border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; } .pure-table-rwd th { display: none; } .pure-table-rwd td { display: block; } .pure-table-rwd td:first-child { padding-top: .5em; } .pure-table-rwd td:last-child { padding-bottom: .5em; } .pure-table-rwd td:before { content: attr(data-th) ": "; font-weight: bold; width: 3.5em; display: inline-block; } .pure-table-rwd th, .pure-table-rwd td { text-align: left; border-left-width: 0; } /* * Pagination * * From https://www.bypeople.com/quick-and-simple-pagination-cssdeck/ */ .pagination { text-align: center; margin: 20px } .pagination a.previous, .pagination a.next { display: none; } .pagination a, .pagination strong { color: #4A4A4A; border: 0; outline: 0; background: #fff; display: inline-block; margin-right: 3px; padding: 4px 12px; text-decoration: none; line-height: 1.5em; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; } .pagination a:hover { background-color: #10556B; color: #fff; } .pagination a:active { background: rgba(190, 190, 190, 0.75); } .pagination strong { color: #fff; background-color: #FFAB80; } /* * -- ALERTS -- * * From https://isabelcastillo.com/error-info-messages-css */ .alert { margin: 10px 0; padding: 12px; border-radius: .5em; } .alert span { float: right; margin-top: -10px; padding-left: 5px; cursor: pointer; text-transform: uppercase; } .alert.info { color: #00529B; background-color: #BDE5F8; } .alert.success { color: #4F8A10; background-color: #DFF2BF; } .alert.warning { color: #9F6000; background-color: #FEEFB3; } .alert.error { color: #D8000C; background-color: #FFBABA; } /* * -- LABELS -- * * From http://www.gumbyframework.com/docs/ui-kit/#!/indicators */ .label_info, .label_success, .label_warning, .label_error, .label_prerelease { padding: 0 5px; font-size: 12px; border-radius: 2px; height: 20px; display: inline-block; font-weight: bold; line-height: 20px; text-align: center; color: #fff; } .label_info { background: #4a4d50; } .label_success { background: #58c026; } .label_warning { background: #f6b83f; color: #644405; } .label_error { background: #ca3838; } .label_prerelease { background: #ffab80; } .feed-status { display: inline-block; min-width: 5.5em; padding: 0.15em 0.55em; border-radius: 999px; background: #EAF2F5; color: #10556B; font-size: 12px; font-weight: bold; line-height: 1.5; text-align: center; } .feed-status-muted { background: #FFF0E8; color: #AF5D37; } .feed-toggle-form { display: inline; margin-left: 0.45em; } .feed-toggle-button { -webkit-appearance: none; appearance: none; background: none; background-color: transparent; border: 0; border-radius: 0; box-shadow: none; color: #10556B; cursor: pointer; display: inline; font: inherit; font-size: 14px; font-weight: 600; line-height: inherit; margin: 0; outline: none; padding: 0; text-decoration: underline; text-underline-offset: 2px; vertical-align: baseline; } .feed-toggle-button:hover, .feed-toggle-button:focus { color: #2B687F; } .included-indicator { color: #58c026; display: inline-block; font-size: 15px; line-height: 1; vertical-align: middle; } .excluded-indicator { color: #ca3838; display: inline-block; font-size: 15px; line-height: 1; vertical-align: middle; } /* This is the class used for the footer */ .footer { background: #10556B; color: #E6E6E6; padding: 1em; } .footer a { color: #FFAB80; text-decoration: none; } .footer a:hover { text-decoration: underline } /* * -- TABLET (AND UP) MEDIA QUERIES -- */ @media (min-width: 48em) { /* We increase the body font size */ body { font-size: 16px; } /* We can align the menu header to the left, but float the menu items to the right. */ .home-menu { text-align: left; } .home-menu ul { float: right; } .pure-menu-item.item-logged-in, .pure-menu-item.item-github { display: inline-block; } .menu-can-transform { text-align: right; } .menu-toggle { display: none; } .splash-head { font-size: 250%; } /* We remove the border-separator assigned to .l-box-lrg */ .l-box-lrg { border: none; } .content { padding: 1em 1em 3em; } .image-productivity, .image-megaphone { display: initial; } .pure-table td:before { display: none; } .pure-table tr { border-top: 0; border-bottom: 0; } .pure-table th, .pure-table td { display: table-cell; border-left: 1px solid #cbcbcb; } .pagination a.previous, .pagination a.next { display: inline-block; } } /* * -- DESKTOP (AND UP) MEDIA QUERIES -- */ @media (min-width: 78em) { /* We increase the header font size even more */ .splash-head { font-size: 300%; } .middle-content { width: 980px; margin: 0 auto; } .l-box { padding: 1em; } } ================================================ FILE: public/css/grids-responsive-min.css ================================================ /*! Pure v3.0.0 Copyright 2013 Yahoo! Licensed under the BSD License. https://github.com/pure-css/pure/blob/master/LICENSE */ @media screen and (min-width:35.5em){.pure-u-sm-1,.pure-u-sm-1-1,.pure-u-sm-1-12,.pure-u-sm-1-2,.pure-u-sm-1-24,.pure-u-sm-1-3,.pure-u-sm-1-4,.pure-u-sm-1-5,.pure-u-sm-1-6,.pure-u-sm-1-8,.pure-u-sm-10-24,.pure-u-sm-11-12,.pure-u-sm-11-24,.pure-u-sm-12-24,.pure-u-sm-13-24,.pure-u-sm-14-24,.pure-u-sm-15-24,.pure-u-sm-16-24,.pure-u-sm-17-24,.pure-u-sm-18-24,.pure-u-sm-19-24,.pure-u-sm-2-24,.pure-u-sm-2-3,.pure-u-sm-2-5,.pure-u-sm-20-24,.pure-u-sm-21-24,.pure-u-sm-22-24,.pure-u-sm-23-24,.pure-u-sm-24-24,.pure-u-sm-3-24,.pure-u-sm-3-4,.pure-u-sm-3-5,.pure-u-sm-3-8,.pure-u-sm-4-24,.pure-u-sm-4-5,.pure-u-sm-5-12,.pure-u-sm-5-24,.pure-u-sm-5-5,.pure-u-sm-5-6,.pure-u-sm-5-8,.pure-u-sm-6-24,.pure-u-sm-7-12,.pure-u-sm-7-24,.pure-u-sm-7-8,.pure-u-sm-8-24,.pure-u-sm-9-24{display:inline-block;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.pure-u-sm-1-24{width:4.1667%}.pure-u-sm-1-12,.pure-u-sm-2-24{width:8.3333%}.pure-u-sm-1-8,.pure-u-sm-3-24{width:12.5%}.pure-u-sm-1-6,.pure-u-sm-4-24{width:16.6667%}.pure-u-sm-1-5{width:20%}.pure-u-sm-5-24{width:20.8333%}.pure-u-sm-1-4,.pure-u-sm-6-24{width:25%}.pure-u-sm-7-24{width:29.1667%}.pure-u-sm-1-3,.pure-u-sm-8-24{width:33.3333%}.pure-u-sm-3-8,.pure-u-sm-9-24{width:37.5%}.pure-u-sm-2-5{width:40%}.pure-u-sm-10-24,.pure-u-sm-5-12{width:41.6667%}.pure-u-sm-11-24{width:45.8333%}.pure-u-sm-1-2,.pure-u-sm-12-24{width:50%}.pure-u-sm-13-24{width:54.1667%}.pure-u-sm-14-24,.pure-u-sm-7-12{width:58.3333%}.pure-u-sm-3-5{width:60%}.pure-u-sm-15-24,.pure-u-sm-5-8{width:62.5%}.pure-u-sm-16-24,.pure-u-sm-2-3{width:66.6667%}.pure-u-sm-17-24{width:70.8333%}.pure-u-sm-18-24,.pure-u-sm-3-4{width:75%}.pure-u-sm-19-24{width:79.1667%}.pure-u-sm-4-5{width:80%}.pure-u-sm-20-24,.pure-u-sm-5-6{width:83.3333%}.pure-u-sm-21-24,.pure-u-sm-7-8{width:87.5%}.pure-u-sm-11-12,.pure-u-sm-22-24{width:91.6667%}.pure-u-sm-23-24{width:95.8333%}.pure-u-sm-1,.pure-u-sm-1-1,.pure-u-sm-24-24,.pure-u-sm-5-5{width:100%}}@media screen and (min-width:48em){.pure-u-md-1,.pure-u-md-1-1,.pure-u-md-1-12,.pure-u-md-1-2,.pure-u-md-1-24,.pure-u-md-1-3,.pure-u-md-1-4,.pure-u-md-1-5,.pure-u-md-1-6,.pure-u-md-1-8,.pure-u-md-10-24,.pure-u-md-11-12,.pure-u-md-11-24,.pure-u-md-12-24,.pure-u-md-13-24,.pure-u-md-14-24,.pure-u-md-15-24,.pure-u-md-16-24,.pure-u-md-17-24,.pure-u-md-18-24,.pure-u-md-19-24,.pure-u-md-2-24,.pure-u-md-2-3,.pure-u-md-2-5,.pure-u-md-20-24,.pure-u-md-21-24,.pure-u-md-22-24,.pure-u-md-23-24,.pure-u-md-24-24,.pure-u-md-3-24,.pure-u-md-3-4,.pure-u-md-3-5,.pure-u-md-3-8,.pure-u-md-4-24,.pure-u-md-4-5,.pure-u-md-5-12,.pure-u-md-5-24,.pure-u-md-5-5,.pure-u-md-5-6,.pure-u-md-5-8,.pure-u-md-6-24,.pure-u-md-7-12,.pure-u-md-7-24,.pure-u-md-7-8,.pure-u-md-8-24,.pure-u-md-9-24{display:inline-block;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.pure-u-md-1-24{width:4.1667%}.pure-u-md-1-12,.pure-u-md-2-24{width:8.3333%}.pure-u-md-1-8,.pure-u-md-3-24{width:12.5%}.pure-u-md-1-6,.pure-u-md-4-24{width:16.6667%}.pure-u-md-1-5{width:20%}.pure-u-md-5-24{width:20.8333%}.pure-u-md-1-4,.pure-u-md-6-24{width:25%}.pure-u-md-7-24{width:29.1667%}.pure-u-md-1-3,.pure-u-md-8-24{width:33.3333%}.pure-u-md-3-8,.pure-u-md-9-24{width:37.5%}.pure-u-md-2-5{width:40%}.pure-u-md-10-24,.pure-u-md-5-12{width:41.6667%}.pure-u-md-11-24{width:45.8333%}.pure-u-md-1-2,.pure-u-md-12-24{width:50%}.pure-u-md-13-24{width:54.1667%}.pure-u-md-14-24,.pure-u-md-7-12{width:58.3333%}.pure-u-md-3-5{width:60%}.pure-u-md-15-24,.pure-u-md-5-8{width:62.5%}.pure-u-md-16-24,.pure-u-md-2-3{width:66.6667%}.pure-u-md-17-24{width:70.8333%}.pure-u-md-18-24,.pure-u-md-3-4{width:75%}.pure-u-md-19-24{width:79.1667%}.pure-u-md-4-5{width:80%}.pure-u-md-20-24,.pure-u-md-5-6{width:83.3333%}.pure-u-md-21-24,.pure-u-md-7-8{width:87.5%}.pure-u-md-11-12,.pure-u-md-22-24{width:91.6667%}.pure-u-md-23-24{width:95.8333%}.pure-u-md-1,.pure-u-md-1-1,.pure-u-md-24-24,.pure-u-md-5-5{width:100%}}@media screen and (min-width:64em){.pure-u-lg-1,.pure-u-lg-1-1,.pure-u-lg-1-12,.pure-u-lg-1-2,.pure-u-lg-1-24,.pure-u-lg-1-3,.pure-u-lg-1-4,.pure-u-lg-1-5,.pure-u-lg-1-6,.pure-u-lg-1-8,.pure-u-lg-10-24,.pure-u-lg-11-12,.pure-u-lg-11-24,.pure-u-lg-12-24,.pure-u-lg-13-24,.pure-u-lg-14-24,.pure-u-lg-15-24,.pure-u-lg-16-24,.pure-u-lg-17-24,.pure-u-lg-18-24,.pure-u-lg-19-24,.pure-u-lg-2-24,.pure-u-lg-2-3,.pure-u-lg-2-5,.pure-u-lg-20-24,.pure-u-lg-21-24,.pure-u-lg-22-24,.pure-u-lg-23-24,.pure-u-lg-24-24,.pure-u-lg-3-24,.pure-u-lg-3-4,.pure-u-lg-3-5,.pure-u-lg-3-8,.pure-u-lg-4-24,.pure-u-lg-4-5,.pure-u-lg-5-12,.pure-u-lg-5-24,.pure-u-lg-5-5,.pure-u-lg-5-6,.pure-u-lg-5-8,.pure-u-lg-6-24,.pure-u-lg-7-12,.pure-u-lg-7-24,.pure-u-lg-7-8,.pure-u-lg-8-24,.pure-u-lg-9-24{display:inline-block;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.pure-u-lg-1-24{width:4.1667%}.pure-u-lg-1-12,.pure-u-lg-2-24{width:8.3333%}.pure-u-lg-1-8,.pure-u-lg-3-24{width:12.5%}.pure-u-lg-1-6,.pure-u-lg-4-24{width:16.6667%}.pure-u-lg-1-5{width:20%}.pure-u-lg-5-24{width:20.8333%}.pure-u-lg-1-4,.pure-u-lg-6-24{width:25%}.pure-u-lg-7-24{width:29.1667%}.pure-u-lg-1-3,.pure-u-lg-8-24{width:33.3333%}.pure-u-lg-3-8,.pure-u-lg-9-24{width:37.5%}.pure-u-lg-2-5{width:40%}.pure-u-lg-10-24,.pure-u-lg-5-12{width:41.6667%}.pure-u-lg-11-24{width:45.8333%}.pure-u-lg-1-2,.pure-u-lg-12-24{width:50%}.pure-u-lg-13-24{width:54.1667%}.pure-u-lg-14-24,.pure-u-lg-7-12{width:58.3333%}.pure-u-lg-3-5{width:60%}.pure-u-lg-15-24,.pure-u-lg-5-8{width:62.5%}.pure-u-lg-16-24,.pure-u-lg-2-3{width:66.6667%}.pure-u-lg-17-24{width:70.8333%}.pure-u-lg-18-24,.pure-u-lg-3-4{width:75%}.pure-u-lg-19-24{width:79.1667%}.pure-u-lg-4-5{width:80%}.pure-u-lg-20-24,.pure-u-lg-5-6{width:83.3333%}.pure-u-lg-21-24,.pure-u-lg-7-8{width:87.5%}.pure-u-lg-11-12,.pure-u-lg-22-24{width:91.6667%}.pure-u-lg-23-24{width:95.8333%}.pure-u-lg-1,.pure-u-lg-1-1,.pure-u-lg-24-24,.pure-u-lg-5-5{width:100%}}@media screen and (min-width:80em){.pure-u-xl-1,.pure-u-xl-1-1,.pure-u-xl-1-12,.pure-u-xl-1-2,.pure-u-xl-1-24,.pure-u-xl-1-3,.pure-u-xl-1-4,.pure-u-xl-1-5,.pure-u-xl-1-6,.pure-u-xl-1-8,.pure-u-xl-10-24,.pure-u-xl-11-12,.pure-u-xl-11-24,.pure-u-xl-12-24,.pure-u-xl-13-24,.pure-u-xl-14-24,.pure-u-xl-15-24,.pure-u-xl-16-24,.pure-u-xl-17-24,.pure-u-xl-18-24,.pure-u-xl-19-24,.pure-u-xl-2-24,.pure-u-xl-2-3,.pure-u-xl-2-5,.pure-u-xl-20-24,.pure-u-xl-21-24,.pure-u-xl-22-24,.pure-u-xl-23-24,.pure-u-xl-24-24,.pure-u-xl-3-24,.pure-u-xl-3-4,.pure-u-xl-3-5,.pure-u-xl-3-8,.pure-u-xl-4-24,.pure-u-xl-4-5,.pure-u-xl-5-12,.pure-u-xl-5-24,.pure-u-xl-5-5,.pure-u-xl-5-6,.pure-u-xl-5-8,.pure-u-xl-6-24,.pure-u-xl-7-12,.pure-u-xl-7-24,.pure-u-xl-7-8,.pure-u-xl-8-24,.pure-u-xl-9-24{display:inline-block;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.pure-u-xl-1-24{width:4.1667%}.pure-u-xl-1-12,.pure-u-xl-2-24{width:8.3333%}.pure-u-xl-1-8,.pure-u-xl-3-24{width:12.5%}.pure-u-xl-1-6,.pure-u-xl-4-24{width:16.6667%}.pure-u-xl-1-5{width:20%}.pure-u-xl-5-24{width:20.8333%}.pure-u-xl-1-4,.pure-u-xl-6-24{width:25%}.pure-u-xl-7-24{width:29.1667%}.pure-u-xl-1-3,.pure-u-xl-8-24{width:33.3333%}.pure-u-xl-3-8,.pure-u-xl-9-24{width:37.5%}.pure-u-xl-2-5{width:40%}.pure-u-xl-10-24,.pure-u-xl-5-12{width:41.6667%}.pure-u-xl-11-24{width:45.8333%}.pure-u-xl-1-2,.pure-u-xl-12-24{width:50%}.pure-u-xl-13-24{width:54.1667%}.pure-u-xl-14-24,.pure-u-xl-7-12{width:58.3333%}.pure-u-xl-3-5{width:60%}.pure-u-xl-15-24,.pure-u-xl-5-8{width:62.5%}.pure-u-xl-16-24,.pure-u-xl-2-3{width:66.6667%}.pure-u-xl-17-24{width:70.8333%}.pure-u-xl-18-24,.pure-u-xl-3-4{width:75%}.pure-u-xl-19-24{width:79.1667%}.pure-u-xl-4-5{width:80%}.pure-u-xl-20-24,.pure-u-xl-5-6{width:83.3333%}.pure-u-xl-21-24,.pure-u-xl-7-8{width:87.5%}.pure-u-xl-11-12,.pure-u-xl-22-24{width:91.6667%}.pure-u-xl-23-24{width:95.8333%}.pure-u-xl-1,.pure-u-xl-1-1,.pure-u-xl-24-24,.pure-u-xl-5-5{width:100%}}@media screen and (min-width:120em){.pure-u-xxl-1,.pure-u-xxl-1-1,.pure-u-xxl-1-12,.pure-u-xxl-1-2,.pure-u-xxl-1-24,.pure-u-xxl-1-3,.pure-u-xxl-1-4,.pure-u-xxl-1-5,.pure-u-xxl-1-6,.pure-u-xxl-1-8,.pure-u-xxl-10-24,.pure-u-xxl-11-12,.pure-u-xxl-11-24,.pure-u-xxl-12-24,.pure-u-xxl-13-24,.pure-u-xxl-14-24,.pure-u-xxl-15-24,.pure-u-xxl-16-24,.pure-u-xxl-17-24,.pure-u-xxl-18-24,.pure-u-xxl-19-24,.pure-u-xxl-2-24,.pure-u-xxl-2-3,.pure-u-xxl-2-5,.pure-u-xxl-20-24,.pure-u-xxl-21-24,.pure-u-xxl-22-24,.pure-u-xxl-23-24,.pure-u-xxl-24-24,.pure-u-xxl-3-24,.pure-u-xxl-3-4,.pure-u-xxl-3-5,.pure-u-xxl-3-8,.pure-u-xxl-4-24,.pure-u-xxl-4-5,.pure-u-xxl-5-12,.pure-u-xxl-5-24,.pure-u-xxl-5-5,.pure-u-xxl-5-6,.pure-u-xxl-5-8,.pure-u-xxl-6-24,.pure-u-xxl-7-12,.pure-u-xxl-7-24,.pure-u-xxl-7-8,.pure-u-xxl-8-24,.pure-u-xxl-9-24{display:inline-block;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.pure-u-xxl-1-24{width:4.1667%}.pure-u-xxl-1-12,.pure-u-xxl-2-24{width:8.3333%}.pure-u-xxl-1-8,.pure-u-xxl-3-24{width:12.5%}.pure-u-xxl-1-6,.pure-u-xxl-4-24{width:16.6667%}.pure-u-xxl-1-5{width:20%}.pure-u-xxl-5-24{width:20.8333%}.pure-u-xxl-1-4,.pure-u-xxl-6-24{width:25%}.pure-u-xxl-7-24{width:29.1667%}.pure-u-xxl-1-3,.pure-u-xxl-8-24{width:33.3333%}.pure-u-xxl-3-8,.pure-u-xxl-9-24{width:37.5%}.pure-u-xxl-2-5{width:40%}.pure-u-xxl-10-24,.pure-u-xxl-5-12{width:41.6667%}.pure-u-xxl-11-24{width:45.8333%}.pure-u-xxl-1-2,.pure-u-xxl-12-24{width:50%}.pure-u-xxl-13-24{width:54.1667%}.pure-u-xxl-14-24,.pure-u-xxl-7-12{width:58.3333%}.pure-u-xxl-3-5{width:60%}.pure-u-xxl-15-24,.pure-u-xxl-5-8{width:62.5%}.pure-u-xxl-16-24,.pure-u-xxl-2-3{width:66.6667%}.pure-u-xxl-17-24{width:70.8333%}.pure-u-xxl-18-24,.pure-u-xxl-3-4{width:75%}.pure-u-xxl-19-24{width:79.1667%}.pure-u-xxl-4-5{width:80%}.pure-u-xxl-20-24,.pure-u-xxl-5-6{width:83.3333%}.pure-u-xxl-21-24,.pure-u-xxl-7-8{width:87.5%}.pure-u-xxl-11-12,.pure-u-xxl-22-24{width:91.6667%}.pure-u-xxl-23-24{width:95.8333%}.pure-u-xxl-1,.pure-u-xxl-1-1,.pure-u-xxl-24-24,.pure-u-xxl-5-5{width:100%}}@media screen and (min-width:160em){.pure-u-xxxl-1,.pure-u-xxxl-1-1,.pure-u-xxxl-1-12,.pure-u-xxxl-1-2,.pure-u-xxxl-1-24,.pure-u-xxxl-1-3,.pure-u-xxxl-1-4,.pure-u-xxxl-1-5,.pure-u-xxxl-1-6,.pure-u-xxxl-1-8,.pure-u-xxxl-10-24,.pure-u-xxxl-11-12,.pure-u-xxxl-11-24,.pure-u-xxxl-12-24,.pure-u-xxxl-13-24,.pure-u-xxxl-14-24,.pure-u-xxxl-15-24,.pure-u-xxxl-16-24,.pure-u-xxxl-17-24,.pure-u-xxxl-18-24,.pure-u-xxxl-19-24,.pure-u-xxxl-2-24,.pure-u-xxxl-2-3,.pure-u-xxxl-2-5,.pure-u-xxxl-20-24,.pure-u-xxxl-21-24,.pure-u-xxxl-22-24,.pure-u-xxxl-23-24,.pure-u-xxxl-24-24,.pure-u-xxxl-3-24,.pure-u-xxxl-3-4,.pure-u-xxxl-3-5,.pure-u-xxxl-3-8,.pure-u-xxxl-4-24,.pure-u-xxxl-4-5,.pure-u-xxxl-5-12,.pure-u-xxxl-5-24,.pure-u-xxxl-5-5,.pure-u-xxxl-5-6,.pure-u-xxxl-5-8,.pure-u-xxxl-6-24,.pure-u-xxxl-7-12,.pure-u-xxxl-7-24,.pure-u-xxxl-7-8,.pure-u-xxxl-8-24,.pure-u-xxxl-9-24{display:inline-block;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.pure-u-xxxl-1-24{width:4.1667%}.pure-u-xxxl-1-12,.pure-u-xxxl-2-24{width:8.3333%}.pure-u-xxxl-1-8,.pure-u-xxxl-3-24{width:12.5%}.pure-u-xxxl-1-6,.pure-u-xxxl-4-24{width:16.6667%}.pure-u-xxxl-1-5{width:20%}.pure-u-xxxl-5-24{width:20.8333%}.pure-u-xxxl-1-4,.pure-u-xxxl-6-24{width:25%}.pure-u-xxxl-7-24{width:29.1667%}.pure-u-xxxl-1-3,.pure-u-xxxl-8-24{width:33.3333%}.pure-u-xxxl-3-8,.pure-u-xxxl-9-24{width:37.5%}.pure-u-xxxl-2-5{width:40%}.pure-u-xxxl-10-24,.pure-u-xxxl-5-12{width:41.6667%}.pure-u-xxxl-11-24{width:45.8333%}.pure-u-xxxl-1-2,.pure-u-xxxl-12-24{width:50%}.pure-u-xxxl-13-24{width:54.1667%}.pure-u-xxxl-14-24,.pure-u-xxxl-7-12{width:58.3333%}.pure-u-xxxl-3-5{width:60%}.pure-u-xxxl-15-24,.pure-u-xxxl-5-8{width:62.5%}.pure-u-xxxl-16-24,.pure-u-xxxl-2-3{width:66.6667%}.pure-u-xxxl-17-24{width:70.8333%}.pure-u-xxxl-18-24,.pure-u-xxxl-3-4{width:75%}.pure-u-xxxl-19-24{width:79.1667%}.pure-u-xxxl-4-5{width:80%}.pure-u-xxxl-20-24,.pure-u-xxxl-5-6{width:83.3333%}.pure-u-xxxl-21-24,.pure-u-xxxl-7-8{width:87.5%}.pure-u-xxxl-11-12,.pure-u-xxxl-22-24{width:91.6667%}.pure-u-xxxl-23-24{width:95.8333%}.pure-u-xxxl-1,.pure-u-xxxl-1-1,.pure-u-xxxl-24-24,.pure-u-xxxl-5-5{width:100%}}@media screen and (min-width:240em){.pure-u-x4k-1,.pure-u-x4k-1-1,.pure-u-x4k-1-12,.pure-u-x4k-1-2,.pure-u-x4k-1-24,.pure-u-x4k-1-3,.pure-u-x4k-1-4,.pure-u-x4k-1-5,.pure-u-x4k-1-6,.pure-u-x4k-1-8,.pure-u-x4k-10-24,.pure-u-x4k-11-12,.pure-u-x4k-11-24,.pure-u-x4k-12-24,.pure-u-x4k-13-24,.pure-u-x4k-14-24,.pure-u-x4k-15-24,.pure-u-x4k-16-24,.pure-u-x4k-17-24,.pure-u-x4k-18-24,.pure-u-x4k-19-24,.pure-u-x4k-2-24,.pure-u-x4k-2-3,.pure-u-x4k-2-5,.pure-u-x4k-20-24,.pure-u-x4k-21-24,.pure-u-x4k-22-24,.pure-u-x4k-23-24,.pure-u-x4k-24-24,.pure-u-x4k-3-24,.pure-u-x4k-3-4,.pure-u-x4k-3-5,.pure-u-x4k-3-8,.pure-u-x4k-4-24,.pure-u-x4k-4-5,.pure-u-x4k-5-12,.pure-u-x4k-5-24,.pure-u-x4k-5-5,.pure-u-x4k-5-6,.pure-u-x4k-5-8,.pure-u-x4k-6-24,.pure-u-x4k-7-12,.pure-u-x4k-7-24,.pure-u-x4k-7-8,.pure-u-x4k-8-24,.pure-u-x4k-9-24{display:inline-block;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.pure-u-x4k-1-24{width:4.1667%}.pure-u-x4k-1-12,.pure-u-x4k-2-24{width:8.3333%}.pure-u-x4k-1-8,.pure-u-x4k-3-24{width:12.5%}.pure-u-x4k-1-6,.pure-u-x4k-4-24{width:16.6667%}.pure-u-x4k-1-5{width:20%}.pure-u-x4k-5-24{width:20.8333%}.pure-u-x4k-1-4,.pure-u-x4k-6-24{width:25%}.pure-u-x4k-7-24{width:29.1667%}.pure-u-x4k-1-3,.pure-u-x4k-8-24{width:33.3333%}.pure-u-x4k-3-8,.pure-u-x4k-9-24{width:37.5%}.pure-u-x4k-2-5{width:40%}.pure-u-x4k-10-24,.pure-u-x4k-5-12{width:41.6667%}.pure-u-x4k-11-24{width:45.8333%}.pure-u-x4k-1-2,.pure-u-x4k-12-24{width:50%}.pure-u-x4k-13-24{width:54.1667%}.pure-u-x4k-14-24,.pure-u-x4k-7-12{width:58.3333%}.pure-u-x4k-3-5{width:60%}.pure-u-x4k-15-24,.pure-u-x4k-5-8{width:62.5%}.pure-u-x4k-16-24,.pure-u-x4k-2-3{width:66.6667%}.pure-u-x4k-17-24{width:70.8333%}.pure-u-x4k-18-24,.pure-u-x4k-3-4{width:75%}.pure-u-x4k-19-24{width:79.1667%}.pure-u-x4k-4-5{width:80%}.pure-u-x4k-20-24,.pure-u-x4k-5-6{width:83.3333%}.pure-u-x4k-21-24,.pure-u-x4k-7-8{width:87.5%}.pure-u-x4k-11-12,.pure-u-x4k-22-24{width:91.6667%}.pure-u-x4k-23-24{width:95.8333%}.pure-u-x4k-1,.pure-u-x4k-1-1,.pure-u-x4k-24-24,.pure-u-x4k-5-5{width:100%}} ================================================ FILE: public/css/pure-min.css ================================================ /*! Pure v3.0.0 Copyright 2013 Yahoo! Licensed under the BSD License. https://github.com/pure-css/pure/blob/master/LICENSE */ /*! normalize.css v | MIT License | https://necolas.github.io/normalize.css/ Copyright (c) Nicolas Gallagher and Jonathan Neal */ /*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}main{display:block}h1{font-size:2em;margin:.67em 0}hr{box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace,monospace;font-size:1em}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,input{overflow:visible}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:.35em .75em .625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}details{display:block}summary{display:list-item}template{display:none}[hidden]{display:none}html{font-family:sans-serif}.hidden,[hidden]{display:none!important}.pure-img{max-width:100%;height:auto;display:block}.pure-g{display:flex;flex-flow:row wrap;align-content:flex-start}.pure-u{display:inline-block;vertical-align:top}.pure-u-1,.pure-u-1-1,.pure-u-1-12,.pure-u-1-2,.pure-u-1-24,.pure-u-1-3,.pure-u-1-4,.pure-u-1-5,.pure-u-1-6,.pure-u-1-8,.pure-u-10-24,.pure-u-11-12,.pure-u-11-24,.pure-u-12-24,.pure-u-13-24,.pure-u-14-24,.pure-u-15-24,.pure-u-16-24,.pure-u-17-24,.pure-u-18-24,.pure-u-19-24,.pure-u-2-24,.pure-u-2-3,.pure-u-2-5,.pure-u-20-24,.pure-u-21-24,.pure-u-22-24,.pure-u-23-24,.pure-u-24-24,.pure-u-3-24,.pure-u-3-4,.pure-u-3-5,.pure-u-3-8,.pure-u-4-24,.pure-u-4-5,.pure-u-5-12,.pure-u-5-24,.pure-u-5-5,.pure-u-5-6,.pure-u-5-8,.pure-u-6-24,.pure-u-7-12,.pure-u-7-24,.pure-u-7-8,.pure-u-8-24,.pure-u-9-24{display:inline-block;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.pure-u-1-24{width:4.1667%}.pure-u-1-12,.pure-u-2-24{width:8.3333%}.pure-u-1-8,.pure-u-3-24{width:12.5%}.pure-u-1-6,.pure-u-4-24{width:16.6667%}.pure-u-1-5{width:20%}.pure-u-5-24{width:20.8333%}.pure-u-1-4,.pure-u-6-24{width:25%}.pure-u-7-24{width:29.1667%}.pure-u-1-3,.pure-u-8-24{width:33.3333%}.pure-u-3-8,.pure-u-9-24{width:37.5%}.pure-u-2-5{width:40%}.pure-u-10-24,.pure-u-5-12{width:41.6667%}.pure-u-11-24{width:45.8333%}.pure-u-1-2,.pure-u-12-24{width:50%}.pure-u-13-24{width:54.1667%}.pure-u-14-24,.pure-u-7-12{width:58.3333%}.pure-u-3-5{width:60%}.pure-u-15-24,.pure-u-5-8{width:62.5%}.pure-u-16-24,.pure-u-2-3{width:66.6667%}.pure-u-17-24{width:70.8333%}.pure-u-18-24,.pure-u-3-4{width:75%}.pure-u-19-24{width:79.1667%}.pure-u-4-5{width:80%}.pure-u-20-24,.pure-u-5-6{width:83.3333%}.pure-u-21-24,.pure-u-7-8{width:87.5%}.pure-u-11-12,.pure-u-22-24{width:91.6667%}.pure-u-23-24{width:95.8333%}.pure-u-1,.pure-u-1-1,.pure-u-24-24,.pure-u-5-5{width:100%}.pure-button{display:inline-block;line-height:normal;white-space:nowrap;vertical-align:middle;text-align:center;cursor:pointer;-webkit-user-drag:none;-webkit-user-select:none;user-select:none;box-sizing:border-box}.pure-button::-moz-focus-inner{padding:0;border:0}.pure-button-group{letter-spacing:-.31em;text-rendering:optimizespeed}.opera-only :-o-prefocus,.pure-button-group{word-spacing:-0.43em}.pure-button-group .pure-button{letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.pure-button{font-family:inherit;font-size:100%;padding:.5em 1em;color:rgba(0,0,0,.8);border:none transparent;background-color:#e6e6e6;text-decoration:none;border-radius:2px}.pure-button-hover,.pure-button:focus,.pure-button:hover{background-image:linear-gradient(transparent,rgba(0,0,0,.05) 40%,rgba(0,0,0,.1))}.pure-button:focus{outline:0}.pure-button-active,.pure-button:active{box-shadow:0 0 0 1px rgba(0,0,0,.15) inset,0 0 6px rgba(0,0,0,.2) inset;border-color:#000}.pure-button-disabled,.pure-button-disabled:active,.pure-button-disabled:focus,.pure-button-disabled:hover,.pure-button[disabled]{border:none;background-image:none;opacity:.4;cursor:not-allowed;box-shadow:none;pointer-events:none}.pure-button-hidden{display:none}.pure-button-primary,.pure-button-selected,a.pure-button-primary,a.pure-button-selected{background-color:#0078e7;color:#fff}.pure-button-group .pure-button{margin:0;border-radius:0;border-right:1px solid rgba(0,0,0,.2)}.pure-button-group .pure-button:first-child{border-top-left-radius:2px;border-bottom-left-radius:2px}.pure-button-group .pure-button:last-child{border-top-right-radius:2px;border-bottom-right-radius:2px;border-right:none}.pure-form input[type=color],.pure-form input[type=date],.pure-form input[type=datetime-local],.pure-form input[type=datetime],.pure-form input[type=email],.pure-form input[type=month],.pure-form input[type=number],.pure-form input[type=password],.pure-form input[type=search],.pure-form input[type=tel],.pure-form input[type=text],.pure-form input[type=time],.pure-form input[type=url],.pure-form input[type=week],.pure-form select,.pure-form textarea{padding:.5em .6em;display:inline-block;border:1px solid #ccc;box-shadow:inset 0 1px 3px #ddd;border-radius:4px;vertical-align:middle;box-sizing:border-box}.pure-form input:not([type]){padding:.5em .6em;display:inline-block;border:1px solid #ccc;box-shadow:inset 0 1px 3px #ddd;border-radius:4px;box-sizing:border-box}.pure-form input[type=color]{padding:.2em .5em}.pure-form input[type=color]:focus,.pure-form input[type=date]:focus,.pure-form input[type=datetime-local]:focus,.pure-form input[type=datetime]:focus,.pure-form input[type=email]:focus,.pure-form input[type=month]:focus,.pure-form input[type=number]:focus,.pure-form input[type=password]:focus,.pure-form input[type=search]:focus,.pure-form input[type=tel]:focus,.pure-form input[type=text]:focus,.pure-form input[type=time]:focus,.pure-form input[type=url]:focus,.pure-form input[type=week]:focus,.pure-form select:focus,.pure-form textarea:focus{outline:0;border-color:#129fea}.pure-form input:not([type]):focus{outline:0;border-color:#129fea}.pure-form input[type=checkbox]:focus,.pure-form input[type=file]:focus,.pure-form input[type=radio]:focus{outline:thin solid #129FEA;outline:1px auto #129FEA}.pure-form .pure-checkbox,.pure-form .pure-radio{margin:.5em 0;display:block}.pure-form input[type=color][disabled],.pure-form input[type=date][disabled],.pure-form input[type=datetime-local][disabled],.pure-form input[type=datetime][disabled],.pure-form input[type=email][disabled],.pure-form input[type=month][disabled],.pure-form input[type=number][disabled],.pure-form input[type=password][disabled],.pure-form input[type=search][disabled],.pure-form input[type=tel][disabled],.pure-form input[type=text][disabled],.pure-form input[type=time][disabled],.pure-form input[type=url][disabled],.pure-form input[type=week][disabled],.pure-form select[disabled],.pure-form textarea[disabled]{cursor:not-allowed;background-color:#eaeded;color:#cad2d3}.pure-form input:not([type])[disabled]{cursor:not-allowed;background-color:#eaeded;color:#cad2d3}.pure-form input[readonly],.pure-form select[readonly],.pure-form textarea[readonly]{background-color:#eee;color:#777;border-color:#ccc}.pure-form input:focus:invalid,.pure-form select:focus:invalid,.pure-form textarea:focus:invalid{color:#b94a48;border-color:#e9322d}.pure-form input[type=checkbox]:focus:invalid:focus,.pure-form input[type=file]:focus:invalid:focus,.pure-form input[type=radio]:focus:invalid:focus{outline-color:#e9322d}.pure-form select{height:2.25em;border:1px solid #ccc;background-color:#fff}.pure-form select[multiple]{height:auto}.pure-form label{margin:.5em 0 .2em}.pure-form fieldset{margin:0;padding:.35em 0 .75em;border:0}.pure-form legend{display:block;width:100%;padding:.3em 0;margin-bottom:.3em;color:#333;border-bottom:1px solid #e5e5e5}.pure-form-stacked input[type=color],.pure-form-stacked input[type=date],.pure-form-stacked input[type=datetime-local],.pure-form-stacked input[type=datetime],.pure-form-stacked input[type=email],.pure-form-stacked input[type=file],.pure-form-stacked input[type=month],.pure-form-stacked input[type=number],.pure-form-stacked input[type=password],.pure-form-stacked input[type=search],.pure-form-stacked input[type=tel],.pure-form-stacked input[type=text],.pure-form-stacked input[type=time],.pure-form-stacked input[type=url],.pure-form-stacked input[type=week],.pure-form-stacked label,.pure-form-stacked select,.pure-form-stacked textarea{display:block;margin:.25em 0}.pure-form-stacked input:not([type]){display:block;margin:.25em 0}.pure-form-aligned input,.pure-form-aligned select,.pure-form-aligned textarea,.pure-form-message-inline{display:inline-block;vertical-align:middle}.pure-form-aligned textarea{vertical-align:top}.pure-form-aligned .pure-control-group{margin-bottom:.5em}.pure-form-aligned .pure-control-group label{text-align:right;display:inline-block;vertical-align:middle;width:10em;margin:0 1em 0 0}.pure-form-aligned .pure-controls{margin:1.5em 0 0 11em}.pure-form .pure-input-rounded,.pure-form input.pure-input-rounded{border-radius:2em;padding:.5em 1em}.pure-form .pure-group fieldset{margin-bottom:10px}.pure-form .pure-group input,.pure-form .pure-group textarea{display:block;padding:10px;margin:0 0 -1px;border-radius:0;position:relative;top:-1px}.pure-form .pure-group input:focus,.pure-form .pure-group textarea:focus{z-index:3}.pure-form .pure-group input:first-child,.pure-form .pure-group textarea:first-child{top:1px;border-radius:4px 4px 0 0;margin:0}.pure-form .pure-group input:first-child:last-child,.pure-form .pure-group textarea:first-child:last-child{top:1px;border-radius:4px;margin:0}.pure-form .pure-group input:last-child,.pure-form .pure-group textarea:last-child{top:-2px;border-radius:0 0 4px 4px;margin:0}.pure-form .pure-group button{margin:.35em 0}.pure-form .pure-input-1{width:100%}.pure-form .pure-input-3-4{width:75%}.pure-form .pure-input-2-3{width:66%}.pure-form .pure-input-1-2{width:50%}.pure-form .pure-input-1-3{width:33%}.pure-form .pure-input-1-4{width:25%}.pure-form-message-inline{display:inline-block;padding-left:.3em;color:#666;vertical-align:middle;font-size:.875em}.pure-form-message{display:block;color:#666;font-size:.875em}@media only screen and (max-width :480px){.pure-form button[type=submit]{margin:.7em 0 0}.pure-form input:not([type]),.pure-form input[type=color],.pure-form input[type=date],.pure-form input[type=datetime-local],.pure-form input[type=datetime],.pure-form input[type=email],.pure-form input[type=month],.pure-form input[type=number],.pure-form input[type=password],.pure-form input[type=search],.pure-form input[type=tel],.pure-form input[type=text],.pure-form input[type=time],.pure-form input[type=url],.pure-form input[type=week],.pure-form label{margin-bottom:.3em;display:block}.pure-group input:not([type]),.pure-group input[type=color],.pure-group input[type=date],.pure-group input[type=datetime-local],.pure-group input[type=datetime],.pure-group input[type=email],.pure-group input[type=month],.pure-group input[type=number],.pure-group input[type=password],.pure-group input[type=search],.pure-group input[type=tel],.pure-group input[type=text],.pure-group input[type=time],.pure-group input[type=url],.pure-group input[type=week]{margin-bottom:0}.pure-form-aligned .pure-control-group label{margin-bottom:.3em;text-align:left;display:block;width:100%}.pure-form-aligned .pure-controls{margin:1.5em 0 0 0}.pure-form-message,.pure-form-message-inline{display:block;font-size:.75em;padding:.2em 0 .8em}}.pure-menu{box-sizing:border-box}.pure-menu-fixed{position:fixed;left:0;top:0;z-index:3}.pure-menu-item,.pure-menu-list{position:relative}.pure-menu-list{list-style:none;margin:0;padding:0}.pure-menu-item{padding:0;margin:0;height:100%}.pure-menu-heading,.pure-menu-link{display:block;text-decoration:none;white-space:nowrap}.pure-menu-horizontal{width:100%;white-space:nowrap}.pure-menu-horizontal .pure-menu-list{display:inline-block}.pure-menu-horizontal .pure-menu-heading,.pure-menu-horizontal .pure-menu-item,.pure-menu-horizontal .pure-menu-separator{display:inline-block;vertical-align:middle}.pure-menu-item .pure-menu-item{display:block}.pure-menu-children{display:none;position:absolute;left:100%;top:0;margin:0;padding:0;z-index:3}.pure-menu-horizontal .pure-menu-children{left:0;top:auto;width:inherit}.pure-menu-active>.pure-menu-children,.pure-menu-allow-hover:hover>.pure-menu-children{display:block;position:absolute}.pure-menu-has-children>.pure-menu-link:after{padding-left:.5em;content:"\25B8";font-size:small}.pure-menu-horizontal .pure-menu-has-children>.pure-menu-link:after{content:"\25BE"}.pure-menu-scrollable{overflow-y:scroll;overflow-x:hidden}.pure-menu-scrollable .pure-menu-list{display:block}.pure-menu-horizontal.pure-menu-scrollable .pure-menu-list{display:inline-block}.pure-menu-horizontal.pure-menu-scrollable{white-space:nowrap;overflow-y:hidden;overflow-x:auto;padding:.5em 0}.pure-menu-horizontal .pure-menu-children .pure-menu-separator,.pure-menu-separator{background-color:#ccc;height:1px;margin:.3em 0}.pure-menu-horizontal .pure-menu-separator{width:1px;height:1.3em;margin:0 .3em}.pure-menu-horizontal .pure-menu-children .pure-menu-separator{display:block;width:auto}.pure-menu-heading{text-transform:uppercase;color:#565d64}.pure-menu-link{color:#777}.pure-menu-children{background-color:#fff}.pure-menu-heading,.pure-menu-link{padding:.5em 1em}.pure-menu-disabled{opacity:.5}.pure-menu-disabled .pure-menu-link:hover{background-color:transparent;cursor:default}.pure-menu-active>.pure-menu-link,.pure-menu-link:focus,.pure-menu-link:hover{background-color:#eee}.pure-menu-selected>.pure-menu-link,.pure-menu-selected>.pure-menu-link:visited{color:#000}.pure-table{border-collapse:collapse;border-spacing:0;empty-cells:show;border:1px solid #cbcbcb}.pure-table caption{color:#000;font:italic 85%/1 arial,sans-serif;padding:1em 0;text-align:center}.pure-table td,.pure-table th{border-left:1px solid #cbcbcb;border-width:0 0 0 1px;font-size:inherit;margin:0;overflow:visible;padding:.5em 1em}.pure-table thead{background-color:#e0e0e0;color:#000;text-align:left;vertical-align:bottom}.pure-table td{background-color:transparent}.pure-table-odd td{background-color:#f2f2f2}.pure-table-striped tr:nth-child(2n-1) td{background-color:#f2f2f2}.pure-table-bordered td{border-bottom:1px solid #cbcbcb}.pure-table-bordered tbody>tr:last-child>td{border-bottom-width:0}.pure-table-horizontal td,.pure-table-horizontal th{border-width:0 0 1px 0;border-bottom:1px solid #cbcbcb}.pure-table-horizontal tbody>tr:last-child>td{border-bottom-width:0} ================================================ FILE: public/fonts/.gitkeep ================================================ ================================================ FILE: public/index.php ================================================ new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); ================================================ FILE: public/js/banditore.js ================================================ (function (window, document) { // close alert messages var alerts = document.querySelectorAll('span.close') for (var i = 0; i < alerts.length; ++i) { alerts[i].addEventListener('click', function (event) { // in case the font awesome element isn't loaded (might be the case on iOS) if (event.target.className === 'fa fa-close') { event .target // font awesome element .parentElement // span element .parentElement // alert element .style.display = 'none' } else { event .target // span element .parentElement // alert element .style.display = 'none' } }, false) } // handle rwd menu var menu = document.getElementById('menu'), WINDOW_CHANGE_EVENT = ('onorientationchange' in window) ? 'orientationchange':'resize' function toggleHorizontal() { [].forEach.call( document.getElementById('menu').querySelectorAll('.menu-can-transform'), function(el){ el.classList.toggle('pure-menu-horizontal') } ) } function toggleMenu() { // set timeout so that the panel has a chance to roll up // before the menu switches states if (menu.classList.contains('open')) { setTimeout(toggleHorizontal, 500) } else { toggleHorizontal() } menu.classList.toggle('open') document.getElementById('toggle').classList.toggle('x') } function closeMenu() { if (menu.classList.contains('open')) { toggleMenu() } } document.getElementById('toggle').addEventListener('click', function (e) { toggleMenu() e.preventDefault() }) window.addEventListener(WINDOW_CHANGE_EVENT, closeMenu) })(this, this.document) ================================================ FILE: public/robots.txt ================================================ # www.robotstxt.org/ # www.google.com/support/webmasters/bin/answer.py?hl=en&answer=156449 User-agent: * Disallow: ================================================ FILE: rector.php ================================================ withPaths([ __DIR__ . '/config', __DIR__ . '/migrations', __DIR__ . '/public', __DIR__ . '/src', __DIR__ . '/templates', __DIR__ . '/tests', ]) ->withRootFiles() ->withImportNames(importShortClasses: false) ->withTypeCoverageLevel(0) ->withDeadCodeLevel(0) ->withCodeQualityLevel(0) ->withRules([ AddVoidReturnTypeWhereNoReturnRector::class, ]) ->withPhpSets() ->withSets([ DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES, SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES, DoctrineSetList::GEDMO_ANNOTATIONS_TO_ATTRIBUTES, PHPUnitSetList::PHPUNIT_110, ]) ->withAttributesSets(symfony: true, doctrine: true, gedmo: true, jms: true, sensiolabs: true) ->withComposerBased(twig: true, doctrine: true, phpunit: true, symfony: true) ->withConfiguredRule(ClassPropertyAssignToConstructorPromotionRector::class, [ 'inline_public' => true, ]) ->withSkip([ ClassPropertyAssignToConstructorPromotionRector::class => [ __DIR__ . '/src/Entity/*', ], ]); ================================================ FILE: src/Cache/CustomRedisCachePool.php ================================================ get(); if (404 === $currentItem['response']->getStatusCode() || 451 === $currentItem['response']->getStatusCode()) { return parent::storeItemInCache($item, $ttl); } $body = json_decode((string) $currentItem['body'], true); // we don't need to reduce empty array ^^ if (empty($body)) { return parent::storeItemInCache($item, $ttl); } // do not cache version (ie: release or tag) information // we don't query them later because the version will be saved and never updated if (isset($body['committer']) || isset($body['tagger']) || isset($body['prerelease'])) { return true; } if (isset($body[0]['ref']) && str_contains((string) $body[0]['ref'], 'refs/tags/')) { // response for git/refs/tags foreach ($body as $key => $element) { $body[$key] = [ 'ref' => $element['ref'], 'object' => [ 'sha' => $element['object']['sha'], 'type' => $element['object']['type'], ], ]; } } elseif (isset($body[0]['zipball_url'])) { // response for only one tag $body = [ 0 => [ 'name' => $body[0]['name'], ], ]; } elseif (isset($body[0]['full_name'])) { // response for starred repos foreach ($body as $key => $element) { $body[$key] = [ 'id' => $element['id'], 'name' => $element['name'], 'homepage' => $element['homepage'], 'language' => $element['language'], 'full_name' => $element['full_name'], 'description' => $element['description'], 'owner' => [ 'avatar_url' => $element['owner']['avatar_url'], ], ]; } } else { $this->log('warning', 'Unmatched response from custom Redis cache', ['body' => $body]); } $currentItem['body'] = json_encode($body); $item->set($currentItem); return parent::storeItemInCache($item, $ttl); } } ================================================ FILE: src/Cache/HierarchicalCachePoolTrait.php ================================================ , Tobias Nyholm * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace App\Cache; use Cache\Adapter\Common\AbstractCachePool; /** * @author Tobias Nyholm */ trait HierarchicalCachePoolTrait { /** * A temporary cache for keys. * * @var array */ private $keyCache = []; /** * Get a value from the storage. * * @param string $name */ abstract public function getDirectValue($name); /** * Get a key to use with the hierarchy. If the key does not start with HierarchicalPoolInterface::SEPARATOR * this will return an unalterered key. This function supports a tagged key. Ie "foo:bar". * * @param string $key The original key * @param string &$pathKey A cache key for the path. If this key is changed everything beyond that path is changed. * * @return string|array */ protected function getHierarchyKey($key, &$pathKey = null) { if (!$this->isHierarchyKey($key)) { return $key; } $key = $this->explodeKey($key); $keyString = ''; // The comments below is for a $key = ["foo!tagHash", "bar!tagHash"] foreach ($key as $name) { // 1) $keyString = "foo!tagHash" // 2) $keyString = "foo!tagHash![foo_index]!bar!tagHash" $keyString .= (string) $name; $pathKey = sha1('path' . AbstractCachePool::SEPARATOR_TAG . $keyString); if (isset($this->keyCache[$pathKey])) { $index = $this->keyCache[$pathKey]; } else { $index = $this->getDirectValue($pathKey); $this->keyCache[$pathKey] = $index; } // 1) $keyString = "foo!tagHash![foo_index]!" // 2) $keyString = "foo!tagHash![foo_index]!bar!tagHash![bar_index]!" $keyString .= AbstractCachePool::SEPARATOR_TAG . $index . AbstractCachePool::SEPARATOR_TAG; } // Assert: $pathKey = "path!foo!tagHash![foo_index]!bar!tagHash" // Assert: $keyString = "foo!tagHash![foo_index]!bar!tagHash![bar_index]!" // Make sure we do not get awfully long (>250 chars) keys return sha1($keyString); } /** * Clear the cache for the keys. */ protected function clearHierarchyKeyCache(): void { $this->keyCache = []; } /** * A hierarchy key MUST begin with the separator. * * @param string $key * * @return bool */ private function isHierarchyKey($key) { return str_starts_with($key, '|'); } /** * This will take a hierarchy key ("|foo|bar") with tags ("|foo|bar!tagHash") and return an array with * each level in the hierarchy appended with the tags. ["foo!tagHash", "bar!tagHash"]. * * @param string $string * * @return array */ private function explodeKey($string) { [$key, $tag] = explode(AbstractCachePool::SEPARATOR_TAG, $string . AbstractCachePool::SEPARATOR_TAG); if ('|' === $key) { $parts = ['root']; } else { $parts = explode('|', $key); // remove first element since it is always empty and replace it with 'root' $parts[0] = 'root'; } return array_map(static fn ($level) => $level . AbstractCachePool::SEPARATOR_TAG . $tag, $parts); } } ================================================ FILE: src/Cache/PredisCachePool.php ================================================ cache->get($this->getHierarchyKey($key)); if (!$value) { return [false, null, [], null]; } $result = unserialize($value); if (false === $result) { return [false, null, [], null]; } return $result; } protected function clearAllObjectsFromCache(): bool { return 'OK' === $this->cache->flushdb()->getPayload(); } protected function clearOneObjectFromCache($key): bool { $path = null; $keyString = $this->getHierarchyKey($key, $path); if ($path) { $this->cache->incr($path); } $this->clearHierarchyKeyCache(); return $this->cache->del($keyString) >= 0; } protected function storeItemInCache(PhpCacheItem $item, $ttl): bool { if ($ttl < 0) { return false; } $key = $this->getHierarchyKey($item->getKey()); $data = serialize([true, $item->get(), $item->getTags(), $item->getExpirationTimestamp()]); if (null === $ttl || 0 === $ttl) { return 'OK' === $this->cache->set($key, $data)->getPayload(); } return 'OK' === $this->cache->setex($key, $ttl, $data)->getPayload(); } protected function getDirectValue($key): mixed { return $this->cache->get($key); } protected function appendListItem($name, $value): void { $this->cache->lpush($name, $value); } protected function getList($name): array { return $this->cache->lrange($name, 0, -1); } protected function removeList($name): bool { return $this->cache->del($name); } protected function removeListItem($name, $key): int { return $this->cache->lrem($name, 0, $key); } } ================================================ FILE: src/Command/SyncStarredReposCommand.php ================================================ transport instanceof MessageCountAwareInterface) { // check that queue is empty before pushing new messages $count = $this->transport->getMessageCount(); if (0 < $count) { $output->writeln('Current queue as too much messages (' . $count . '), skipping.'); return Command::FAILURE; } } $users = $this->retrieveUsers($id, $username); if (\count(array_filter($users)) <= 0) { $output->writeln('No users found'); return Command::FAILURE; } $userSynced = 0; $totalUsers = \count($users); foreach ($users as $userId) { ++$userSynced; $output->writeln('[' . $userSynced . '/' . $totalUsers . '] Sync user ' . $userId . ' … '); $message = new StarredReposSync($userId); if ($useQueue) { $this->bus->dispatch($message); } else { $this->syncRepo->__invoke($message); } } $output->writeln('User synced: ' . $userSynced . ''); return Command::SUCCESS; } /** * Retrieve users to work on. */ private function retrieveUsers(?string $id, ?string $username): array { if ($id) { return [$id]; } if ($username) { $user = $this->userRepository->findOneByUsername((string) $username); if ($user) { return [$user->getId()]; } return []; } return $this->userRepository->findAllToSync(); } } ================================================ FILE: src/Command/SyncVersionsCommand.php ================================================ transport instanceof MessageCountAwareInterface) { // check that queue is empty before pushing new messages $count = $this->transport->getMessageCount(); if (0 < $count) { $output->writeln('Current queue as too much messages (' . $count . '), skipping.'); return Command::FAILURE; } } $repos = $this->retrieveRepos($repoId, $repoName); if (\count(array_filter($repos)) <= 0) { $output->writeln('No repos found'); return Command::FAILURE; } $repoChecked = 0; $totalRepos = \count($repos); foreach ($repos as $repoId) { ++$repoChecked; $output->writeln('[' . $repoChecked . '/' . $totalRepos . '] Check ' . $repoId . ' … '); $message = new VersionsSync($repoId); if ($useQueue) { $this->bus->dispatch($message); } else { $this->syncVersions->__invoke($message); } } $output->writeln('Repo checked: ' . $repoChecked . ''); return Command::SUCCESS; } /** * Retrieve repos to work on. */ private function retrieveRepos(?string $repoId, ?string $repoName): array { if ($repoId) { return [$repoId]; } if ($repoName) { $repo = $this->repoRepository->findOneByFullName((string) $repoName); if ($repo) { return [$repo->getId()]; } return []; } return $this->repoRepository->findAllForRelease(); } } ================================================ FILE: src/Controller/DefaultController.php ================================================ security->isGranted('IS_AUTHENTICATED_FULLY')) { return $this->redirect($this->generateUrl('dashboard')); } return $this->render('default/index.html.twig'); } #[Route(path: '/status', name: 'status')] public function statusAction(): Response { $latest = $this->repoVersion->findLatest(); if (null === $latest) { return $this->json([]); } $diff = (new \DateTime())->getTimestamp() - $latest['createdAt']->getTimestamp(); return $this->json([ 'latest' => $latest['createdAt'], 'diff' => $diff, 'is_fresh' => $diff / 60 < $this->diffInterval, ]); } #[Route(path: '/dashboard', name: 'dashboard')] public function dashboardAction(Request $request, Paginator $paginator): Response { if (!$this->security->isGranted('IS_AUTHENTICATED_FULLY')) { return $this->redirect($this->generateUrl('homepage')); } /** @var User */ $user = $this->getUser(); $userId = $user->getId(); // Pass the item total $paginator->setItemTotalCallback(fn () => $this->repoVersion->countForUser($userId)); // Pass the slice $paginator->setSliceCallback(fn ($offset, $length) => $this->repoVersion->findForUser($userId, $offset, $length)); // Paginate using the current page number try { $pagination = $paginator->paginate((int) $request->query->get('page', '1')); } catch (InvalidPageNumberException $e) { throw $this->createNotFoundException($e->getMessage()); } // Avoid displaying empty page when page is too high if ($request->query->get('page') > $pagination->getTotalNumberOfPages()) { return $this->redirect($this->generateUrl('dashboard')); } return $this->render('default/dashboard.html.twig', [ 'pagination' => $pagination, 'sync_status' => $this->redis->get('banditore:user-sync:' . $userId), ]); } #[Route(path: '/dashboard/repositories/{repoId}/feed', name: 'dashboard_repo_feed', methods: ['POST'])] public function updateDashboardRepoFeedAction(int $repoId, Request $request, StarRepository $starRepository, EntityManagerInterface $entityManager): RedirectResponse { if (!$this->security->isGranted('IS_AUTHENTICATED_FULLY')) { return $this->redirect($this->generateUrl('homepage')); } /** @var User */ $user = $this->getUser(); $star = $starRepository->findOneByUserAndRepo($user->getId(), $repoId); if (null === $star) { throw $this->createNotFoundException('Repository subscription not found.'); } $ignoreInFeed = $request->request->getBoolean('ignore_in_feed'); $star->setIgnoredInFeed($ignoreInFeed); $entityManager->flush(); $this->addFlash( 'info', \sprintf( '%s %s in your RSS feed.', $star->getRepo()->getFullName(), $ignoreInFeed ? 'is now ignored' : 'is now included again' ) ); return $this->redirect($this->generateUrl('dashboard')); } /** * Empty callback action. * The request will be handle by the GithubAuthenticator. */ #[Route(path: '/callback', name: 'github_callback')] public function githubCallbackAction(): RedirectResponse { return $this->redirect($this->generateUrl('github_connect')); } /** * Link to this controller to start the "connect" process. */ #[Route(path: '/connect', name: 'github_connect')] public function connectAction(ClientRegistry $oauth): RedirectResponse { if ($this->security->isGranted('IS_AUTHENTICATED_FULLY')) { return $this->redirect($this->generateUrl('dashboard')); } return $oauth ->getClient('github') ->redirect(['user:email'], []); } #[Route(path: '/{uuid}.atom', name: 'rss_user')] public function rssAction( #[MapEntity(expr: 'repository.findOneBy({"uuid": uuid})')] User $user, Generator $rssGenerator, RssWriter $rssWriter, ): RssStreamedResponse { $channel = $rssGenerator->generate( $user, $this->repoVersion->findForFeedUser($user->getId()), $this->generateUrl('rss_user', ['uuid' => $user->getUuid()], UrlGeneratorInterface::ABSOLUTE_URL) ); return new RssStreamedResponse($channel, $rssWriter); } /** * Display some global stats. */ #[Route(path: '/stats', name: 'stats')] public function statsAction(RepoRepository $repoRepo, StarRepository $repoStar, UserRepository $repoUser): Response { $nbRepos = $repoRepo->countTotal(); $nbReleases = $this->repoVersion->countTotal(); $nbStars = $repoStar->countTotal(); $nbUsers = $repoUser->countTotal(); return $this->render('default/stats.html.twig', [ 'counters' => [ 'nbRepos' => $nbRepos, 'nbReleases' => $nbReleases, 'avgReleasePerRepo' => ($nbRepos > 0) ? round($nbReleases / $nbRepos, 2) : 0, 'avgStarPerUser' => ($nbUsers > 0) ? round($nbStars / $nbUsers, 2) : 0, ], 'mostReleases' => $repoRepo->mostVersionsPerRepo(), 'lastestReleases' => $this->repoVersion->findLastVersionForEachRepo(20), ]); } } ================================================ FILE: src/DataFixtures/AppFixtures.php ================================================ loadUsers($manager); $this->loadRepos($manager); $this->loadStars($manager); $this->loadVersions($manager); } private function loadUsers(ObjectManager $manager): void { $user1 = new User(); $user1->setId(123); $user1->setUsername('admin'); $user1->setName('Bob'); $user1->setAccessToken('1234567890'); $user1->setAvatar('http://0.0.0.0/avatar.jpg'); $manager->persist($user1); $manager->flush(); $this->addReference('user1', $user1); } private function loadRepos(ObjectManager $manager): void { $repo1 = new Repo(); $repo1->hydrateFromGithub([ 'id' => 666, 'name' => 'test', 'full_name' => 'test/test', 'description' => 'This is a test repo', 'homepage' => 'http://homepage.io', 'language' => 'Go', 'owner' => [ 'avatar_url' => 'http://0.0.0.0/test.jpg', ], ]); $manager->persist($repo1); $repo2 = new Repo(); $repo2->hydrateFromGithub([ 'id' => 555, 'name' => 'symfony', 'full_name' => 'symfony/symfony', 'description' => 'The Symfony PHP framework', 'homepage' => 'http://symfony.com', 'language' => 'PHP', 'owner' => [ 'avatar_url' => 'https://avatars2.githubusercontent.com/u/143937?v=3', ], ]); $manager->persist($repo2); $repo3 = new Repo(); $repo3->hydrateFromGithub([ 'id' => 444, 'name' => 'graby', 'full_name' => 'j0k3r/graby', 'description' => 'graby', 'homepage' => 'http://graby.io', 'language' => 'PHP', 'owner' => [ 'avatar_url' => 'http://0.0.0.0/graby.jpg', ], ]); $manager->persist($repo3); $manager->flush(); $this->addReference('repo1', $repo1); $this->addReference('repo2', $repo2); $this->addReference('repo3', $repo3); } private function loadStars(ObjectManager $manager): void { /** @var User */ $user1 = $this->getReference('user1', User::class); /** @var Repo */ $repo1 = $this->getReference('repo1', Repo::class); /** @var Repo */ $repo2 = $this->getReference('repo2', Repo::class); $star1 = new Star($user1, $repo1); $star2 = new Star($user1, $repo2); $manager->persist($star1); $manager->persist($star2); $manager->flush(); $this->addReference('star1', $star1); $this->addReference('star2', $star2); } private function loadVersions(ObjectManager $manager): void { /** @var Repo */ $repo1 = $this->getReference('repo1', Repo::class); /** @var Repo */ $repo2 = $this->getReference('repo2', Repo::class); /** @var Repo */ $repo3 = $this->getReference('repo3', Repo::class); $version1 = new Version($repo1); $version1->hydrateFromGithub([ 'tag_name' => '1.0.0', 'name' => 'First release', 'prerelease' => false, 'message' => 'YAY', 'published_at' => '2019-10-15T07:49:21Z', ]); $manager->persist($version1); $version2 = new Version($repo2); $version2->hydrateFromGithub([ 'tag_name' => '1.0.21', 'name' => 'First release', 'prerelease' => false, 'message' => 'YAY 555', 'published_at' => '2019-06-15T07:49:21Z', ]); $manager->persist($version2); $manager->flush(); $version3 = new Version($repo3); $version3->hydrateFromGithub([ 'tag_name' => '0.0.21', 'name' => 'Outdated release', 'prerelease' => false, 'message' => 'YAY OLD', 'published_at' => date('Y') . '-06-15T07:49:21Z', ]); $manager->persist($version3); $manager->flush(); $this->addReference('version1', $version1); $this->addReference('version2', $version2); } } ================================================ FILE: src/Entity/Repo.php ================================================ */ #[ORM\OneToMany(targetEntity: Star::class, mappedBy: 'repo')] private $stars; /** * @var ArrayCollection */ #[ORM\OneToMany(targetEntity: Version::class, mappedBy: 'repo')] private $versions; public function __construct() { $this->stars = new ArrayCollection(); $this->versions = new ArrayCollection(); } /** * Set id. * * @param int $id * * @return Repo */ public function setId($id) { $this->id = $id; return $this; } /** * Get id. * * @return int */ public function getId() { return $this->id; } /** * Set name. * * @param string $name * * @return Repo */ public function setName($name) { $this->name = $name; return $this; } /** * Get name. * * @return string */ public function getName() { return $this->name; } /** * Set fullName. * * @param string $fullName * * @return Repo */ public function setFullName($fullName) { $this->fullName = $fullName; return $this; } /** * Get fullName. * * @return string */ public function getFullName() { return $this->fullName; } /** * Set description. * * @param string $description * * @return Repo */ public function setDescription($description) { $this->description = $description; return $this; } /** * Get description. * * @return string */ public function getDescription() { return (string) $this->description; } /** * Set homepage. * * @param string $homepage * * @return Repo */ public function setHomepage($homepage) { $this->homepage = $homepage; return $this; } /** * Get homepage. * * @return string */ public function getHomepage() { return (string) $this->homepage; } /** * Set language. * * @param string $language * * @return Repo */ public function setLanguage($language) { $this->language = $language; return $this; } /** * Get language. * * @return string */ public function getLanguage() { return (string) $this->language; } /** * Set ownerAvatar. * * @param string $ownerAvatar * * @return Repo */ public function setOwnerAvatar($ownerAvatar) { $this->ownerAvatar = $ownerAvatar; return $this; } /** * Get ownerAvatar. * * @return string */ public function getOwnerAvatar() { return $this->ownerAvatar; } /** * Set createdAt. * * @param \DateTime $createdAt * * @return Repo */ public function setCreatedAt($createdAt) { $this->createdAt = $createdAt; return $this; } /** * Get createdAt. * * @return \DateTime */ public function getCreatedAt() { return $this->createdAt; } /** * Set updatedAt. * * @param \DateTime $updatedAt * * @return Repo */ public function setUpdatedAt($updatedAt) { $this->updatedAt = $updatedAt; return $this; } /** * Get updatedAt. * * @return \DateTime */ public function getUpdatedAt() { return $this->updatedAt; } #[ORM\PrePersist] #[ORM\PreUpdate] public function timestamps(): void { if (null === $this->createdAt) { $this->createdAt = new \DateTime(); } $this->updatedAt = new \DateTime(); } public function hydrateFromGithub(array $data): void { $this->setId($data['id']); $this->setName($data['name']); $this->setHomepage($data['homepage']); $this->setLanguage($data['language']); $this->setFullName($data['full_name']); $this->setDescription($data['description']); $this->setOwnerAvatar($data['owner']['avatar_url']); } /** * Set removedAt. * * @param \DateTime $removedAt * * @return Repo */ public function setRemovedAt($removedAt) { $this->removedAt = $removedAt; return $this; } /** * Get removedAt. * * @return \DateTime|null */ public function getRemovedAt() { return $this->removedAt; } } ================================================ FILE: src/Entity/Star.php ================================================ false])] private bool $ignoredInFeed = false; public function __construct(#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'stars')] #[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: false)] private readonly User $user, #[ORM\ManyToOne(targetEntity: Repo::class, inversedBy: 'stars')] #[ORM\JoinColumn(name: 'repo_id', referencedColumnName: 'id', nullable: false)] private readonly Repo $repo) { $this->createdAt = new \DateTime(); } /** * Get id. * * @return int */ public function getId() { return $this->id; } /** * Set createdAt. * * @param \DateTime $createdAt * * @return Star */ public function setCreatedAt($createdAt) { $this->createdAt = $createdAt; return $this; } /** * Get createdAt. * * @return \DateTime */ public function getCreatedAt() { return $this->createdAt; } public function getUser(): User { return $this->user; } public function getRepo(): Repo { return $this->repo; } public function isIgnoredInFeed(): bool { return $this->ignoredInFeed; } public function setIgnoredInFeed(bool $ignoredInFeed): self { $this->ignoredInFeed = $ignoredInFeed; return $this; } } ================================================ FILE: src/Entity/User.php ================================================ */ #[ORM\OneToMany(targetEntity: Star::class, mappedBy: 'user')] private $stars; public function __construct() { $this->uuid = Uuid::uuid4()->toString(); $this->stars = new ArrayCollection(); } /** * Set id. * * @param int $id * * @return User */ public function setId($id) { $this->id = $id; return $this; } /** * Get id. * * @return int */ public function getId() { return $this->id; } /** * Set username. * * @param string $username * * @return User */ public function setUsername($username) { $this->username = $username; return $this; } /** * Get username. * * @return string */ public function getUsername() { return $this->username; } /** * Get uuid. * * @return string */ public function getUuid() { return $this->uuid; } /** * Set avatar. * * @param string $avatar * * @return User */ public function setAvatar($avatar) { $this->avatar = $avatar; return $this; } /** * Get avatar. * * @return string */ public function getAvatar() { return $this->avatar; } /** * Set name. * * @param string $name * * @return User */ public function setName($name) { $this->name = $name; return $this; } /** * Get name. * * @return string */ public function getName() { return (string) $this->name; } /** * Set createdAt. * * @param \DateTime $createdAt * * @return User */ public function setCreatedAt($createdAt) { $this->createdAt = $createdAt; return $this; } /** * Get createdAt. * * @return \DateTime */ public function getCreatedAt() { return $this->createdAt; } /** * Set updatedAt. * * @param \DateTime $updatedAt * * @return User */ public function setUpdatedAt($updatedAt) { $this->updatedAt = $updatedAt; return $this; } /** * Get updatedAt. * * @return \DateTime */ public function getUpdatedAt() { return $this->updatedAt; } #[ORM\PrePersist] #[ORM\PreUpdate] public function timestamps(): void { if (null === $this->createdAt) { $this->createdAt = new \DateTime(); } $this->updatedAt = new \DateTime(); } /** * Hydrate a user with data from Github. */ public function hydrateFromGithub(GithubResourceOwner $data): void { $info = $data->toArray(); $this->setId($info['id']); $this->setUsername($info['login']); $this->setAvatar($info['avatar_url']); $this->setName($info['name']); } public function getRoles(): array { return ['ROLE_USER']; } public function getPassword(): ?string { return ''; } public function getSalt(): ?string { return null; } public function eraseCredentials(): void { } /** * Set accessToken. * * @param string $accessToken * * @return User */ public function setAccessToken($accessToken) { $this->accessToken = $accessToken; return $this; } /** * Get accessToken. * * @return string */ public function getAccessToken() { return $this->accessToken; } /** * Set removedAt. * * @param \DateTime $removedAt * * @return User */ public function setRemovedAt($removedAt) { $this->removedAt = $removedAt; return $this; } /** * Get removedAt. * * @return \DateTime|null */ public function getRemovedAt() { return $this->removedAt; } /** * Trying to determine if the user should be logged out because it has changed or not. * * @see https://stackoverflow.com/a/47676103/569101 * @see https://symfony.com/doc/4.4/reference/configuration/security.html#logout-on-user-change */ public function isEqualTo(UserInterface $user): bool { if ($user instanceof self) { if ($this->accessToken !== $user->getAccessToken()) { return false; } if ($this->uuid !== $user->getUuid()) { return false; } } if ($this->username !== $user->getUserIdentifier()) { return false; } return true; } public function getUserIdentifier(): string { return $this->getUsername(); } } ================================================ FILE: src/Entity/Version.php ================================================ id; } /** * Set tagName. * * @param string $tagName * * @return Version */ public function setTagName($tagName) { $this->tagName = $tagName; return $this; } /** * Get tagName. * * @return string */ public function getTagName() { return $this->tagName; } /** * Set name. * * @param string $name * * @return Version */ public function setName($name) { // hard truncate name if (mb_strlen($name) > 190) { $name = mb_substr($name, 0, 190); } $this->name = $name; return $this; } /** * Get name. * * @return string */ public function getName() { return (string) $this->name; } /** * Set prerelease. * * @param bool $prerelease * * @return Version */ public function setPrerelease($prerelease) { $this->prerelease = $prerelease; return $this; } /** * Get prerelease. * * @return bool */ public function getPrerelease() { return $this->prerelease; } /** * Set createdAt. * * @param \DateTime $createdAt * * @return Version */ public function setCreatedAt($createdAt) { $this->createdAt = $createdAt; return $this; } /** * Get createdAt. * * @return \DateTime */ public function getCreatedAt() { return $this->createdAt; } /** * Set body. * * @param string $body * * @return Version */ public function setBody($body) { $this->body = $body; return $this; } /** * Get body. * * @return string */ public function getBody() { return (string) $this->body; } public function hydrateFromGithub(array $data): void { $this->setTagName($data['tag_name']); $this->setName($data['name']); $this->setPrerelease($data['prerelease']); $this->setCreatedAt((new \DateTime())->setTimestamp(strtotime((string) $data['published_at']))); $this->setBody($data['message']); } } ================================================ FILE: src/Github/ClientDiscovery.php ================================================ client = new GithubClient(); } /** * Allow to override Github client. * Only used in test. */ public function setGithubClient(GithubClient $client): void { $this->client = $client; } /** * Find the best authentication to use: * - check the rate limit of the application default client (which should be used in most case) * - if the rate limit is too low for the application client, loop on all user to check their rate limit * - if none client have enough rate limit, we'll have a problem to perform further request, stop every thing ! * * @return GithubClient|null */ public function find() { // attache the cache in anycase $this->client->addCache( new CustomRedisCachePool($this->redis), [ // the default config include "private" to avoid caching request with this header // since we can use a user token, Github will return a "private" but we want to cache that request // it's safe because we don't require critical user value 'respect_response_cache_directives' => ['no-cache', 'max-age', 'no-store'], ] ); // try with the application default client $this->client->authenticate($this->clientId, $this->clientSecret, AuthMethod::CLIENT_ID); $remaining = $this->getRateLimits($this->client, $this->logger); if ($remaining >= self::THRESHOLD_RATE_REMAIN_APP) { $this->logger->notice('RateLimit ok (' . $remaining . ') with default application'); return $this->client; } // if it doesn't work, try with all user tokens // when at least one is ok, use it! $users = $this->userRepository->findAllTokens(); foreach ($users as $user) { $this->client->authenticate($user['accessToken'], null, AuthMethod::ACCESS_TOKEN); $remaining = $this->getRateLimits($this->client, $this->logger); if ($remaining >= self::THRESHOLD_RATE_REMAIN_USER) { $this->logger->notice('RateLimit ok (' . $remaining . ') with user: ' . $user['username']); return $this->client; } } $this->logger->warning('No way to authenticate a client with enough rate limit remaining :('); return null; } } ================================================ FILE: src/Github/RateLimitTrait.php ================================================ api('rate_limit'); $rateLimitResource = $rateLimit->getResource('core'); if (false === $rateLimitResource) { throw new \Exception('Unable to retrieve "core" resource from RateLimitTrait'); } return $rateLimitResource->getRemaining(); } catch (HttpException $e) { $logger->error('RateLimit call goes bad.', ['exception' => $e]); return false; } catch (\Exception $e) { $logger->error('RateLimit call goes REALLY bad.', ['exception' => $e]); return false; } } } ================================================ FILE: src/Kernel.php ================================================ userId; } } ================================================ FILE: src/Message/VersionsSync.php ================================================ repoId; } } ================================================ FILE: src/MessageHandler/StarredReposSyncHandler.php ================================================ client) { $this->logger->error('No client provided'); return false; } $userId = $message->getUserId(); /** @var User|null */ $user = $this->userRepository->find($userId); if (null === $user) { $this->logger->error('Can not find user', ['user' => $userId]); return false; } // to be able to notify user about repos sync (will be remove after 1h to avoid infinite sync notification) $this->redis->setex('banditore:user-sync:' . $user->getId(), 3600, time()); $this->logger->info('Consume banditore.sync_starred_repos message', ['user' => $user->getUsername()]); $rateLimit = $this->getRateLimits($this->client, $this->logger); $this->logger->info('[' . $rateLimit . '] Check ' . $user->getUsername() . ' … '); if (0 === $rateLimit || false === $rateLimit) { $this->logger->warning('RateLimit reached, stopping.'); return false; } // this shouldn't be catched so the worker will die when an exception is thrown $nbRepos = $this->doSyncRepo($user); $this->logger->notice('[' . $this->getRateLimits($this->client, $this->logger) . '] Synced repos: ' . $nbRepos, ['user' => $user->getUsername()]); // sync is done, remove notification $this->redis->del(['banditore:user-sync:' . $user->getId()]); return true; } /** * Do the job to sync repo & star of a user. * * @param User $user User to work on */ private function doSyncRepo(User $user): ?int { $newStars = []; $page = 1; $perPage = 100; /** @var EntityManager */ $em = $this->doctrine->getManager(); /** @var \Github\Api\User */ $githubUserApi = $this->client->api('user'); // in case of the manager is closed following a previous exception if (!$em->isOpen()) { /** @var EntityManager */ $em = $this->doctrine->resetManager(); } try { $starredRepos = $githubUserApi->starred($user->getUsername(), $page, $perPage); } catch (\Exception $e) { $this->logger->warning('(starred) ' . $e->getMessage() . ''); // user got removed from GitHub if (404 === $e->getCode()) { $user->setRemovedAt(new \DateTime()); $em->persist($user); } return null; } $currentStars = $this->starRepository->findAllByUser($user->getId()); do { $this->logger->info(' sync ' . \count($starredRepos) . ' starred repos', [ 'user' => $user->getUsername(), 'rate' => $this->getRateLimits($this->client, $this->logger), ]); foreach ($starredRepos as $starredRepo) { /** @var Repo|null */ $repo = $this->repoRepository->find($starredRepo['id']); // if repo doesn't exist // OR repo doesn't get updated since XX days if (null === $repo || $repo->getUpdatedAt()->diff(new \DateTime())->days > self::DAYS_SINCE_LAST_UPDATE) { if (null === $repo) { $repo = new Repo(); } $repo->hydrateFromGithub($starredRepo); $em->persist($repo); } // store current repo id to compare it later when we'll sync removed star // using `id` instead of `full_name` to be more accurated (full_name can change) $newStars[] = $repo->getId(); if (false === \in_array($repo->getId(), $currentStars, true)) { $star = new Star($user, $repo); $em->persist($star); } } $em->flush(); try { $starredRepos = $githubUserApi->starred($user->getUsername(), ++$page, $perPage); } catch (RuntimeException) { // api limit is reached or whatever other error, we'll try next time return null; } } while (!empty($starredRepos)); // now remove unstarred repos $this->doCleanOldStar($user, $newStars); return \count($newStars); } /** * Clean old star. * When user unstar a repo we also need to remove that association. * * @param array $newStars Current starred repos Id of the user */ private function doCleanOldStar(User $user, array $newStars): void { $currentStars = $this->starRepository->findAllByUser($user->getId()); $repoIdsToRemove = array_diff($currentStars, $newStars); if (!empty($repoIdsToRemove)) { $this->logger->info('Removed stars: ' . \count($repoIdsToRemove), ['user' => $user->getUsername()]); $this->starRepository->removeFromUser($repoIdsToRemove, $user->getId()); } } } ================================================ FILE: src/MessageHandler/VersionsSyncHandler.php ================================================ client) { $this->logger->error('No client provided'); return false; } $repoId = $message->getRepoId(); /** @var Repo|null */ $repo = $this->repoRepository->find($repoId); if (null === $repo) { $this->logger->error('Can not find repo', ['repo' => $repoId]); return false; } $this->logger->info('Consume banditore.sync_versions message', ['repo' => $repo->getFullName()]); $rateLimit = $this->getRateLimits($this->client, $this->logger); $this->logger->info('[' . $rateLimit . '] Check ' . $repo->getFullName() . ' … '); if (0 === $rateLimit || false === $rateLimit) { $this->logger->warning('RateLimit reached, stopping.'); return false; } // this shouldn't be catched so the worker will die when an exception is thrown $nbVersions = $this->doSyncVersions($repo); // notify pubsubhubbub for that repo if ($nbVersions > 0) { $this->pubsubhubbub->pingHub([$repoId]); } $this->logger->notice('[' . $this->getRateLimits($this->client, $this->logger) . '] ' . $nbVersions . ' new versions for ' . $repo->getFullName() . ''); return true; } /** * Do the job to sync repo & star of a user. * * @param Repo $repo Repo to work on */ private function doSyncVersions(Repo $repo): ?int { $newVersion = 0; /** @var EntityManager */ $em = $this->doctrine->getManager(); /** @var \Github\Api\Repo */ $githubRepoApi = $this->client->api('repo'); // in case of the manager is closed following a previous exception if (!$em->isOpen()) { /** @var EntityManager */ $em = $this->doctrine->resetManager(); } [$username, $repoName] = explode('/', $repo->getFullName()); // this is a simple call to retrieve at least one tag from the selected repo // using git/refs/tags when repo has no tag throws a 404 which can't be cached // this query return an empty array when repo has no tag and it can be cached try { $tags = $githubRepoApi->tags($username, $repoName, ['per_page' => 1, 'page' => 1]); } catch (\Exception $e) { $this->logger->warning('(repo/tags) ' . $e->getMessage() . ''); // repo not found OR access blocked? Ignore it in future loops if (404 === $e->getCode() || 451 === $e->getCode()) { $repo->setRemovedAt(new \DateTime()); $em->persist($repo); } return null; } if (empty($tags)) { return $newVersion; } // use git/refs/tags because tags aren't order by date creation (so we retrieve ALL tags every time …) try { /** @var GitData */ $githubGitApi = $this->client->api('git'); $tags = $githubGitApi->tags()->all($username, $repoName); } catch (\Exception $e) { $this->logger->warning('(git/refs/tags) ' . $e->getMessage() . ''); return null; } foreach ($tags as $tag) { // it'll be like `refs/tags/2.2.1` $tag['name'] = str_replace('refs/tags/', '', $tag['ref']); $version = $this->versionRepository->findExistingOne($tag['name'], $repo->getId()); if (null !== $version) { continue; } // check for scheduled version to be persisted later // in rare case where the tag name is almost equal, like "v1.1.0" & "V1.1.0" in might avoid error foreach ($em->getUnitOfWork()->getScheduledEntityInsertions() as $entity) { if ($entity instanceof Version && strtolower($entity->getTagName()) === strtolower($tag['name'])) { $this->logger->info($tag['name'] . ' skipped because it seems to be already scheduled'); continue 2; } } // is there an associated release? $newRelease = [ 'tag_name' => $tag['name'], ]; try { $newRelease = $githubRepoApi->releases()->tag($username, $repoName, $tag['name']); // use same key as tag to store the content of the release $newRelease['message'] = $newRelease['body']; } catch (\Exception $e) { // it should be `Github\Exception\RuntimeException` but I can't reproduce this exception in test :-( // when a tag isn't a release, it'll be catched here switch ($tag['object']['type']) { // https://api.github.com/repos/ampproject/amphtml/git/tags/694b8cc3983f52209029605300910507bec700b4 case 'tag': $tagInfo = $githubGitApi->tags()->show($username, $repoName, $tag['object']['sha']); $newRelease += [ 'name' => $tag['name'], 'prerelease' => false, 'published_at' => $tagInfo['tagger']['date'], 'message' => $tagInfo['message'], ]; break; // https://api.github.com/repos/ampproject/amphtml/git/commits/c0a5834b32ae4b45b4bacf677c391e0f9cca82fb case 'commit': $commitInfo = $githubGitApi->commits()->show($username, $repoName, $tag['object']['sha']); $newRelease += [ 'name' => $tag['name'], 'prerelease' => false, 'published_at' => $commitInfo['author']['date'], 'message' => $commitInfo['message'], ]; break; case 'blob': $blobInfo = $githubGitApi->blobs()->show($username, $repoName, $tag['object']['sha']); $newRelease += [ 'name' => $tag['name'], 'prerelease' => false, // we can't retrieve a date for a blob tag, sadly. 'published_at' => date('c'), 'message' => '(blob, size ' . $blobInfo['size'] . ') ' . base64_decode((string) $blobInfo['content'], true), ]; break; default: $this->logger->error('Tag object type not supported: ' . $tag['object']['type'] . ' (for: ' . $repo->getFullName() . ')'); continue 2; } $newRelease['message'] = $this->removePgpSignature((string) $newRelease['message']); } // render markdown in plain html and use default markdown file if it fails if (isset($newRelease['message']) && '' !== trim($newRelease['message'])) { try { /** @var Markdown */ $githubMarkdownApi = $this->client->api('markdown'); $newRelease['message'] = $githubMarkdownApi->render($newRelease['message'], 'gfm', $repo->getFullName()); } catch (\Exception $e) { $this->logger->warning('Failed to parse markdown: ' . $e->getMessage() . ''); // it is usually a problem from the abuse detection mechanism, to avoid multiple call, we just skip to the next repo return $newVersion; } } $version = new Version($repo); $version->hydrateFromGithub($newRelease); $em->persist($version); ++$newVersion; // for big repos, flush every 200 versions in case of hitting rate limit if (0 === ($newVersion % 200)) { $em->flush(); } } $em->flush(); return $newVersion; } /** * Remove PGP signature from commit / tag. */ private function removePgpSignature(string $message): string { $pos = stripos($message, '-----BEGIN PGP SIGNATURE-----'); if ($pos) { return trim(substr($message, 0, $pos)); } return $message; } } ================================================ FILE: src/Pagination/Exception/CallbackNotFoundException.php ================================================ */ class CallbackNotFoundException extends \RuntimeException { } ================================================ FILE: src/Pagination/Exception/InvalidPageNumberException.php ================================================ */ class InvalidPageNumberException extends \InvalidArgumentException { } ================================================ FILE: src/Pagination/Pagination.php ================================================ * * @author Ashley Dawson */ class Pagination implements \IteratorAggregate, \Countable { private array $items = []; private array $pages = []; private int $totalNumberOfPages = 0; private int $currentPageNumber = 0; private int $firstPageNumber = 0; private int $lastPageNumber = 0; private int $previousPageNumber = 0; private int $nextPageNumber = 0; private int $itemsPerPage = 0; private int $totalNumberOfItems = 0; private int $firstPageNumberInRange = 0; private int $lastPageNumberInRange = 0; /** * Get items. */ public function getItems(): array { return $this->items; } /** * Set items. * * @return $this */ public function setItems(array $items) { $this->items = $items; return $this; } /** * Get currentPageNumber. * * @return int */ public function getCurrentPageNumber() { return $this->currentPageNumber; } /** * Set currentPageNumber. * * @param int $currentPageNumber * * @return $this */ public function setCurrentPageNumber($currentPageNumber) { $this->currentPageNumber = $currentPageNumber; return $this; } /** * Get firstPageNumber. * * @return int */ public function getFirstPageNumber() { return $this->firstPageNumber; } /** * Set firstPageNumber. * * @param int $firstPageNumber * * @return $this */ public function setFirstPageNumber($firstPageNumber) { $this->firstPageNumber = $firstPageNumber; return $this; } /** * Get firstPageNumberInRange. * * @return int */ public function getFirstPageNumberInRange() { return $this->firstPageNumberInRange; } /** * Set firstPageNumberInRange. * * @param int $firstPageNumberInRange * * @return $this */ public function setFirstPageNumberInRange($firstPageNumberInRange) { $this->firstPageNumberInRange = $firstPageNumberInRange; return $this; } /** * Get itemsPerPage. * * @return int */ public function getItemsPerPage() { return $this->itemsPerPage; } /** * Set itemsPerPage. * * @param int $itemsPerPage * * @return $this */ public function setItemsPerPage($itemsPerPage) { $this->itemsPerPage = $itemsPerPage; return $this; } /** * Get lastPageNumber. * * @return int */ public function getLastPageNumber() { return $this->lastPageNumber; } /** * Set lastPageNumber. * * @param int $lastPageNumber * * @return $this */ public function setLastPageNumber($lastPageNumber) { $this->lastPageNumber = $lastPageNumber; return $this; } /** * Get lastPageNumberInRange. * * @return int */ public function getLastPageNumberInRange() { return $this->lastPageNumberInRange; } /** * Set lastPageNumberInRange. * * @param int $lastPageNumberInRange * * @return $this */ public function setLastPageNumberInRange($lastPageNumberInRange) { $this->lastPageNumberInRange = $lastPageNumberInRange; return $this; } /** * Get nextPageNumber. * * @return int */ public function getNextPageNumber() { return $this->nextPageNumber; } /** * Set nextPageNumber. * * @param int $nextPageNumber * * @return $this */ public function setNextPageNumber($nextPageNumber) { $this->nextPageNumber = $nextPageNumber; return $this; } /** * Get pages. * * @return array */ public function getPages() { return $this->pages; } /** * Set pages. * * @return $this */ public function setPages(array $pages) { $this->pages = $pages; return $this; } /** * Get previousPageNumber. * * @return int */ public function getPreviousPageNumber() { return $this->previousPageNumber; } /** * Set previousPageNumber. * * @param int $previousPageNumber * * @return $this */ public function setPreviousPageNumber($previousPageNumber) { $this->previousPageNumber = $previousPageNumber; return $this; } /** * Get totalNumberOfItems. * * @return int */ public function getTotalNumberOfItems() { return $this->totalNumberOfItems; } /** * Set totalNumberOfItems. * * @param int $totalNumberOfItems * * @return $this */ public function setTotalNumberOfItems($totalNumberOfItems) { $this->totalNumberOfItems = $totalNumberOfItems; return $this; } /** * Get totalNumberOfPages. * * @return int */ public function getTotalNumberOfPages() { return $this->totalNumberOfPages; } /** * Set totalNumberOfPages. * * @param int $totalNumberOfPages * * @return $this */ public function setTotalNumberOfPages($totalNumberOfPages) { $this->totalNumberOfPages = $totalNumberOfPages; return $this; } public function getIterator(): \Traversable { return new \ArrayIterator($this->items); } public function count(): int { return \count($this->items); } } ================================================ FILE: src/Pagination/Paginator.php ================================================ */ class Paginator implements PaginatorInterface { /** * @var \Closure */ private $itemTotalCallback; /** * @var \Closure */ private $sliceCallback; /** * @var \Closure */ private $beforeQueryCallback; /** * @var \Closure */ private $afterQueryCallback; /** * @var int */ private $itemsPerPage = 10; /** * @var int */ private $pagesInRange = 5; /** * Constructor - passing optional configuration. * * * $paginator = new Paginator(array( * 'itemTotalCallback' => function () { * // ... * }, * 'sliceCallback' => function ($offset, $length) { * // ... * }, * 'itemsPerPage' => 10, * 'pagesInRange' => 5 * )); * */ public function __construct(?array $config = null) { if (\array_key_exists('itemTotalCallback', $config)) { $this->setItemTotalCallback($config['itemTotalCallback']); } if (\array_key_exists('sliceCallback', $config)) { $this->setSliceCallback($config['sliceCallback']); } if (\array_key_exists('itemsPerPage', $config)) { $this->setItemsPerPage($config['itemsPerPage']); } if (\array_key_exists('pagesInRange', $config)) { $this->setPagesInRange($config['pagesInRange']); } } public function paginate($currentPageNumber = 1) { if (!$this->itemTotalCallback instanceof \Closure) { throw new CallbackNotFoundException('Item total callback not found, set it using Paginator::setItemTotalCallback()'); } if (!$this->sliceCallback instanceof \Closure) { throw new CallbackNotFoundException('Slice callback not found, set it using Paginator::setSliceCallback()'); } if (!\is_int($currentPageNumber)) { throw new \InvalidArgumentException(\sprintf('Current page number must be of type integer, %s given', \gettype($currentPageNumber))); } if ($currentPageNumber <= 0) { throw new InvalidPageNumberException(\sprintf('Current page number must have a value of 1 or more, %s given', $currentPageNumber)); } $beforeQueryCallback = $this->beforeQueryCallback instanceof \Closure ? $this->beforeQueryCallback : static function (): void {} ; $afterQueryCallback = $this->afterQueryCallback instanceof \Closure ? $this->afterQueryCallback : static function (): void {} ; $pagination = new Pagination(); $itemTotalCallback = $this->itemTotalCallback; $beforeQueryCallback($this, $pagination); $totalNumberOfItems = (int) $itemTotalCallback($pagination); $afterQueryCallback($this, $pagination); $numberOfPages = (int) ceil($totalNumberOfItems / $this->itemsPerPage); $pagesInRange = $this->pagesInRange; if ($pagesInRange > $numberOfPages) { $pagesInRange = $numberOfPages; } $change = (int) ceil($pagesInRange / 2); if (($currentPageNumber - $change) > ($numberOfPages - $pagesInRange)) { $pages = range(($numberOfPages - $pagesInRange) + 1, $numberOfPages); } else { if (($currentPageNumber - $change) < 0) { $change = $currentPageNumber; } $offset = $currentPageNumber - $change; $pages = range($offset + 1, $offset + $pagesInRange); } $offset = ($currentPageNumber - 1) * $this->itemsPerPage; $sliceCallback = $this->sliceCallback; $beforeQueryCallback($this, $pagination); if (-1 === $this->itemsPerPage) { $items = $sliceCallback(0, 999999999, $pagination); } else { $items = $sliceCallback($offset, $this->itemsPerPage, $pagination); } if ($items instanceof \Iterator) { $items = iterator_to_array($items); } $afterQueryCallback($this, $pagination); $pagination ->setItems($items) ->setPages($pages) ->setTotalNumberOfPages($numberOfPages) ->setCurrentPageNumber($currentPageNumber) ->setFirstPageNumber(1) ->setLastPageNumber($numberOfPages) ->setItemsPerPage($this->itemsPerPage) ->setTotalNumberOfItems($totalNumberOfItems) ->setFirstPageNumberInRange(min($pages)) ->setLastPageNumberInRange(max($pages)) ; $previousPageNumber = null; if (($currentPageNumber - 1) > 0) { $pagination->setPreviousPageNumber($currentPageNumber - 1); } $nextPageNumber = null; if (($currentPageNumber + 1) <= $numberOfPages) { $pagination->setNextPageNumber($currentPageNumber + 1); } return $pagination; } public function getSliceCallback() { return $this->sliceCallback; } public function setSliceCallback(\Closure $sliceCallback) { $this->sliceCallback = $sliceCallback; return $this; } public function getItemTotalCallback() { return $this->itemTotalCallback; } public function getBeforeQueryCallback() { return $this->beforeQueryCallback; } public function setBeforeQueryCallback(\Closure $beforeQueryCallback) { $this->beforeQueryCallback = $beforeQueryCallback; return $this; } public function getAfterQueryCallback() { return $this->afterQueryCallback; } public function setAfterQueryCallback(\Closure $afterQueryCallback) { $this->afterQueryCallback = $afterQueryCallback; return $this; } public function setItemTotalCallback(\Closure $itemTotalCallback) { $this->itemTotalCallback = $itemTotalCallback; return $this; } public function getItemsPerPage() { return $this->itemsPerPage; } public function setItemsPerPage($itemsPerPage) { if (!\is_int($itemsPerPage)) { throw new \InvalidArgumentException(\sprintf('Items per page must be of type integer, %s given', \gettype($itemsPerPage))); } $this->itemsPerPage = $itemsPerPage; return $this; } public function getPagesInRange() { return $this->pagesInRange; } public function setPagesInRange($pagesInRange) { if (!\is_int($pagesInRange)) { throw new \InvalidArgumentException(\sprintf('Pages in range must be of type integer, %s given', \gettype($pagesInRange))); } $this->pagesInRange = $pagesInRange; return $this; } } ================================================ FILE: src/Pagination/PaginatorInterface.php ================================================ */ interface PaginatorInterface { /** * Run paginate algorithm using the current page number. * * @param int $currentPageNumber Page number, usually passed from the current request * * @throws \InvalidArgumentException * @throws InvalidPageNumberException * * @return Pagination Collection of items returned by the slice callback with pagination meta information */ public function paginate($currentPageNumber = 1); /** * Get sliceCallback. * * @return \Closure */ public function getSliceCallback(); /** * Set sliceCallback. * * @return $this */ public function setSliceCallback(\Closure $sliceCallback); /** * Get itemTotalCallback. * * @return \Closure */ public function getItemTotalCallback(); /** * Set itemTotalCallback. * * @return $this */ public function setItemTotalCallback(\Closure $itemTotalCallback); /** * @return \Closure */ public function getBeforeQueryCallback(); /** * @return $this */ public function setBeforeQueryCallback(\Closure $beforeQueryCallback); /** * @return \Closure */ public function getAfterQueryCallback(); /** * @return $this */ public function setAfterQueryCallback(\Closure $afterQueryCallback); /** * Get itemsPerPage. * * @return int */ public function getItemsPerPage(); /** * Set itemsPerPage. * * @param int $itemsPerPage * * @throws \InvalidArgumentException * * @return $this */ public function setItemsPerPage($itemsPerPage); /** * Get pagesInRange. * * @return int */ public function getPagesInRange(); /** * Set pagesInRange. * * @param int $pagesInRange * * @throws \InvalidArgumentException * * @return $this */ public function setPagesInRange($pagesInRange); } ================================================ FILE: src/PubSubHubbub/Publisher.php ================================================ router->getContext(); $context->setHost($host); $context->setScheme($scheme); } /** * Ping available hub when new items are cached. * * http://nathangrigg.net/2012/09/real-time-publishing/ * * @param array $repoIds Id of repo from the database * * @return bool */ public function pingHub(array $repoIds) { if (empty($this->hub) || empty($repoIds)) { return false; } $urls = $this->retrieveFeedUrls($repoIds); // ping publisher // https://github.com/pubsubhubbub/php-publisher/blob/master/library/Publisher.php $params = 'hub.mode=publish'; foreach ($urls as $url) { $params .= '&hub.url=' . $url; } $response = $this->client->post( $this->hub, [ 'http_errors' => false, 'body' => $params, 'headers' => [ 'Content-Type' => 'application/x-www-form-urlencoded', 'User-Agent' => 'Banditore/1.0', ], ] ); // hub should response 204 if everything went fine return !(204 !== $response->getStatusCode()); } /** * Retrieve user feed urls from a list of repository ids. * * @return array */ private function retrieveFeedUrls(array $repoIds) { $users = $this->userRepository->findByRepoIds($repoIds); $urls = []; foreach ($users as $user) { $urls[] = $this->router->generate( 'rss_user', ['uuid' => $user['uuid']], UrlGeneratorInterface::ABSOLUTE_URL ); } return $urls; } } ================================================ FILE: src/Repository/RepoRepository.php ================================================ */ class RepoRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, Repo::class); } /** * Retrieve all repositories to be fetched for new release. * * @return array */ public function findAllForRelease() { $data = $this->createQueryBuilder('r') ->select('r.id') ->where('r.removedAt IS NULL') ->getQuery() ->getArrayResult(); $return = []; foreach ($data as $oneData) { $return[] = $oneData['id']; } return $return; } /** * Count total repos. * * @return int */ public function countTotal() { return (int) $this->createQueryBuilder('r') ->select('COUNT(r.id) as total') ->getQuery() ->getSingleScalarResult(); } /** * Retrieve repos with the most releases. * Used for stats. * * @return array */ public function mostVersionsPerRepo() { return $this->createQueryBuilder('r') ->select('r.fullName', 'r.description', 'r.ownerAvatar') ->addSelect('(SELECT COUNT(v.id) FROM App\Entity\Version v WHERE v.repo = r.id) AS total' ) ->groupBy('r.fullName', 'r.description', 'r.ownerAvatar', 'total') ->orderBy('total', 'desc') ->setMaxResults(5) ->getQuery() ->getArrayResult(); } } ================================================ FILE: src/Repository/StarRepository.php ================================================ */ class StarRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, Star::class); } /** * Retrieve all repos starred by a user. * * @param int $userId User id * * @return array */ public function findAllByUser($userId) { $repos = $this->createQueryBuilder('s') ->select('r.id') ->leftJoin('s.repo', 'r') ->where('s.user = ' . $userId) ->getQuery() ->getArrayResult(); $res = []; foreach ($repos as $repo) { $res[] = $repo['id']; } return $res; } /** * Remove stars for a user. */ public function removeFromUser(array $repoIds, int $userId): void { $this->createQueryBuilder('s') ->delete() ->where('s.repo IN (:ids)')->setParameter('ids', $repoIds) ->andWhere('s.user = :userId')->setParameter('userId', $userId) ->getQuery() ->execute(); } /** * Count total stars. * * @return int */ public function countTotal() { return (int) $this->createQueryBuilder('s') ->select('COUNT(s.id) as total') ->getQuery() ->getSingleScalarResult(); } public function findOneByUserAndRepo(int $userId, int $repoId): ?Star { $stars = $this->createQueryBuilder('s') ->leftJoin('s.repo', 'r') ->where('s.user = :userId')->setParameter('userId', $userId) ->andWhere('r.id = :repoId')->setParameter('repoId', $repoId) ->setMaxResults(1) ->getQuery() ->getResult(); return $stars[0] ?? null; } } ================================================ FILE: src/Repository/UserRepository.php ================================================ */ class UserRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, User::class); } /** * Retrieve user. * * @return array */ public function findByRepoIds(array $repoIds) { return $this->createQueryBuilder('u') ->select('DISTINCT u.uuid') ->leftJoin('u.stars', 's') ->where('s.repo IN (:ids)')->setParameter('ids', $repoIds) ->andWhere('s.ignoredInFeed = :ignoredInFeed')->setParameter('ignoredInFeed', false) ->getQuery() ->getArrayResult(); } /** * Retrieve all users to be synced. * We only retrieve ids to be as fast as possible. * * @return array */ public function findAllToSync() { $data = $this->createQueryBuilder('u') ->select('u.id') ->where('u.removedAt IS NULL') ->getQuery() ->getArrayResult(); $return = []; foreach ($data as $oneData) { $return[] = $oneData['id']; } return $return; } /** * Retrieve all tokens available. * This is used for the GithubClientDiscovery. * * @return array */ public function findAllTokens() { return $this->createQueryBuilder('u') ->select('u.id', 'u.username', 'u.accessToken') ->where('u.removedAt IS NULL') ->getQuery() ->enableResultCache() ->setResultCacheLifetime(10 * 60) ->getArrayResult(); } /** * Count total users. * * @return int */ public function countTotal() { return (int) $this->createQueryBuilder('u') ->select('COUNT(u.id) as total') ->getQuery() ->getSingleScalarResult(); } } ================================================ FILE: src/Repository/VersionRepository.php ================================================ */ class VersionRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, Version::class); } /** * Find one version for a given tag name and repo id. * This is exactly the same as `findOneBy` but this one use a result cache. * Version doesn't change after being inserted and since we check to many times for a version * it's faster to store result in a cache. * * @param string $tagName Tag name to search, like v1.0.0 * @param int $repoId Repository ID * * @return int|null */ public function findExistingOne($tagName, $repoId) { $query = $this->createQueryBuilder('v') ->select('v.id') ->where('v.repo = :repoId')->setParameter('repoId', $repoId) ->andWhere('v.tagName = :tagName')->setParameter('tagName', $tagName) ->setMaxResults(1) ->getQuery() ; return $query->getOneOrNullResult(AbstractQuery::HYDRATE_SINGLE_SCALAR); } /** * Find all versions available for the given user. * * @param int $userId * @param int $offset * @param int $length * * @return array */ public function findForUser($userId, $offset = 0, $length = 20) { return $this->createQueryBuilder('v') ->select('r.id AS repoId', 'v.tagName', 'v.name', 'v.createdAt', 'v.body', 'v.prerelease', 's.ignoredInFeed', 'r.fullName', 'r.ownerAvatar', 'r.ownerAvatar', 'r.homepage', 'r.language', 'r.description') ->leftJoin('v.repo', 'r') ->leftJoin('r.stars', 's') ->where('s.user = :userId')->setParameter('userId', $userId) ->orderBy('v.createdAt', 'desc') ->setFirstResult($offset) ->setMaxResults($length) ->getQuery() ->getArrayResult(); } /** * Count all versions available for the given user. * Used in the dashboard pagination and auth process. * * @param int $userId * * @return int */ public function countForUser($userId) { return (int) $this->createQueryBuilder('v') ->select('COUNT(v.id)') ->leftJoin('v.repo', 'r') ->leftJoin('r.stars', 's') ->where('s.user = :userId')->setParameter('userId', $userId) ->getQuery() ->getSingleScalarResult(); } /** * Find all versions available in the feed for the given user. */ public function findForFeedUser(int $userId, int $offset = 0, int $length = 20): array { return $this->createQueryBuilder('v') ->select('r.id AS repoId', 'v.tagName', 'v.name', 'v.createdAt', 'v.body', 'v.prerelease', 'r.fullName', 'r.ownerAvatar', 'r.ownerAvatar', 'r.homepage', 'r.language', 'r.description') ->leftJoin('v.repo', 'r') ->leftJoin('r.stars', 's') ->where('s.user = :userId')->setParameter('userId', $userId) ->andWhere('s.ignoredInFeed = :ignoredInFeed')->setParameter('ignoredInFeed', false) ->orderBy('v.createdAt', 'desc') ->setFirstResult($offset) ->setMaxResults($length) ->getQuery() ->getArrayResult(); } /** * Retrieve latest version of each repo. * * @param int $length Number of items * * @return array */ public function findLastVersionForEachRepo($length = 10) { $query = ' SELECT v1.tagName, v1.name, v1.createdAt, r.fullName, r.description, r.ownerAvatar, v1.prerelease FROM App\Entity\Version v1 LEFT JOIN App\Entity\Version v2 WITH (v1.repo = v2.repo AND v1.createdAt < v2.createdAt) LEFT JOIN App\Entity\Repo r WITH r.id = v1.repo WHERE v2.repo IS NULL ORDER BY v1.createdAt DESC '; return $this->getEntityManager()->createQuery($query) ->setFirstResult(0) ->setMaxResults($length) ->getArrayResult(); } /** * Count total versions. * * @return int */ public function countTotal() { return (int) $this->createQueryBuilder('v') ->select('COUNT(v.id) as total') ->getQuery() ->getSingleScalarResult(); } /** * Retrieve the latest version saved. * * @return array|null */ public function findLatest() { return $this->createQueryBuilder('v') ->select('v.createdAt') ->orderBy('v.createdAt', 'desc') ->setMaxResults(1) ->getQuery() ->getOneOrNullResult(); } } ================================================ FILE: src/Rss/Generator.php ================================================ addExtension( (new AtomLink()) ->setRel('self') ->setHref($feedUrl) ->setType('application/rss+xml') ); $channel->addExtension( (new AtomLink()) ->setRel('hub') ->setHref('http://pubsubhubbub.appspot.com/') ); $channel->addExtension( (new Webfeeds()) ->setLogo($user->getAvatar()) ->setIcon($user->getAvatar()) ->setAccentColor('10556B') ); $channel->setTitle(str_replace('%USERNAME%', $user->getUsername(), self::CHANNEL_TITLE)) ->setLink($feedUrl) ->setDescription(str_replace('%USERNAME%', $user->getUsername(), self::CHANNEL_DESCRIPTION)) ->setLanguage('en') ->setCopyright('(c) ' . (new \DateTime())->format('Y') . ' banditore') ->setLastBuildDate(isset($releases[0]) ? $releases[0]['createdAt'] : new \DateTime()) ->setGenerator('banditore'); foreach ($releases as $release) { // build repo top information $repoHome = $release['homepage'] ? '(' . $release['homepage'] . ')' : ''; $repoLanguage = $release['language'] ? '

#' . $release['language'] . '

' : ''; $repoInformation = '
' . $release['fullName'] . ' ' . $release['fullName'] . ' ' . $repoHome . '
' . $release['description'] . '
' . $repoLanguage . '

'; $item = new Item(); $item->setTitle($release['fullName'] . ' ' . $release['tagName']) ->setLink('https://github.com/' . $release['fullName'] . '/releases/' . urlencode((string) $release['tagName'])) ->setDescription($repoInformation . $release['body']) ->setPubDate($release['createdAt']) ->setGuid((new Guid())->setIsPermaLink(true)->setGuid('https://github.com/' . $release['fullName'] . '/releases/' . urlencode((string) $release['tagName']))) ; $channel->addItem($item); } return $channel; } } ================================================ FILE: src/Security/GithubAuthenticator.php ================================================ attributes->get('_route'); } public function authenticate(Request $request): Passport { $client = $this->clientRegistry->getClient('github'); $accessToken = $this->fetchAccessToken($client); return new SelfValidatingPassport( new UserBadge($accessToken->getToken(), function () use ($accessToken, $client) { /** @var GithubResourceOwner */ $githubUser = $client->fetchUserFromToken($accessToken); /** @var User|null */ $user = $this->entityManager->getRepository(User::class)->find($githubUser->getId()); // always update user information at login if (null === $user) { $user = new User(); } $user->setAccessToken($accessToken->getToken()); $user->hydrateFromGithub($githubUser); $this->entityManager->persist($user); $this->entityManager->flush(); return $user; }) ); } public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response { /** @var User */ $user = $token->getUser(); /** @var VersionRepository */ $versionRepo = $this->entityManager->getRepository(Version::class); $versions = $versionRepo->countForUser($user->getId()); // if no versions were found, it means the user logged in for the first time // and we need to display an explanation message $message = 'Successfully logged in!'; if (0 === $versions) { $message = 'Successfully logged in. Your starred repos will soon be synced!'; } /** @var FlashBag */ $flash = $request->getSession()->getBag('flashes'); $flash->add('info', $message); $this->bus->dispatch(new StarredReposSync($user->getId())); return new RedirectResponse($this->router->generate('dashboard')); } public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response { $message = strtr($exception->getMessageKey(), $exception->getMessageData()); return new Response($message, Response::HTTP_FORBIDDEN); } } ================================================ FILE: src/Twig/PaginationExtension.php ================================================ render('default/_pagination.html.twig', [ 'pagination' => $pagination, 'routeName' => $routeName, 'pageParameterName' => $pageParameterName, 'queryParameters' => $queryParameters, ]); } } ================================================ FILE: src/Twig/RepoVersionExtension.php ================================================ logo = $logo; return $this; } public function getLogo(): ?string { return $this->logo; } public function setIcon(?string $icon): self { $this->icon = $icon; return $this; } public function getIcon(): ?string { return $this->icon; } public function setAccentColor(?string $accentColor): self { $this->accentColor = $accentColor; return $this; } public function getAccentColor(): ?string { return $this->accentColor; } } ================================================ FILE: src/Webfeeds/WebfeedsWriter.php ================================================ $this->write(...), ]; } public function getRegisteredNamespaces(): array { return [ 'webfeeds' => 'http://webfeeds.org/rss/1.0', ]; } public function write(RssWriter $rssWriter, Webfeeds $extension): void { $writer = $rssWriter->getXmlWriter(); if ($extension->getLogo()) { $writer->writeElement('webfeeds:logo', $extension->getLogo()); } if ($extension->getIcon()) { $writer->writeElement('webfeeds:icon', $extension->getIcon()); } if ($extension->getAccentColor()) { $writer->writeElement('webfeeds:accentColor', $extension->getAccentColor()); } } } ================================================ FILE: templates/base.html.twig ================================================ {% block title %}Bandito.re{% endblock %} {% block stylesheets -%} {% endblock %} {% block javascripts -%} {% endblock %}
{% block body %}{% endblock %}
================================================ FILE: templates/bundles/TwigBundle/Exception/error.html.twig ================================================ {% extends 'base.html.twig' %} {% block body %}

Hum. Problem.

Looks like we have a problem here.

You might want to return to the homepage.

And if you are already on the homepage, it might be a bigger problem. So don't move.

{% endblock %} ================================================ FILE: templates/default/_line_version.html.twig ================================================ {{ repo.fullName }} {% if repo.name and repo.name != repo.tagName -%} {{ repo.name }} ({{ repo.tagName }}) {%- else -%} {{ repo.tagName }} {%- endif %} {% if repo.prerelease -%} pre-release {% endif -%} {% if repo.repoId is defined -%} {% if repo.ignoredInFeed|default(false) -%} {% else -%} {% endif -%}
{% endif -%} ================================================ FILE: templates/default/_pagination.html.twig ================================================ ================================================ FILE: templates/default/dashboard.html.twig ================================================ {% extends 'base.html.twig' %} {% block body %}
{% if app.session.flashBag.has('info') %}
{{- app.session.flashBag.get('info')|first -}}
{% endif %} {% if sync_status %}
Your starred repos are being sync (this can happen many times per day). It started {{ sync_status|date|time_diff }} and should be pretty fast depending on how many stars you have.
{% endif %}

Your latest releases

{% if pagination.items %} {% if pagination.totalNumberOfPages > 1 %}

{{ pagination_render( pagination, 'dashboard', 'page', app.request.query.all ) }}

{% endif %} {% else %}

Here are some sample display.

{% endif %} {% for repo in pagination.items -%} {% include 'default/_line_version.html.twig' with { 'loop': loop, 'repo': repo} %} {% else %} {% endfor -%}
Repository Last version Published at Included in feed
sample/sample First release (v1.0.0)
sample/sample Prepare first release (v1.0.0-alpha.1) pre-release
{% if pagination.items and pagination.totalNumberOfPages > 1 %}

{{ pagination_render( pagination, 'dashboard', 'page', app.request.query.all ) }}

{% endif %}

Got some questions? Here is a FAQ

How often does the app check for new release?

Banditore will check for new release every 10 minutes.

How often does the app check for my starred repos?

Banditore will sync your starred repos every 5 minutes. You can also force it by logged out / logged in.

Why do I not see all my starred repos on the dashboard?

First, they can still be in sync. This could be the case if it's the very first time you logged in here. Second, not all repos got tag or release (which is sad). In that case, they'll never show up on your dashboard.

Another question?

Feel free to open an issue.

{% endblock %} ================================================ FILE: templates/default/index.html.twig ================================================ {% extends 'base.html.twig' %} {% block body %}

Get new releases in your feed reader

We gather new releases from your starred GitHub repositories and generate an Atom feed with them.

Just for you.

Try it!

What Banditore can do for me?

Be notified for a new release

When a new release / tag is available, you'll know it right away. So you won't forget to update your project.

Soft notification, because of RSS feed

I know you're tired of emails, popups & browser / mobile notifications. RSS feed is soft notification that won't bother you.

Don't forget starred repository

We all do that: you star a repo and the next few days you already forget about it. That's over. Any new release will remind you about it!

Install your own Banditore

Banditore is full open source. If you don't want to use this website, you can install it on your own server.

How it works

Retrieve starred repositories from your GitHub account

When you first login, we retrieve minimal information from you (name, username & avatar). Then we fetch your stars & their associated repository.

Periodically retrieve new release & tag

At least twice per hour, we retrieve new release or tag for your repository using your token. Once we have gathered all these information, we build a feed with them, ordered by published date of each release.

Markdownified content

Some release contains markdown information which will be converted in HTML for a better rendering. For tag (which doesn't come with a body), we'll only display the tag name.

Do you want to improve it?

As I said, Banditore is open source. If something bother you or if you want to improve it, I'll be much happy to check your issue or review your PR!

File Icons
File Icons

Bandi … what?

Banditore is an italian word. It means a town crier (or in french un crieur public).

Wikipedia says: "A town crier, or bellman, is an officer of the court who makes public pronouncements as required by the court ".

We are not in court here but I think you get the idea. Banditore will makes "announcements" about new releases from repositories you starred. On every new release (or tag, because some people don't use the Release feature) it'll push a new item right away in your Atom feed.

{% endblock %} ================================================ FILE: templates/default/stats.html.twig ================================================ {% extends 'base.html.twig' %} {% block body %}
{% if app.session.flashBag.has('info') %}
{{ app.session.flashBag.get('info')|first }}
{% endif %}

Stats are cool, eh?

Counters

Number of repos {{ counters.nbRepos }}
Numbers of releases {{ counters.nbReleases }}
Average release per repo {{ counters.avgReleasePerRepo }}
Average star per user {{ counters.avgStarPerUser }}

Repos with most releases

{% for repo in mostReleases %} {% endfor %}
{{ repo.fullName }} {{ repo.total }}

Releases per day

Soon …

Latest releases

{% for repo in lastestReleases -%} {% include 'default/_line_version.html.twig' with { 'loop': loop, 'repo': repo} %} {% endfor %}
Repository Last version Published at
{% endblock %} ================================================ FILE: tests/Cache/CustomRedisCachePoolTest.php ================================================ getMockBuilder(ClientInterface::class) ->disableOriginalConstructor() ->getMock(); $cache->expects($this->once()) ->method('__call') ->willReturn($redisStatus); $body = (string) json_encode([]); $response = new Response( 200, [], $body ); $item = new CacheItem('superkey', true, [ 'response' => $response, 'body' => $body, ]); $cachePool = new CustomRedisCachePool($cache); $cachePool->save($item); } public function testResponseWith404(): void { $redisStatus = new Status('OK'); $cache = $this->getMockBuilder(ClientInterface::class) ->disableOriginalConstructor() ->getMock(); $cache->expects($this->once()) ->method('__call') ->willReturn($redisStatus); $response = new Response(404); $item = new CacheItem('superkey', true, [ 'response' => $response, 'body' => '', ]); $cachePool = new CustomRedisCachePool($cache); $cachePool->save($item); } public function testResponseWithRelease(): void { $cache = $this->getMockBuilder(ClientInterface::class) ->disableOriginalConstructor() ->getMock(); $cache->expects($this->never()) ->method('__call'); $body = (string) json_encode([ 'tag_name' => 'V1.1.0', 'name' => 'V1.1.0', 'prerelease' => false, 'published_at' => '2014-12-01T18:28:39Z', 'body' => 'This is the first release after our major push.', ]); $response = new Response( 200, [], $body ); $item = new CacheItem('superkey', true, [ 'response' => $response, 'body' => $body, ]); $cachePool = new CustomRedisCachePool($cache); $cachePool->save($item); } public function testResponseWithRefTags(): void { $redisStatus = new Status('OK'); $cache = $this->getMockBuilder(ClientInterface::class) ->disableOriginalConstructor() ->getMock(); $cache->expects($this->once()) ->method('__call') ->willReturn($redisStatus); $body = (string) json_encode([[ 'ref' => 'refs/tags/1.0.0', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/git/refs/tags/1.0.0', 'object' => [ 'sha' => '04b99722e0c25bfc45926cd3a1081c04a8e950ed', 'type' => 'commit', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/git/commits/04b99722e0c25bfc45926cd3a1081c04a8e950ed', ], ], [ 'ref' => 'refs/tags/1.0.1', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/git/refs/tags/1.0.1', 'object' => [ 'sha' => '4845571072d49c2794b165482420b66c206a942a', 'type' => 'commit', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/git/commits/4845571072d49c2794b165482420b66c206a942a', ], ], ]); $response = new Response( 200, [], $body ); $item = new CacheItem('superkey', true, [ 'response' => $response, 'body' => $body, ]); $cachePool = new CustomRedisCachePool($cache); $cachePool->save($item); } public function testResponseWithTag(): void { $redisStatus = new Status('OK'); $cache = $this->getMockBuilder(ClientInterface::class) ->disableOriginalConstructor() ->getMock(); $cache->expects($this->once()) ->method('__call') ->willReturn($redisStatus); $body = (string) json_encode([[ 'name' => '2.0.1', 'zipball_url' => 'https://api.github.com/repos/snc/SncRedisBundle/zipball/2.0.1', 'tarball_url' => 'https://api.github.com/repos/snc/SncRedisBundle/tarball/2.0.1', 'commit' => [ 'sha' => '02c808d157c79ac32777e19f3ec31af24a32d2df', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/commits/02c808d157c79ac32777e19f3ec31af24a32d2df', ], ]]); $response = new Response( 200, [], $body ); $item = new CacheItem('superkey', true, [ 'response' => $response, 'body' => $body, ]); $cachePool = new CustomRedisCachePool($cache); $cachePool->save($item); } public function testResponseWithStarredRepos(): void { $redisStatus = new Status('OK'); $cache = $this->getMockBuilder(ClientInterface::class) ->disableOriginalConstructor() ->getMock(); $cache->expects($this->once()) ->method('__call') ->willReturn($redisStatus); $body = (string) json_encode([[ 'description' => 'banditore', 'homepage' => 'http://banditore.io', 'language' => 'PHP', 'name' => 'banditore', 'full_name' => 'j0k3r/banditore', 'id' => 666, 'owner' => [ 'avatar_url' => 'http://avatar.api/banditore.jpg', ], ]]); $response = new Response( 200, [], $body ); $item = new CacheItem('superkey', true, [ 'response' => $response, 'body' => $body, ]); $cachePool = new CustomRedisCachePool($cache); $cachePool->save($item); } } ================================================ FILE: tests/Command/SyncStarredReposCommandTest.php ================================================ getMockBuilder(MessageBusInterface::class) ->disableOriginalConstructor() ->getMock(); $bus->expects($this->never()) ->method('dispatch'); $syncRepo = $this->getMockBuilder(StarredReposSyncHandler::class) ->disableOriginalConstructor() ->getMock(); $syncRepo->expects($this->once()) ->method('__invoke') ->with($message); $command = new SyncStarredReposCommand( self::getContainer()->get(UserRepository::class), $syncRepo, self::getContainer()->get('messenger.transport.sync_starred_repos'), $bus ); $output = new BufferedOutput(); $res = $command->__invoke($output, false, false, false); $this->assertSame($res, 0); $this->assertStringContainsString('Sync user 123 …', $output->fetch()); } public function testCommandSyncAllUsersWithQueue(): void { $message = new StarredReposSync(123); $bus = $this->getMockBuilder(MessageBusInterface::class) ->disableOriginalConstructor() ->getMock(); $bus->expects($this->once()) ->method('dispatch') ->with($message) ->willReturn(new Envelope($message)); $syncRepo = $this->getMockBuilder(StarredReposSyncHandler::class) ->disableOriginalConstructor() ->getMock(); $syncRepo->expects($this->never()) ->method('__invoke'); $command = new SyncStarredReposCommand( self::getContainer()->get(UserRepository::class), $syncRepo, $this->getTransportMessageCount(0), $bus ); $output = new BufferedOutput(); $res = $command->__invoke($output, false, false, true); $this->assertSame($res, 0); $this->assertStringContainsString('Sync user 123 …', $output->fetch()); } public function testCommandSyncAllUsersWithQueueFull(): void { $bus = $this->getMockBuilder(MessageBusInterface::class) ->disableOriginalConstructor() ->getMock(); $bus->expects($this->never()) ->method('dispatch'); $syncRepo = $this->getMockBuilder(StarredReposSyncHandler::class) ->disableOriginalConstructor() ->getMock(); $syncRepo->expects($this->never()) ->method('__invoke'); $command = new SyncStarredReposCommand( self::getContainer()->get(UserRepository::class), $syncRepo, $this->getTransportMessageCount(10), $bus ); $output = new BufferedOutput(); $res = $command->__invoke($output, false, false, true); $this->assertSame($res, 1); $this->assertStringContainsString('Current queue as too much messages (10), skipping.', $output->fetch()); } public function testCommandSyncOneUserById(): void { $message = new StarredReposSync(123); $bus = $this->getMockBuilder(MessageBusInterface::class) ->disableOriginalConstructor() ->getMock(); $bus->expects($this->once()) ->method('dispatch') ->with($message) ->willReturn(new Envelope($message)); $syncRepo = $this->getMockBuilder(StarredReposSyncHandler::class) ->disableOriginalConstructor() ->getMock(); $syncRepo->expects($this->never()) ->method('__invoke'); $command = new SyncStarredReposCommand( self::getContainer()->get(UserRepository::class), $syncRepo, $this->getTransportMessageCount(0), $bus ); $output = new BufferedOutput(); $res = $command->__invoke($output, '123', false, true); $this->assertSame($res, 0); $buffer = $output->fetch(); $this->assertStringContainsString('Sync user 123 …', $buffer); $this->assertStringContainsString('User synced: 1', $buffer); } public function testCommandSyncOneUserByUsername(): void { $bus = $this->getMockBuilder(MessageBusInterface::class) ->disableOriginalConstructor() ->getMock(); $bus->expects($this->never()) ->method('dispatch'); $syncRepo = $this->getMockBuilder(StarredReposSyncHandler::class) ->disableOriginalConstructor() ->getMock(); $syncRepo->expects($this->once()) ->method('__invoke') ->with(new StarredReposSync(123)); $command = new SyncStarredReposCommand( self::getContainer()->get(UserRepository::class), $syncRepo, self::getContainer()->get('messenger.transport.sync_starred_repos'), $bus ); $output = new BufferedOutput(); $res = $command->__invoke($output, false, 'admin', false); $this->assertSame($res, 0); $buffer = $output->fetch(); $this->assertStringContainsString('Sync user 123 …', $buffer); $this->assertStringContainsString('User synced: 1', $buffer); } public function testCommandSyncOneUserNotFound(): void { $bus = $this->getMockBuilder(MessageBusInterface::class) ->disableOriginalConstructor() ->getMock(); $bus->expects($this->never()) ->method('dispatch'); $syncRepo = $this->getMockBuilder(StarredReposSyncHandler::class) ->disableOriginalConstructor() ->getMock(); $syncRepo->expects($this->never()) ->method('__invoke'); $command = new SyncStarredReposCommand( self::getContainer()->get(UserRepository::class), $syncRepo, self::getContainer()->get('messenger.transport.sync_starred_repos'), $bus ); $output = new BufferedOutput(); $res = $command->__invoke($output, false, 'toto', false); $this->assertSame($res, 1); $this->assertStringContainsString('No users found', $output->fetch()); } private function getTransportMessageCount(int $totalMessage = 0): AmqpTransport { $connection = $this->getMockBuilder(Connection::class) ->disableOriginalConstructor() ->getMock(); $connection->expects($this->once()) ->method('countMessagesInQueues') ->willReturn($totalMessage); return new AmqpTransport($connection); } } ================================================ FILE: tests/Command/SyncVersionsCommandTest.php ================================================ getMockBuilder(MessageBusInterface::class) ->disableOriginalConstructor() ->getMock(); $bus->expects($this->never()) ->method('dispatch'); $syncVersion = $this->getMockBuilder(VersionsSyncHandler::class) ->disableOriginalConstructor() ->getMock(); $syncVersion->expects($this->any()) ->method('__invoke'); $command = new SyncVersionsCommand( self::getContainer()->get(RepoRepository::class), $syncVersion, self::getContainer()->get('messenger.transport.sync_versions'), $bus ); $output = new BufferedOutput(); $res = $command->__invoke($output, false, false, false); $this->assertSame($res, 0); $this->assertStringContainsString('Check 555 …', $output->fetch()); } public function testCommandSyncAllUsersWithQueue(): void { $bus = $this->getMockBuilder(MessageBusInterface::class) ->disableOriginalConstructor() ->getMock(); $bus->expects($this->any()) ->method('dispatch') ->willReturn(new Envelope(new VersionsSync(555))); $syncVersion = $this->getMockBuilder(VersionsSyncHandler::class) ->disableOriginalConstructor() ->getMock(); $syncVersion->expects($this->any()) ->method('__invoke'); $command = new SyncVersionsCommand( self::getContainer()->get(RepoRepository::class), $syncVersion, $this->getTransportMessageCount(0), $bus ); $output = new BufferedOutput(); $res = $command->__invoke($output, false, false, true); $this->assertSame($res, 0); $this->assertStringContainsString('Check 555 …', $output->fetch()); } public function testCommandSyncAllUsersWithQueueFull(): void { $bus = $this->getMockBuilder(MessageBusInterface::class) ->disableOriginalConstructor() ->getMock(); $bus->expects($this->never()) ->method('dispatch'); $syncVersion = $this->getMockBuilder(VersionsSyncHandler::class) ->disableOriginalConstructor() ->getMock(); $syncVersion->expects($this->never()) ->method('__invoke'); $command = new SyncVersionsCommand( self::getContainer()->get(RepoRepository::class), $syncVersion, $this->getTransportMessageCount(10), $bus ); $output = new BufferedOutput(); $res = $command->__invoke($output, false, false, true); $this->assertSame($res, 1); $this->assertStringContainsString('Current queue as too much messages (10), skipping.', $output->fetch()); } public function testCommandSyncOneUserById(): void { $message = new VersionsSync(555); $bus = $this->getMockBuilder(MessageBusInterface::class) ->disableOriginalConstructor() ->getMock(); $bus->expects($this->once()) ->method('dispatch') ->with($message) ->willReturn(new Envelope($message)); $syncVersion = $this->getMockBuilder(VersionsSyncHandler::class) ->disableOriginalConstructor() ->getMock(); $syncVersion->expects($this->never()) ->method('__invoke'); $command = new SyncVersionsCommand( self::getContainer()->get(RepoRepository::class), $syncVersion, $this->getTransportMessageCount(0), $bus ); $output = new BufferedOutput(); $res = $command->__invoke($output, '555', false, true); $this->assertSame($res, 0); $buffer = $output->fetch(); $this->assertStringContainsString('Check 555 …', $buffer); $this->assertStringContainsString('Repo checked: 1', $buffer); } public function testCommandSyncOneUserByUsername(): void { $message = new VersionsSync(666); $bus = $this->getMockBuilder(MessageBusInterface::class) ->disableOriginalConstructor() ->getMock(); $bus->expects($this->never()) ->method('dispatch'); $syncVersion = $this->getMockBuilder(VersionsSyncHandler::class) ->disableOriginalConstructor() ->getMock(); $syncVersion->expects($this->once()) ->method('__invoke') ->with($message); $command = new SyncVersionsCommand( self::getContainer()->get(RepoRepository::class), $syncVersion, self::getContainer()->get('messenger.transport.sync_versions'), $bus ); $output = new BufferedOutput(); $res = $command->__invoke($output, false, 'test/test', false); $this->assertSame($res, 0); $buffer = $output->fetch(); $this->assertStringContainsString('Check 666 …', $buffer); $this->assertStringContainsString('Repo checked: 1', $buffer); } public function testCommandSyncOneUserNotFound(): void { $bus = $this->getMockBuilder(MessageBusInterface::class) ->disableOriginalConstructor() ->getMock(); $bus->expects($this->never()) ->method('dispatch'); $syncVersion = $this->getMockBuilder(VersionsSyncHandler::class) ->disableOriginalConstructor() ->getMock(); $syncVersion->expects($this->never()) ->method('__invoke'); $command = new SyncVersionsCommand( self::getContainer()->get(RepoRepository::class), $syncVersion, self::getContainer()->get('messenger.transport.sync_versions'), $bus ); $output = new BufferedOutput(); $res = $command->__invoke($output, false, 'toto', false); $this->assertSame($res, 1); $this->assertStringContainsString('No repos found', $output->fetch()); } private function getTransportMessageCount(int $totalMessage = 0): AmqpTransport { $connection = $this->getMockBuilder(Connection::class) ->disableOriginalConstructor() ->getMock(); $connection->expects($this->once()) ->method('countMessagesInQueues') ->willReturn($totalMessage); return new AmqpTransport($connection); } } ================================================ FILE: tests/Controller/DefaultControllerTest.php ================================================ client = static::createClient(); self::getContainer()->get(Connection::class)->executeStatement('UPDATE star SET ignored_in_feed = 0'); } public function testIndexNotLoggedIn(): void { $crawler = $this->client->request('GET', '/'); $this->assertResponseIsSuccessful(); $this->assertSelectorTextContains('a.pure-menu-heading', 'Bandito.re'); } public function testIndexLoggedIn(): void { /** @var User */ $user = self::getContainer()->get(UserRepository::class)->find(123); $this->client->loginUser($user); $this->client->request('GET', '/'); $this->assertResponseRedirects('/dashboard', 302); } public function testConnect(): void { $this->client->request('GET', '/connect'); /** @var RedirectResponse */ $response = $this->client->getResponse(); $this->assertSame(302, $response->getStatusCode()); $this->assertStringContainsString('https://github.com/login/oauth/authorize?', $response->getTargetUrl()); } public function testConnectWithLoggedInUser(): void { /** @var User */ $user = self::getContainer()->get(UserRepository::class)->find(123); $this->client->loginUser($user); $this->client->request('GET', '/connect'); $this->assertResponseRedirects('/dashboard', 302); } public function testDashboardNotLoggedIn(): void { $this->client->request('GET', '/dashboard'); $this->assertResponseRedirects('/', 302); } public function testDashboard(): void { /** @var User */ $user = self::getContainer()->get(UserRepository::class)->find(123); $this->client->loginUser($user); $crawler = $this->client->request('GET', '/dashboard'); $this->assertResponseIsSuccessful(); $menu = $crawler->filter('.menu-wrapper')->text(); $this->assertStringContainsString('View it on GitHub', $menu, 'Link to GitHub is here'); $this->assertStringContainsString('Logout (admin)', $menu, 'Info about logged in user is here'); $aside = $crawler->filter('aside.feed')->text(); $this->assertStringContainsString('your feed link', $aside, 'Feed link is here'); $table = $crawler->filter('table')->text(); $this->assertStringContainsString('test/test', $table, 'Repo test/test exist in a table'); $this->assertStringContainsString('Exclude', $table, 'Feed toggle is available from the dashboard'); $this->assertStringContainsString('ago', $table, 'Date is translated and ok'); } public function testDashboardRepoFeedToggle(): void { /** @var User */ $user = self::getContainer()->get(UserRepository::class)->find(123); $this->client->loginUser($user); $this->client->request('POST', '/dashboard/repositories/666/feed', [ 'ignore_in_feed' => '1', ]); $this->assertResponseRedirects('/dashboard', 302); $this->client->followRedirect(); $this->assertSelectorTextContains('.alert.success', 'test/test is now ignored in your RSS feed.'); $star = self::getContainer()->get(StarRepository::class)->findOneByUserAndRepo(123, 666); $this->assertNotNull($star); $this->assertTrue($star->isIgnoredInFeed()); } public function testDashboardPageTooHigh(): void { /** @var User */ $user = self::getContainer()->get(UserRepository::class)->find(123); $this->client->loginUser($user); $crawler = $this->client->request('GET', '/dashboard?page=20000'); $this->assertResponseRedirects('/dashboard', 302); } public function testDashboardBadPage(): void { /** @var User */ $user = self::getContainer()->get(UserRepository::class)->find(123); $this->client->loginUser($user); $this->client->request('GET', '/dashboard?page=dsdsds'); $this->assertResponseStatusCodeSame(404); } public function testRss(): void { /** @var User */ $user = self::getContainer()->get(UserRepository::class)->find(123); $crawler = $this->client->request('GET', '/' . $user->getUuid() . '.atom'); $this->assertResponseIsSuccessful(); $this->assertInstanceOf(RssStreamedResponse::class, $this->client->getResponse()); $this->assertSelectorTextContains('channel>title', 'New releases from starred repo of admin'); $this->assertSelectorTextContains('channel>description', 'Here are all the new releases from all repos starred by admin'); $this->assertSame('http://0.0.0.0/avatar.jpg', $crawler->filterXPath('//webfeeds:icon')->text()); $this->assertSame('10556B', $crawler->filterXPath('//webfeeds:accentColor')->text()); $link = $crawler->filterXPath('//atom:link'); $this->assertSame('http://localhost/' . $user->getUuid() . '.atom', $link->getNode(0)->getAttribute('href')); $this->assertSame('http://pubsubhubbub.appspot.com/', $link->getNode(1)->getAttribute('href')); $this->assertSame('http://localhost/' . $user->getUuid() . '.atom', $crawler->filter('channel>link')->text()); $this->assertSame('test/test 1.0.0', $crawler->filter('item>title')->text()); } public function testStats(): void { $crawler = $this->client->request('GET', '/stats'); $this->assertResponseIsSuccessful(); } public function testStatus(): void { $crawler = $this->client->request('GET', '/status'); $data = json_decode((string) $this->client->getResponse()->getContent(), true); $this->assertTrue($data['is_fresh']); } } ================================================ FILE: tests/Github/ClientDiscoveryTest.php ================================================ getMockBuilder(UserRepository::class) ->disableOriginalConstructor() ->getMock(); $responses = new MockHandler([ // first rate_limit, it'll be ok because remaining > 50 new Response(200, ['Content-Type' => 'application/json'], (string) json_encode(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => ClientDiscovery::THRESHOLD_RATE_REMAIN_APP + 1]]])), ]); $clientHandler = HandlerStack::create($responses); $guzzleClient = new Client([ 'handler' => $clientHandler, ]); $httpClient = new Guzzle7Client($guzzleClient); $httpBuilder = new Builder($httpClient); $githubClient = new GithubClient($httpBuilder); $redis = new RedisClient(); $logger = new Logger('foo'); $logHandler = new TestHandler(); $logger->pushHandler($logHandler); $disco = new ClientDiscovery( $userRepository, $redis, 'client_id', 'client_secret', $logger ); $disco->setGithubClient($githubClient); $resClient = $disco->find(); $records = $logHandler->getRecords(); $this->assertInstanceOf(GithubClient::class, $resClient); $this->assertSame('RateLimit ok (' . (ClientDiscovery::THRESHOLD_RATE_REMAIN_APP + 1) . ') with default application', $records[0]['message']); } public function testUseUserToken(): void { $userRepository = $this->getMockBuilder(UserRepository::class) ->disableOriginalConstructor() ->getMock(); $userRepository->expects($this->once()) ->method('findAllTokens') ->willReturn([ [ 'id' => '123', 'username' => 'bob', 'accessToken' => '123123', ], [ 'id' => '456', 'username' => 'lion', 'accessToken' => '456456', ], ]); $responses = new MockHandler([ // first rate_limit, it won't be ok because remaining < 50 new Response(200, ['Content-Type' => 'application/json'], (string) json_encode(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => ClientDiscovery::THRESHOLD_RATE_REMAIN_APP - 40]]])), // second rate_limit, it won't be ok because remaining < 50 new Response(200, ['Content-Type' => 'application/json'], (string) json_encode(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => ClientDiscovery::THRESHOLD_RATE_REMAIN_USER - 20]]])), // third rate_limit, it'll' be ok because remaining > 50 new Response(200, ['Content-Type' => 'application/json'], (string) json_encode(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => ClientDiscovery::THRESHOLD_RATE_REMAIN_USER + 150]]])), ]); $clientHandler = HandlerStack::create($responses); $guzzleClient = new Client([ 'handler' => $clientHandler, ]); $httpClient = new Guzzle7Client($guzzleClient); $httpBuilder = new Builder($httpClient); $githubClient = new GithubClient($httpBuilder); $redis = new RedisClient(); $logger = new Logger('foo'); $logHandler = new TestHandler(); $logger->pushHandler($logHandler); $disco = new ClientDiscovery( $userRepository, $redis, 'client_id', 'client_secret', $logger ); $disco->setGithubClient($githubClient); $resClient = $disco->find(); $records = $logHandler->getRecords(); $this->assertInstanceOf(GithubClient::class, $resClient); $this->assertSame('RateLimit ok (' . (ClientDiscovery::THRESHOLD_RATE_REMAIN_USER + 150) . ') with user: lion', $records[0]['message']); } public function testNoTokenAvailable(): void { $userRepository = $this->getMockBuilder(UserRepository::class) ->disableOriginalConstructor() ->getMock(); $userRepository->expects($this->once()) ->method('findAllTokens') ->willReturn([ [ 'id' => '123', 'username' => 'bob', 'accessToken' => '123123', ], ]); $responses = new MockHandler([ // first rate_limit, it won't be ok because remaining < 50 new Response(200, ['Content-Type' => 'application/json'], (string) json_encode(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => ClientDiscovery::THRESHOLD_RATE_REMAIN_APP - 10]]])), // second rate_limit, it won't be ok because remaining < 50 new Response(200, ['Content-Type' => 'application/json'], (string) json_encode(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => ClientDiscovery::THRESHOLD_RATE_REMAIN_APP - 20]]])), ]); $clientHandler = HandlerStack::create($responses); $guzzleClient = new Client([ 'handler' => $clientHandler, ]); $httpClient = new Guzzle7Client($guzzleClient); $httpBuilder = new Builder($httpClient); $githubClient = new GithubClient($httpBuilder); $redis = new RedisClient(); $logger = new Logger('foo'); $logHandler = new TestHandler(); $logger->pushHandler($logHandler); $disco = new ClientDiscovery( $userRepository, $redis, 'client_id', 'client_secret', $logger ); $disco->setGithubClient($githubClient); $resClient = $disco->find(); $records = $logHandler->getRecords(); $this->assertNull($resClient); $this->assertSame('No way to authenticate a client with enough rate limit remaining :(', $records[0]['message']); } public function testOneCallFail(): void { $userRepository = $this->getMockBuilder(UserRepository::class) ->disableOriginalConstructor() ->getMock(); $userRepository->expects($this->once()) ->method('findAllTokens') ->willReturn([ [ 'id' => '123', 'username' => 'bob', 'accessToken' => '123123', ], ]); $responses = new MockHandler([ // first rate_limit request fail (Github booboo) new Response(400, ['Content-Type' => 'application/json'], (string) json_encode(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => ClientDiscovery::THRESHOLD_RATE_REMAIN_USER + 100]]])), // second rate_limit, it'll be ok because remaining > 50 new Response(200, ['Content-Type' => 'application/json'], (string) json_encode(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => ClientDiscovery::THRESHOLD_RATE_REMAIN_USER + 100]]])), ]); $clientHandler = HandlerStack::create($responses); $guzzleClient = new Client([ 'handler' => $clientHandler, ]); $httpClient = new Guzzle7Client($guzzleClient); $httpBuilder = new Builder($httpClient); $githubClient = new GithubClient($httpBuilder); $redis = new RedisClient(); $logger = new Logger('foo'); $logHandler = new TestHandler(); $logger->pushHandler($logHandler); $disco = new ClientDiscovery( $userRepository, $redis, 'client_id', 'client_secret', $logger ); $disco->setGithubClient($githubClient); $resClient = $disco->find(); $records = $logHandler->getRecords(); $this->assertInstanceOf(GithubClient::class, $resClient); $this->assertSame('RateLimit call goes bad.', $records[0]['message']); $this->assertSame('RateLimit ok (' . (ClientDiscovery::THRESHOLD_RATE_REMAIN_USER + 100) . ') with user: bob', $records[1]['message']); } /** * Using only mocks for request. */ public function testFunctionnal(): void { $client = static::createClient(); try { self::getContainer()->get('snc_redis.guzzle_cache')->connect(); } catch (\Exception) { $this->markTestSkipped('Redis is not installed/activated'); } $responses = new MockHandler([ // first rate_limit request fail (Github booboo) new Response(200, ['Content-Type' => 'application/json'], (string) json_encode(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => ClientDiscovery::THRESHOLD_RATE_REMAIN_APP - 10]]])), // second rate_limit, it'll be ok because remaining > 50 new Response(200, ['Content-Type' => 'application/json'], (string) json_encode(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => ClientDiscovery::THRESHOLD_RATE_REMAIN_USER + 100]]])), ]); $clientHandler = HandlerStack::create($responses); $guzzleClient = new Client([ 'handler' => $clientHandler, ]); $httpClient = new Guzzle7Client($guzzleClient); $httpBuilder = new Builder($httpClient); $githubClient = new GithubClient($httpBuilder); $disco = self::getContainer()->get(ClientDiscovery::class); $disco->setGithubClient($githubClient); $resClient = $disco->find(); $this->assertInstanceOf(GithubClient::class, $resClient); } } ================================================ FILE: tests/MessageHandler/StarredReposSyncHandlerTest.php ================================================ getMockBuilder(Registry::class) ->disableOriginalConstructor() ->getMock(); $userRepository = $this->getMockBuilder(UserRepository::class) ->disableOriginalConstructor() ->getMock(); $userRepository->expects($this->once()) ->method('find') ->with(123) ->willReturn(null); $starRepository = $this->getMockBuilder(StarRepository::class) ->disableOriginalConstructor() ->getMock(); $repoRepository = $this->getMockBuilder(RepoRepository::class) ->disableOriginalConstructor() ->getMock(); $githubClient = $this->getMockBuilder(GithubClient::class) ->disableOriginalConstructor() ->getMock(); $githubClient->expects($this->never()) ->method('authenticate'); $redisClient = $this->getMockBuilder(\Predis\Client::class) ->disableOriginalConstructor() ->getMock(); // will use `setex` & `del` but will be called dynamically by `_call` $redisClient->expects($this->never()) ->method('__call'); $handler = new StarredReposSyncHandler( $doctrine, $userRepository, $starRepository, $repoRepository, $githubClient, new NullLogger(), $redisClient ); $handler->__invoke(new StarredReposSync(123)); } public function testProcessSuccessfulMessage(): void { $em = $this->getMockBuilder(EntityManager::class) ->disableOriginalConstructor() ->getMock(); $em->expects($this->once()) ->method('isOpen') ->willReturn(true); $doctrine = $this->getMockBuilder(Registry::class) ->disableOriginalConstructor() ->getMock(); $doctrine->expects($this->once()) ->method('getManager') ->willReturn($em); $user = new User(); $user->setId(123); $user->setUsername('bob'); $user->setName('Bobby'); $userRepository = $this->getMockBuilder(UserRepository::class) ->disableOriginalConstructor() ->getMock(); $userRepository->expects($this->once()) ->method('find') ->with(123) ->willReturn($user); $starRepository = $this->getMockBuilder(StarRepository::class) ->disableOriginalConstructor() ->getMock(); $starRepository->expects($this->exactly(2)) ->method('findAllByUser') ->with(123) ->willReturn([666, 777]); $starRepository->expects($this->once()) ->method('removeFromUser') ->with([1 => 777], 123); $repo = new Repo(); $repo->setId(666); $repo->setFullName('j0k3r/banditore'); $repo->setUpdatedAt((new \DateTime())->setTimestamp(time() - 3600 * 72)); $repoRepository = $this->getMockBuilder(RepoRepository::class) ->disableOriginalConstructor() ->getMock(); $repoRepository->expects($this->once()) ->method('find') ->with(666) ->willReturn($repo); $responses = new MockHandler([ // /rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), // first /user/starred $this->getOKResponse([[ 'description' => 'banditore', 'homepage' => 'http://banditore.io', 'language' => 'PHP', 'name' => 'banditore', 'full_name' => 'j0k3r/banditore', 'id' => 666, 'owner' => [ 'avatar_url' => 'http://avatar.api/banditore.jpg', ], ]]), // /rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), // third /user/starred will return empty response which means, we reached the last page $this->getOKResponse([]), // /rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), ]); $githubClient = $this->getMockClient($responses); $logger = new Logger('foo'); $logHandler = new TestHandler(); $logger->pushHandler($logHandler); $redisClient = $this->getMockBuilder(\Predis\Client::class) ->disableOriginalConstructor() ->getMock(); // will use `setex` & `del` but will be called dynamically by `_call` $redisClient->expects($this->exactly(2)) ->method('__call'); $handler = new StarredReposSyncHandler( $doctrine, $userRepository, $starRepository, $repoRepository, $githubClient, $logger, $redisClient ); $handler->__invoke(new StarredReposSync(123)); $records = $logHandler->getRecords(); $this->assertSame('Consume banditore.sync_starred_repos message', $records[0]['message']); $this->assertSame('[10] Check bob … ', $records[1]['message']); $this->assertSame(' sync 1 starred repos', $records[2]['message']); $this->assertSame('Removed stars: 1', $records[3]['message']); $this->assertSame('[10] Synced repos: 1', $records[4]['message']); } public function testUserRemovedFromGitHub(): void { $em = $this->getMockBuilder(EntityManager::class) ->disableOriginalConstructor() ->getMock(); $em->expects($this->once()) ->method('isOpen') ->willReturn(true); $doctrine = $this->getMockBuilder(Registry::class) ->disableOriginalConstructor() ->getMock(); $doctrine->expects($this->once()) ->method('getManager') ->willReturn($em); $user = new User(); $user->setId(123); $user->setUsername('bob'); $user->setName('Bobby'); $userRepository = $this->getMockBuilder(UserRepository::class) ->disableOriginalConstructor() ->getMock(); $userRepository->expects($this->once()) ->method('find') ->with(123) ->willReturn($user); $starRepository = $this->getMockBuilder(StarRepository::class) ->disableOriginalConstructor() ->getMock(); $starRepository->expects($this->never()) ->method('findAllByUser'); $repoRepository = $this->getMockBuilder(RepoRepository::class) ->disableOriginalConstructor() ->getMock(); $repoRepository->expects($this->never()) ->method('find'); $responses = new MockHandler([ // /rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), // first /user/starred new Response(404, ['Content-Type' => 'application/json']), ]); $githubClient = $this->getMockClient($responses); $logger = new Logger('foo'); $logHandler = new TestHandler(); $logger->pushHandler($logHandler); $redisClient = $this->getMockBuilder(\Predis\Client::class) ->disableOriginalConstructor() ->getMock(); // will use `setex` & `del` but will be called dynamically by `_call` $redisClient->expects($this->exactly(2)) ->method('__call'); $handler = new StarredReposSyncHandler( $doctrine, $userRepository, $starRepository, $repoRepository, $githubClient, $logger, $redisClient ); $handler->__invoke(new StarredReposSync(123)); $records = $logHandler->getRecords(); $this->assertSame('Consume banditore.sync_starred_repos message', $records[0]['message']); $this->assertSame('[10] Check bob … ', $records[1]['message']); $this->assertStringContainsString('(starred) ', $records[2]['message']); $this->assertNotNull($user->getRemovedAt()); } public function testProcessUnexpectedError(): void { $this->expectException(\Exception::class); $this->expectExceptionMessage('booboo'); $em = $this->getMockBuilder(EntityManager::class) ->disableOriginalConstructor() ->getMock(); $em->expects($this->once()) ->method('isOpen') ->willReturn(true); $doctrine = $this->getMockBuilder(Registry::class) ->disableOriginalConstructor() ->getMock(); $doctrine->expects($this->once()) ->method('getManager') ->willReturn($em); $user = new User(); $user->setId(123); $user->setUsername('bob'); $user->setName('Bobby'); $userRepository = $this->getMockBuilder(UserRepository::class) ->disableOriginalConstructor() ->getMock(); $userRepository->expects($this->once()) ->method('find') ->with(123) ->willReturn($user); $starRepository = $this->getMockBuilder(StarRepository::class) ->disableOriginalConstructor() ->getMock(); $starRepository->expects($this->once()) ->method('findAllByUser') ->with(123) ->willReturn([666]); $repoRepository = $this->getMockBuilder(RepoRepository::class) ->disableOriginalConstructor() ->getMock(); $repoRepository->expects($this->once()) ->method('find') ->with(666) ->will($this->throwException(new \Exception('booboo'))); $responses = new MockHandler([ // /rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), // first /user/starred $this->getOKResponse([[ 'description' => 'banditore', 'homepage' => 'http://banditore.io', 'language' => 'PHP', 'name' => 'banditore', 'full_name' => 'j0k3r/banditore', 'id' => 666, 'owner' => [ 'avatar_url' => 'http://avatar.api/banditore.jpg', ], ]]), // /rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), // second /user/starred will return empty response which means, we reached the last page $this->getOKResponse([]), // /rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), ]); $githubClient = $this->getMockClient($responses); $redisClient = $this->getMockBuilder(\Predis\Client::class) ->disableOriginalConstructor() ->getMock(); // will use `setex` & `del` but will be called dynamically by `_call` $redisClient->expects($this->once()) ->method('__call'); $handler = new StarredReposSyncHandler( $doctrine, $userRepository, $starRepository, $repoRepository, $githubClient, new NullLogger(), $redisClient ); $handler->__invoke(new StarredReposSync(123)); } /** * Everything will goes fine (like testProcessSuccessfulMessage) and we won't remove old stars (no change detected in starred repos). */ public function testProcessSuccessfulMessageNoStarToRemove(): void { $em = $this->getMockBuilder(EntityManager::class) ->disableOriginalConstructor() ->getMock(); $em->expects($this->once()) ->method('isOpen') ->willReturn(false); // simulate a closing manager $doctrine = $this->getMockBuilder(Registry::class) ->disableOriginalConstructor() ->getMock(); $doctrine->expects($this->once()) ->method('getManager') ->willReturn($em); $doctrine->expects($this->once()) ->method('resetManager') ->willReturn($em); $user = new User(); $user->setId(123); $user->setUsername('bob'); $user->setName('Bobby'); $userRepository = $this->getMockBuilder(UserRepository::class) ->disableOriginalConstructor() ->getMock(); $userRepository->expects($this->once()) ->method('find') ->with(123) ->willReturn($user); $starRepository = $this->getMockBuilder(StarRepository::class) ->disableOriginalConstructor() ->getMock(); $starRepository->expects($this->exactly(2)) ->method('findAllByUser') ->with(123) ->willReturn([123]); $repo = new Repo(); $repo->setId(123); $repo->setFullName('j0k3r/banditore'); $repo->setUpdatedAt((new \DateTime())->setTimestamp(time() - 3600 * 72)); $repoRepository = $this->getMockBuilder(RepoRepository::class) ->disableOriginalConstructor() ->getMock(); $repoRepository->expects($this->once()) ->method('find') ->with(123) ->willReturn($repo); $responses = new MockHandler([ // /rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), // first /user/starred $this->getOKResponse([[ 'description' => 'banditore', 'homepage' => 'http://banditore.io', 'language' => 'PHP', 'name' => 'banditore', 'full_name' => 'j0k3r/banditore', 'id' => 123, 'owner' => [ 'avatar_url' => 'http://avatar.api/banditore.jpg', ], ]]), // /rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), // second /user/starred will return empty response which means, we reached the last page $this->getOKResponse([]), // /rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), ]); $githubClient = $this->getMockClient($responses); $logger = new Logger('foo'); $logHandler = new TestHandler(); $logger->pushHandler($logHandler); $redisClient = $this->getMockBuilder(\Predis\Client::class) ->disableOriginalConstructor() ->getMock(); // will use `setex` & `del` but will be called dynamically by `_call` $redisClient->expects($this->exactly(2)) ->method('__call'); $handler = new StarredReposSyncHandler( $doctrine, $userRepository, $starRepository, $repoRepository, $githubClient, $logger, $redisClient ); $handler->__invoke(new StarredReposSync(123)); $records = $logHandler->getRecords(); $this->assertSame('Consume banditore.sync_starred_repos message', $records[0]['message']); $this->assertSame('[10] Check bob … ', $records[1]['message']); $this->assertSame(' sync 1 starred repos', $records[2]['message']); $this->assertSame('[10] Synced repos: 1', $records[3]['message']); } public function testProcessWithBadClient(): void { $doctrine = $this->getMockBuilder(Registry::class) ->disableOriginalConstructor() ->getMock(); $userRepository = $this->getMockBuilder(UserRepository::class) ->disableOriginalConstructor() ->getMock(); $userRepository->expects($this->never()) ->method('find'); $starRepository = $this->getMockBuilder(StarRepository::class) ->disableOriginalConstructor() ->getMock(); $starRepository->expects($this->never()) ->method('findAllByUser'); $repoRepository = $this->getMockBuilder(RepoRepository::class) ->disableOriginalConstructor() ->getMock(); $repoRepository->expects($this->never()) ->method('find'); $logger = new Logger('foo'); $logHandler = new TestHandler(); $logger->pushHandler($logHandler); $redisClient = $this->getMockBuilder(\Predis\Client::class) ->disableOriginalConstructor() ->getMock(); // will use `setex` & `del` but will be called dynamically by `_call` $redisClient->expects($this->never()) ->method('__call'); $handler = new StarredReposSyncHandler( $doctrine, $userRepository, $starRepository, $repoRepository, null, // simulate a bad client $logger, $redisClient ); $handler->__invoke(new StarredReposSync(123)); $records = $logHandler->getRecords(); $this->assertSame('No client provided', $records[0]['message']); } public function testProcessWithRateLimitReached(): void { $em = $this->getMockBuilder(EntityManager::class) ->disableOriginalConstructor() ->getMock(); $em->expects($this->never()) ->method('isOpen'); $doctrine = $this->getMockBuilder(Registry::class) ->disableOriginalConstructor() ->getMock(); $doctrine->expects($this->never()) ->method('getManager'); $user = new User(); $user->setId(123); $user->setUsername('bob'); $user->setName('Bobby'); $userRepository = $this->getMockBuilder(UserRepository::class) ->disableOriginalConstructor() ->getMock(); $userRepository->expects($this->once()) ->method('find') ->with(123) ->willReturn($user); $starRepository = $this->getMockBuilder(StarRepository::class) ->disableOriginalConstructor() ->getMock(); $starRepository->expects($this->never()) ->method('findAllByUser'); $starRepository->expects($this->never()) ->method('removeFromUser'); $repoRepository = $this->getMockBuilder(RepoRepository::class) ->disableOriginalConstructor() ->getMock(); $repoRepository->expects($this->never()) ->method('find'); $responses = new MockHandler([ // /rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 0]]]), ]); $githubClient = $this->getMockClient($responses); $logger = new Logger('foo'); $logHandler = new TestHandler(); $logger->pushHandler($logHandler); $redisClient = $this->getMockBuilder(\Predis\Client::class) ->disableOriginalConstructor() ->getMock(); // will use `setex` & `del` but will be called dynamically by `_call` $redisClient->expects($this->once()) ->method('__call'); $handler = new StarredReposSyncHandler( $doctrine, $userRepository, $starRepository, $repoRepository, $githubClient, $logger, $redisClient ); $handler->__invoke(new StarredReposSync(123)); $records = $logHandler->getRecords(); $this->assertSame('Consume banditore.sync_starred_repos message', $records[0]['message']); $this->assertSame('[0] Check bob … ', $records[1]['message']); $this->assertSame('RateLimit reached, stopping.', $records[2]['message']); } public function testFunctionalConsumer(): void { $this->restoreFunctionalState(); $responses = new MockHandler([ // /rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), // first /user/starred $this->getOKResponse([[ 'description' => 'banditore', 'homepage' => 'http://banditore.io', 'language' => 'PHP', 'name' => 'banditore', 'full_name' => 'j0k3r/banditore', 'id' => 777, 'owner' => [ 'avatar_url' => 'http://avatar.api/banditore.jpg', ], ]]), // /rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), // second /user/starred $this->getOKResponse([[ 'description' => 'This is a test repo', 'homepage' => 'http://test.io', 'language' => 'Ruby', 'name' => 'test', 'full_name' => 'test/test', 'id' => 666, 'owner' => [ 'avatar_url' => 'http://0.0.0.0/test.jpg', ], ]]), // /rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 8]]]), // third /user/starred will return empty response which means, we reached the last page $this->getOKResponse([]), // /rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 6]]]), ]); $githubClient = $this->getMockClient($responses); $client = static::createClient(); // override factory to avoid real call to Github self::getContainer()->set('banditore.client.github.test', $githubClient); $handler = self::getContainer()->get(StarredReposSyncHandler::class); // before import $stars = self::getContainer()->get(StarRepository::class)->findAllByUser(123); $this->assertCount(2, $stars, 'User 123 has 2 starred repos'); $this->assertSame(555, $stars[0], 'User 123 has "symfony/symfony" starred repo'); $this->assertSame(666, $stars[1], 'User 123 has "test/test" starred repo'); $handler->__invoke(new StarredReposSync(123)); /** @var Repo */ $repo = self::getContainer()->get(RepoRepository::class)->find(777); $this->assertNotNull($repo, 'Imported repo with id 777 exists'); $this->assertSame('j0k3r/banditore', $repo->getFullName(), 'Imported repo with id 777 exists'); // validate that `test/test` association got removed $stars = self::getContainer()->get(StarRepository::class)->findAllByUser(123); $this->assertCount(2, $stars, 'User 123 has 2 starred repos'); $this->assertSame(666, $stars[0], 'User 123 has "test/test" starred repo'); $this->assertSame(777, $stars[1], 'User 123 has "j0k3r/banditore" starred repo'); } private function getOKResponse(array $body): Response { return new Response( 200, ['Content-Type' => 'application/json'], (string) json_encode($body) ); } private function restoreFunctionalState(): void { static::ensureKernelShutdown(); static::createClient(); /** @var EntityManager $entityManager */ $entityManager = self::getContainer()->get('doctrine')->getManager(); /** @var User $user */ $user = self::getContainer()->get(UserRepository::class)->find(123); /** @var Repo $repoSymfony */ $repoSymfony = self::getContainer()->get(RepoRepository::class)->find(555); /** @var Repo $repoTest */ $repoTest = self::getContainer()->get(RepoRepository::class)->find(666); $entityManager->createQuery('DELETE FROM App\Entity\Star s WHERE s.user = :user') ->setParameter('user', $user) ->execute(); $entityManager->createQuery('DELETE FROM App\Entity\Repo r WHERE r.id = :repoId') ->setParameter('repoId', 777) ->execute(); $entityManager->persist(new Star($user, $repoSymfony)); $entityManager->persist(new Star($user, $repoTest)); $entityManager->flush(); $entityManager->clear(); static::ensureKernelShutdown(); } private function getMockClient(MockHandler $responses): GithubClient { $clientHandler = HandlerStack::create($responses); $guzzleClient = new Client([ 'handler' => $clientHandler, ]); $httpClient = new Guzzle7Client($guzzleClient); $httpBuilder = new Builder($httpClient); $githubClient = new GithubClient($httpBuilder); return $githubClient; } } ================================================ FILE: tests/MessageHandler/VersionsSyncHandlerTest.php ================================================ getMockBuilder(Registry::class) ->disableOriginalConstructor() ->getMock(); $repoRepository = $this->getMockBuilder(RepoRepository::class) ->disableOriginalConstructor() ->getMock(); $repoRepository->expects($this->once()) ->method('find') ->with(123) ->willReturn(null); $versionRepository = $this->getMockBuilder(VersionRepository::class) ->disableOriginalConstructor() ->getMock(); $pubsubhubbub = $this->getMockBuilder(Publisher::class) ->disableOriginalConstructor() ->getMock(); $githubClient = $this->getMockBuilder(GithubClient::class) ->disableOriginalConstructor() ->getMock(); $githubClient->expects($this->never()) ->method('authenticate'); $handler = new VersionsSyncHandler( $doctrine, $repoRepository, $versionRepository, $pubsubhubbub, $githubClient, new NullLogger() ); $handler->__invoke(new VersionsSync(123)); } public function getWorkingResponses(): MockHandler { return new MockHandler([ // rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), // repo/tags $this->getOKResponse([[ 'name' => '2.0.1', 'zipball_url' => 'https://api.github.com/repos/snc/SncRedisBundle/zipball/2.0.1', 'tarball_url' => 'https://api.github.com/repos/snc/SncRedisBundle/tarball/2.0.1', 'commit' => [ 'sha' => '02c808d157c79ac32777e19f3ec31af24a32d2df', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/commits/02c808d157c79ac32777e19f3ec31af24a32d2df', ], ]]), // git/refs/tags $this->getOKResponse([ [ 'ref' => 'refs/tags/1.0.0', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/git/refs/tags/1.0.0', 'object' => [ 'sha' => '04b99722e0c25bfc45926cd3a1081c04a8e950ed', 'type' => 'commit', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/git/commits/04b99722e0c25bfc45926cd3a1081c04a8e950ed', ], ], [ 'ref' => 'refs/tags/1.0.1', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/git/refs/tags/1.0.1', 'object' => [ 'sha' => '4845571072d49c2794b165482420b66c206a942a', 'type' => 'commit', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/git/commits/4845571072d49c2794b165482420b66c206a942a', ], ], [ 'ref' => 'refs/tags/1.0.2', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/git/refs/tags/1.0.2', 'object' => [ 'sha' => '694b8cc3983f52209029605300910507bec700b4', 'type' => 'tag', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/git/tags/694b8cc3983f52209029605300910507bec700b4', ], ], [ 'ref' => 'refs/tags/2.0.1', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/git/refs/tags/2.0.1', 'object' => [ 'sha' => '02c808d157c79ac32777e19f3ec31af24a32d2df', 'type' => 'commit', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/git/commits/02c808d157c79ac32777e19f3ec31af24a32d2df', ], ], ]), // TAG 1.0.1 // repos/release with tag 1.0.1 (which is not a release) new Response(404, ['Content-Type' => 'application/json'], (string) json_encode([ 'message' => 'Not Found', 'documentation_url' => 'https://developer.github.com/v3', ])), // retrieve tag information from the commit (since the release does not exist) $this->getOKResponse([ 'sha' => '4845571072d49c2794b165482420b66c206a942a', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/git/commits/4845571072d49c2794b165482420b66c206a942a', 'html_url' => 'https://github.com/snc/SncRedisBundle/commit/4845571072d49c2794b165482420b66c206a942a', 'author' => [ 'name' => 'Daniele Alessandri', 'email' => 'suppakilla@gmail.com', 'date' => '2011-10-15T07:49:04Z', ], 'committer' => [ 'name' => 'Daniele Alessandri', 'email' => 'suppakilla@gmail.com', 'date' => '2011-10-15T07:49:21Z', ], 'tree' => [ 'sha' => '0f570c5083aa017b7cb5a4b83869ed5054c17764', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/git/trees/0f570c5083aa017b7cb5a4b83869ed5054c17764', ], 'message' => 'Use the correct package type for composer.', 'parents' => [[ 'sha' => '40f7ee543e217aa3a1eadbc952df56b548071d20', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/git/commits/40f7ee543e217aa3a1eadbc952df56b548071d20', 'html_url' => 'https://github.com/snc/SncRedisBundle/commit/40f7ee543e217aa3a1eadbc952df56b548071d20', ]], ]), // markdown new Response(200, ['Content-Type' => 'text/html'], '

Use the correct package type for composer.

'), // TAG 1.0.2 // repos/release with tag 1.0.2 (which is not a release) new Response(404, ['Content-Type' => 'application/json'], (string) json_encode([ 'message' => 'Not Found', 'documentation_url' => 'https://developer.github.com/v3', ])), // retrieve tag information from the tag (since the release does not exist) $this->getOKResponse([ 'sha' => '694b8cc3983f52209029605300910507bec700b4', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/git/tags/694b8cc3983f52209029605300910507bec700b4', 'tagger' => [ 'name' => 'Erwin Mombay', 'email' => 'erwinm@google.com', 'date' => '2012-10-18T17:23:37Z', ], 'object' => [ 'sha' => '694b8cc3983f52209029605300910507bec700b5', 'type' => 'commit', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/git/commits/694b8cc3983f52209029605300910507bec700b5', ], 'tag' => '1.0.2', 'message' => "weekly release\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v2\n\niF4EABEIAAYFAliw58IACgkQ64qmmlZsB5VNFwD+L1M86cO76oohqSy4TCbubPAL\n6341glOKJpfkwyjQnUkBAPCTZSBbe8CFHLxLUvypIiQSMn+AIkPfvzvSEahA40Vz\n=SaF+\n-----END PGP SIGNATURE-----\n", ]), // markdown new Response(200, ['Content-Type' => 'text/html'], '

weekly release

'), // TAG 2.0.1 // now tag 2.0.1 which is a release $this->getOKResponse([ 'tag_name' => '2.0.1', 'name' => 'Trade-off memory for compute, Windows support, 24 distributions with cdf, variance etc., dtypes, zero-dimensional Tensors, Tensor-Variable merge, , faster distributed, perf and bug fixes, CuDNN 7.1', 'prerelease' => false, 'published_at' => '2017-02-19T13:27:32Z', 'body' => 'yay', ]), // markdown new Response(200, ['Content-Type' => 'text/html'], '

yay

'), // rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), ]); } public function testProcessSuccessfulMessage(): void { $uow = $this->getMockBuilder(UnitOfWork::class) ->disableOriginalConstructor() ->getMock(); $uow->expects($this->exactly(3)) ->method('getScheduledEntityInsertions') ->willReturn([]); $em = $this->getMockBuilder(EntityManager::class) ->disableOriginalConstructor() ->getMock(); $em->expects($this->once()) ->method('isOpen') ->willReturn(false); // simulate a closing manager $em->expects($this->exactly(3)) ->method('getUnitOfWork') ->willReturn($uow); $doctrine = $this->getMockBuilder(Registry::class) ->disableOriginalConstructor() ->getMock(); $doctrine->expects($this->once()) ->method('getManager') ->willReturn($em); $doctrine->expects($this->once()) ->method('resetManager') ->willReturn($em); $repo = new Repo(); $repo->setId(123); $repo->setFullName('bob/wow'); $repo->setName('wow'); $repoRepository = $this->getMockBuilder(RepoRepository::class) ->disableOriginalConstructor() ->getMock(); $repoRepository->expects($this->once()) ->method('find') ->with(123) ->willReturn($repo); $versionRepository = $this->getMockBuilder(VersionRepository::class) ->disableOriginalConstructor() ->getMock(); $versionRepository->expects($this->exactly(4)) ->method('findExistingOne') ->willReturnCallback(static function ($tagName, $repoId) use ($repo) { // first version will exist, next one won't if ('1.0.0' === $tagName) { return new Version($repo); } }); $pubsubhubbub = $this->getMockBuilder(Publisher::class) ->disableOriginalConstructor() ->getMock(); $pubsubhubbub->expects($this->once()) ->method('pingHub') ->with([123]); $clientHandler = HandlerStack::create($this->getWorkingResponses()); $guzzleClient = new Client([ 'handler' => $clientHandler, ]); $httpClient = new Guzzle7Client($guzzleClient); $httpBuilder = new Builder($httpClient); $githubClient = new GithubClient($httpBuilder); $logger = new Logger('foo'); $logHandler = new TestHandler(); $logger->pushHandler($logHandler); $handler = new VersionsSyncHandler( $doctrine, $repoRepository, $versionRepository, $pubsubhubbub, $githubClient, $logger ); $handler->__invoke(new VersionsSync(123)); $records = $logHandler->getRecords(); $this->assertSame('Consume banditore.sync_versions message', $records[0]['message']); $this->assertSame('[10] Check bob/wow … ', $records[1]['message']); $this->assertSame('[10] 3 new versions for bob/wow', $records[2]['message']); } /** * The call to repo/tags will return a bad response. */ public function testProcessRepoTagFailed(): void { $em = $this->getMockBuilder(EntityManager::class) ->disableOriginalConstructor() ->getMock(); $em->expects($this->once()) ->method('isOpen') ->willReturn(true); $doctrine = $this->getMockBuilder(Registry::class) ->disableOriginalConstructor() ->getMock(); $doctrine->expects($this->once()) ->method('getManager') ->willReturn($em); $repo = new Repo(); $repo->setId(123); $repo->setFullName('bob/wow'); $repo->setName('wow'); $repoRepository = $this->getMockBuilder(RepoRepository::class) ->disableOriginalConstructor() ->getMock(); $repoRepository->expects($this->once()) ->method('find') ->with(123) ->willReturn($repo); $versionRepository = $this->getMockBuilder(VersionRepository::class) ->disableOriginalConstructor() ->getMock(); $pubsubhubbub = $this->getMockBuilder(Publisher::class) ->disableOriginalConstructor() ->getMock(); $pubsubhubbub->expects($this->never()) ->method('pingHub'); $responses = new MockHandler([ // rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), // repo/tags generate a bad request new Response(400, ['Content-Type' => 'application/json']), // rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), ]); $clientHandler = HandlerStack::create($responses); $guzzleClient = new Client([ 'handler' => $clientHandler, ]); $httpClient = new Guzzle7Client($guzzleClient); $httpBuilder = new Builder($httpClient); $githubClient = new GithubClient($httpBuilder); $logger = new Logger('foo'); $logHandler = new TestHandler(); $logger->pushHandler($logHandler); $handler = new VersionsSyncHandler( $doctrine, $repoRepository, $versionRepository, $pubsubhubbub, $githubClient, $logger ); $handler->__invoke(new VersionsSync(123)); $records = $logHandler->getRecords(); $this->assertSame('Consume banditore.sync_versions message', $records[0]['message']); $this->assertSame('[10] Check bob/wow … ', $records[1]['message']); $this->assertStringContainsString('(repo/tags) ', $records[2]['message']); } /** * The call to repo/tags will return a "404" then the repo will be flag as removed. */ public function testProcessRepoNotFound(): void { $em = $this->getMockBuilder(EntityManager::class) ->disableOriginalConstructor() ->getMock(); $em->expects($this->once()) ->method('isOpen') ->willReturn(true); $doctrine = $this->getMockBuilder(Registry::class) ->disableOriginalConstructor() ->getMock(); $doctrine->expects($this->once()) ->method('getManager') ->willReturn($em); $repo = new Repo(); $repo->setId(123); $repo->setFullName('bob/wow'); $repo->setName('wow'); $repoRepository = $this->getMockBuilder(RepoRepository::class) ->disableOriginalConstructor() ->getMock(); $repoRepository->expects($this->once()) ->method('find') ->with(123) ->willReturn($repo); $versionRepository = $this->getMockBuilder(VersionRepository::class) ->disableOriginalConstructor() ->getMock(); $pubsubhubbub = $this->getMockBuilder(Publisher::class) ->disableOriginalConstructor() ->getMock(); $pubsubhubbub->expects($this->never()) ->method('pingHub'); $responses = new MockHandler([ // rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), // repo/tags generate a bad request new Response(404, ['Content-Type' => 'application/json']), // rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), ]); $clientHandler = HandlerStack::create($responses); $guzzleClient = new Client([ 'handler' => $clientHandler, ]); $httpClient = new Guzzle7Client($guzzleClient); $httpBuilder = new Builder($httpClient); $githubClient = new GithubClient($httpBuilder); $logger = new Logger('foo'); $logHandler = new TestHandler(); $logger->pushHandler($logHandler); $handler = new VersionsSyncHandler( $doctrine, $repoRepository, $versionRepository, $pubsubhubbub, $githubClient, $logger ); $handler->__invoke(new VersionsSync(123)); $records = $logHandler->getRecords(); $this->assertSame('Consume banditore.sync_versions message', $records[0]['message']); $this->assertSame('[10] Check bob/wow … ', $records[1]['message']); $this->assertStringContainsString('(repo/tags) ', $records[2]['message']); $this->assertNotNull($repo->getRemovedAt()); } /** * Not enough calls remaining. */ public function testProcessCallsRemaingLow(): void { $em = $this->getMockBuilder(EntityManager::class) ->disableOriginalConstructor() ->getMock(); $em->expects($this->never()) ->method('isOpen'); $doctrine = $this->getMockBuilder(Registry::class) ->disableOriginalConstructor() ->getMock(); $doctrine->expects($this->never()) ->method('getManager'); $repo = new Repo(); $repo->setId(123); $repo->setFullName('bob/wow'); $repo->setName('wow'); $repoRepository = $this->getMockBuilder(RepoRepository::class) ->disableOriginalConstructor() ->getMock(); $repoRepository->expects($this->once()) ->method('find') ->with(123) ->willReturn($repo); $versionRepository = $this->getMockBuilder(VersionRepository::class) ->disableOriginalConstructor() ->getMock(); $pubsubhubbub = $this->getMockBuilder(Publisher::class) ->disableOriginalConstructor() ->getMock(); $pubsubhubbub->expects($this->never()) ->method('pingHub'); $responses = new MockHandler([ // rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 0]]]), ]); $clientHandler = HandlerStack::create($responses); $guzzleClient = new Client([ 'handler' => $clientHandler, ]); $httpClient = new Guzzle7Client($guzzleClient); $httpBuilder = new Builder($httpClient); $githubClient = new GithubClient($httpBuilder); $logger = new Logger('foo'); $logHandler = new TestHandler(); $logger->pushHandler($logHandler); $handler = new VersionsSyncHandler( $doctrine, $repoRepository, $versionRepository, $pubsubhubbub, $githubClient, $logger ); $handler->__invoke(new VersionsSync(123)); $records = $logHandler->getRecords(); $this->assertSame('Consume banditore.sync_versions message', $records[0]['message']); $this->assertSame('[0] Check bob/wow … ', $records[1]['message']); $this->assertStringContainsString('RateLimit reached, stopping.', $records[2]['message']); } /** * The call to markdown will return a bad response. */ public function testProcessMarkdownFailed(): void { $uow = $this->getMockBuilder(UnitOfWork::class) ->disableOriginalConstructor() ->getMock(); $uow->expects($this->once()) ->method('getScheduledEntityInsertions') ->willReturn([]); $em = $this->getMockBuilder(EntityManager::class) ->disableOriginalConstructor() ->getMock(); $em->expects($this->once()) ->method('isOpen') ->willReturn(true); $em->expects($this->once()) ->method('getUnitOfWork') ->willReturn($uow); $doctrine = $this->getMockBuilder(Registry::class) ->disableOriginalConstructor() ->getMock(); $doctrine->expects($this->once()) ->method('getManager') ->willReturn($em); $repo = new Repo(); $repo->setId(123); $repo->setFullName('bob/wow'); $repo->setName('wow'); $repoRepository = $this->getMockBuilder(RepoRepository::class) ->disableOriginalConstructor() ->getMock(); $repoRepository->expects($this->once()) ->method('find') ->with(123) ->willReturn($repo); $versionRepository = $this->getMockBuilder(VersionRepository::class) ->disableOriginalConstructor() ->getMock(); $versionRepository->expects($this->once()) ->method('findExistingOne') ->willReturn(null); $pubsubhubbub = $this->getMockBuilder(Publisher::class) ->disableOriginalConstructor() ->getMock(); $pubsubhubbub->expects($this->never()) ->method('pingHub'); $responses = new MockHandler([ // rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), // repo/tags $this->getOKResponse([[ 'name' => '2.0.1', 'zipball_url' => 'https://api.github.com/repos/snc/SncRedisBundle/zipball/2.0.1', 'tarball_url' => 'https://api.github.com/repos/snc/SncRedisBundle/tarball/2.0.1', 'commit' => [ 'sha' => '02c808d157c79ac32777e19f3ec31af24a32d2df', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/commits/02c808d157c79ac32777e19f3ec31af24a32d2df', ], ]]), // git/refs/tags generate a bad request $this->getOKResponse([ [ 'ref' => 'refs/tags/1.0.0', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/git/refs/tags/1.0.0', 'object' => [ 'sha' => '04b99722e0c25bfc45926cd3a1081c04a8e950ed', 'type' => 'commit', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/git/commits/04b99722e0c25bfc45926cd3a1081c04a8e950ed', ], ], ]), // now tag 1.0.0 which is a release $this->getOKResponse([ 'tag_name' => '1.0.0', 'name' => '1.0.0', 'prerelease' => false, 'published_at' => '2017-02-19T13:27:32Z', 'body' => 'yay', ]), // markdown failed new Response(400, ['Content-Type' => 'text/html'], 'booboo'), // rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), ]); $clientHandler = HandlerStack::create($responses); $guzzleClient = new Client([ 'handler' => $clientHandler, ]); $httpClient = new Guzzle7Client($guzzleClient); $httpBuilder = new Builder($httpClient); $githubClient = new GithubClient($httpBuilder); $logger = new Logger('foo'); $logHandler = new TestHandler(); $logger->pushHandler($logHandler); $handler = new VersionsSyncHandler( $doctrine, $repoRepository, $versionRepository, $pubsubhubbub, $githubClient, $logger ); $handler->__invoke(new VersionsSync(123)); $records = $logHandler->getRecords(); $this->assertSame('Consume banditore.sync_versions message', $records[0]['message']); $this->assertSame('[10] Check bob/wow … ', $records[1]['message']); $this->assertStringContainsString('Failed to parse markdown', $records[2]['message']); } /** * No tag found for that repo. */ public function testProcessNoTagFound(): void { $em = $this->getMockBuilder(EntityManager::class) ->disableOriginalConstructor() ->getMock(); $em->expects($this->once()) ->method('isOpen') ->willReturn(true); $doctrine = $this->getMockBuilder(Registry::class) ->disableOriginalConstructor() ->getMock(); $doctrine->expects($this->once()) ->method('getManager') ->willReturn($em); $repo = new Repo(); $repo->setId(123); $repo->setFullName('bob/wow'); $repo->setName('wow'); $repoRepository = $this->getMockBuilder(RepoRepository::class) ->disableOriginalConstructor() ->getMock(); $repoRepository->expects($this->once()) ->method('find') ->with(123) ->willReturn($repo); $versionRepository = $this->getMockBuilder(VersionRepository::class) ->disableOriginalConstructor() ->getMock(); $pubsubhubbub = $this->getMockBuilder(Publisher::class) ->disableOriginalConstructor() ->getMock(); $pubsubhubbub->expects($this->never()) ->method('pingHub'); $responses = new MockHandler([ // rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), // repo/tags $this->getOKResponse([]), // rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), ]); $clientHandler = HandlerStack::create($responses); $guzzleClient = new Client([ 'handler' => $clientHandler, ]); $httpClient = new Guzzle7Client($guzzleClient); $httpBuilder = new Builder($httpClient); $githubClient = new GithubClient($httpBuilder); $logger = new Logger('foo'); $logHandler = new TestHandler(); $logger->pushHandler($logHandler); $handler = new VersionsSyncHandler( $doctrine, $repoRepository, $versionRepository, $pubsubhubbub, $githubClient, $logger ); $handler->__invoke(new VersionsSync(123)); $records = $logHandler->getRecords(); $this->assertSame('Consume banditore.sync_versions message', $records[0]['message']); $this->assertSame('[10] Check bob/wow … ', $records[1]['message']); $this->assertSame('[10] 0 new versions for bob/wow', $records[2]['message']); } /** * Generate an unexpected error (like from MySQL). */ public function testProcessUnexpectedError(): void { $this->expectException(\Exception::class); $this->expectExceptionMessage('booboo'); $em = $this->getMockBuilder(EntityManager::class) ->disableOriginalConstructor() ->getMock(); $em->expects($this->once()) ->method('isOpen') ->willReturn(true); $doctrine = $this->getMockBuilder(Registry::class) ->disableOriginalConstructor() ->getMock(); $doctrine->expects($this->once()) ->method('getManager') ->willReturn($em); $repo = new Repo(); $repo->setId(123); $repo->setFullName('bob/wow'); $repo->setName('wow'); $repoRepository = $this->getMockBuilder(RepoRepository::class) ->disableOriginalConstructor() ->getMock(); $repoRepository->expects($this->once()) ->method('find') ->with(123) ->willReturn($repo); $versionRepository = $this->getMockBuilder(VersionRepository::class) ->disableOriginalConstructor() ->getMock(); $versionRepository->expects($this->once()) ->method('findExistingOne') ->will($this->throwException(new \Exception('booboo'))); $pubsubhubbub = $this->getMockBuilder(Publisher::class) ->disableOriginalConstructor() ->getMock(); $pubsubhubbub->expects($this->never()) ->method('pingHub'); $responses = new MockHandler([ // rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), // repo/tags $this->getOKResponse([[ 'name' => '2.0.1', 'zipball_url' => 'https://api.github.com/repos/snc/SncRedisBundle/zipball/2.0.1', 'tarball_url' => 'https://api.github.com/repos/snc/SncRedisBundle/tarball/2.0.1', 'commit' => [ 'sha' => '02c808d157c79ac32777e19f3ec31af24a32d2df', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/commits/02c808d157c79ac32777e19f3ec31af24a32d2df', ], ]]), // git/refs/tags $this->getOKResponse([ [ 'ref' => 'refs/tags/1.0.0', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/git/refs/tags/1.0.0', 'object' => [ 'sha' => '04b99722e0c25bfc45926cd3a1081c04a8e950ed', 'type' => 'commit', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/git/commits/04b99722e0c25bfc45926cd3a1081c04a8e950ed', ], ], ]), // rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), ]); $clientHandler = HandlerStack::create($responses); $guzzleClient = new Client([ 'handler' => $clientHandler, ]); $httpClient = new Guzzle7Client($guzzleClient); $httpBuilder = new Builder($httpClient); $githubClient = new GithubClient($httpBuilder); $handler = new VersionsSyncHandler( $doctrine, $repoRepository, $versionRepository, $pubsubhubbub, $githubClient, new NullLogger() ); $handler->__invoke(new VersionsSync(123)); } /** * The call to git/refs/tags will return a bad response. */ public function testProcessGitRefTagFailed(): void { $em = $this->getMockBuilder(EntityManager::class) ->disableOriginalConstructor() ->getMock(); $em->expects($this->once()) ->method('isOpen') ->willReturn(true); $doctrine = $this->getMockBuilder(Registry::class) ->disableOriginalConstructor() ->getMock(); $doctrine->expects($this->once()) ->method('getManager') ->willReturn($em); $repo = new Repo(); $repo->setId(123); $repo->setFullName('bob/wow'); $repo->setName('wow'); $repoRepository = $this->getMockBuilder(RepoRepository::class) ->disableOriginalConstructor() ->getMock(); $repoRepository->expects($this->once()) ->method('find') ->with(123) ->willReturn($repo); $versionRepository = $this->getMockBuilder(VersionRepository::class) ->disableOriginalConstructor() ->getMock(); $pubsubhubbub = $this->getMockBuilder(Publisher::class) ->disableOriginalConstructor() ->getMock(); $pubsubhubbub->expects($this->never()) ->method('pingHub'); $responses = new MockHandler([ // rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), // repo/tags $this->getOKResponse([[ 'name' => '2.0.1', 'zipball_url' => 'https://api.github.com/repos/snc/SncRedisBundle/zipball/2.0.1', 'tarball_url' => 'https://api.github.com/repos/snc/SncRedisBundle/tarball/2.0.1', 'commit' => [ 'sha' => '02c808d157c79ac32777e19f3ec31af24a32d2df', 'url' => 'https://api.github.com/repos/snc/SncRedisBundle/commits/02c808d157c79ac32777e19f3ec31af24a32d2df', ], ]]), // git/refs/tags generate a bad request new Response(400, ['Content-Type' => 'application/json']), // rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), ]); $clientHandler = HandlerStack::create($responses); $guzzleClient = new Client([ 'handler' => $clientHandler, ]); $httpClient = new Guzzle7Client($guzzleClient); $httpBuilder = new Builder($httpClient); $githubClient = new GithubClient($httpBuilder); $logger = new Logger('foo'); $logHandler = new TestHandler(); $logger->pushHandler($logHandler); $handler = new VersionsSyncHandler( $doctrine, $repoRepository, $versionRepository, $pubsubhubbub, $githubClient, $logger ); $handler->__invoke(new VersionsSync(123)); $records = $logHandler->getRecords(); $this->assertSame('Consume banditore.sync_versions message', $records[0]['message']); $this->assertSame('[10] Check bob/wow … ', $records[1]['message']); $this->assertStringContainsString('(git/refs/tags) ', $records[2]['message']); } public function testProcessWithBadClient(): void { $doctrine = $this->getMockBuilder(Registry::class) ->disableOriginalConstructor() ->getMock(); $repoRepository = $this->getMockBuilder(RepoRepository::class) ->disableOriginalConstructor() ->getMock(); $repoRepository->expects($this->never()) ->method('find'); $versionRepository = $this->getMockBuilder(VersionRepository::class) ->disableOriginalConstructor() ->getMock(); $pubsubhubbub = $this->getMockBuilder(Publisher::class) ->disableOriginalConstructor() ->getMock(); $pubsubhubbub->expects($this->never()) ->method('pingHub'); $logger = new Logger('foo'); $logHandler = new TestHandler(); $logger->pushHandler($logHandler); $handler = new VersionsSyncHandler( $doctrine, $repoRepository, $versionRepository, $pubsubhubbub, null, // simulate a bad client $logger ); $handler->__invoke(new VersionsSync(123)); $records = $logHandler->getRecords(); $this->assertSame('No client provided', $records[0]['message']); } /** * Using mocks only for request. */ #[Group('only')] public function testFunctionalConsumer(): void { $this->restoreFunctionalState(); $clientHandler = HandlerStack::create($this->getWorkingResponses()); $guzzleClient = new Client([ 'handler' => $clientHandler, ]); $httpClient = new Guzzle7Client($guzzleClient); $httpBuilder = new Builder($httpClient); $githubClient = new GithubClient($httpBuilder); $client = static::createClient(); // override factory to avoid real call to Github self::getContainer()->set('banditore.client.github.test', $githubClient); // mock pubsubhubbub request $guzzleClientPub = $this->getMockBuilder(Client::class) ->disableOriginalConstructor() ->getMock(); $guzzleClientPub->expects($this->once()) ->method('post') ->willReturn(new Response(204)); self::getContainer()->set('banditore.client.guzzle.test', $guzzleClientPub); $handler = self::getContainer()->get(VersionsSyncHandler::class); /** @var Version[] */ $versions = self::getContainer()->get(VersionRepository::class)->findBy(['repo' => 666]); $this->assertCount(1, $versions, 'Repo 666 has 1 version'); $this->assertSame('1.0.0', $versions[0]->getTagName(), 'Repo 666 has 1 version, which is 1.0.0'); $handler->__invoke(new VersionsSync(666)); /** @var Version[] */ $versions = self::getContainer()->get(VersionRepository::class)->findBy(['repo' => 666]); $this->assertCount(4, $versions, 'Repo 666 has now 4 versions'); $this->assertSame('1.0.0', $versions[0]->getTagName(), 'Repo 666 has 4 version. First one is 1.0.0'); $this->assertSame('1.0.1', $versions[1]->getTagName(), 'Repo 666 has 4 version. Second one is 1.0.1'); $this->assertSame('1.0.2', $versions[2]->getTagName(), 'Repo 666 has 4 version. Third one is 1.0.2'); $this->assertSame('

weekly release

', $versions[2]->getBody(), 'Version 1.0.2 does NOT have a PGP signature'); $this->assertSame('2.0.1', $versions[3]->getTagName(), 'Repo 666 has 4 version. Fourth one is 2.0.1'); } public function testFunctionalConsumerWithTagCaseInsensitive(): void { $this->restoreFunctionalState(); $responses = new MockHandler([ // rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), // repo/tags $this->getOKResponse([[ 'name' => 'v2.11.0', 'zipball_url' => 'https://api.github.com/repos/mozilla/metrics-graphics/zipball/v2.11.0', 'tarball_url' => 'https://api.github.com/repos/mozilla/metrics-graphics/tarball/v2.11.0', ]]), // git/refs/tags $this->getOKResponse([ [ 'ref' => 'refs/tags/V1.1.0', 'url' => 'https://api.github.com/repos/mozilla/metrics-graphics/git/refs/tags/V1.1.0', 'object' => [ 'sha' => '6402716c3165eb90cdace5729a18706ea2921187', 'type' => 'commit', 'url' => 'https://api.github.com/repos/mozilla/metrics-graphics/git/commits/6402716c3165eb90cdace5729a18706ea2921187', ], ], [ 'ref' => 'refs/tags/v1.1.0', 'url' => 'https://api.github.com/repos/mozilla/metrics-graphics/git/refs/tags/v1.1.0', 'object' => [ 'sha' => '15a4703db568342043f156b5635d10b17ebe98cb', 'type' => 'commit', 'url' => 'https://api.github.com/repos/mozilla/metrics-graphics/git/commits/15a4703db568342043f156b5635d10b17ebe98cb', ], ], ]), // TAG V1.1.0 // now tag V1.1.0 which is a release $this->getOKResponse([ 'tag_name' => 'V1.1.0', 'name' => 'V1.1.0', 'prerelease' => false, 'published_at' => '2014-12-01T18:28:39Z', 'body' => 'This is the first release after our major push.', ]), // markdown new Response(200, ['Content-Type' => 'text/html'], '

This is the first release after our major push.

'), // rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), ]); $clientHandler = HandlerStack::create($responses); $guzzleClient = new Client([ 'handler' => $clientHandler, ]); $httpClient = new Guzzle7Client($guzzleClient); $httpBuilder = new Builder($httpClient); $githubClient = new GithubClient($httpBuilder); $client = static::createClient(); // override factory to avoid real call to Github self::getContainer()->set('banditore.client.github.test', $githubClient); // mock pubsubhubbub request $guzzleClientPub = $this->getMockBuilder(Client::class) ->disableOriginalConstructor() ->getMock(); $guzzleClientPub->expects($this->once()) ->method('post') ->willReturn(new Response(204)); self::getContainer()->set('banditore.client.guzzle.test', $guzzleClientPub); $handler = self::getContainer()->get(VersionsSyncHandler::class); /** @var Version[] */ $versions = self::getContainer()->get(VersionRepository::class)->findBy(['repo' => 555]); $this->assertCount(1, $versions, 'Repo 555 has 1 version'); $this->assertSame('1.0.21', $versions[0]->getTagName(), 'Repo 555 has 1 version, which is 1.0.21'); $handler->__invoke(new VersionsSync(555)); /** @var Version[] */ $versions = self::getContainer()->get(VersionRepository::class)->findBy(['repo' => 555]); $this->assertCount(2, $versions, 'Repo 555 has now 2 versions'); $this->assertSame('1.0.21', $versions[0]->getTagName(), 'Repo 555 has 2 version. First one is 1.0.21'); $this->assertSame('V1.1.0', $versions[1]->getTagName(), 'Repo 555 has 2 version. Second one is V1.1.0'); $this->assertSame('

This is the first release after our major push.

', $versions[1]->getBody(), 'Version V1.1.0 body is ok'); } public function testProcessSuccessfulMessageWithBlobTag(): void { $uow = $this->getMockBuilder(UnitOfWork::class) ->disableOriginalConstructor() ->getMock(); $uow->expects($this->once()) ->method('getScheduledEntityInsertions') ->willReturn([]); $em = $this->getMockBuilder(EntityManager::class) ->disableOriginalConstructor() ->getMock(); $em->expects($this->once()) ->method('isOpen') ->willReturn(false); // simulate a closing manager $em->expects($this->once()) ->method('getUnitOfWork') ->willReturn($uow); $doctrine = $this->getMockBuilder(Registry::class) ->disableOriginalConstructor() ->getMock(); $doctrine->expects($this->once()) ->method('getManager') ->willReturn($em); $doctrine->expects($this->once()) ->method('resetManager') ->willReturn($em); $repo = new Repo(); $repo->setId(123); $repo->setFullName('bob/wow'); $repo->setName('wow'); $repoRepository = $this->getMockBuilder(RepoRepository::class) ->disableOriginalConstructor() ->getMock(); $repoRepository->expects($this->once()) ->method('find') ->with(123) ->willReturn($repo); $versionRepository = $this->getMockBuilder(VersionRepository::class) ->disableOriginalConstructor() ->getMock(); $versionRepository->expects($this->once()) ->method('findExistingOne') ->willReturn(null); $pubsubhubbub = $this->getMockBuilder(Publisher::class) ->disableOriginalConstructor() ->getMock(); $pubsubhubbub->expects($this->once()) ->method('pingHub') ->with([123]); $responses = new MockHandler([ // rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), // repo/tags $this->getOKResponse([[ 'name' => 'street/wilson_gardens', 'zipball_url' => 'https://api.github.com/repos/nivbend/gitstery/zipball/street/wilson_gardens', 'tarball_url' => 'https://api.github.com/repos/nivbend/gitstery/tarball/street/wilson_gardens', 'commit' => [ 'sha' => '659f0c110cd80286eaff33d34b9caf6c8e183102', 'url' => 'https://api.github.com/repos/nivbend/gitstery/commits/659f0c110cd80286eaff33d34b9caf6c8e183102', ], ]]), // git/refs/tags $this->getOKResponse([ [ 'ref' => 'refs/tags/solution', 'url' => 'https://api.github.com/repos/nivbend/gitstery/git/refs/tags/solution', 'object' => [ 'sha' => 'b3618a9ec1bbc13bf7133c50fb8d15ef8cbe7594', 'type' => 'blob', 'url' => 'https://api.github.com/repos/nivbend/gitstery/git/blobs/b3618a9ec1bbc13bf7133c50fb8d15ef8cbe7594', ], ], ]), // TAG solution // repos/release with tag solution (which is not a release) new Response(404, ['Content-Type' => 'application/json'], (string) json_encode([ 'message' => 'Not Found', 'documentation_url' => 'https://developer.github.com/v3', ])), // retrieve tag information from the blob $this->getOKResponse([ 'sha' => 'b3618a9ec1bbc13bf7133c50fb8d15ef8cbe7594', 'url' => 'https://api.github.com/repos/nivbend/gitstery/git/blobs/b3618a9ec1bbc13bf7133c50fb8d15ef8cbe7594', 'size' => 40, 'content' => "ZGUxMzI0OTUxYWZlNmU0NjI0MDY2MGNiYzAzYzE1MDBhOTBmYzkyOA==\n", 'encoding' => 'base64', ]), // markdown new Response(200, ['Content-Type' => 'text/html'], '

(blob, size 40) de1324951afe6e46240660cbc03c1500a90fc928

'), // rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), ]); $clientHandler = HandlerStack::create($responses); $guzzleClient = new Client([ 'handler' => $clientHandler, ]); $httpClient = new Guzzle7Client($guzzleClient); $httpBuilder = new Builder($httpClient); $githubClient = new GithubClient($httpBuilder); $logger = new Logger('foo'); $logHandler = new TestHandler(); $logger->pushHandler($logHandler); $handler = new VersionsSyncHandler( $doctrine, $repoRepository, $versionRepository, $pubsubhubbub, $githubClient, $logger ); $handler->__invoke(new VersionsSync(123)); $records = $logHandler->getRecords(); $this->assertSame('Consume banditore.sync_versions message', $records[0]['message']); $this->assertSame('[10] Check bob/wow … ', $records[1]['message']); $this->assertSame('[10] 1 new versions for bob/wow', $records[2]['message']); } public function testBadTagObjectType(): void { $uow = $this->getMockBuilder(UnitOfWork::class) ->disableOriginalConstructor() ->getMock(); $uow->expects($this->once()) ->method('getScheduledEntityInsertions') ->willReturn([]); $em = $this->getMockBuilder(EntityManager::class) ->disableOriginalConstructor() ->getMock(); $em->expects($this->once()) ->method('isOpen') ->willReturn(false); // simulate a closing manager $em->expects($this->once()) ->method('getUnitOfWork') ->willReturn($uow); $doctrine = $this->getMockBuilder(Registry::class) ->disableOriginalConstructor() ->getMock(); $doctrine->expects($this->once()) ->method('getManager') ->willReturn($em); $doctrine->expects($this->once()) ->method('resetManager') ->willReturn($em); $repo = new Repo(); $repo->setId(123); $repo->setFullName('bob/wow'); $repo->setName('wow'); $repoRepository = $this->getMockBuilder(RepoRepository::class) ->disableOriginalConstructor() ->getMock(); $repoRepository->expects($this->once()) ->method('find') ->with(123) ->willReturn($repo); $versionRepository = $this->getMockBuilder(VersionRepository::class) ->disableOriginalConstructor() ->getMock(); $versionRepository->expects($this->once()) ->method('findExistingOne') ->willReturn(null); $pubsubhubbub = $this->getMockBuilder(Publisher::class) ->disableOriginalConstructor() ->getMock(); $pubsubhubbub->expects($this->never()) ->method('pingHub'); $responses = new MockHandler([ // rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), // repo/tags $this->getOKResponse([[ 'name' => 'awesometag', 'zipball_url' => 'https://api.github.com/repos/aweosome/repo/zipball/street/awesometag', 'tarball_url' => 'https://api.github.com/repos/aweosome/repo/tarball/street/awesometag', 'commit' => [ 'sha' => '659f0c110cd80286eaff33d34b9caf6c8e183102', 'url' => 'https://api.github.com/repos/aweosome/repo/commits/659f0c110cd80286eaff33d34b9caf6c8e183102', ], ]]), // git/refs/tags $this->getOKResponse([ [ 'ref' => 'refs/tags/awesometag', 'url' => 'https://api.github.com/repos/aweosome/repo/git/refs/tags/awesometag', 'object' => [ 'sha' => 'b3618a9ec1bbc13bf7133c50fb8d15ef8cbe7594', 'type' => 'unknown', 'url' => 'https://api.github.com/repos/aweosome/repo/git/blobs/b3618a9ec1bbc13bf7133c50fb8d15ef8cbe7594', ], ], ]), // release for that tag does not exist new Response(404, ['Content-Type' => 'application/json']), // rate_limit $this->getOKResponse(['resources' => ['core' => ['reset' => time() + 1000, 'limit' => 200, 'remaining' => 10]]]), ]); $clientHandler = HandlerStack::create($responses); $guzzleClient = new Client([ 'handler' => $clientHandler, ]); $httpClient = new Guzzle7Client($guzzleClient); $httpBuilder = new Builder($httpClient); $githubClient = new GithubClient($httpBuilder); $logger = new Logger('foo'); $logHandler = new TestHandler(); $logger->pushHandler($logHandler); $handler = new VersionsSyncHandler( $doctrine, $repoRepository, $versionRepository, $pubsubhubbub, $githubClient, $logger ); $handler->__invoke(new VersionsSync(123)); $records = $logHandler->getRecords(); $this->assertSame('Consume banditore.sync_versions message', $records[0]['message']); $this->assertSame('[10] Check bob/wow … ', $records[1]['message']); $this->assertSame('Tag object type not supported: unknown (for: bob/wow)', $records[2]['message']); } private function getOKResponse(array $body): Response { return new Response( 200, ['Content-Type' => 'application/json'], (string) json_encode($body) ); } private function restoreFunctionalState(): void { static::ensureKernelShutdown(); static::createClient(); /** @var EntityManager $entityManager */ $entityManager = self::getContainer()->get('doctrine')->getManager(); /** @var Repo $repoTest */ $repoTest = self::getContainer()->get(RepoRepository::class)->find(666); /** @var Repo $repoSymfony */ $repoSymfony = self::getContainer()->get(RepoRepository::class)->find(555); $entityManager->createQuery('DELETE FROM App\Entity\Version v WHERE v.repo IN (:repoIds)') ->setParameter('repoIds', [555, 666]) ->execute(); $versionTest = new Version($repoTest); $versionTest->hydrateFromGithub([ 'tag_name' => '1.0.0', 'name' => 'First release', 'prerelease' => false, 'message' => 'YAY', 'published_at' => '2019-10-15T07:49:21Z', ]); $entityManager->persist($versionTest); $versionSymfony = new Version($repoSymfony); $versionSymfony->hydrateFromGithub([ 'tag_name' => '1.0.21', 'name' => 'First release', 'prerelease' => false, 'message' => 'YAY 555', 'published_at' => '2019-06-15T07:49:21Z', ]); $entityManager->persist($versionSymfony); $entityManager->flush(); $entityManager->clear(); static::ensureKernelShutdown(); } } ================================================ FILE: tests/PubSubHubbub/PublisherTest.php ================================================ add('rss_user', new Route('/{uuid}.atom')); $sc = $this->getServiceContainer($routes); $this->router = new Router($sc, 'rss_user'); } public function testNoHubDefined(): void { $userRepository = $this->getMockBuilder(UserRepository::class) ->disableOriginalConstructor() ->getMock(); $client = new Client(); $publisher = new Publisher('', $this->router, $client, $userRepository, 'banditore.com', 'http'); $res = $publisher->pingHub([1]); // the hub url is invalid, so it will be generate an error and return false $this->assertFalse($res); } public function testBadResponse(): void { $userRepository = $this->getMockBuilder(UserRepository::class) ->disableOriginalConstructor() ->getMock(); $userRepository->expects($this->once()) ->method('findByRepoIds') ->with([123]) ->willReturn([['uuid' => '7fc8de31-5371-4f0a-b606-a7e164c41d46']]); $mock = new MockHandler([ new Response(500), ]); $handler = HandlerStack::create($mock); $client = new Client(['handler' => $handler]); $publisher = new Publisher('http://pubsubhubbub.io', $this->router, $client, $userRepository, 'banditore.com', 'http'); $res = $publisher->pingHub([123]); // the response is bad, so it will return false $this->assertFalse($res); } public function testGoodResponse(): void { $userRepository = $this->getMockBuilder(UserRepository::class) ->disableOriginalConstructor() ->getMock(); $userRepository->expects($this->once()) ->method('findByRepoIds') ->with([123]) ->willReturn([['uuid' => '7fc8de31-5371-4f0a-b606-a7e164c41d46']]); $mock = new MockHandler([ new Response(204), ]); $handler = HandlerStack::create($mock); $client = new Client(['handler' => $handler]); $publisher = new Publisher('http://pubsubhubbub.io', $this->router, $client, $userRepository, 'banditore.com', 'http'); $res = $publisher->pingHub([123]); $this->assertTrue($res); } public function testUrlGeneration(): void { $userRepository = $this->getMockBuilder(UserRepository::class) ->disableOriginalConstructor() ->getMock(); $userRepository->expects($this->once()) ->method('findByRepoIds') ->with([123]) ->willReturn([['uuid' => '7fc8de31-5371-4f0a-b606-a7e164c41d46']]); $method = new \ReflectionMethod( Publisher::class, 'retrieveFeedUrls' ); $urls = $method->invoke( new Publisher('http://pubsubhubbub.io', $this->router, new Client(), $userRepository, 'banditore.com', 'http'), [123] ); $this->assertSame(['http://banditore.com/7fc8de31-5371-4f0a-b606-a7e164c41d46.atom'], $urls); } /** * @see \Symfony\Bundle\FrameworkBundle\Tests\Routing\RouterTest */ private function getServiceContainer(RouteCollection $routes): Container { $loader = $this->getMockBuilder(LoaderInterface::class)->getMock(); $loader ->expects($this->any()) ->method('load') ->willReturn($routes) ; $sc = $this->getMockBuilder(Container::class)->onlyMethods(['get'])->getMock(); $sc ->expects($this->any()) ->method('get') ->willReturn($loader) ; return $sc; } } ================================================ FILE: tests/Repository/UserRepositoryTest.php ================================================ get(Connection::class)->executeStatement('UPDATE star SET ignored_in_feed = 0'); } public function testFindByRepoIdsExcludesIgnoredStars(): void { $repository = self::getContainer()->get(UserRepository::class); $this->assertCount(1, $repository->findByRepoIds([666])); self::getContainer()->get(Connection::class)->executeStatement('UPDATE star SET ignored_in_feed = 1 WHERE user_id = 123 AND repo_id = 666'); $this->assertSame([], $repository->findByRepoIds([666])); } } ================================================ FILE: tests/Repository/VersionRepositoryTest.php ================================================ get(EntityManagerInterface::class); $entityManager->createQuery('DELETE FROM App\Entity\Star s WHERE s.user = :userId') ->setParameter('userId', 123) ->execute(); $entityManager->createQuery('DELETE FROM App\Entity\Version v WHERE v.repo IN (:repoIds)') ->setParameter('repoIds', [555, 666]) ->execute(); $user = $entityManager->getReference(User::class, 123); $repo666 = $entityManager->getReference(Repo::class, 666); $repo555 = $entityManager->getReference(Repo::class, 555); $entityManager->persist(new Star($user, $repo666)); $entityManager->persist(new Star($user, $repo555)); $version666 = new Version($repo666); $version666->hydrateFromGithub([ 'tag_name' => '1.0.0', 'name' => 'First release', 'prerelease' => false, 'message' => 'YAY', 'published_at' => '2019-10-15T07:49:21Z', ]); $version555 = new Version($repo555); $version555->hydrateFromGithub([ 'tag_name' => '1.0.21', 'name' => 'First release', 'prerelease' => false, 'message' => 'YAY 555', 'published_at' => '2019-06-15T07:49:21Z', ]); $entityManager->persist($version666); $entityManager->persist($version555); $entityManager->flush(); $entityManager->clear(); } public function testFindForFeedUserExcludesIgnoredStars(): void { $repository = self::getContainer()->get(VersionRepository::class); self::getContainer()->get(Connection::class)->executeStatement('UPDATE star SET ignored_in_feed = 1 WHERE user_id = 123 AND repo_id = 666'); $dashboardVersions = $repository->findForUser(123); $feedVersions = $repository->findForFeedUser(123); $this->assertNotEmpty($dashboardVersions); $this->assertTrue($dashboardVersions[0]['ignoredInFeed']); $this->assertCount(1, $feedVersions); $this->assertSame('symfony/symfony', $feedVersions[0]['fullName']); } } ================================================ FILE: tests/Rss/GeneratorTest.php ================================================ setId(123); $user->setUsername('bob'); $user->setName('Bobby'); $generator = new Generator(); $channel = $generator->generate( $user, [ [ 'homepage' => 'http://homepa.ge', 'language' => 'Thus', 'ownerAvatar' => 'http://avat.ar/mine.png', 'fullName' => 'test/test', 'description' => 'This is an awesome description', 'tagName' => '1.0.0', 'body' => '

yay

', 'createdAt' => (new \DateTime())->setTimestamp(1171502725), ], ], 'http://myfeed.api/.rss' ); $this->assertSame('New releases from starred repo of bob', $channel->getTitle()); $this->assertSame('http://myfeed.api/.rss', $channel->getLink()); $this->assertSame('Here are all the new releases from all repos starred by bob', $channel->getDescription()); $this->assertSame('en', $channel->getLanguage()); $this->assertStringContainsString('(c)', $channel->getCopyright()); $this->assertStringContainsString('banditore', $channel->getCopyright()); $this->assertStringContainsString('15 Feb 2007', $channel->getLastBuildDate()->format('r')); $this->assertSame('banditore', $channel->getGenerator()); $items = $channel->getItems(); $this->assertCount(1, $items); $this->assertSame('test/test 1.0.0', $items[0]->getTitle()); $this->assertSame('https://github.com/test/test/releases/1.0.0', $items[0]->getLink()); $this->assertStringContainsString('test/test', $items[0]->getDescription()); $this->assertStringContainsString('#Thus', $items[0]->getDescription()); $this->assertStringContainsString('

yay

', $items[0]->getDescription()); $this->assertStringContainsString('test/test', $items[0]->getDescription()); $this->assertStringContainsString('(http://homepa.ge)', $items[0]->getDescription()); $this->assertStringContainsString('This is an awesome description', $items[0]->getDescription()); $this->assertSame('https://github.com/test/test/releases/1.0.0', $items[0]->getGuid()->getGuid()); $this->assertTrue($items[0]->getGuid()->getIsPermaLink()); $this->assertStringContainsString('15 Feb 2007', $items[0]->getPubDate()->format('r')); } } ================================================ FILE: tests/Security/GithubAuthenticatorTest.php ================================================ markTestSkipped('Dunno how to mock the session / access it from the container'); $client = static::createClient(); $responses = new MockHandler([ // /login/oauth/access_token (to retrieve the access_token from `authenticate()`) new Response(200, ['Content-Type' => 'application/json'], (string) json_encode([ 'access_token' => 'blablabla', ])), // /api/v3/user (to retrieve user information from Github) new Response(200, ['Content-Type' => 'application/json'], (string) json_encode([ 'id' => 123, 'email' => 'toto@test.io', 'name' => 'Bob', 'login' => 'admin', 'avatar_url' => 'http://avat.ar/my.png', ])), ]); $clientHandler = HandlerStack::create($responses); $guzzleClient = new Client([ 'handler' => $clientHandler, ]); $httpClient = new Guzzle7Client($guzzleClient); $httpBuilder = new Builder($httpClient); $githubClient = new GithubClient($httpBuilder); self::getContainer()->set('banditore.client.github.application', $githubClient); self::getContainer()->get('oauth2.registry')->getClient('github')->getOAuth2Provider()->setHttpClient($guzzleClient); self::getContainer()->get('session')->set(OAuth2Client::OAUTH2_SESSION_STATE_KEY, 'MyAwesomeState'); // before login /** @var User */ $user = self::getContainer()->get(UserRepository::class)->find(123); $this->assertSame('1234567890', $user->getAccessToken()); $this->assertSame('http://0.0.0.0/avatar.jpg', $user->getAvatar()); $client->request('GET', '/callback?state=MyAwesomeState&code=MyAwesomeCode'); // after login /** @var User */ $user = self::getContainer()->get(UserRepository::class)->find(123); $this->assertSame('blablabla', $user->getAccessToken()); $this->assertSame('http://avat.ar/my.png', $user->getAvatar()); $this->assertSame(302, $client->getResponse()->getStatusCode()); /** @var RedirectResponse */ $response = $client->getResponse(); $this->assertSame('/dashboard', $response->getTargetUrl()); $message = self::getContainer()->get('session')->getFlashBag()->get('info'); $this->assertSame('Successfully logged in!', $message[0]); $transport = self::getContainer()->get('messenger.transport.sync_starred_repos'); $this->assertCount(1, $transport->get()); $messages = (array) $transport->get(); /** @var StarredReposSync */ $message = $messages[0]->getMessage(); $this->assertSame(123, $message->getUserId()); } public function testCallbackWithNewUser(): void { $this->markTestSkipped('Dunno how to mock the session / access it from the container'); $client = static::createClient(); $responses = new MockHandler([ // /login/oauth/access_token (to retrieve the access_token from `authenticate()`) new Response(200, ['Content-Type' => 'application/json'], (string) json_encode([ 'access_token' => 'superboum', ])), // /api/v3/user (to retrieve user information from Github) new Response(200, ['Content-Type' => 'application/json'], (string) json_encode([ 'id' => 456, 'email' => 'down@g.et', 'name' => 'Any', 'login' => 'getdown', 'avatar_url' => 'http://avat.ar/down.png', ])), ]); $clientHandler = HandlerStack::create($responses); $guzzleClient = new Client([ 'handler' => $clientHandler, ]); $httpClient = new Guzzle7Client($guzzleClient); $httpBuilder = new Builder($httpClient); $githubClient = new GithubClient($httpBuilder); self::getContainer()->set('banditore.client.github.application', $githubClient); self::getContainer()->get('oauth2.registry')->getClient('github')->getOAuth2Provider()->setHttpClient($guzzleClient); self::getContainer()->get('session')->set(OAuth2Client::OAUTH2_SESSION_STATE_KEY, 'MyAwesomeState'); // before login $user = self::getContainer()->get(UserRepository::class)->find(456); $this->assertNull($user, 'User 456 does not YET exist'); $client->request('GET', '/callback?state=MyAwesomeState&code=MyAwesomeCode'); // after login /** @var User */ $user = self::getContainer()->get(UserRepository::class)->find(456); $this->assertSame('superboum', $user->getAccessToken()); $this->assertSame('http://avat.ar/down.png', $user->getAvatar()); $this->assertSame('getdown', $user->getUsername()); $this->assertSame('Any', $user->getName()); $this->assertSame(302, $client->getResponse()->getStatusCode()); /** @var RedirectResponse */ $response = $client->getResponse(); $this->assertSame('/dashboard', $response->getTargetUrl()); $message = self::getContainer()->get('session')->getFlashBag()->get('info'); $this->assertSame('Successfully logged in. Your starred repos will soon be synced!', $message[0]); $transport = self::getContainer()->get('messenger.transport.sync_starred_repos'); $this->assertCount(1, $transport->get()); $messages = (array) $transport->get(); /** @var StarredReposSync */ $message = $messages[0]->getMessage(); $this->assertSame(456, $message->getUserId()); } } ================================================ FILE: tests/Twig/RepoVersionExtensionTest.php ================================================ assertNull($ext->linkToVersion([])); $this->assertNull($ext->linkToVersion(['fullName' => 'test/test'])); $this->assertNull($ext->linkToVersion(['tagName' => 'v1.0.0'])); $this->assertSame('https://github.com/test/test/releases/v1.0.0', $ext->linkToVersion(['fullName' => 'test/test', 'tagName' => 'v1.0.0'])); } public function testEncodedTagName(): void { $ext = new RepoVersionExtension(); $this->assertNull($ext->linkToVersion([])); $this->assertNull($ext->linkToVersion(['fullName' => 'test/test'])); $this->assertNull($ext->linkToVersion(['tagName' => '@1.0.0-alpha.1'])); $this->assertSame('https://github.com/test/test/releases/%401.0.0-alpha.1', $ext->linkToVersion(['fullName' => 'test/test', 'tagName' => '@1.0.0-alpha.1'])); } } ================================================ FILE: tests/Webfeeds/WebfeedsTest.php ================================================ setLogo('https://upload.wikimedia.org/wikipedia/commons/a/ab/Logo_TV_2015.png') ->setIcon('https://upload.wikimedia.org/wikipedia/commons/a/ab/Logo_TV_2015.png') ->setAccentColor('404040'); $this->assertSame('https://upload.wikimedia.org/wikipedia/commons/a/ab/Logo_TV_2015.png', $webfeeds->getLogo()); $this->assertSame('https://upload.wikimedia.org/wikipedia/commons/a/ab/Logo_TV_2015.png', $webfeeds->getIcon()); $this->assertSame('404040', $webfeeds->getAccentColor()); } } ================================================ FILE: tests/Webfeeds/WebfeedsWriterTest.php ================================================ setLogo('https://upload.wikimedia.org/wikipedia/commons/a/ab/Logo_TV_2015.png') ->setIcon('https://upload.wikimedia.org/wikipedia/commons/a/ab/Logo_TV_2015.png') ->setAccentColor('404040'); $writer->write($rssWriter, $webfeeds); $expected = <<<'EOF' https://upload.wikimedia.org/wikipedia/commons/a/ab/Logo_TV_2015.pnghttps://upload.wikimedia.org/wikipedia/commons/a/ab/Logo_TV_2015.png404040 EOF ; $this->assertSame( $expected, $rssWriter->getXmlWriter()->flush() ); } } ================================================ FILE: tests/bootstrap.php ================================================ bootEnv(dirname(__DIR__) . '/.env'); } if ($_SERVER['APP_DEBUG']) { umask(0000); } ================================================ FILE: tests/console-application.php ================================================ boot(); return $kernel->getContainer()->get('doctrine')->getManager();