Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/Console/Commands/QueueSubmissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Console\Commands;

use App\Jobs\ProcessSubmission;
use App\Services\AuthTokenService;
use App\Utils\AuthTokenUtil;
use CDash\Model\Project;

use Illuminate\Console\Command;
Expand Down Expand Up @@ -88,7 +88,7 @@ private function queueFile($inboxFile)
return;
}
$len = $end - $begin;
if (!AuthTokenService::checkToken(substr($filename, $begin, $len), $project->Id)) {
if (!AuthTokenUtil::checkToken(substr($filename, $begin, $len), $project->Id)) {
\Storage::move("inbox/{$filename}", "failed/{$filename}");
echo "Invalid authentication token for $filename\n";
return;
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/AbstractBuildController.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace App\Http\Controllers;

use App\Services\TestingDay;
use App\Utils\TestingDay;
use CDash\Model\Build;
use Illuminate\View\View;

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/AbstractProjectController.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace App\Http\Controllers;

use App\Services\TestingDay;
use App\Utils\TestingDay;
use CDash\Model\Project;
use Illuminate\Support\Facades\Gate;
use Illuminate\View\View;
Expand Down
8 changes: 4 additions & 4 deletions app/Http/Controllers/AuthTokenController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace App\Http\Controllers;

use App\Models\AuthToken;
use App\Services\AuthTokenService;
use App\Utils\AuthTokenUtil;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Auth;
use Illuminate\View\View;
Expand All @@ -25,7 +25,7 @@ public function manage(): View
*/
public function fetchAll(): JsonResponse
{
$token_array = AuthTokenService::getAllTokens();
$token_array = AuthTokenUtil::getAllTokens();
$token_map = [];
foreach ($token_array as $token) {
$token_map[$token['hash']] = $token;
Expand Down Expand Up @@ -55,7 +55,7 @@ public function createToken(Request $request): JsonResponse
}

try {
$gen_auth_token = AuthTokenService::generateToken(
$gen_auth_token = AuthTokenUtil::generateToken(
Auth::id(),
$projectid,
$request->input('scope'),
Expand All @@ -70,7 +70,7 @@ public function createToken(Request $request): JsonResponse

public function deleteToken(string $token_hash): JsonResponse
{
if (!AuthTokenService::deleteToken($token_hash, Auth::id())) {
if (!AuthTokenUtil::deleteToken($token_hash, Auth::id())) {
return response()->json(['error' => 'Permissions error'], status: Response::HTTP_FORBIDDEN);
}
return response()->json('Token deleted');
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/BuildController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

use App\Models\User;
use App\Models\Build as EloquentBuild;
use App\Services\PageTimer;
use App\Services\TestingDay;
use App\Utils\PageTimer;
use App\Utils\TestingDay;
use CDash\Database;
use CDash\Model\Build;
use CDash\Model\BuildConfigure;
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/BuildNoteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use App\Models\Build as EloquentBuild;
use App\Models\Note;
use App\Services\PageTimer;
use App\Services\TestingDay;
use App\Utils\PageTimer;
use App\Utils\TestingDay;
use CDash\Model\Build;
use Illuminate\Http\JsonResponse;

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/BuildPropertiesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Http\Controllers;

use App\Services\PageTimer;
use App\Utils\PageTimer;
use CDash\Database;
use DateInterval;
use DateTime;
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/CoverageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
namespace App\Http\Controllers;

use App\Models\User;
use App\Services\PageTimer;
use App\Services\TestingDay;
use App\Utils\PageTimer;
use App\Utils\TestingDay;
use CDash\Config;
use CDash\Database;
use CDash\Model\Build;
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/DynamicAnalysisController.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
namespace App\Http\Controllers;

use App\Services\PageTimer;
use App\Services\TestingDay;
use App\Utils\PageTimer;
use App\Utils\TestingDay;
use CDash\Model\DynamicAnalysis;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Response;
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ManageMeasurementsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use App\Models\Measurement;
use App\Models\Project as EloquentProject;
use App\Services\PageTimer;
use App\Utils\PageTimer;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Gate;

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace App\Http\Controllers;

use App\Services\PageTimer;
use App\Utils\PageTimer;
use CDash\Config;
use CDash\Model\Project;
use CDash\Model\Repository;
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ProjectOverviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Http\Controllers;

use App\Services\PageTimer;
use App\Utils\PageTimer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB;
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/SiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use App\Models\Site;
use App\Models\User;
use App\Services\TestingDay;
use App\Utils\TestingDay;
use CDash\Database;
use CDash\Model\Project;
use Illuminate\Http\RedirectResponse;
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/SubProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use App\Models\Banner;
use App\Models\User;
use App\Services\PageTimer;
use App\Utils\PageTimer;
use CDash\Model\SubProject;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
Expand Down
10 changes: 5 additions & 5 deletions app/Http/Controllers/SubmissionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use App\Jobs\ProcessSubmission;
use App\Models\Site;
use App\Services\AuthTokenService;
use App\Services\UnparsedSubmissionProcessor;
use App\Utils\AuthTokenUtil;
use App\Utils\UnparsedSubmissionProcessor;
use CDash\Model\Build;
use CDash\Model\PendingSubmissions;
use CDash\Model\Project;
Expand Down Expand Up @@ -75,8 +75,8 @@ private function submitProcess(): Response
}

// Get auth token (if any).
$authtoken = AuthTokenService::getBearerToken();
$authtoken_hash = $authtoken === null || $authtoken === '' ? '' : AuthTokenService::hashToken($authtoken);
$authtoken = AuthTokenUtil::getBearerToken();
$authtoken_hash = $authtoken === null || $authtoken === '' ? '' : AuthTokenUtil::hashToken($authtoken);

// Save the incoming file in the inbox directory.
$filename = "{$projectname}_-_{$authtoken_hash}_-_" . Str::uuid()->toString() . "_-_{$expected_md5}.xml";
Expand Down Expand Up @@ -115,7 +115,7 @@ private function submitProcess(): Response
$this->project->CheckForTooManyBuilds();

// Check for valid authentication token if this project requires one.
if ($this->project->AuthenticateSubmissions && !AuthTokenService::checkToken($authtoken_hash, $this->project->Id)) {
if ($this->project->AuthenticateSubmissions && !AuthTokenUtil::checkToken($authtoken_hash, $this->project->Id)) {
Storage::delete("inbox/{$filename}");
abort(Response::HTTP_FORBIDDEN, 'Invalid Token');
} elseif (intval($this->project->Id) < 1) {
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/TestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace App\Http\Controllers;

use App\Models\BuildTest;
use App\Services\PageTimer;
use App\Utils\PageTimer;
use CDash\Database;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Response;
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
namespace App\Http\Controllers;

use App\Models\User;
use App\Services\AuthTokenService;
use App\Services\PageTimer;
use App\Utils\AuthTokenUtil;
use App\Utils\PageTimer;
use App\Validators\Password;
use CDash\Config;
use CDash\Database;
Expand Down Expand Up @@ -89,7 +89,7 @@ public function userPageContent(): JsonResponse
}
$response['projects'] = $projects_response;

$response['authtokens'] = AuthTokenService::getTokensForUser($userid);
$response['authtokens'] = AuthTokenUtil::getTokensForUser($userid);
$response['allow_full_access_tokens'] = config('cdash.allow_full_access_tokens') === true;
$response['allow_submit_only_tokens'] = config('cdash.allow_submit_only_tokens') === true;

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/UserStatisticsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace App\Http\Controllers;

use App\Models\User;
use App\Services\PageTimer;
use App\Utils\PageTimer;
use Illuminate\Http\JsonResponse;

final class UserStatisticsController extends AbstractProjectController
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Middleware/AuthenticateToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Http\Middleware;

use App\Services\AuthTokenService;
use App\Utils\AuthTokenUtil;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
Expand All @@ -19,7 +19,7 @@ class AuthenticateToken
*/
public function handle(Request $request, Closure $next)
{
$user_id = AuthTokenService::getUserIdFromRequest();
$user_id = AuthTokenUtil::getUserIdFromRequest();
if ($user_id !== null) {
Auth::loginUsingId($user_id);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/ProcessSubmission.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Jobs;

use App\Services\UnparsedSubmissionProcessor;
use App\Utils\UnparsedSubmissionProcessor;
use App\Models\SuccessfulJob;

use BuildPropertiesJSONHandler;
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use App\Models\Test;
use App\Models\TestImage;
use App\Models\User;
use App\Services\ProjectPermissions;
use App\Utils\ProjectPermissions;
use CDash\Model\Image;
use CDash\Model\Project;
use Illuminate\Auth\Access\Response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace App\Services;
namespace App\Utils;

use App\Models\AuthToken;
use App\Models\User;
Expand All @@ -16,7 +16,7 @@
use Illuminate\Support\Facades\Auth;
use RuntimeException;

class AuthTokenService
class AuthTokenUtil
{
/**
* Contract: we assume that $user_id has already been validated and blindly create a token
Expand Down
2 changes: 1 addition & 1 deletion app/Services/NoteCreator.php → app/Utils/NoteCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/

namespace App\Services;
namespace App\Utils;

use App\Models\Note;

Expand Down
2 changes: 1 addition & 1 deletion app/Services/PageTimer.php → app/Utils/PageTimer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/

namespace App\Services;
namespace App\Utils;

/**
* This class handles page load time calculations, reporting, and logging.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

declare(strict_types=1);

namespace App\Services;
namespace App\Utils;

use CDash\Model\Project;
use CDash\Model\UserProject;
Expand Down
2 changes: 1 addition & 1 deletion app/Services/TestCreator.php → app/Utils/TestCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/

namespace App\Services;
namespace App\Utils;

use App\Models\BuildTest;
use App\Models\TestImage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace App\Services;
namespace App\Utils;

use App\Enums\TestDiffType;
use App\Models\TestDiff;
Expand All @@ -15,7 +15,7 @@
* It also sets `build2test::newstatus` = 1 as appropriate.
**/

class TestDiffService
class TestDiffUtil
{
public static function computeDifferences(Build $build) : bool
{
Expand Down
2 changes: 1 addition & 1 deletion app/Services/TestingDay.php → app/Utils/TestingDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/

namespace App\Services;
namespace App\Utils;

use CDash\Model\Project;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/

namespace App\Services;
namespace App\Utils;

use App\Jobs\ProcessSubmission;
use CDash\Model\Build;
Expand Down Expand Up @@ -154,7 +154,7 @@ public function initializeBuild(): JsonResponse
$projectid = $project_row->id;

// Check if this submission requires a valid authentication token.
if (($this->token || $project_row->authenticatesubmissions) && !AuthTokenService::checkToken($this->token, $projectid)) {
if (($this->token || $project_row->authenticatesubmissions) && !AuthTokenUtil::checkToken($this->token, $projectid)) {
abort(Response::HTTP_FORBIDDEN, 'Forbidden');
}

Expand Down Expand Up @@ -311,9 +311,9 @@ public function populateBuildFileRow(): void

// Check if this submission requires a valid authentication token.
if ($this->project->AuthenticateSubmissions) {
$token = AuthTokenService::getBearerToken();
$authtoken_hash = AuthTokenService::hashToken($token);
if (!AuthTokenService::checkToken($authtoken_hash, $this->project->Id)) {
$token = AuthTokenUtil::getBearerToken();
$authtoken_hash = AuthTokenUtil::hashToken($token);
if (!AuthTokenUtil::checkToken($authtoken_hash, $this->project->Id)) {
Storage::delete($this->inboxdatafilename);
abort(Response::HTTP_FORBIDDEN, 'Forbidden');
}
Expand Down Expand Up @@ -444,9 +444,9 @@ private function getAuthTokenHash(): void
if ($this->token) {
return;
}
$token = AuthTokenService::getBearerToken();
$token = AuthTokenUtil::getBearerToken();
if ($token) {
$this->token = AuthTokenService::hashToken($token);
$this->token = AuthTokenUtil::hashToken($token);
} else {
$this->token = '';
}
Expand Down
Loading