forked from TrueCloudLab/frostfs-s3-gw
[#306] Fix billing tests
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
3285a2e105
commit
7de1ffdbe9
1 changed files with 9 additions and 22 deletions
|
@ -442,33 +442,24 @@ func putObjectBase(router *routerMock, namespace, bktName, objName string) *http
|
||||||
func TestOwnerIDRetrieving(t *testing.T) {
|
func TestOwnerIDRetrieving(t *testing.T) {
|
||||||
chiRouter := prepareRouter(t)
|
chiRouter := prepareRouter(t)
|
||||||
|
|
||||||
w := httptest.NewRecorder()
|
ns, bktName, objName := "", "test-bucket", "test-object"
|
||||||
r := httptest.NewRequest(http.MethodGet, "/test-bucket", nil)
|
|
||||||
|
|
||||||
chiRouter.ServeHTTP(w, r)
|
createBucket(chiRouter, ns, bktName)
|
||||||
resp := readResponse(t, w)
|
|
||||||
|
resp := putObject(chiRouter, ns, bktName, objName)
|
||||||
require.NotEqual(t, "anon", resp.ReqInfo.User)
|
require.NotEqual(t, "anon", resp.ReqInfo.User)
|
||||||
|
|
||||||
w = httptest.NewRecorder()
|
|
||||||
r = httptest.NewRequest(http.MethodGet, "/test-bucket", nil)
|
|
||||||
|
|
||||||
chiRouter.cfg.Center.(*centerMock).anon = true
|
chiRouter.cfg.Center.(*centerMock).anon = true
|
||||||
|
resp = putObject(chiRouter, ns, bktName, objName)
|
||||||
chiRouter.ServeHTTP(w, r)
|
|
||||||
resp = readResponse(t, w)
|
|
||||||
require.Equal(t, "anon", resp.ReqInfo.User)
|
require.Equal(t, "anon", resp.ReqInfo.User)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBillingMetrics(t *testing.T) {
|
func TestBillingMetrics(t *testing.T) {
|
||||||
chiRouter := prepareRouter(t)
|
chiRouter := prepareRouter(t)
|
||||||
|
|
||||||
bktName, objName := "test-bucket", "test-object"
|
ns, bktName, objName := "", "test-bucket", "test-object"
|
||||||
target := fmt.Sprintf("/%s/%s", bktName, objName)
|
|
||||||
|
|
||||||
w := httptest.NewRecorder()
|
createBucket(chiRouter, ns, bktName)
|
||||||
r := httptest.NewRequest(http.MethodPut, target, nil)
|
|
||||||
|
|
||||||
chiRouter.ServeHTTP(w, r)
|
|
||||||
dump := chiRouter.cfg.Metrics.UsersAPIStats().DumpMetrics()
|
dump := chiRouter.cfg.Metrics.UsersAPIStats().DumpMetrics()
|
||||||
require.Len(t, dump.Requests, 1)
|
require.Len(t, dump.Requests, 1)
|
||||||
require.NotEqual(t, "anon", dump.Requests[0].User)
|
require.NotEqual(t, "anon", dump.Requests[0].User)
|
||||||
|
@ -477,11 +468,7 @@ func TestBillingMetrics(t *testing.T) {
|
||||||
require.Equal(t, 1, dump.Requests[0].Requests)
|
require.Equal(t, 1, dump.Requests[0].Requests)
|
||||||
|
|
||||||
chiRouter.cfg.Center.(*centerMock).anon = true
|
chiRouter.cfg.Center.(*centerMock).anon = true
|
||||||
|
putObject(chiRouter, ns, bktName, objName)
|
||||||
w = httptest.NewRecorder()
|
|
||||||
r = httptest.NewRequest(http.MethodPut, target, nil)
|
|
||||||
|
|
||||||
chiRouter.ServeHTTP(w, r)
|
|
||||||
dump = chiRouter.cfg.Metrics.UsersAPIStats().DumpMetrics()
|
dump = chiRouter.cfg.Metrics.UsersAPIStats().DumpMetrics()
|
||||||
require.Len(t, dump.Requests, 1)
|
require.Len(t, dump.Requests, 1)
|
||||||
require.Equal(t, "anon", dump.Requests[0].User)
|
require.Equal(t, "anon", dump.Requests[0].User)
|
||||||
|
|
Loading…
Reference in a new issue