logo

cve-client

CLI-based client / toolbox for CVE.org git clone https://anongit.hacktivis.me/git/cve-client.git/

cve_schema50.t (1274B)


  1. #!/usr/bin/env perl
  2. # CVE-Client: CLI-based client / toolbox for CVE.org
  3. # Copyright © 2021-2023 CVE-Client Authors <https://hacktivis.me/git/cve-client/>
  4. # SPDX-License-Identifier: AGPL-3.0-only
  5. use strict;
  6. use utf8;
  7. use Test::More tests => 2;
  8. use Test::Output;
  9. use JSON::MaybeXS;
  10. use App::CveClient qw(print_cve);
  11. my $json = JSON::MaybeXS->new(utf8 => 1);
  12. open(CVE_IN, '<', 't/cve_schema50.CVE-2022-24903.json') or die "$!";
  13. open(CVE_OUT, '<', 't/cve_schema50.CVE-2022-24903.txt') or die "$!";
  14. my $object = $json->decode(<CVE_IN>) or die "$!";
  15. # Read whole files
  16. undef $/;
  17. output_is { print_cve($object, 'CVE-2022-24903') } <CVE_OUT>, '',
  18. 'Test printing CVE-2022-24903';
  19. output_is { print_cve($object, 'CVE-222-24903') } <CVE_OUT>,
  20. "Warning: Got <CVE-2022-24903> instead of <CVE-222-24903>\n",
  21. 'XTest printing CVE-2022-24903 with cve_id being CVE-222-24903';
  22. close(CVE_IN);
  23. close(CVE_OUT);
  24. # TODO: Figure out how to test fails properly
  25. #
  26. #my $nx_object = $json->decode('{"error":"CVE_RECORD_DNE","message":"The cve record for the cve id does not exist."}');
  27. #
  28. #output_is { print_cve($nx_object, 'CVE-1995-24903') } '', 'Error (CVE_RECORD_DNE): The cve record for the cve id does not exist.', 'Test printing non-existant CVE-1995-24903';
  29. done_testing;