mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-30 22:11:07 +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 commitca32f14bc2)
This commit is contained in:
		
					parent
					
						
							
								347a2e7372
							
						
					
				
			
			
				commit
				
					
						6a4abb928f
					
				
			
		
					 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