From b30af55cc7071b71df2eddfdb711c1e383ecb24b Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Sun, 20 Oct 2024 18:46:42 +0100 Subject: [PATCH] Fix tests --- composer.json | 107 ++++---- composer.lock | 246 +++++++++--------- src/Controllers/Controller.php | 7 +- src/Controllers/ControllerV2.php | 14 +- .../CreateVulnerabilityController.php | 2 +- .../Controllers/Auth/LoginControllerTest.php | 6 - .../Controllers/Auth/LogoutControllerTest.php | 10 +- .../Projects/GetProjectsControllerTest.php | 9 +- .../System/ExportDataControllerTest.php | 11 +- .../System/ImportDataControllerTest.php | 17 +- .../CreateVulnerabilityControllerTest.php | 17 +- tests/Services/ApplicationContainerTest.php | 23 +- 12 files changed, 240 insertions(+), 229 deletions(-) diff --git a/composer.json b/composer.json index 6d181d3..da90798 100644 --- a/composer.json +++ b/composer.json @@ -1,56 +1,57 @@ { - "name": "reconmap/rest-api", - "description": "Reconmap REST API", - "license": "Apache-2.0", - "minimum-stability": "stable", - "prefer-stable": true, - "require": { - "ext-curl": "*", - "ext-dom": "*", - "ext-gd": "*", - "ext-intl": "*", - "ext-json": "*", - "ext-mbstring": "*", - "ext-mysqli": "*", - "ext-mysqlnd": "*", - "ext-redis": "*", - "ext-simplexml": "*", - "ext-zip": "*", - "firebase/php-jwt": "^v6.0", - "geoip2/geoip2": "~3.0", - "graylog2/gelf-php": "dev-master", - "guzzlehttp/guzzle": "^7.2", - "guzzlehttp/psr7": "^2.1", - "league/commonmark": "^2.0", - "league/html-to-markdown": "^5.0", - "league/route": "^5.0", - "monolog/monolog": "^3.0", - "netresearch/jsonmapper": "^5.0", - "php": "^8.3", - "phpoffice/phpword": "^1.0", - "ponup/sql-builders": "^1.0", - "reconmap/command-output-parsers": "^2.0", - "symfony/config": "^7.1", - "symfony/console": "^7", - "symfony/dependency-injection": "^7.1", - "symfony/filesystem": "^7", - "symfony/http-foundation": "^7.1", - "symfony/mailer": "^7", - "symfony/psr-http-message-bridge": "^7.1", - "twig/twig": "^3.0", - "zircote/swagger-php": "^4.7" - }, - "autoload": { - "psr-4": { - "Reconmap\\": "src/" + "type": "project", + "name": "reconmap/rest-api", + "description": "Reconmap REST API", + "license": "Apache-2.0", + "minimum-stability": "stable", + "prefer-stable": true, + "require": { + "ext-curl": "*", + "ext-dom": "*", + "ext-gd": "*", + "ext-intl": "*", + "ext-json": "*", + "ext-mbstring": "*", + "ext-mysqli": "*", + "ext-mysqlnd": "*", + "ext-redis": "*", + "ext-simplexml": "*", + "ext-zip": "*", + "firebase/php-jwt": "^v6.0", + "geoip2/geoip2": "~3.0", + "graylog2/gelf-php": "dev-master", + "guzzlehttp/guzzle": "^7.2", + "guzzlehttp/psr7": "^2.1", + "league/commonmark": "^2.0", + "league/html-to-markdown": "^5.0", + "league/route": "^5.0", + "monolog/monolog": "^3.0", + "netresearch/jsonmapper": "^5.0", + "php": "^8.3", + "phpoffice/phpword": "^1.0", + "ponup/sql-builders": "^1.0", + "reconmap/command-output-parsers": "^2.0", + "symfony/config": "^7.1", + "symfony/console": "^7", + "symfony/dependency-injection": "^7.1", + "symfony/filesystem": "^7", + "symfony/http-foundation": "^7.1", + "symfony/mailer": "^7", + "symfony/psr-http-message-bridge": "^7.1", + "twig/twig": "^3.0", + "zircote/swagger-php": "^4.7" + }, + "autoload": { + "psr-4": { + "Reconmap\\": "src/" + } + }, + "require-dev": { + "phpunit/phpunit": "^11" + }, + "autoload-dev": { + "psr-4": { + "Reconmap\\": "tests/" + } } - }, - "require-dev": { - "phpunit/phpunit": "^11" - }, - "autoload-dev": { - "psr-4": { - "Reconmap\\": "tests/" - } - } } diff --git a/composer.lock b/composer.lock index c8fcff3..cff7d7d 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "composer/ca-bundle", - "version": "1.5.1", + "version": "1.5.2", "source": { "type": "git", "url": "https://github.com/composer/ca-bundle.git", - "reference": "063d9aa8696582f5a41dffbbaf3c81024f0a604a" + "reference": "48a792895a2b7a6ee65dd5442c299d7b835b6137" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/ca-bundle/zipball/063d9aa8696582f5a41dffbbaf3c81024f0a604a", - "reference": "063d9aa8696582f5a41dffbbaf3c81024f0a604a", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/48a792895a2b7a6ee65dd5442c299d7b835b6137", + "reference": "48a792895a2b7a6ee65dd5442c299d7b835b6137", "shasum": "" }, "require": { @@ -27,8 +27,8 @@ }, "require-dev": { "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^8 || ^9", "psr/log": "^1.0 || ^2.0 || ^3.0", - "symfony/phpunit-bridge": "^4.2 || ^5", "symfony/process": "^4.0 || ^5.0 || ^6.0 || ^7.0" }, "type": "library", @@ -64,7 +64,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/ca-bundle/issues", - "source": "https://github.com/composer/ca-bundle/tree/1.5.1" + "source": "https://github.com/composer/ca-bundle/tree/1.5.2" }, "funding": [ { @@ -80,7 +80,7 @@ "type": "tidelift" } ], - "time": "2024-07-08T15:28:20+00:00" + "time": "2024-09-25T07:49:53+00:00" }, { "name": "dflydev/dot-access-data", @@ -607,16 +607,16 @@ }, { "name": "guzzlehttp/promises", - "version": "2.0.3", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8" + "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8", - "reference": "6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8", + "url": "https://api.github.com/repos/guzzle/promises/zipball/f9c436286ab2892c7db7be8c8da4ef61ccf7b455", + "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455", "shasum": "" }, "require": { @@ -670,7 +670,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/2.0.3" + "source": "https://github.com/guzzle/promises/tree/2.0.4" }, "funding": [ { @@ -686,7 +686,7 @@ "type": "tidelift" } ], - "time": "2024-07-18T10:29:17+00:00" + "time": "2024-10-17T10:06:22+00:00" }, { "name": "guzzlehttp/psr7", @@ -1440,24 +1440,24 @@ }, { "name": "nette/schema", - "version": "v1.3.0", + "version": "v1.3.2", "source": { "type": "git", "url": "https://github.com/nette/schema.git", - "reference": "a6d3a6d1f545f01ef38e60f375d1cf1f4de98188" + "reference": "da801d52f0354f70a638673c4a0f04e16529431d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/schema/zipball/a6d3a6d1f545f01ef38e60f375d1cf1f4de98188", - "reference": "a6d3a6d1f545f01ef38e60f375d1cf1f4de98188", + "url": "https://api.github.com/repos/nette/schema/zipball/da801d52f0354f70a638673c4a0f04e16529431d", + "reference": "da801d52f0354f70a638673c4a0f04e16529431d", "shasum": "" }, "require": { "nette/utils": "^4.0", - "php": "8.1 - 8.3" + "php": "8.1 - 8.4" }, "require-dev": { - "nette/tester": "^2.4", + "nette/tester": "^2.5.2", "phpstan/phpstan-nette": "^1.0", "tracy/tracy": "^2.8" }, @@ -1496,9 +1496,9 @@ ], "support": { "issues": "https://github.com/nette/schema/issues", - "source": "https://github.com/nette/schema/tree/v1.3.0" + "source": "https://github.com/nette/schema/tree/v1.3.2" }, - "time": "2023-12-11T11:54:22+00:00" + "time": "2024-10-06T23:10:23+00:00" }, { "name": "nette/utils", @@ -2547,16 +2547,16 @@ }, { "name": "symfony/console", - "version": "v7.1.4", + "version": "v7.1.5", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "1eed7af6961d763e7832e874d7f9b21c3ea9c111" + "reference": "0fa539d12b3ccf068a722bbbffa07ca7079af9ee" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/1eed7af6961d763e7832e874d7f9b21c3ea9c111", - "reference": "1eed7af6961d763e7832e874d7f9b21c3ea9c111", + "url": "https://api.github.com/repos/symfony/console/zipball/0fa539d12b3ccf068a722bbbffa07ca7079af9ee", + "reference": "0fa539d12b3ccf068a722bbbffa07ca7079af9ee", "shasum": "" }, "require": { @@ -2620,7 +2620,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.1.4" + "source": "https://github.com/symfony/console/tree/v7.1.5" }, "funding": [ { @@ -2636,20 +2636,20 @@ "type": "tidelift" } ], - "time": "2024-08-15T22:48:53+00:00" + "time": "2024-09-20T08:28:38+00:00" }, { "name": "symfony/dependency-injection", - "version": "v7.1.4", + "version": "v7.1.5", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "5320e0bc2c9e2d7450bb4091e497a305a68b28ed" + "reference": "38465f925ec4e0707b090e9147c65869837d639d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/5320e0bc2c9e2d7450bb4091e497a305a68b28ed", - "reference": "5320e0bc2c9e2d7450bb4091e497a305a68b28ed", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/38465f925ec4e0707b090e9147c65869837d639d", + "reference": "38465f925ec4e0707b090e9147c65869837d639d", "shasum": "" }, "require": { @@ -2700,7 +2700,7 @@ "description": "Allows you to standardize and centralize the way objects are constructed in your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/dependency-injection/tree/v7.1.4" + "source": "https://github.com/symfony/dependency-injection/tree/v7.1.5" }, "funding": [ { @@ -2716,7 +2716,7 @@ "type": "tidelift" } ], - "time": "2024-08-29T08:16:25+00:00" + "time": "2024-09-20T08:28:38+00:00" }, { "name": "symfony/deprecation-contracts", @@ -2943,16 +2943,16 @@ }, { "name": "symfony/filesystem", - "version": "v7.1.2", + "version": "v7.1.5", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "92a91985250c251de9b947a14bb2c9390b1a562c" + "reference": "61fe0566189bf32e8cfee78335d8776f64a66f5a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/92a91985250c251de9b947a14bb2c9390b1a562c", - "reference": "92a91985250c251de9b947a14bb2c9390b1a562c", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/61fe0566189bf32e8cfee78335d8776f64a66f5a", + "reference": "61fe0566189bf32e8cfee78335d8776f64a66f5a", "shasum": "" }, "require": { @@ -2989,7 +2989,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v7.1.2" + "source": "https://github.com/symfony/filesystem/tree/v7.1.5" }, "funding": [ { @@ -3005,7 +3005,7 @@ "type": "tidelift" } ], - "time": "2024-06-28T10:03:55+00:00" + "time": "2024-09-17T09:16:35+00:00" }, { "name": "symfony/finder", @@ -3073,16 +3073,16 @@ }, { "name": "symfony/http-foundation", - "version": "v7.1.3", + "version": "v7.1.5", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "f602d5c17d1fa02f8019ace2687d9d136b7f4a1a" + "reference": "e30ef73b1e44eea7eb37ba69600a354e553f694b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/f602d5c17d1fa02f8019ace2687d9d136b7f4a1a", - "reference": "f602d5c17d1fa02f8019ace2687d9d136b7f4a1a", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/e30ef73b1e44eea7eb37ba69600a354e553f694b", + "reference": "e30ef73b1e44eea7eb37ba69600a354e553f694b", "shasum": "" }, "require": { @@ -3130,7 +3130,7 @@ "description": "Defines an object-oriented layer for the HTTP specification", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-foundation/tree/v7.1.3" + "source": "https://github.com/symfony/http-foundation/tree/v7.1.5" }, "funding": [ { @@ -3146,20 +3146,20 @@ "type": "tidelift" } ], - "time": "2024-07-26T12:41:01+00:00" + "time": "2024-09-20T08:28:38+00:00" }, { "name": "symfony/mailer", - "version": "v7.1.2", + "version": "v7.1.5", "source": { "type": "git", "url": "https://github.com/symfony/mailer.git", - "reference": "8fcff0af9043c8f8a8e229437cea363e282f9aee" + "reference": "bbf21460c56f29810da3df3e206e38dfbb01e80b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mailer/zipball/8fcff0af9043c8f8a8e229437cea363e282f9aee", - "reference": "8fcff0af9043c8f8a8e229437cea363e282f9aee", + "url": "https://api.github.com/repos/symfony/mailer/zipball/bbf21460c56f29810da3df3e206e38dfbb01e80b", + "reference": "bbf21460c56f29810da3df3e206e38dfbb01e80b", "shasum": "" }, "require": { @@ -3210,7 +3210,7 @@ "description": "Helps sending emails", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/mailer/tree/v7.1.2" + "source": "https://github.com/symfony/mailer/tree/v7.1.5" }, "funding": [ { @@ -3226,20 +3226,20 @@ "type": "tidelift" } ], - "time": "2024-06-28T08:00:31+00:00" + "time": "2024-09-08T12:32:26+00:00" }, { "name": "symfony/mime", - "version": "v7.1.4", + "version": "v7.1.5", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "ccaa6c2503db867f472a587291e764d6a1e58758" + "reference": "711d2e167e8ce65b05aea6b258c449671cdd38ff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/ccaa6c2503db867f472a587291e764d6a1e58758", - "reference": "ccaa6c2503db867f472a587291e764d6a1e58758", + "url": "https://api.github.com/repos/symfony/mime/zipball/711d2e167e8ce65b05aea6b258c449671cdd38ff", + "reference": "711d2e167e8ce65b05aea6b258c449671cdd38ff", "shasum": "" }, "require": { @@ -3294,7 +3294,7 @@ "mime-type" ], "support": { - "source": "https://github.com/symfony/mime/tree/v7.1.4" + "source": "https://github.com/symfony/mime/tree/v7.1.5" }, "funding": [ { @@ -3310,7 +3310,7 @@ "type": "tidelift" } ], - "time": "2024-08-13T14:28:19+00:00" + "time": "2024-09-20T08:28:38+00:00" }, { "name": "symfony/polyfill-ctype", @@ -4113,16 +4113,16 @@ }, { "name": "symfony/string", - "version": "v7.1.4", + "version": "v7.1.5", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "6cd670a6d968eaeb1c77c2e76091c45c56bc367b" + "reference": "d66f9c343fa894ec2037cc928381df90a7ad4306" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/6cd670a6d968eaeb1c77c2e76091c45c56bc367b", - "reference": "6cd670a6d968eaeb1c77c2e76091c45c56bc367b", + "url": "https://api.github.com/repos/symfony/string/zipball/d66f9c343fa894ec2037cc928381df90a7ad4306", + "reference": "d66f9c343fa894ec2037cc928381df90a7ad4306", "shasum": "" }, "require": { @@ -4180,7 +4180,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v7.1.4" + "source": "https://github.com/symfony/string/tree/v7.1.5" }, "funding": [ { @@ -4196,7 +4196,7 @@ "type": "tidelift" } ], - "time": "2024-08-12T09:59:40+00:00" + "time": "2024-09-20T08:28:38+00:00" }, { "name": "symfony/var-exporter", @@ -4276,16 +4276,16 @@ }, { "name": "symfony/yaml", - "version": "v7.1.4", + "version": "v7.1.5", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "92e080b851c1c655c786a2da77f188f2dccd0f4b" + "reference": "4e561c316e135e053bd758bf3b3eb291d9919de4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/92e080b851c1c655c786a2da77f188f2dccd0f4b", - "reference": "92e080b851c1c655c786a2da77f188f2dccd0f4b", + "url": "https://api.github.com/repos/symfony/yaml/zipball/4e561c316e135e053bd758bf3b3eb291d9919de4", + "reference": "4e561c316e135e053bd758bf3b3eb291d9919de4", "shasum": "" }, "require": { @@ -4327,7 +4327,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v7.1.4" + "source": "https://github.com/symfony/yaml/tree/v7.1.5" }, "funding": [ { @@ -4343,7 +4343,7 @@ "type": "tidelift" } ], - "time": "2024-08-12T09:59:40+00:00" + "time": "2024-09-17T12:49:58+00:00" }, { "name": "twig/twig", @@ -4426,16 +4426,16 @@ }, { "name": "zircote/swagger-php", - "version": "4.10.6", + "version": "4.11.0", "source": { "type": "git", "url": "https://github.com/zircote/swagger-php.git", - "reference": "e462ff5269ea0ec91070edd5d51dc7215bdea3b6" + "reference": "3b6f3800f4fd6544ada4dce180c6b69eaead7c7c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zircote/swagger-php/zipball/e462ff5269ea0ec91070edd5d51dc7215bdea3b6", - "reference": "e462ff5269ea0ec91070edd5d51dc7215bdea3b6", + "url": "https://api.github.com/repos/zircote/swagger-php/zipball/3b6f3800f4fd6544ada4dce180c6b69eaead7c7c", + "reference": "3b6f3800f4fd6544ada4dce180c6b69eaead7c7c", "shasum": "" }, "require": { @@ -4449,7 +4449,7 @@ "require-dev": { "composer/package-versions-deprecated": "^1.11", "doctrine/annotations": "^1.7 || ^2.0", - "friendsofphp/php-cs-fixer": "^2.17 || ^3.47.1", + "friendsofphp/php-cs-fixer": "^2.17 || 3.62.0", "phpstan/phpstan": "^1.6", "phpunit/phpunit": ">=8", "vimeo/psalm": "^4.23" @@ -4501,9 +4501,9 @@ ], "support": { "issues": "https://github.com/zircote/swagger-php/issues", - "source": "https://github.com/zircote/swagger-php/tree/4.10.6" + "source": "https://github.com/zircote/swagger-php/tree/4.11.0" }, - "time": "2024-07-26T03:04:43+00:00" + "time": "2024-10-09T03:11:12+00:00" } ], "packages-dev": [ @@ -4569,16 +4569,16 @@ }, { "name": "nikic/php-parser", - "version": "v5.1.0", + "version": "v5.3.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "683130c2ff8c2739f4822ff7ac5c873ec529abd1" + "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/683130c2ff8c2739f4822ff7ac5c873ec529abd1", - "reference": "683130c2ff8c2739f4822ff7ac5c873ec529abd1", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/8eea230464783aa9671db8eea6f8c6ac5285794b", + "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b", "shasum": "" }, "require": { @@ -4621,9 +4621,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.1.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.3.1" }, - "time": "2024-07-01T20:03:41+00:00" + "time": "2024-10-08T18:51:32+00:00" }, { "name": "phar-io/manifest", @@ -4745,35 +4745,35 @@ }, { "name": "phpunit/php-code-coverage", - "version": "11.0.6", + "version": "11.0.7", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "ebdffc9e09585dafa71b9bffcdb0a229d4704c45" + "reference": "f7f08030e8811582cc459871d28d6f5a1a4d35ca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ebdffc9e09585dafa71b9bffcdb0a229d4704c45", - "reference": "ebdffc9e09585dafa71b9bffcdb0a229d4704c45", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f7f08030e8811582cc459871d28d6f5a1a4d35ca", + "reference": "f7f08030e8811582cc459871d28d6f5a1a4d35ca", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^5.1.0", + "nikic/php-parser": "^5.3.1", "php": ">=8.2", - "phpunit/php-file-iterator": "^5.0.1", + "phpunit/php-file-iterator": "^5.1.0", "phpunit/php-text-template": "^4.0.1", "sebastian/code-unit-reverse-lookup": "^4.0.1", "sebastian/complexity": "^4.0.1", "sebastian/environment": "^7.2.0", "sebastian/lines-of-code": "^3.0.1", - "sebastian/version": "^5.0.1", + "sebastian/version": "^5.0.2", "theseer/tokenizer": "^1.2.3" }, "require-dev": { - "phpunit/phpunit": "^11.0" + "phpunit/phpunit": "^11.4.1" }, "suggest": { "ext-pcov": "PHP extension that provides line coverage", @@ -4811,7 +4811,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/11.0.6" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/11.0.7" }, "funding": [ { @@ -4819,7 +4819,7 @@ "type": "github" } ], - "time": "2024-08-22T04:37:56+00:00" + "time": "2024-10-09T06:21:38+00:00" }, { "name": "phpunit/php-file-iterator", @@ -5068,16 +5068,16 @@ }, { "name": "phpunit/phpunit", - "version": "11.3.5", + "version": "11.4.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "4dc07a589a68f8f2d5132ac0849146d122e08347" + "reference": "1863643c3f04ad03dcb9c6996c294784cdda4805" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4dc07a589a68f8f2d5132ac0849146d122e08347", - "reference": "4dc07a589a68f8f2d5132ac0849146d122e08347", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1863643c3f04ad03dcb9c6996c294784cdda4805", + "reference": "1863643c3f04ad03dcb9c6996c294784cdda4805", "shasum": "" }, "require": { @@ -5091,21 +5091,21 @@ "phar-io/manifest": "^2.0.4", "phar-io/version": "^3.2.1", "php": ">=8.2", - "phpunit/php-code-coverage": "^11.0.6", + "phpunit/php-code-coverage": "^11.0.7", "phpunit/php-file-iterator": "^5.1.0", "phpunit/php-invoker": "^5.0.1", "phpunit/php-text-template": "^4.0.1", "phpunit/php-timer": "^7.0.1", "sebastian/cli-parser": "^3.0.2", "sebastian/code-unit": "^3.0.1", - "sebastian/comparator": "^6.1.0", + "sebastian/comparator": "^6.1.1", "sebastian/diff": "^6.0.2", "sebastian/environment": "^7.2.0", "sebastian/exporter": "^6.1.3", "sebastian/global-state": "^7.0.2", "sebastian/object-enumerator": "^6.0.1", - "sebastian/type": "^5.0.1", - "sebastian/version": "^5.0.1" + "sebastian/type": "^5.1.0", + "sebastian/version": "^5.0.2" }, "suggest": { "ext-soap": "To be able to generate mocks based on WSDL files" @@ -5116,7 +5116,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "11.3-dev" + "dev-main": "11.4-dev" } }, "autoload": { @@ -5148,7 +5148,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/11.3.5" + "source": "https://github.com/sebastianbergmann/phpunit/tree/11.4.2" }, "funding": [ { @@ -5164,7 +5164,7 @@ "type": "tidelift" } ], - "time": "2024-09-13T05:22:17+00:00" + "time": "2024-10-19T13:05:19+00:00" }, { "name": "sebastian/cli-parser", @@ -5338,16 +5338,16 @@ }, { "name": "sebastian/comparator", - "version": "6.1.0", + "version": "6.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "fa37b9e2ca618cb051d71b60120952ee8ca8b03d" + "reference": "5ef523a49ae7a302b87b2102b72b1eda8918d686" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa37b9e2ca618cb051d71b60120952ee8ca8b03d", - "reference": "fa37b9e2ca618cb051d71b60120952ee8ca8b03d", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5ef523a49ae7a302b87b2102b72b1eda8918d686", + "reference": "5ef523a49ae7a302b87b2102b72b1eda8918d686", "shasum": "" }, "require": { @@ -5403,7 +5403,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", "security": "https://github.com/sebastianbergmann/comparator/security/policy", - "source": "https://github.com/sebastianbergmann/comparator/tree/6.1.0" + "source": "https://github.com/sebastianbergmann/comparator/tree/6.1.1" }, "funding": [ { @@ -5411,7 +5411,7 @@ "type": "github" } ], - "time": "2024-09-11T15:42:56+00:00" + "time": "2024-10-18T15:00:48+00:00" }, { "name": "sebastian/complexity", @@ -5980,28 +5980,28 @@ }, { "name": "sebastian/type", - "version": "5.0.1", + "version": "5.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "fb6a6566f9589e86661291d13eba708cce5eb4aa" + "reference": "461b9c5da241511a2a0e8f240814fb23ce5c0aac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb6a6566f9589e86661291d13eba708cce5eb4aa", - "reference": "fb6a6566f9589e86661291d13eba708cce5eb4aa", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/461b9c5da241511a2a0e8f240814fb23ce5c0aac", + "reference": "461b9c5da241511a2a0e8f240814fb23ce5c0aac", "shasum": "" }, "require": { "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^11.0" + "phpunit/phpunit": "^11.3" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.0-dev" + "dev-main": "5.1-dev" } }, "autoload": { @@ -6025,7 +6025,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/type/issues", "security": "https://github.com/sebastianbergmann/type/security/policy", - "source": "https://github.com/sebastianbergmann/type/tree/5.0.1" + "source": "https://github.com/sebastianbergmann/type/tree/5.1.0" }, "funding": [ { @@ -6033,20 +6033,20 @@ "type": "github" } ], - "time": "2024-07-03T05:11:49+00:00" + "time": "2024-09-17T13:12:04+00:00" }, { "name": "sebastian/version", - "version": "5.0.1", + "version": "5.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "45c9debb7d039ce9b97de2f749c2cf5832a06ac4" + "reference": "c687e3387b99f5b03b6caa64c74b63e2936ff874" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/45c9debb7d039ce9b97de2f749c2cf5832a06ac4", - "reference": "45c9debb7d039ce9b97de2f749c2cf5832a06ac4", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c687e3387b99f5b03b6caa64c74b63e2936ff874", + "reference": "c687e3387b99f5b03b6caa64c74b63e2936ff874", "shasum": "" }, "require": { @@ -6079,7 +6079,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/version/issues", "security": "https://github.com/sebastianbergmann/version/security/policy", - "source": "https://github.com/sebastianbergmann/version/tree/5.0.1" + "source": "https://github.com/sebastianbergmann/version/tree/5.0.2" }, "funding": [ { @@ -6087,7 +6087,7 @@ "type": "github" } ], - "time": "2024-07-03T05:13:08+00:00" + "time": "2024-10-09T05:16:32+00:00" }, { "name": "theseer/tokenizer", diff --git a/src/Controllers/Controller.php b/src/Controllers/Controller.php index fd08622..f58a44c 100644 --- a/src/Controllers/Controller.php +++ b/src/Controllers/Controller.php @@ -28,10 +28,15 @@ public function getJsonBodyDecoded(ServerRequestInterface $request): object } public function getJsonBodyDecodedAsClass(ServerRequestInterface $request, object $instance, bool $strictNullTypes = true): object + { + return $this->getJsonAsClass($this->getJsonBodyDecoded($request), $instance, $strictNullTypes); + } + + public function getJsonAsClass(array|object $json, object $instance, bool $strictNullTypes = true): object { $jsonMapper = new \JsonMapper(); $jsonMapper->bStrictNullTypes = $strictNullTypes; - $object = $jsonMapper->map($this->getJsonBodyDecoded($request), $instance); + $object = $jsonMapper->map($json, $instance); if ($object instanceof Cleanable) { $object->clean(); } diff --git a/src/Controllers/ControllerV2.php b/src/Controllers/ControllerV2.php index 224d87d..cf81c14 100644 --- a/src/Controllers/ControllerV2.php +++ b/src/Controllers/ControllerV2.php @@ -9,13 +9,15 @@ abstract class ControllerV2 extends Controller { + private AuthorisationService $authorisationService; + public function __invoke(ServerRequestInterface $serverRequest, array $args): ResponseInterface { $applicationRequest = new ApplicationRequest($serverRequest, $args); $user = $applicationRequest->getUser(); /** @var AuthorisationService $authorisationService */ - $authorisationService = new AuthorisationService(); + $authorisationService = $this->getAuthorisationService(); if (!$authorisationService->isRoleAllowed($user->role, $this->getPermissionRequired())) { return $this->createForbiddenResponse(); } @@ -23,6 +25,16 @@ public function __invoke(ServerRequestInterface $serverRequest, array $args): Re return $this->process($applicationRequest); } + public function setAuthorisationService(AuthorisationService $authorisationService): void + { + $this->authorisationService = $authorisationService; + } + + private function getAuthorisationService(): AuthorisationService + { + return $this->authorisationService ?? new AuthorisationService(); + } + protected function getPermissionRequired(): string { return '*.*'; diff --git a/src/Controllers/Vulnerabilities/CreateVulnerabilityController.php b/src/Controllers/Vulnerabilities/CreateVulnerabilityController.php index 037e48d..f4bf582 100644 --- a/src/Controllers/Vulnerabilities/CreateVulnerabilityController.php +++ b/src/Controllers/Vulnerabilities/CreateVulnerabilityController.php @@ -23,7 +23,7 @@ public function __invoke(ServerRequestInterface $request): ResponseInterface $customFields = array_filter($body, fn($v, $k) => in_array($k, $customFieldNames), ARRAY_FILTER_USE_BOTH); /** @var Vulnerability $vulnerability */ - $vulnerability = $this->getJsonBodyDecodedAsClass($request, new Vulnerability(), false); + $vulnerability = $this->getJsonAsClass((object)$body, new Vulnerability(), false); $vulnerability->custom_fields = json_encode($customFields); $vulnerability->creator_uid = $request->getAttribute('userId'); $vulnerability->id = $this->repository->insert($vulnerability); diff --git a/tests/Controllers/Auth/LoginControllerTest.php b/tests/Controllers/Auth/LoginControllerTest.php index a620a40..ecd8e51 100644 --- a/tests/Controllers/Auth/LoginControllerTest.php +++ b/tests/Controllers/Auth/LoginControllerTest.php @@ -38,14 +38,8 @@ public function testLogin() ->willReturn(['key' => 'aaa']); $mockAuthorisationService = $this->createMock(AuthorisationService::class); - $mockAuthorisationService->expects($this->once()) - ->method('isRoleAllowed') - ->willReturn(true); $mockContainer = $this->createMock(Container::class); - $mockContainer->expects($this->once()) - ->method('get') - ->willReturn($mockAuthorisationService); $mockAuditLogService = $this->createMock(AuditLogService::class); $mockJwtPayloadCreator = $this->createMock(JwtPayloadCreator::class); diff --git a/tests/Controllers/Auth/LogoutControllerTest.php b/tests/Controllers/Auth/LogoutControllerTest.php index 2ff0618..71a8091 100644 --- a/tests/Controllers/Auth/LogoutControllerTest.php +++ b/tests/Controllers/Auth/LogoutControllerTest.php @@ -8,7 +8,7 @@ use Reconmap\Models\AuditActions\UserAuditActions; use Reconmap\Services\AuditLogService; use Reconmap\Services\Security\AuthorisationService; -use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpFoundation\Response; class LogoutControllerTest extends TestCase { @@ -27,19 +27,15 @@ public function testLogout() ->method('isRoleAllowed') ->willReturn(true); - $mockContainer = $this->createMock(ContainerInterface::class); - $mockContainer->expects($this->once()) - ->method('get') - ->willReturn($mockAuthorisationService); - $mockAuditLogService = $this->createMock(AuditLogService::class); $mockAuditLogService->expects($this->once()) ->method('insert') ->with(509, UserAuditActions::USER_LOGGED_OUT); $controller = new LogoutController($mockAuditLogService); + $controller->setAuthorisationService($mockAuthorisationService); $response = $controller($mockRequest, []); - $this->assertEquals(\Symfony\Component\HttpFoundation\Response::HTTP_OK, $response->getStatusCode()); + $this->assertEquals(Response::HTTP_OK, $response->getStatusCode()); } } diff --git a/tests/Controllers/Projects/GetProjectsControllerTest.php b/tests/Controllers/Projects/GetProjectsControllerTest.php index 6468ff4..6bd3573 100644 --- a/tests/Controllers/Projects/GetProjectsControllerTest.php +++ b/tests/Controllers/Projects/GetProjectsControllerTest.php @@ -7,6 +7,7 @@ use Reconmap\ConsecutiveParamsTrait; use Reconmap\Repositories\ProjectRepository; use Reconmap\Repositories\SearchCriterias\ProjectSearchCriteria; +use Symfony\Component\EventDispatcher\EventDispatcher; class GetProjectsControllerTest extends TestCase { @@ -35,7 +36,9 @@ public function testGetRegularProjects() ->with($searchCriteria) ->willReturn($mockProjects); - $controller = new GetProjectsController($mockRepository, $searchCriteria); + $mockEventDispatcher = $this->createMock(EventDispatcher::class); + + $controller = new GetProjectsController($mockRepository, $searchCriteria, $mockEventDispatcher); $response = $controller($mockRequest); $this->assertEquals(json_encode($mockProjects), (string)$response->getBody()); @@ -64,7 +67,9 @@ public function testGetProjectTemplates() ->with($searchCriteria) ->willReturn($mockProjects); - $controller = new GetProjectsController($mockRepository, $searchCriteria); + $mockEventDispatcher = $this->createMock(EventDispatcher::class); + + $controller = new GetProjectsController($mockRepository, $searchCriteria, $mockEventDispatcher); $response = $controller($mockRequest); $this->assertEquals(json_encode($mockProjects), (string)$response->getBody()); diff --git a/tests/Controllers/System/ExportDataControllerTest.php b/tests/Controllers/System/ExportDataControllerTest.php index 18776ff..cf9b3be 100644 --- a/tests/Controllers/System/ExportDataControllerTest.php +++ b/tests/Controllers/System/ExportDataControllerTest.php @@ -3,7 +3,7 @@ namespace Reconmap\Controllers\System; use GuzzleHttp\Psr7\ServerRequest; -use League\Container\Container; +use Psr\Container\ContainerInterface; use Reconmap\ControllerTestCase; use Reconmap\Repositories\Exporters\ClientsExporter; use Reconmap\Services\AuditLogService; @@ -27,15 +27,14 @@ public function testExport() ->method('export') ->willReturn(['client1']); - $mockContainer = $this->createMock(Container::class); + $mockContainer = $this->createMock(ContainerInterface::class); $mockContainer->expects($this->once()) ->method('get') ->with('Reconmap\Repositories\Exporters\ClientsExporter') ->willReturn($mockClientExporter); /** @var $controller ExportDataController */ - $controller = $this->injectController(new ExportDataController($mockAuditLogService)); - $controller->setContainer($mockContainer); + $controller = $this->injectController(new ExportDataController($mockAuditLogService, $mockContainer)); $response = $controller($request); $this->assertEquals(\Symfony\Component\HttpFoundation\Response::HTTP_OK, $response->getStatusCode()); @@ -55,8 +54,10 @@ public function testExportInvalidEntities() 'entities' => 'passwords' ]); + $mockContainer = $this->createMock(ContainerInterface::class); + /** @var $controller ExportDataController */ - $controller = $this->injectController(new ExportDataController($mockAuditLogService)); + $controller = $this->injectController(new ExportDataController($mockAuditLogService, $mockContainer)); $response = $controller($request); $this->assertEquals(\Symfony\Component\HttpFoundation\Response::HTTP_BAD_REQUEST, $response->getStatusCode()); diff --git a/tests/Controllers/System/ImportDataControllerTest.php b/tests/Controllers/System/ImportDataControllerTest.php index 73c705e..fa93a40 100644 --- a/tests/Controllers/System/ImportDataControllerTest.php +++ b/tests/Controllers/System/ImportDataControllerTest.php @@ -2,9 +2,9 @@ namespace Reconmap\Controllers\System; -use League\Container\Container; use Monolog\Logger; use PHPUnit\Framework\TestCase; +use Psr\Container\ContainerInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\StreamInterface; use Psr\Http\Message\UploadedFileInterface; @@ -35,13 +35,12 @@ public function testEmptyFileReturnsError() $mockProjectImporter->expects($this->never()) ->method('import'); - $mockContainer = $this->createMock(Container::class); + $mockContainer = $this->createMock(ContainerInterface::class); $mockContainer->expects($this->never()) ->method('get'); - $controller = new ImportDataController($mockAuditLogService); + $controller = new ImportDataController($mockAuditLogService, $mockContainer); $controller->setLogger($mockLogger); - $controller->setContainer($mockContainer); $response = $controller($mockRequest); $expectedResponse = [ @@ -79,13 +78,12 @@ public function testInvalidJsonReturnsError() $mockProjectImporter->expects($this->never()) ->method('import'); - $mockContainer = $this->createMock(Container::class); + $mockContainer = $this->createMock(ContainerInterface::class); $mockContainer->expects($this->never()) ->method('get'); - $controller = new ImportDataController($mockAuditLogService); + $controller = new ImportDataController($mockAuditLogService, $mockContainer); $controller->setLogger($mockLogger); - $controller->setContainer($mockContainer); $response = $controller($mockRequest); $expectedResponse = [ @@ -124,14 +122,13 @@ public function testProjectImport() ->method('import') ->willReturn(['count' => 0, 'errors' => []]); - $mockContainer = $this->createMock(Container::class); + $mockContainer = $this->createMock(ContainerInterface::class); $mockContainer->expects($this->once()) ->method('get') ->with(ProjectsImporter::class) ->willReturn($mockProjectImporter); - $controller = new ImportDataController($mockAuditLogService); - $controller->setContainer($mockContainer); + $controller = new ImportDataController($mockAuditLogService, $mockContainer); $response = $controller($mockRequest); $expectedResponse = [ diff --git a/tests/Controllers/Vulnerabilities/CreateVulnerabilityControllerTest.php b/tests/Controllers/Vulnerabilities/CreateVulnerabilityControllerTest.php index a732bed..c5e444c 100644 --- a/tests/Controllers/Vulnerabilities/CreateVulnerabilityControllerTest.php +++ b/tests/Controllers/Vulnerabilities/CreateVulnerabilityControllerTest.php @@ -3,8 +3,10 @@ namespace Reconmap\Controllers\Vulnerabilities; use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Message\StreamInterface; use Reconmap\ControllerTestCase; use Reconmap\Models\Vulnerability; +use Reconmap\Repositories\CustomFieldRepository; use Reconmap\Repositories\VulnerabilityRepository; class CreateVulnerabilityControllerTest extends ControllerTestCase @@ -18,9 +20,13 @@ public function testSuccess(): void ->method('getAttribute') ->with('userId') ->willReturn($userId); - $request->expects($this->once()) + + $mockStream = $this->createMock(StreamInterface::class); + $mockStream->expects($this->any())->method('getContents')->willReturn(json_encode(['project_id' => 1, 'summary' => 'SQL injection', 'risk' => 'low', 'tags' => null])); + + $request->expects($this->atLeastOnce()) ->method('getBody') - ->willReturn(json_encode(['project_id' => 1, 'summary' => 'SQL injection', 'risk' => 'low', 'tags' => null])); + ->willReturn($mockStream); $vulnerability = new Vulnerability(); $vulnerability->project_id = 1; @@ -28,6 +34,7 @@ public function testSuccess(): void $vulnerability->summary = 'SQL injection'; $vulnerability->risk = 'low'; $vulnerability->tags = null; + $vulnerability->custom_fields = '[]'; $mockVulnerabilityRepository = $this->createPartialMock(VulnerabilityRepository::class, ['insert']); $mockVulnerabilityRepository->expects($this->once()) @@ -35,10 +42,12 @@ public function testSuccess(): void ->with($vulnerability) ->willReturn(5); - $controller = $this->injectController(new CreateVulnerabilityController($mockVulnerabilityRepository)); + $mockCustomFieldRepository = $this->createMock(CustomFieldRepository::class); + + $controller = $this->injectController(new CreateVulnerabilityController($mockVulnerabilityRepository, $mockCustomFieldRepository)); $response = $controller($request); $this->assertEquals(\Symfony\Component\HttpFoundation\Response::HTTP_CREATED, $response->getStatusCode()); - $this->assertEquals('{"id":5,"insert_ts":null,"update_ts":null,"creator_uid":1,"is_template":false,"external_id":null,"project_id":1,"target_id":null,"category_id":null,"summary":"SQL injection","external_refs":null,"visibility":"public","risk":"low","proof_of_concept":null,"impact":null,"remediation":null,"remediation_complexity":null,"remediation_priority":null,"cvss_score":null,"cvss_vector":null,"tags":null,"owasp_vector":null,"owasp_likehood":null,"owasp_impact":null,"owasp_overall":null}', (string)$response->getBody()); + $this->assertEquals('{"id":5,"insert_ts":null,"update_ts":null,"creator_uid":1,"is_template":false,"external_id":null,"project_id":1,"target_id":null,"category_id":null,"summary":"SQL injection","description":null,"external_refs":null,"visibility":"public","risk":"low","proof_of_concept":null,"impact":null,"remediation":null,"remediation_complexity":null,"remediation_priority":null,"cvss_score":null,"cvss_vector":null,"tags":null,"owasp_vector":null,"owasp_likehood":null,"owasp_impact":null,"owasp_overall":null,"custom_fields":"[]"}', (string)$response->getBody()); } } diff --git a/tests/Services/ApplicationContainerTest.php b/tests/Services/ApplicationContainerTest.php index 559d5e8..f83973d 100644 --- a/tests/Services/ApplicationContainerTest.php +++ b/tests/Services/ApplicationContainerTest.php @@ -4,11 +4,10 @@ namespace Reconmap\Services; -use League\Container\Inflector\InflectorInterface; -use League\Container\ReflectionContainer; use Monolog\Logger; use PHPUnit\Framework\TestCase; use Reconmap\DatabaseTestCase; +use Symfony\Component\DependencyInjection\ContainerBuilder; class ApplicationContainerTest extends TestCase { @@ -22,20 +21,12 @@ public function testDelegationIsSetup() ->willReturn(DatabaseTestCase::DATABASE_SETTINGS); $logger = $this->createMock(Logger::class); - /** @var ApplicationContainer $container */ - $container = $this->getMockBuilder(ApplicationContainer::class) - ->onlyMethods(['delegate', 'add', 'inflector']) - ->disableOriginalConstructor() - ->getMock(); - $container->expects($this->once()) - ->method('delegate') - ->with($this->isInstanceOf(ReflectionContainer::class)); - $container->expects($this->atLeastOnce()) - ->method('add'); - $container->expects($this->atLeastOnce()) - ->method('inflector') - ->willReturn($this->createMock(InflectorInterface::class)); + /** @var ContainerBuilder $container */ + $mockContainer = $this->createMock(ContainerBuilder::class); + $mockContainer->expects($this->atLeastOnce()) + ->method('set'); - $container->initialise($config, $logger); + $container = new ApplicationContainer(); + $container->initialise($mockContainer, $config, $logger); } }