mirror of
1
Fork 0

FIX: use proper time format (activitypub/client) (#4132)

use proper http time format than replacing with GMT in time.RFC1123 =)

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4132
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: Shiny Nematoda <snematoda.751k2@aleeas.com>
Co-committed-by: Shiny Nematoda <snematoda.751k2@aleeas.com>
This commit is contained in:
Shiny Nematoda 2024-06-14 15:22:37 +00:00 committed by Earl Warren
parent ab95cc6726
commit d6abb363f6
2 changed files with 9 additions and 3 deletions

View File

@ -31,10 +31,8 @@ const (
httpsigExpirationTime = 60 httpsigExpirationTime = 60
) )
// Gets the current time as an RFC 2616 formatted string
// RFC 2616 requires RFC 1123 dates but with GMT instead of UTC
func CurrentTime() string { func CurrentTime() string {
return strings.ReplaceAll(time.Now().UTC().Format(time.RFC1123), "UTC", "GMT") return time.Now().UTC().Format(http.TimeFormat)
} }
func containsRequiredHTTPHeaders(method string, headers []string) error { func containsRequiredHTTPHeaders(method string, headers []string) error {

View File

@ -11,6 +11,7 @@ import (
"net/http/httptest" "net/http/httptest"
"regexp" "regexp"
"testing" "testing"
"time"
"code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/models/unittest"
@ -23,6 +24,13 @@ import (
_ "github.com/mattn/go-sqlite3" _ "github.com/mattn/go-sqlite3"
) )
func TestCurrentTime(t *testing.T) {
date := CurrentTime()
_, err := time.Parse(http.TimeFormat, date)
assert.NoError(t, err)
assert.Equal(t, date[len(date)-3:], "GMT")
}
/* ToDo: Set Up tests for http get requests /* ToDo: Set Up tests for http get requests
Set up an expected response for GET on api with user-id = 1: Set up an expected response for GET on api with user-id = 1: