mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-23 11:01:49 +01:00
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:
parent
ab95cc6726
commit
d6abb363f6
2 changed files with 9 additions and 3 deletions
|
@ -31,10 +31,8 @@ const (
|
|||
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 {
|
||||
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 {
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"net/http/httptest"
|
||||
"regexp"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
|
@ -23,6 +24,13 @@ import (
|
|||
_ "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
|
||||
|
||||
Set up an expected response for GET on api with user-id = 1:
|
||||
|
|
Loading…
Reference in a new issue