[GITEA] Use existing jsonschema library
- Use the 'existing' jsonschema library for the nodeinfo integration test. (cherry picked from commit 73864840f27274d4cdaef23d47a6a71fc60529c3) (cherry picked from commit da36df306b7a75434c75ed5f63608e06266ca480) Conflicts: go.mod https://codeberg.org/forgejo/forgejo/pulls/1581 (cherry picked from commit 2b4ab46d8eacd2e6b2318f26e327ec59b804ea23) Conflicts: go.mod https://codeberg.org/forgejo/forgejo/pulls/1617 (cherry picked from commit 8064130344eb0d797838f8444a6d5c0e3d425716) (cherry picked from commit 0ccefc633e5cd206bd51f642c9fe7be56dae51ec) (cherry picked from commit 19e647b531c5cfaba5beabbd1de2fe65dfd44da0) (cherry picked from commit 2bcc04889d4d765eba0ebdffe7ba788c91923d35) (cherry picked from commit 2fd1932699572a666ef616b7fb191ab5f56d75c6) (cherry picked from commit b9a3e1e5258e1896550cc3750b7f688fdab1bb22) (cherry picked from commit 92d932d23f2fcab4b38b72bb6b39778026418ecd) (cherry picked from commit c125217fea154d6eb87ae86735906c90575bbff3) (cherry picked from commit f9801ba57b58fefe5a4cc8c9da91a3593129f656) Conflicts: go.mod https://codeberg.org/forgejo/forgejo/pulls/2034 (cherry picked from commit 2558a8a764ff6d35c70beb7510626cdeac38771d) (cherry picked from commit f53b2d31127ddf17b6593d1bb3ec536ee04c8937) (cherry picked from commit c098055f0a3266a94651bc2783330cf7b12efff2) (cherry picked from commit 0e1591554a275d14da09114db8572bf731c5f112) (cherry picked from commit 876d9d5c6f272120d31bdb18df39c3a9d25e2917) Conflicts: go.mod https://codeberg.org/forgejo/forgejo/pulls/2249 (cherry picked from commit 7110bb6a783cb37db3a75abd08534760812d05fd)
This commit is contained in:
parent
b896a87103
commit
662c8ee341
3 changed files with 9 additions and 20 deletions
3
go.mod
3
go.mod
|
@ -99,7 +99,6 @@ require (
|
||||||
github.com/ulikunitz/xz v0.5.11
|
github.com/ulikunitz/xz v0.5.11
|
||||||
github.com/urfave/cli/v2 v2.27.1
|
github.com/urfave/cli/v2 v2.27.1
|
||||||
github.com/xanzy/go-gitlab v0.96.0
|
github.com/xanzy/go-gitlab v0.96.0
|
||||||
github.com/xeipuuv/gojsonschema v1.2.0
|
|
||||||
github.com/yohcop/openid-go v1.0.1
|
github.com/yohcop/openid-go v1.0.1
|
||||||
github.com/yuin/goldmark v1.6.0
|
github.com/yuin/goldmark v1.6.0
|
||||||
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc
|
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc
|
||||||
|
@ -275,8 +274,6 @@ require (
|
||||||
github.com/valyala/fastjson v1.6.4 // indirect
|
github.com/valyala/fastjson v1.6.4 // indirect
|
||||||
github.com/x448/float16 v0.8.4 // indirect
|
github.com/x448/float16 v0.8.4 // indirect
|
||||||
github.com/xanzy/ssh-agent v0.3.3 // indirect
|
github.com/xanzy/ssh-agent v0.3.3 // indirect
|
||||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
|
|
||||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
|
|
||||||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
|
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
|
||||||
github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e // indirect
|
github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e // indirect
|
||||||
github.com/zeebo/blake3 v0.2.3 // indirect
|
github.com/zeebo/blake3 v0.2.3 // indirect
|
||||||
|
|
7
go.sum
7
go.sum
|
@ -832,13 +832,6 @@ github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23n
|
||||||
github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4=
|
github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4=
|
||||||
github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=
|
github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=
|
||||||
github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
|
github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
|
||||||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
|
||||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
|
|
||||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
|
||||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
|
|
||||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
|
|
||||||
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
|
|
||||||
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
|
|
||||||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo=
|
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo=
|
||||||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
|
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
|
||||||
github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e h1:+SOyEddqYF09QP7vr7CgJ1eti3pY9Fn3LHO1M1r/0sI=
|
github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e h1:+SOyEddqYF09QP7vr7CgJ1eti3pY9Fn3LHO1M1r/0sI=
|
||||||
|
|
|
@ -43,8 +43,8 @@ import (
|
||||||
"github.com/markbates/goth"
|
"github.com/markbates/goth"
|
||||||
"github.com/markbates/goth/gothic"
|
"github.com/markbates/goth/gothic"
|
||||||
goth_gitlab "github.com/markbates/goth/providers/gitlab"
|
goth_gitlab "github.com/markbates/goth/providers/gitlab"
|
||||||
|
"github.com/santhosh-tekuri/jsonschema/v5"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/xeipuuv/gojsonschema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var testWebRoutes *web.Route
|
var testWebRoutes *web.Route
|
||||||
|
@ -543,16 +543,15 @@ func VerifyJSONSchema(t testing.TB, resp *httptest.ResponseRecorder, schemaFile
|
||||||
_, schemaFileErr := os.Stat(schemaFilePath)
|
_, schemaFileErr := os.Stat(schemaFilePath)
|
||||||
assert.Nil(t, schemaFileErr)
|
assert.Nil(t, schemaFileErr)
|
||||||
|
|
||||||
schema, schemaFileReadErr := os.ReadFile(schemaFilePath)
|
schema, err := jsonschema.Compile(schemaFilePath)
|
||||||
assert.Nil(t, schemaFileReadErr)
|
assert.NoError(t, err)
|
||||||
assert.True(t, len(schema) > 0)
|
|
||||||
|
|
||||||
nodeinfoSchema := gojsonschema.NewStringLoader(string(schema))
|
var data interface{}
|
||||||
nodeinfoString := gojsonschema.NewStringLoader(resp.Body.String())
|
err = json.Unmarshal(resp.Body.Bytes(), &data)
|
||||||
result, schemaValidationErr := gojsonschema.Validate(nodeinfoSchema, nodeinfoString)
|
assert.NoError(t, err)
|
||||||
assert.Nil(t, schemaValidationErr)
|
|
||||||
assert.Empty(t, result.Errors())
|
schemaValidation := schema.Validate(data)
|
||||||
assert.True(t, result.Valid())
|
assert.Nil(t, schemaValidation)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetCSRF(t testing.TB, session *TestSession, urlStr string) string {
|
func GetCSRF(t testing.TB, session *TestSession, urlStr string) string {
|
||||||
|
|
Loading…
Reference in a new issue