mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-26 12:27:06 +00:00 
			
		
		
		
	Use single shared random string generation function (#15741)
* Use single shared random string generation function - Replace 3 functions that do the same with 1 shared one - Use crypto/rand over math/rand for a stronger RNG - Output only alphanumerical for URL compatibilty Fixes: #15536 * use const string method * Update modules/avatar/avatar.go Co-authored-by: a1012112796 <1012112796@qq.com> Co-authored-by: a1012112796 <1012112796@qq.com>
This commit is contained in:
		| @@ -1,24 +0,0 @@ | ||||
| // Copyright 2020 The Gitea Authors. All rights reserved. | ||||
| // Use of this source code is governed by a MIT-style | ||||
| // license that can be found in the LICENSE file. | ||||
|  | ||||
| package generate | ||||
|  | ||||
| import ( | ||||
| 	"os" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/stretchr/testify/assert" | ||||
| ) | ||||
|  | ||||
| func TestMain(m *testing.M) { | ||||
| 	retVal := m.Run() | ||||
|  | ||||
| 	os.Exit(retVal) | ||||
| } | ||||
|  | ||||
| func TestGetRandomString(t *testing.T) { | ||||
| 	randomString, err := GetRandomString(4) | ||||
| 	assert.NoError(t, err) | ||||
| 	assert.Len(t, randomString, 4) | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 silverwind
					silverwind