mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-11-20 07:58:01 +00:00
[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 commit0ccefc633e) (cherry picked from commit19e647b531) (cherry picked from commit2bcc04889d) (cherry picked from commit2fd1932699) (cherry picked from commitb9a3e1e525) (cherry picked from commit92d932d23f) (cherry picked from commitc125217fea) (cherry picked from commitf9801ba57b) Conflicts: go.mod https://codeberg.org/forgejo/forgejo/pulls/2034
This commit is contained in:
parent
5e2065c1c0
commit
2558a8a764
3 changed files with 9 additions and 20 deletions
|
|
@ -43,8 +43,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
|
||||
|
|
@ -544,16 +544,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