forked from forgejo/forgejo
[GITEA] Use existing jsonschema library
- Use the 'existing' jsonschema library for the nodeinfo integration test. (cherry picked from commit73864840f2
) (cherry picked from commitda36df306b
) Conflicts: go.mod https://codeberg.org/forgejo/forgejo/pulls/1581 (cherry picked from commit2b4ab46d8e
) Conflicts: go.mod https://codeberg.org/forgejo/forgejo/pulls/1617 (cherry picked from commit8064130344
) (cherry picked from commitca32f14bc2
) (cherry picked from commit6a4abb928f
) (cherry picked from commit0059a44ae8
)
This commit is contained in:
parent
cf8b64f937
commit
8dc8451fd0
3 changed files with 9 additions and 20 deletions
|
@ -42,8 +42,8 @@ import (
|
|||
"github.com/markbates/goth"
|
||||
"github.com/markbates/goth/gothic"
|
||||
goth_gitlab "github.com/markbates/goth/providers/gitlab"
|
||||
"github.com/santhosh-tekuri/jsonschema/v5"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/xeipuuv/gojsonschema"
|
||||
)
|
||||
|
||||
var testWebRoutes *web.Route
|
||||
|
@ -512,16 +512,15 @@ func VerifyJSONSchema(t testing.TB, resp *httptest.ResponseRecorder, schemaFile
|
|||
_, schemaFileErr := os.Stat(schemaFilePath)
|
||||
assert.Nil(t, schemaFileErr)
|
||||
|
||||
schema, schemaFileReadErr := os.ReadFile(schemaFilePath)
|
||||
assert.Nil(t, schemaFileReadErr)
|
||||
assert.True(t, len(schema) > 0)
|
||||
schema, err := jsonschema.Compile(schemaFilePath)
|
||||
assert.NoError(t, err)
|
||||
|
||||
nodeinfoSchema := gojsonschema.NewStringLoader(string(schema))
|
||||
nodeinfoString := gojsonschema.NewStringLoader(resp.Body.String())
|
||||
result, schemaValidationErr := gojsonschema.Validate(nodeinfoSchema, nodeinfoString)
|
||||
assert.Nil(t, schemaValidationErr)
|
||||
assert.Empty(t, result.Errors())
|
||||
assert.True(t, result.Valid())
|
||||
var data interface{}
|
||||
err = json.Unmarshal(resp.Body.Bytes(), &data)
|
||||
assert.NoError(t, err)
|
||||
|
||||
schemaValidation := schema.Validate(data)
|
||||
assert.Nil(t, schemaValidation)
|
||||
}
|
||||
|
||||
func GetCSRF(t testing.TB, session *TestSession, urlStr string) string {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue