Skip to content

Commit

Permalink
Fixed mosts tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Forceu committed Feb 2, 2025
1 parent 8ee4e74 commit a7a31c3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
3 changes: 3 additions & 0 deletions internal/test/TestHelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ func HttpPostRequest(t MockT, config HttpTestConfig) []*http.Cookie {
})
}
r.Header.Set("Content-type", "application/x-www-form-urlencoded")
for _, header := range config.Headers {
r.Header.Set(header.Name, header.Value)
}
client := &http.Client{}
response, err := client.Do(r)
IsNil(t, err)
Expand Down
7 changes: 7 additions & 0 deletions internal/test/testconfiguration/TestConfiguration.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@ func writeApiKeys() {
UserId: 5,
PublicId: "Queime3iun",
})
database.SaveApiKey(models.ApiKey{
Id: "validkeyid7",
FriendlyName: "Key for uid 7",
Permissions: models.ApiPermAll, // TODO
UserId: 7,
PublicId: "Queime3iun7",
})
database.SaveApiKey(models.ApiKey{
Id: "GAh1IhXDvYnqfYLazWBqMB9HSFmNPO",
FriendlyName: "Second Key",
Expand Down
29 changes: 8 additions & 21 deletions internal/webserver/Webserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,13 +449,6 @@ func TestPostUploadNoAuth(t *testing.T) {

RequiredContent: []string{"{\"Result\":\"error\",\"ErrorMessage\":\"Not authenticated\"}"},
})
test.HttpPostUploadRequest(t, test.HttpTestConfig{
Url: "http://127.0.0.1:53843/uploadComplete",
UploadFileName: "test/fileupload.jpg",
UploadFieldName: "file",
ResultCode: http.StatusUnauthorized,
RequiredContent: []string{"{\"Result\":\"error\",\"ErrorMessage\":\"Not authenticated\"}"},
})
}

func TestPostUpload(t *testing.T) {
Expand Down Expand Up @@ -507,20 +500,14 @@ func TestPostUpload(t *testing.T) {
go func() {
time.Sleep(200 * time.Millisecond)
test.HttpPostRequest(t, test.HttpTestConfig{
Url: "http://127.0.0.1:53843/uploadComplete",
PostValues: []test.PostBody{{
Key: "chunkid",
Value: "eeng4ier3Taen7a",
}, {
Key: "filename",
Value: "fileupload.jpg",
}, {
Key: "filecontenttype",
Value: "test-content",
}, {
Key: "filesize",
Value: "50",
}},
Url: "http://127.0.0.1:53843/api/chunk/complete",
Headers: []test.Header{
{"apikey", "validkeyid7"},
{"uuid", "eeng4ier3Taen7a"},
{"filename", "fileupload.jpg"},
{"filecontenttype", "test-content"},
{"filesize", "50"},
},
RequiredContent: []string{"{\"result\":\"OK\"}"},
Cookies: []test.Cookie{{
Name: "session_token",
Expand Down
File renamed without changes.

0 comments on commit a7a31c3

Please sign in to comment.