Skip to content

Commit 8a7a9d7

Browse files
committed
Adding tests and fixing bugs.
1 parent 44e2ec2 commit 8a7a9d7

5 files changed

Lines changed: 433 additions & 21 deletions

File tree

app/V1Module/presenters/ExtensionsPresenter.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ public function checkToken(string $extId)
9191
*/
9292

9393
// All users within this scope are allowed the operation...
94-
$this->isInScope(TokenScope::EXTENSIONS);
94+
if (!$this->isInScope(TokenScope::EXTENSIONS)) {
95+
throw new ForbiddenRequestException();
96+
}
9597

9698
// ...but the token must be also valid...
9799
$token = $this->getAccessToken();

app/commands/BaseCommand.php

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,15 @@
22

33
namespace App\Console;
44

5-
use App\Model\Repository\RuntimeEnvironments;
6-
use App\Model\Repository\Pipelines;
7-
use App\Model\Repository\UploadedFiles;
8-
use App\Model\Entity\RuntimeEnvironment;
9-
use App\Model\Entity\Pipeline;
10-
use App\Model\Entity\SupplementaryExerciseFile;
11-
use App\Helpers\TmpFilesHelper;
12-
use App\Helpers\FileStorageManager;
13-
use App\Helpers\FileStorage\ZipFileStorage;
14-
use App\Helpers\ExerciseConfig\Loader;
15-
use App\Helpers\ExerciseConfig\Validator as ConfigValidator;
165
use DateTime;
176
use Exception;
187
use RuntimeException;
198
use Symfony\Component\Console\Command\Command;
20-
use Symfony\Component\Console\Input\InputArgument;
21-
use Symfony\Component\Console\Input\InputOption;
229
use Symfony\Component\Console\Input\InputInterface;
2310
use Symfony\Component\Console\Output\OutputInterface;
2411
use Symfony\Component\Console\Question\ConfirmationQuestion;
2512
use Symfony\Component\Console\Question\ChoiceQuestion;
13+
use Symfony\Component\Console\Question\Question;
2614
use Symfony\Component\Console\Helper\QuestionHelper;
2715

2816
/**
@@ -138,4 +126,23 @@ protected function select(string $text, array $options, ?callable $renderer = nu
138126
$selectedKey = $helper->ask($this->input, $this->output, $question);
139127
return array_key_exists($selectedKey, $translateBack) ? $translateBack[$selectedKey] : null;
140128
}
129+
130+
/**
131+
* Prompts the user for inputting specific text value.
132+
* @param string $text question asked to the user before prompt
133+
* @param string $default default value returned if the user does not input anything
134+
* @param bool $hidden input (e.g., when password is prompted)
135+
* @return string input (answer) from the user
136+
*/
137+
protected function prompt(string $text, string $default = '', bool $hidden = false): string
138+
{
139+
/** @var QuestionHelper */
140+
$helper = $this->getHelper('question');
141+
$question = new Question($text, $default);
142+
if ($hidden) {
143+
$question->setHidden(true);
144+
$question->setHiddenFallback(false);
145+
}
146+
return $helper->ask($this->input, $this->output, $question);
147+
}
141148
}

app/model/entity/ExternalLogin.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
namespace App\Model\Entity;
44

55
use Doctrine\ORM\Mapping as ORM;
6-
use App\Exceptions\InvalidArgumentException;
7-
use Nette\Utils\Validators;
86

97
/**
108
* @ORM\Entity

0 commit comments

Comments
 (0)