Trog-Routes-JSON.t 861 B

1234567891011121314151617181920212223
  1. #!/usr/bin/env perl
  2. use 5.040;
  3. use re '/aasx';
  4. use warnings FATAL => 'all';
  5. use Test::More;
  6. use FindBin::libs;
  7. require_ok('Trog::Routes::JSON') or BAIL_OUT("Can't find SUT");
  8. subtest 'the change request token is a uuid, and nothing else' => sub {
  9. no warnings 'once';
  10. my $valid = $Trog::Routes::JSON::routes{'/api/auth_change_request/(.*)'}{parameters}{token};
  11. ok( $valid->('5bed1745-4201-40dd-b5dd-65acc0316604'), 'a uuid is a token' );
  12. ok( !$valid->(q{}), 'nothing is not' );
  13. ok( !$valid->('x;drop table user'), 'and neither is text with a hex digit in it' );
  14. ok( !$valid->("5bed1745-4201\n"), 'nor a token with something after it' );
  15. ok( !$valid->('a|b'), 'nor a pipe, which the class used to hold' );
  16. };
  17. done_testing();