Skip to content

Commit

Permalink
Allow more special characters for test names seen in production
Browse files Browse the repository at this point in the history
* Allow more special characters including the colon (the `openqa-clone-job`
  script will have to cope with it by only splitting the key/testname on
  the first colon)
* Keep `=` and tabs disallowed; the production jobs using those characters
  are most likely created by accident
* See https://progress.opensuse.org/issues/177267
  • Loading branch information
Martchus committed Feb 21, 2025
1 parent b1b2cf4 commit f088b72
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/OpenQA/Jobs/Constants.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ use Mojo::Base -base, -signatures;
use Exporter 'import';

# define regex for validating test names in accordance with `JobScenarios-01.yaml` and `JobTemplates-01.yaml`
use constant TEST_NAME_REGEX => qr/^[A-Za-z 0-9_*.+-]+$/;
# note: In contrast to the YAML schema a few more characters are allowed here as they are useful for manually
# triggered jobs, e.g. via `openqa-clone-custom-git-refspec`.
use constant TEST_NAME_REGEX => qr|^[A-Za-z 0-9_*.+,:/#@%"'-]+$|;

# job states
use constant {
Expand Down
4 changes: 2 additions & 2 deletions t/api/04-jobs.t
Original file line number Diff line number Diff line change
Expand Up @@ -826,8 +826,8 @@ subtest 'get job status' => sub {
};

subtest 'validation of test name' => sub {
my @disallowed = ('spam@eggs', 'spam:eggs', "spam\teggs");
my @allowed = ('spam.eggs', 'spam+eggs', 'spam eggs');
my @disallowed = ('spam=eggs', "spam\teggs");
my @allowed = ('spam.eggs', 'spam+eggs', 'spam:"eggs"', 'spam@eggs', "spam 'eggs'");
$t->post_ok('/api/v1/jobs', form => {TEST => $_})->status_is(400, "test name $_ disallowed") for @disallowed;
$t->json_is('/error' => 'The following settings are invalid: TEST', 'error for invalid test name returned');
$t->post_ok('/api/v1/jobs', form => {TEST => $_})->status_is(200, "test name $_ allowed") for @allowed;
Expand Down

0 comments on commit f088b72

Please sign in to comment.