mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-11-04 08:21:11 +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)
This commit is contained in:
		
					parent
					
						
							
								6931a8f6bb
							
						
					
				
			
			
				commit
				
					
						f9801ba57b
					
				
			
		
					 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
 | 
			
		||||
| 
						 | 
				
			
			@ -519,16 +519,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