Bugzilla – Attachment 121270 Details for
Bug 28370
Routes still missing additionalProperties in spec
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28370: Add tests
Bug-28370-Add-tests.patch (text/plain), 3.20 KB, created by
Jonathan Druart
on 2021-05-21 08:49:16 UTC
(
hide
)
Description:
Bug 28370: Add tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-05-21 08:49:16 UTC
Size:
3.20 KB
patch
obsolete
>From bda3fbb9bd0454d10ff742f4c552d73e1d69de18 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 21 May 2021 10:48:44 +0200 >Subject: [PATCH] Bug 28370: Add tests > >--- > xt/api.t | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 75 insertions(+) > create mode 100755 xt/api.t > >diff --git a/xt/api.t b/xt/api.t >new file mode 100755 >index 00000000000..0a64bb422af >--- /dev/null >+++ b/xt/api.t >@@ -0,0 +1,75 @@ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+use File::Slurp qw( read_file ); >+use JSON qw( from_json ); >+use Test::More tests => 4; >+use Data::Dumper; >+ >+my $dh; >+ >+my $definitions_dir = 'api/v1/swagger/definitions'; >+opendir( $dh, $definitions_dir ) or die "$!"; >+my @files = readdir $dh; >+my @wrong_additionalProperties; >+ok( @files, "making sure we found definitions files" ); >+for my $file (@files) { >+ next unless $file =~ m|\.json$|; >+ my $spec = from_json read_file("$definitions_dir/$file"); >+ if ( not exists $spec->{additionalProperties} >+ or $spec->{additionalProperties} != 0 ) >+ { >+ push @wrong_additionalProperties, { file => $file, }; >+ } >+} >+is( scalar @wrong_additionalProperties, 0 ) >+ or diag Dumper \@wrong_additionalProperties; >+ >+ >+my $paths_dir = 'api/v1/swagger/paths'; >+opendir( $dh, $paths_dir ) or die "$!"; >+@files = readdir $dh; >+@wrong_additionalProperties = (); >+ok(@files, "making sure we found paths files"); >+for my $file (@files) { >+ next unless $file =~ m|\.json$|; >+ my $spec = from_json read_file("$paths_dir/$file"); >+ for my $route ( keys %$spec ) { >+ for my $method ( keys %{ $spec->{$route} } ) { >+ next if $method ne 'post' && $method ne 'put'; >+ for my $parameter ( @{ $spec->{$route}->{$method}->{parameters} } ) { >+ if ( exists $parameter->{schema} ) { >+ >+ # If it's a ref we inherit from the definition file >+ next if exists $parameter->{schema}->{'$ref'}; >+ >+ if ( not exists $parameter->{schema}->{additionalProperties} >+ or $parameter->{schema}->{additionalProperties} != 0 ) >+ { >+ push @wrong_additionalProperties, >+ { >+ file => "$paths_dir/$file", >+ route => $route, >+ method => $method, >+ }; >+ } >+ } >+ } >+ } >+ } >+} >+ >+is( scalar @wrong_additionalProperties, 0 ) >+ or diag Dumper \@wrong_additionalProperties; >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 28370
:
121110
|
121134
|
121232
|
121270
|
121284
|
121285
|
121286
|
121287
|
121289