Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share access request #1144

Open
wants to merge 3 commits into
base: sprint-1.19
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions internal/api/model/zbox.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package model

import (
"time"

"github.com/0chain/gosdk/core/common"
"github.com/0chain/system_test/internal/api/util/test"
resty "github.com/go-resty/resty/v2"
Expand All @@ -16,6 +18,11 @@ type ZboxMessageResponse struct {
Message string `json:"message"`
}

type ZboxMessageDataResponse[T any] struct {
Message string `json:"message"`
Data T `json:"data"`
}

type ZboxMessageDataShareinfoResponse struct {
Message string `json:"message"`
Data []ZboxShareInfo `json:"data"`
Expand Down Expand Up @@ -142,6 +149,19 @@ type ZboxShareInfo struct {
UpdatedAt string `json:"UpdatedAt"`
}

type ZboxShareRequest struct {
ID int64
OwnerID string
ClientID string
LookupHash string
AuthTicket string
Message *string
Status uint8
AppType int64
CreatedAt time.Time
UpdatedAt time.Time
}

type ZboxNftCollection struct {
AllocationId string `json:"allocation_id"`
CollectionId string `json:"collection_id"`
Expand Down
115 changes: 115 additions & 0 deletions internal/api/util/client/zbox_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
X_APP_CLIENT_ID_R = "bcf5f517be521e0ffdb22d1fc26a35abdec8556bcb9ed075244a358df7337cd0"
X_APP_CLIENT_KEY_R = "de9351bbf460c761ea979764831759369ced3c6de38b856e7921eee9cc034323cce23c562c74a0629867fbea33d5009b9f473bc3b766871b65e7cf864ba4301d"
X_APP_CLIENT_SIGNATURE_R = "43fa947257ae0b5da8b073f0efeaa2570c4faf66fcabd93407e3597bc34e440b"
X_APP_USER_ID_B = "test_user_id_B"
X_APP_CLIENT_ID_B = "fc6ed0246c8bb4f7251acf521c81d7fdb3f042a7bb2234a032723c9bba8dda9b"
X_APP_CLIENT_KEY_B = "92843dc9dafc041e88b778356bf39533606911828d50f420fb24e0cc2dcc4b06a8ed6dc0f083c988bc8cc64c7525f943dff8d1ece4955e456c450d34faf8da12"
X_APP_CLIENT_SIGNATURE_B = "11648e1f79b90419166c13f09d9bdf15e32105591c1f94d461aa82c569480f17"
X_APP_ID_TOKEN = "test_firebase_token"
X_APP_TIMESTAMP = "123456789"
X_APP_CSRF = "test_csrf_token"
Expand Down Expand Up @@ -550,6 +554,25 @@
return ZboxShareInfoList, resp, err
}

func (c *ZboxClient) GetShareInfoReceivedWithParams(t *test.SystemTest, headers map[string]string, queryParams map[string]string) (*model.ZboxMessageDataShareinfoResponse, *resty.Response, error) {

Check failure on line 557 in internal/api/util/client/zbox_client.go

View workflow job for this annotation

GitHub Actions / lint

paramTypeCombine: func(t *test.SystemTest, headers map[string]string, queryParams map[string]string) (*model.ZboxMessageDataShareinfoResponse, *resty.Response, error) could be replaced with func(t *test.SystemTest, headers, queryParams map[string]string) (*model.ZboxMessageDataShareinfoResponse, *resty.Response, error) (gocritic)
t.Logf("Getting share Info for [%v] using 0box...", headers["X-App-User-ID"])
var ZboxShareInfoList *model.ZboxMessageDataShareinfoResponse

urlBuilder := NewURLBuilder()
err := urlBuilder.MustShiftParse(c.zboxEntrypoint)
require.NoError(t, err, "URL parse error")
urlBuilder.SetPath("/v2/shareinfo/received")

resp, err := c.executeForServiceProvider(t, urlBuilder.String(), model.ExecutionRequest{
Dst: &ZboxShareInfoList,
QueryParams: queryParams,
Headers: headers,
RequiredStatusCode: 200,
}, HttpGETMethod)

return ZboxShareInfoList, resp, err
}

func (c *ZboxClient) CreateShareInfo(t *test.SystemTest, headers, shareinfoData map[string]string) (*model.ZboxMessageResponse, *resty.Response, error) {
t.Logf("Posting ShareInfo using 0box...")
var message *model.ZboxMessageResponse
Expand Down Expand Up @@ -588,6 +611,98 @@
return message, resp, err
}

func (c *ZboxClient) CreateShareRequest(t *test.SystemTest, headers, shareRequestData map[string]string) (*model.ZboxMessageDataResponse[int64], *resty.Response, error) {
t.Logf("Posting ShareRequest using 0box...")
var out model.ZboxMessageDataResponse[int64]

urlBuilder := NewURLBuilder()
err := urlBuilder.MustShiftParse(c.zboxEntrypoint)
require.NoError(t, err, "URL parse error")
urlBuilder.SetPath("/v2/sharereq")

resp, err := c.executeForServiceProvider(t, urlBuilder.String(), model.ExecutionRequest{
Dst: &out,
Body: shareRequestData,
Headers: headers,
RequiredStatusCode: 201,
}, HttpPOSTMethod)
return &out, resp, err
}

func (c *ZboxClient) GetReceivedShareReq(t *test.SystemTest, headers map[string]string, queryParams map[string]string) (*model.ZboxMessageDataResponse[[]model.ZboxShareRequest], *resty.Response, error) {

Check failure on line 632 in internal/api/util/client/zbox_client.go

View workflow job for this annotation

GitHub Actions / lint

paramTypeCombine: func(t *test.SystemTest, headers map[string]string, queryParams map[string]string) (*model.ZboxMessageDataResponse[[]model.ZboxShareRequest], *resty.Response, error) could be replaced with func(t *test.SystemTest, headers, queryParams map[string]string) (*model.ZboxMessageDataResponse[[]model.ZboxShareRequest], *resty.Response, error) (gocritic)
t.Logf("Getting received share requests for [%v] using 0box...", headers["X-App-User-ID"])
var out model.ZboxMessageDataResponse[[]model.ZboxShareRequest]

urlBuilder := NewURLBuilder()
err := urlBuilder.MustShiftParse(c.zboxEntrypoint)
require.NoError(t, err, "URL parse error")
urlBuilder.SetPath("/v2/sharereq/received")

resp, err := c.executeForServiceProvider(t, urlBuilder.String(), model.ExecutionRequest{
Dst: &out,
QueryParams: queryParams,
Headers: headers,
RequiredStatusCode: 200,
}, HttpGETMethod)

return &out, resp, err
}

func (c *ZboxClient) GetRequestedShareReq(t *test.SystemTest, headers map[string]string, queryParams map[string]string) (*model.ZboxMessageDataResponse[[]model.ZboxShareRequest], *resty.Response, error) {

Check failure on line 651 in internal/api/util/client/zbox_client.go

View workflow job for this annotation

GitHub Actions / lint

paramTypeCombine: func(t *test.SystemTest, headers map[string]string, queryParams map[string]string) (*model.ZboxMessageDataResponse[[]model.ZboxShareRequest], *resty.Response, error) could be replaced with func(t *test.SystemTest, headers, queryParams map[string]string) (*model.ZboxMessageDataResponse[[]model.ZboxShareRequest], *resty.Response, error) (gocritic)
t.Logf("Getting requested share requests for [%v] using 0box...", headers["X-App-User-ID"])
var out model.ZboxMessageDataResponse[[]model.ZboxShareRequest]

urlBuilder := NewURLBuilder()
err := urlBuilder.MustShiftParse(c.zboxEntrypoint)
require.NoError(t, err, "URL parse error")
urlBuilder.SetPath("/v2/sharereq/requested")

resp, err := c.executeForServiceProvider(t, urlBuilder.String(), model.ExecutionRequest{
Dst: &out,
QueryParams: queryParams,
Headers: headers,
RequiredStatusCode: 200,
}, HttpGETMethod)

return &out, resp, err
}

func (c *ZboxClient) UpdateShareReq(t *test.SystemTest, headers, updateShareReqData map[string]string) (*model.ZboxMessageDataResponse[model.ZboxShareRequest], *resty.Response, error) {
t.Logf("Updating ShareRequest using 0box...")
var out model.ZboxMessageDataResponse[model.ZboxShareRequest]

urlBuilder := NewURLBuilder()
err := urlBuilder.MustShiftParse(c.zboxEntrypoint)
require.NoError(t, err, "URL parse error")
urlBuilder.SetPath("/v2/sharereq")

resp, err := c.executeForServiceProvider(t, urlBuilder.String(), model.ExecutionRequest{
Dst: &out,
FormData: updateShareReqData,
Headers: headers,
RequiredStatusCode: 201,
}, HttpPUTMethod)
return &out, resp, err
}

func (c *ZboxClient) DeleteShareReq(t *test.SystemTest, headers, queryParams map[string]string) (*model.ZboxMessageDataResponse[int64], *resty.Response, error) {
t.Logf("Deleting ShareRequest using 0box...")
var out model.ZboxMessageDataResponse[int64]

urlBuilder := NewURLBuilder()
err := urlBuilder.MustShiftParse(c.zboxEntrypoint)
require.NoError(t, err, "URL parse error")
urlBuilder.SetPath("/v2/sharereq")

resp, err := c.executeForServiceProvider(t, urlBuilder.String(), model.ExecutionRequest{
Dst: &out,
QueryParams: queryParams,
Headers: headers,
RequiredStatusCode: 200,
}, HttpDELETEMethod)
return &out, resp, err
}

func (c *ZboxClient) CreateNftCollection(t *test.SystemTest, headers, nfCollectionData map[string]string) (*model.ZboxNftCollection, *resty.Response, error) {
t.Logf("Creating nft collection using 0box...")
var ZboxNftCollection *model.ZboxNftCollection
Expand Down
Loading
Loading