mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 04:10:20 +08:00
feat: fix the bug that admin cannot upload avatar for other users (#1323)
This commit is contained in:
@ -123,8 +123,8 @@ func GenerateSimpleTimeId() string {
|
||||
return t
|
||||
}
|
||||
|
||||
func GetId(name string) string {
|
||||
return fmt.Sprintf("admin/%s", name)
|
||||
func GetId(owner, name string) string {
|
||||
return fmt.Sprintf("%s/%s", owner, name)
|
||||
}
|
||||
|
||||
func GetMd5Hash(text string) string {
|
||||
|
@ -137,16 +137,16 @@ func TestGenerateId(t *testing.T) {
|
||||
func TestGetId(t *testing.T) {
|
||||
scenarios := []struct {
|
||||
description string
|
||||
input string
|
||||
input []string
|
||||
expected interface{}
|
||||
}{
|
||||
{"Scenery one", "casdoor", "admin/casdoor"},
|
||||
{"Scenery two", "casbin", "admin/casbin"},
|
||||
{"Scenery three", "lorem ipsum", "admin/lorem ipsum"},
|
||||
{"Scenery one", []string{"admin", "casdoor"}, "admin/casdoor"},
|
||||
{"Scenery two", []string{"admin", "casbin"}, "admin/casbin"},
|
||||
{"Scenery three", []string{"test", "lorem ipsum"}, "test/lorem ipsum"},
|
||||
}
|
||||
for _, scenery := range scenarios {
|
||||
t.Run(scenery.description, func(t *testing.T) {
|
||||
actual := GetId(scenery.input)
|
||||
actual := GetId(scenery.input[0], scenery.input[1])
|
||||
assert.Equal(t, scenery.expected, actual, "This not is a valid MD5")
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user