From d6f9ade8a9d38ff7074c1cd57bad5c9956678acc Mon Sep 17 00:00:00 2001 From: Alessandro Sebastiani Date: Thu, 29 Oct 2020 18:22:26 +0100 Subject: [PATCH 1/3] fix: bump publiccode-parser-go to v1.2.2 --- go.mod | 15 ++++++++------- go.sum | 50 +++++++++++++++++++++++++------------------------- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/go.mod b/go.mod index bca7107..8a28ddc 100644 --- a/go.mod +++ b/go.mod @@ -3,15 +3,16 @@ module github.com/italia/publiccode-validator go 1.12 require ( - github.com/alranel/go-vcsurl v0.0.0-20190918163743-e14328dc728a - github.com/dyatlov/go-oembed v0.0.0-20191018083617-475682269b4c // indirect + github.com/alranel/go-vcsurl v0.0.0-20201009104729-56346a70f40a + github.com/dyatlov/go-oembed v0.0.0-20191103150536-a57c85b3b37c // indirect github.com/ghodss/yaml v1.0.0 github.com/gorilla/mux v1.7.3 - github.com/italia/publiccode-parser-go v0.0.0-20191028193426-165ad614cbc3 - github.com/kr/pretty v0.1.0 // indirect - github.com/sirupsen/logrus v1.6.0 + github.com/italia/httpclient-lib-go v0.0.1 // indirect + github.com/italia/publiccode-parser-go v1.2.2 + github.com/sirupsen/logrus v1.7.0 github.com/stretchr/testify v1.4.0 - golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae // indirect - gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect + github.com/thoas/go-funk v0.7.0 // indirect + golang.org/x/sys v0.0.0-20201029080932-201ba4db2418 // indirect + golang.org/x/text v0.3.4 // indirect gopkg.in/yaml.v2 v2.3.0 ) diff --git a/go.sum b/go.sum index b40b6cf..c53b5e2 100644 --- a/go.sum +++ b/go.sum @@ -2,10 +2,8 @@ github.com/Jeffail/gabs v1.4.0 h1://5fYRRTq1edjfIrQGvdkcd22pkYUrHZ5YC/H2GJVAo= github.com/Jeffail/gabs v1.4.0/go.mod h1:6xMvQMK4k33lb7GUUpaAPh6nKMmemQeg5d4gn7/bOXc= github.com/alranel/go-spdx v0.0.5 h1:dpWfqUWDd3IEf9KTjWu++ZiC3pKws+77lk+/qXjgir8= github.com/alranel/go-spdx v0.0.5/go.mod h1:lcAlhyAoH9rjd33PkIx+2gsCIYwDpL4H0WX7Jrays70= -github.com/alranel/go-vcsurl v0.0.0-20190819164520-88a614c7acb4 h1:a+SmZVgzBVoCfNK1LPRyy/rXDn8JiA/8SpMwcaBRRO0= -github.com/alranel/go-vcsurl v0.0.0-20190819164520-88a614c7acb4/go.mod h1:tp+e312yiwgu8H4/Ly26J8MevK9lz7BucU4PPlEv0ag= -github.com/alranel/go-vcsurl v0.0.0-20190918163743-e14328dc728a h1:rC0zhGHCi9ejH0KDdQDN/mXlSauNJKzmjxhpKLIQya0= -github.com/alranel/go-vcsurl v0.0.0-20190918163743-e14328dc728a/go.mod h1:tp+e312yiwgu8H4/Ly26J8MevK9lz7BucU4PPlEv0ag= +github.com/alranel/go-vcsurl v0.0.0-20201009104729-56346a70f40a h1:NiIou8dzFGaIVFfhuBdRiPUqgMpcys1RDADgjB7qrps= +github.com/alranel/go-vcsurl v0.0.0-20201009104729-56346a70f40a/go.mod h1:tp+e312yiwgu8H4/Ly26J8MevK9lz7BucU4PPlEv0ag= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -15,8 +13,8 @@ github.com/deadcheat/gonch v0.0.0-20180528124129-c2ff7a019863 h1:WiIagMEsLYiZCeD github.com/deadcheat/gonch v0.0.0-20180528124129-c2ff7a019863/go.mod h1:/5mH3gAuXUxGN3maOBAxBfB8RXvP9tBIX5fx2x1k0V0= github.com/dyatlov/go-oembed v0.0.0-20180429203341-4bc5ab7a42e9 h1:cdw1dgA549x0tZR5zM5bjobQXFFShOsozUbzWZgmd30= github.com/dyatlov/go-oembed v0.0.0-20180429203341-4bc5ab7a42e9/go.mod h1:3XylPVY2YGcV9RQBie0DspVncA1nsgsYQ8BtIs52fz4= -github.com/dyatlov/go-oembed v0.0.0-20191018083617-475682269b4c h1:0B3ir49BfmASr/MXci0VWY1aagmjXYHdeO/ZztSllQU= -github.com/dyatlov/go-oembed v0.0.0-20191018083617-475682269b4c/go.mod h1:DjlDZiZGRRKbiJZmiEiiXozsBQAQzHmxwHKFeXifL2g= +github.com/dyatlov/go-oembed v0.0.0-20191103150536-a57c85b3b37c h1:MEV1LrQtCBGacXajlT4CSuYWbZuLl/qaZVqwoOmwAbU= +github.com/dyatlov/go-oembed v0.0.0-20191103150536-a57c85b3b37c/go.mod h1:DjlDZiZGRRKbiJZmiEiiXozsBQAQzHmxwHKFeXifL2g= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-bindata/go-bindata v3.1.2+incompatible/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo= @@ -24,10 +22,12 @@ github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/italia/publiccode-parser-go v0.0.0-20191028193426-165ad614cbc3 h1:MuB1sy0dOIU0lzj+HiSJPg4wWr20P0Z/UHFEZ8R8uc0= -github.com/italia/publiccode-parser-go v0.0.0-20191028193426-165ad614cbc3/go.mod h1:q18a0jHIXgRVNJ12lI5mBHnVlhqLcUdQ2a3888PhTqY= -github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/italia/httpclient-lib-go v0.0.0-20201009133728-9044482688d7 h1:jxY6N3KOTkhCrRN/Yj6+5nwBA0OR9O11918AV7PwEG8= +github.com/italia/httpclient-lib-go v0.0.0-20201009133728-9044482688d7/go.mod h1:tO13wT41NVbqsP9MFBMulFqeC6zFdwuLNXi29lx/FiM= +github.com/italia/httpclient-lib-go v0.0.1 h1:wxbmNmeHO4fM3+Z6p86WnjTK6B8+Zk2VMij0T1HcZYU= +github.com/italia/httpclient-lib-go v0.0.1/go.mod h1:tO13wT41NVbqsP9MFBMulFqeC6zFdwuLNXi29lx/FiM= +github.com/italia/publiccode-parser-go v1.2.2 h1:xVpR37GJJU+JfI07HGaiRxTAuFXZq7tlQPhYtduUJTo= +github.com/italia/publiccode-parser-go v1.2.2/go.mod h1:zYlDR8AbitTI9RzX3IRV73tqsmR0SOmhWCJDb3FpMT0= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -35,8 +35,10 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY= +github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= +github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -46,33 +48,31 @@ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJy github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/thoas/go-funk v0.4.0 h1:KBaa5NL7NMtsFlQaD8nQMbDt1wuM+OOaNQyYNYQFhVo= github.com/thoas/go-funk v0.4.0/go.mod h1:mlR+dHGb+4YgXkf13rkQTuzrneeHANxOm6+ZnEV9HsA= +github.com/thoas/go-funk v0.7.0 h1:GmirKrs6j6zJbhJIficOsz2aAI7700KsU/5YrdHRM1Y= +github.com/thoas/go-funk v0.7.0/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q= +github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 h1:nrZ3ySNYwJbSpD6ce9duiP+QkD3JuLCcWkdaehUS/3Y= +github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80/go.mod h1:iFyPdL66DjUD96XmzVL3ZntbzcflLnznH0fr99w5VqE= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/net v0.0.0-20180404174746-b3c676e531a6/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7 h1:LepdCS8Gf/MVejFIt8lsiexZATdoGVyp5bcyS+rYoUI= -golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae h1:Ih9Yo4hSPImZOpfGuA4bR/ORKTAbhZo2AbWNRCnevdo= -golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634 h1:bNEHhJCnrwMKNMmOx3yAynp5vs5/gRy+XWFtZFu7NBM= +golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201029080932-201ba4db2418 h1:HlFl4V6pEMziuLXyRkm5BIYq1y1GAbb02pRlWvI54OM= +golang.org/x/sys v0.0.0-20201029080932-201ba4db2418/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc= +golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190308174544-00c44ba9c14f/go.mod h1:25r3+/G6/xytQM8iWZKq3Hn0kr0rgFKPUNVEL/dr3z4= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190724185037-8aa4eac1a7c1/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From fd13928c43bf35eb7e49620e974996bb43291cea Mon Sep 17 00:00:00 2001 From: Alessandro Sebastiani Date: Thu, 29 Oct 2020 18:22:59 +0100 Subject: [PATCH 2/3] fix: tests are compliant with new error format --- main_test.go | 4 ++-- tests/out_invalid.json | 2 +- tests/out_invalid_network.json | 2 +- tests/out_invalid_network_v1.json | 2 +- tests/out_invalid_v1.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/main_test.go b/main_test.go index 985caae..03b74ba 100644 --- a/main_test.go +++ b/main_test.go @@ -235,8 +235,8 @@ func TestEmptyURLv1(t *testing.T) { func TestValidationErrWithNetworkv1(t *testing.T) { log.SetLevel(log.InfoLevel) - var errs utils.Message //[]map[string]interface{} - var errOut utils.Message //[]map[string]interface{} + var errs utils.Message + var errOut utils.Message fileYML, err := os.Open("tests/invalid.yml") if err != nil { diff --git a/tests/out_invalid.json b/tests/out_invalid.json index be3455f..7d14dfc 100644 --- a/tests/out_invalid.json +++ b/tests/out_invalid.json @@ -1 +1 @@ -[{"Key":"logo","Reason":"HTTP GET returned 404 for https://raw.githubusercontent.com/italia/developers.italia.it/master/tests/img/logo.png; 200 was expected"},{"Key":"monochromeLogo","Reason":"HTTP GET returned 404 for https://raw.githubusercontent.com/italia/developers.italia.it/master/tests/img/logo-mono.svg; 200 was expected"},{"Key":"description/eng/screenshots","Reason":"HTTP GET returned 404 for https://raw.githubusercontent.com/italia/developers.italia.it/master/tests/img/sshot1.png; 200 was expected"},{"Key":"legal/authorsFile","Reason":"HTTP GET returned 404 for https://raw.githubusercontent.com/italia/developers.italia.it/master/tests/AUTHORS; 200 was expected"},{"Key":"Unexpected boolean key: it/conforme/accessibile"},{"Key":"Unexpected boolean key: it/conforme/interoperabile"},{"Key":"Unexpected boolean key: it/conforme/sicuro"},{"Key":"Unexpected boolean key: it/conforme/privacy"},{"Key":"Unexpected boolean key: it/spid"},{"Key":"Unexpected boolean key: it/pagopa"},{"Key":"Unexpected boolean key: it/cie"},{"Key":"Unexpected boolean key: it/anpr"},{"Key":"Unexpected array key: it/ecosistemi"},{"Key":"Unexpected boolean key: it/designKit/content"},{"Key":"Unexpected boolean key: it/designKit/seo"},{"Key":"Unexpected boolean key: it/designKit/ui"},{"Key":"Unexpected boolean key: it/designKit/web"},{"Key":"Unexpected array key: intendedAudience/onlyFor"}] +[{"Key":"logo","Reason":"HTTP GET failed for https://raw.githubusercontent.com/italia/developers.italia.it/master/tests/img/logo.png: not found"},{"Key":"monochromeLogo","Reason":"HTTP GET failed for https://raw.githubusercontent.com/italia/developers.italia.it/master/tests/img/logo-mono.svg: not found"},{"Key":"description/eng/screenshots","Reason":"HTTP GET failed for https://raw.githubusercontent.com/italia/developers.italia.it/master/tests/img/sshot1.png: not found"},{"Key":"intendedAudience/onlyFor","Reason":"Unexpected array key"},{"Key":"it/conforme/accessibile","Reason":"Unexpected boolean key"},{"Key":"it/conforme/interoperabile","Reason":"Unexpected boolean key"},{"Key":"it/conforme/privacy","Reason":"Unexpected boolean key"},{"Key":"it/conforme/sicuro","Reason":"Unexpected boolean key"},{"Key":"it/designKit/content","Reason":"Unexpected boolean key"},{"Key":"it/designKit/seo","Reason":"Unexpected boolean key"},{"Key":"it/designKit/ui","Reason":"Unexpected boolean key"},{"Key":"it/designKit/web","Reason":"Unexpected boolean key"},{"Key":"it/ecosistemi","Reason":"Unexpected array key"},{"Key":"it/pagopa","Reason":"Unexpected boolean key"},{"Key":"it/spid","Reason":"Unexpected boolean key"},{"Key":"it/anpr","Reason":"Unexpected boolean key"},{"Key":"it/cie","Reason":"Unexpected boolean key"},{"Key":"legal/authorsFile","Reason":"HTTP GET failed for https://raw.githubusercontent.com/italia/developers.italia.it/master/tests/AUTHORS: not found"}] \ No newline at end of file diff --git a/tests/out_invalid_network.json b/tests/out_invalid_network.json index c091629..d4495b0 100644 --- a/tests/out_invalid_network.json +++ b/tests/out_invalid_network.json @@ -1 +1 @@ -{"status":422,"message":"Validation Errors","validationErrors":[{"Key":"invalid key: Unexpected array key: intendedAudience/onlyFor","Reason":""},{"Key":"invalid key: Unexpected boolean key: it/designKit/seo","Reason":""},{"Key":"invalid key: Unexpected boolean key: it/designKit/ui","Reason":""},{"Key":"invalid key: Unexpected boolean key: it/designKit/web","Reason":""},{"Key":"invalid key: Unexpected boolean key: it/designKit/content","Reason":""},{"Key":"invalid key: Unexpected boolean key: it/conforme/interoperabile","Reason":""},{"Key":"invalid key: Unexpected boolean key: it/conforme/sicuro","Reason":""},{"Key":"invalid key: Unexpected boolean key: it/conforme/privacy","Reason":""},{"Key":"invalid key: Unexpected boolean key: it/conforme/accessibile","Reason":""},{"Key":"invalid key: Unexpected boolean key: it/spid","Reason":""},{"Key":"invalid key: Unexpected boolean key: it/pagopa","Reason":""},{"Key":"invalid key: Unexpected boolean key: it/cie","Reason":""},{"Key":"invalid key: Unexpected boolean key: it/anpr","Reason":""},{"Key":"invalid key: Unexpected array key: it/ecosistemi","Reason":""}]} +{"status":422,"message":"Validation Errors","validationErrors":[{"Key":"it/conforme/privacy: Unexpected boolean key","Reason":""},{"Key":"it/conforme/accessibile: Unexpected boolean key","Reason":""},{"Key":"it/conforme/interoperabile: Unexpected boolean key","Reason":""},{"Key":"it/conforme/sicuro: Unexpected boolean key","Reason":""},{"Key":"it/spid: Unexpected boolean key","Reason":""},{"Key":"it/pagopa: Unexpected boolean key","Reason":""},{"Key":"it/cie: Unexpected boolean key","Reason":""},{"Key":"it/anpr: Unexpected boolean key","Reason":""},{"Key":"it/ecosistemi: Unexpected array key","Reason":""},{"Key":"it/designKit/ui: Unexpected boolean key","Reason":""},{"Key":"it/designKit/web: Unexpected boolean key","Reason":""},{"Key":"it/designKit/content: Unexpected boolean key","Reason":""},{"Key":"it/designKit/seo: Unexpected boolean key","Reason":""},{"Key":"intendedAudience/onlyFor: Unexpected array key","Reason":""}]} \ No newline at end of file diff --git a/tests/out_invalid_network_v1.json b/tests/out_invalid_network_v1.json index b72518a..5223369 100644 --- a/tests/out_invalid_network_v1.json +++ b/tests/out_invalid_network_v1.json @@ -1 +1 @@ -{"status":422,"message":"Validation Errors","validationErrors":[{"Key":"Unexpected array key: intendedAudience/onlyFor","Value":""},{"Key":"Unexpected boolean key: it/spid","Value":""},{"Key":"Unexpected boolean key: it/pagopa","Value":""},{"Key":"Unexpected boolean key: it/cie","Value":""},{"Key":"Unexpected boolean key: it/anpr","Value":""},{"Key":"Unexpected array key: it/ecosistemi","Value":""},{"Key":"Unexpected boolean key: it/designKit/web","Value":""},{"Key":"Unexpected boolean key: it/designKit/content","Value":""},{"Key":"Unexpected boolean key: it/designKit/seo","Value":""},{"Key":"Unexpected boolean key: it/designKit/ui","Value":""},{"Key":"Unexpected boolean key: it/conforme/accessibile","Value":""},{"Key":"Unexpected boolean key: it/conforme/interoperabile","Value":""},{"Key":"Unexpected boolean key: it/conforme/sicuro","Value":""},{"Key":"Unexpected boolean key: it/conforme/privacy","Value":""}]} +{"status":422,"message":"Validation Errors","validationErrors":[{"Key":"intendedAudience/onlyFor","Reason":"Unexpected array key"},{"Key":"it/designKit/web","Reason":"Unexpected boolean key"},{"Key":"it/designKit/content","Reason":"Unexpected boolean key"},{"Key":"it/designKit/seo","Reason":"Unexpected boolean key"},{"Key":"it/designKit/ui","Reason":"Unexpected boolean key"},{"Key":"it/conforme/interoperabile","Reason":"Unexpected boolean key"},{"Key":"it/conforme/sicuro","Reason":"Unexpected boolean key"},{"Key":"it/conforme/privacy","Reason":"Unexpected boolean key"},{"Key":"it/conforme/accessibile","Reason":"Unexpected boolean key"},{"Key":"it/spid","Reason":"Unexpected boolean key"},{"Key":"it/pagopa","Reason":"Unexpected boolean key"},{"Key":"it/cie","Reason":"Unexpected boolean key"},{"Key":"it/anpr","Reason":"Unexpected boolean key"},{"Key":"it/ecosistemi","Reason":"Unexpected array key"}]} \ No newline at end of file diff --git a/tests/out_invalid_v1.json b/tests/out_invalid_v1.json index 0663ec8..ac8b7c4 100644 --- a/tests/out_invalid_v1.json +++ b/tests/out_invalid_v1.json @@ -1 +1 @@ -{"status":422,"message":"Validation Errors","validationErrors":[{"Key":"monochromeLogo","Reason":"HTTP GET returned 404 for https://raw.githubusercontent.com/italia/developers.italia.it/master/tests/img/logo-mono.svg; 200 was expected"},{"Key":"Unexpected array key: intendedAudience/onlyFor","Reason":""},{"Key":"legal/authorsFile","Reason":"HTTP GET returned 404 for https://raw.githubusercontent.com/italia/developers.italia.it/master/tests/AUTHORS; 200 was expected"},{"Key":"description/eng/screenshots","Reason":"HTTP GET returned 404 for https://raw.githubusercontent.com/italia/developers.italia.it/master/tests/img/sshot1.png; 200 was expected"},{"Key":"logo","Reason":"HTTP GET returned 404 for https://raw.githubusercontent.com/italia/developers.italia.it/master/tests/img/logo.png; 200 was expected"},{"Key":"Unexpected array key: it/ecosistemi","Reason":""},{"Key":"Unexpected boolean key: it/designKit/seo","Reason":""},{"Key":"Unexpected boolean key: it/designKit/ui","Reason":""},{"Key":"Unexpected boolean key: it/designKit/web","Reason":""},{"Key":"Unexpected boolean key: it/designKit/content","Reason":""},{"Key":"Unexpected boolean key: it/conforme/sicuro","Reason":""},{"Key":"Unexpected boolean key: it/conforme/privacy","Reason":""},{"Key":"Unexpected boolean key: it/conforme/accessibile","Reason":""},{"Key":"Unexpected boolean key: it/conforme/interoperabile","Reason":""},{"Key":"Unexpected boolean key: it/spid","Reason":""},{"Key":"Unexpected boolean key: it/pagopa","Reason":""},{"Key":"Unexpected boolean key: it/cie","Reason":""},{"Key":"Unexpected boolean key: it/anpr","Reason":""}]} \ No newline at end of file +{"status":422,"message":"Validation Errors","validationErrors":[{"Key":"intendedAudience/onlyFor","Reason":"Unexpected array key"},{"Key":"it/spid","Reason":"Unexpected boolean key"},{"Key":"it/pagopa","Reason":"Unexpected boolean key"},{"Key":"it/cie","Reason":"Unexpected boolean key"},{"Key":"it/anpr","Reason":"Unexpected boolean key"},{"Key":"it/ecosistemi","Reason":"Unexpected array key"},{"Key":"it/designKit/ui","Reason":"Unexpected boolean key"},{"Key":"it/designKit/web","Reason":"Unexpected boolean key"},{"Key":"it/designKit/content","Reason":"Unexpected boolean key"},{"Key":"it/designKit/seo","Reason":"Unexpected boolean key"},{"Key":"it/conforme/sicuro","Reason":"Unexpected boolean key"},{"Key":"it/conforme/privacy","Reason":"Unexpected boolean key"},{"Key":"it/conforme/accessibile","Reason":"Unexpected boolean key"},{"Key":"it/conforme/interoperabile","Reason":"Unexpected boolean key"},{"Key":"description/eng/screenshots","Reason":"HTTP GET failed for https://raw.githubusercontent.com/italia/developers.italia.it/master/tests/img/sshot1.png: not found"},{"Key":"legal/authorsFile","Reason":"HTTP GET failed for https://raw.githubusercontent.com/italia/developers.italia.it/master/tests/AUTHORS: not found"},{"Key":"logo","Reason":"HTTP GET failed for https://raw.githubusercontent.com/italia/developers.italia.it/master/tests/img/logo.png: not found"},{"Key":"monochromeLogo","Reason":"HTTP GET failed for https://raw.githubusercontent.com/italia/developers.italia.it/master/tests/img/logo-mono.svg: not found"}]} \ No newline at end of file From 8f501cae8475478360cf16d3627a226e5a0156fc Mon Sep 17 00:00:00 2001 From: Alessandro Sebastiani Date: Thu, 29 Oct 2020 18:58:49 +0100 Subject: [PATCH 3/3] fix: legacy api was reporting old error format --- apiv1/api.go | 8 +------- main.go | 2 +- tests/out_invalid_network.json | 2 +- utils/utils.go | 14 +++++--------- 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/apiv1/api.go b/apiv1/api.go index 30288b1..4b7d6d9 100644 --- a/apiv1/api.go +++ b/apiv1/api.go @@ -54,19 +54,13 @@ func parseRemoteURL(urlString string) ([]byte, error, error) { return pc, errParse, err } -func errorsToValidationErrors(err error) (out []utils.ErrorInvalidValue) { - j, _ := json.Marshal(err) - _ = json.Unmarshal(j, &out) - return -} - func promptError(err error, w http.ResponseWriter, acceptHeader string, httpStatus int, mess string) { message := utils.Message{ Status: httpStatus, Message: mess, - ValidationError: errorsToValidationErrors(err), + ValidationError: utils.ErrorsToValidationErrors(err), } if message.ValidationError == nil { message.Error = err.Error() diff --git a/main.go b/main.go index 785d1e5..eeb7b04 100644 --- a/main.go +++ b/main.go @@ -150,7 +150,7 @@ func promptValidationErrors(err error, w http.ResponseWriter, message := utils.Message{ Status: httpStatus, Message: mess, - ValidationError: utils.ErrorsToSlice(err), + ValidationError: utils.ErrorsToValidationErrors(err), } w.Header().Set("Content-type", "application/json") diff --git a/tests/out_invalid_network.json b/tests/out_invalid_network.json index d4495b0..3ea9b5e 100644 --- a/tests/out_invalid_network.json +++ b/tests/out_invalid_network.json @@ -1 +1 @@ -{"status":422,"message":"Validation Errors","validationErrors":[{"Key":"it/conforme/privacy: Unexpected boolean key","Reason":""},{"Key":"it/conforme/accessibile: Unexpected boolean key","Reason":""},{"Key":"it/conforme/interoperabile: Unexpected boolean key","Reason":""},{"Key":"it/conforme/sicuro: Unexpected boolean key","Reason":""},{"Key":"it/spid: Unexpected boolean key","Reason":""},{"Key":"it/pagopa: Unexpected boolean key","Reason":""},{"Key":"it/cie: Unexpected boolean key","Reason":""},{"Key":"it/anpr: Unexpected boolean key","Reason":""},{"Key":"it/ecosistemi: Unexpected array key","Reason":""},{"Key":"it/designKit/ui: Unexpected boolean key","Reason":""},{"Key":"it/designKit/web: Unexpected boolean key","Reason":""},{"Key":"it/designKit/content: Unexpected boolean key","Reason":""},{"Key":"it/designKit/seo: Unexpected boolean key","Reason":""},{"Key":"intendedAudience/onlyFor: Unexpected array key","Reason":""}]} \ No newline at end of file +{"status":422,"message":"Validation Errors","validationErrors":[{"Key":"it/ecosistemi","Reason":"Unexpected array key"},{"Key":"it/designKit/content","Reason":"Unexpected boolean key"},{"Key":"it/designKit/seo","Reason":"Unexpected boolean key"},{"Key":"it/designKit/ui","Reason":"Unexpected boolean key"},{"Key":"it/designKit/web","Reason":"Unexpected boolean key"},{"Key":"it/conforme/accessibile","Reason":"Unexpected boolean key"},{"Key":"it/conforme/interoperabile","Reason":"Unexpected boolean key"},{"Key":"it/conforme/sicuro","Reason":"Unexpected boolean key"},{"Key":"it/conforme/privacy","Reason":"Unexpected boolean key"},{"Key":"it/spid","Reason":"Unexpected boolean key"},{"Key":"it/pagopa","Reason":"Unexpected boolean key"},{"Key":"it/cie","Reason":"Unexpected boolean key"},{"Key":"it/anpr","Reason":"Unexpected boolean key"},{"Key":"intendedAudience/onlyFor","Reason":"Unexpected array key"}]} \ No newline at end of file diff --git a/utils/utils.go b/utils/utils.go index 2bf564c..be06d7d 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -2,11 +2,11 @@ package utils import ( "bytes" + "encoding/json" "errors" "fmt" "net/http" "net/url" - "strings" vcsurl "github.com/alranel/go-vcsurl" "github.com/ghodss/yaml" @@ -78,14 +78,10 @@ func GetRawFile(urlString string) (string, error) { return "", errors.New("URL is not valid or response http code is not success either") } -// ErrorsToSlice return a slice of errors -func ErrorsToSlice(errs error) (arr []ErrorInvalidValue) { - keys := strings.Split(errs.Error(), "\n") - for _, key := range keys { - arr = append(arr, ErrorInvalidValue{ - Key: key, - }) - } +// ErrorsToValidationErrors converts validation errors +func ErrorsToValidationErrors(err error) (out []ErrorInvalidValue) { + j, _ := json.Marshal(err) + _ = json.Unmarshal(j, &out) return }