mirror of
https://github.com/go-gitea/gitea.git
synced 2024-09-01 14:56:30 +00:00
fixed file size for mock and scope of time patch
This commit is contained in:
parent
2685f1a307
commit
1df0a1d252
@ -24,6 +24,7 @@ var (
|
|||||||
LimitTotalOwnerCount int64
|
LimitTotalOwnerCount int64
|
||||||
LimitTotalOwnerSize int64
|
LimitTotalOwnerSize int64
|
||||||
LimitSizeAlpine int64
|
LimitSizeAlpine int64
|
||||||
|
LimitSizeArch int64
|
||||||
LimitSizeCargo int64
|
LimitSizeCargo int64
|
||||||
LimitSizeChef int64
|
LimitSizeChef int64
|
||||||
LimitSizeComposer int64
|
LimitSizeComposer int64
|
||||||
|
@ -59,6 +59,7 @@ func Push(ctx *context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if message is outdated.
|
||||||
if time.Since(t) > time.Hour {
|
if time.Since(t) > time.Hour {
|
||||||
apiError(ctx, http.StatusUnauthorized, "outdated message")
|
apiError(ctx, http.StatusUnauthorized, "outdated message")
|
||||||
return
|
return
|
||||||
|
@ -355,6 +355,8 @@ func CheckSizeQuotaExceeded(ctx context.Context, doer, owner *user_model.User, p
|
|||||||
switch packageType {
|
switch packageType {
|
||||||
case packages_model.TypeAlpine:
|
case packages_model.TypeAlpine:
|
||||||
typeSpecificSize = setting.Packages.LimitSizeAlpine
|
typeSpecificSize = setting.Packages.LimitSizeAlpine
|
||||||
|
case packages_model.TypeArch:
|
||||||
|
typeSpecificSize = setting.Packages.LimitSizeArch
|
||||||
case packages_model.TypeCargo:
|
case packages_model.TypeCargo:
|
||||||
typeSpecificSize = setting.Packages.LimitSizeCargo
|
typeSpecificSize = setting.Packages.LimitSizeCargo
|
||||||
case packages_model.TypeChef:
|
case packages_model.TypeChef:
|
||||||
|
@ -249,6 +249,8 @@ ht719b7ZWR3+SRcXySXC/cP8DL/N12kaf8wQSBkjjLKkAPBDnLyL32YFQur67qtbXtxcd/23w375
|
|||||||
|
|
||||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||||
|
|
||||||
|
setting.Packages.LimitSizeArch = 99999999999999
|
||||||
|
|
||||||
user := &user_model.User{
|
user := &user_model.User{
|
||||||
Name: "dancheg97",
|
Name: "dancheg97",
|
||||||
Email: "dancheg97@fmnx.su",
|
Email: "dancheg97@fmnx.su",
|
||||||
@ -267,7 +269,7 @@ ht719b7ZWR3+SRcXySXC/cP8DL/N12kaf8wQSBkjjLKkAPBDnLyL32YFQur67qtbXtxcd/23w375
|
|||||||
req := NewRequestWithJSON(t, "POST", "/api/v1/user/gpg_keys?token="+token, api.CreateGPGKeyOption{
|
req := NewRequestWithJSON(t, "POST", "/api/v1/user/gpg_keys?token="+token, api.CreateGPGKeyOption{
|
||||||
ArmoredKey: gpgkey,
|
ArmoredKey: gpgkey,
|
||||||
})
|
})
|
||||||
MakeRequest(t, req, http.StatusOK)
|
MakeRequest(t, req, http.StatusCreated)
|
||||||
|
|
||||||
pkgData, err := base64.StdEncoding.DecodeString(pkg)
|
pkgData, err := base64.StdEncoding.DecodeString(pkg)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
@ -286,12 +288,11 @@ ht719b7ZWR3+SRcXySXC/cP8DL/N12kaf8wQSBkjjLKkAPBDnLyL32YFQur67qtbXtxcd/23w375
|
|||||||
wayback, err := time.Parse(time.RFC3339, "2023-07-04T19:57:09+03:00")
|
wayback, err := time.Parse(time.RFC3339, "2023-07-04T19:57:09+03:00")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
patch := monkey.Patch(time.Now, func() time.Time { return wayback })
|
|
||||||
defer patch.Unpatch()
|
|
||||||
|
|
||||||
t.Run("Push", func(t *testing.T) {
|
t.Run("Push", func(t *testing.T) {
|
||||||
defer tests.PrintCurrentTest(t)()
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
|
patch := monkey.Patch(time.Now, func() time.Time { return wayback })
|
||||||
|
|
||||||
req := NewRequest(t, "PUT", path.Join(rootURL, "/push"))
|
req := NewRequest(t, "PUT", path.Join(rootURL, "/push"))
|
||||||
|
|
||||||
req.Header.Set("filename", "randpkg-1-1-x86_64.pkg.tar.zst")
|
req.Header.Set("filename", "randpkg-1-1-x86_64.pkg.tar.zst")
|
||||||
@ -304,6 +305,8 @@ ht719b7ZWR3+SRcXySXC/cP8DL/N12kaf8wQSBkjjLKkAPBDnLyL32YFQur67qtbXtxcd/23w375
|
|||||||
req.Body = io.NopCloser(bytes.NewReader(pkgData))
|
req.Body = io.NopCloser(bytes.NewReader(pkgData))
|
||||||
|
|
||||||
MakeRequest(t, req, http.StatusOK)
|
MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
|
patch.Unpatch()
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Get", func(t *testing.T) {
|
t.Run("Get", func(t *testing.T) {
|
||||||
@ -338,6 +341,8 @@ ht719b7ZWR3+SRcXySXC/cP8DL/N12kaf8wQSBkjjLKkAPBDnLyL32YFQur67qtbXtxcd/23w375
|
|||||||
t.Run("Remove", func(t *testing.T) {
|
t.Run("Remove", func(t *testing.T) {
|
||||||
defer tests.PrintCurrentTest(t)()
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
|
patch := monkey.Patch(time.Now, func() time.Time { return wayback })
|
||||||
|
|
||||||
req := NewRequest(t, "PUT", path.Join(rootURL, "/push"))
|
req := NewRequest(t, "PUT", path.Join(rootURL, "/push"))
|
||||||
|
|
||||||
req.Header.Set("username", "dancheg97")
|
req.Header.Set("username", "dancheg97")
|
||||||
@ -349,5 +354,7 @@ ht719b7ZWR3+SRcXySXC/cP8DL/N12kaf8wQSBkjjLKkAPBDnLyL32YFQur67qtbXtxcd/23w375
|
|||||||
req.Body = io.NopCloser(bytes.NewReader(mdSigData))
|
req.Body = io.NopCloser(bytes.NewReader(mdSigData))
|
||||||
|
|
||||||
MakeRequest(t, req, http.StatusOK)
|
MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
|
patch.Unpatch()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user