Skip to content

Commit

Permalink
[api] use real username when query the DB
Browse files Browse the repository at this point in the history
  • Loading branch information
jbygdell committed Aug 13, 2024
1 parent d9789c0 commit 450b1ca
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sda/cmd/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ func listUserFiles(c *gin.Context) {
username = strings.TrimPrefix(username, "/")
username = strings.TrimSuffix(username, "/files")
log.Debugln(username)
files, err := Conf.API.DB.GetUserFiles(strings.ReplaceAll(username, "@", "_"))
files, err := Conf.API.DB.GetUserFiles(username)
if err != nil {
c.AbortWithStatusJSON(http.StatusInternalServerError, err.Error())

Expand Down
3 changes: 2 additions & 1 deletion sda/cmd/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"path"
"runtime"
"strconv"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -1138,7 +1139,7 @@ func (suite *TestSuite) TestListUserFiles() {
testUsers := []string{"user_example.org", "User-B", "User-C"}
for _, user := range testUsers {
for i := 0; i < 5; i++ {
fileID, err := Conf.API.DB.RegisterFile(fmt.Sprintf("/%v/TestGetUserFiles-00%d.c4gh", user, i), user)
fileID, err := Conf.API.DB.RegisterFile(fmt.Sprintf("/%v/TestGetUserFiles-00%d.c4gh", user, i), strings.ReplaceAll(user,"_","@"))
if err != nil {
suite.FailNow("failed to register file in database")
}
Expand Down

0 comments on commit 450b1ca

Please sign in to comment.