From f1cc649a0651177c41b76dac6656b99c121cb630 Mon Sep 17 00:00:00 2001 From: hirokisan Date: Sun, 19 Feb 2023 09:54:41 +0900 Subject: [PATCH] test(integration): get api key --- .../v5/user/testdata/v5-user-get-api-key.json | 48 +++++++++++++++++++ .../v5/user/{api_key_test.go => user_test.go} | 6 +-- v5_user_service.go | 18 +++---- 3 files changed, 60 insertions(+), 12 deletions(-) create mode 100644 integrationtest/v5/user/testdata/v5-user-get-api-key.json rename integrationtest/v5/user/{api_key_test.go => user_test.go} (74%) diff --git a/integrationtest/v5/user/testdata/v5-user-get-api-key.json b/integrationtest/v5/user/testdata/v5-user-get-api-key.json new file mode 100644 index 0000000..011f596 --- /dev/null +++ b/integrationtest/v5/user/testdata/v5-user-get-api-key.json @@ -0,0 +1,48 @@ +{ + "id": "214087", + "note": "full3", + "apiKey": "TrswBXTLDVhxqkfDEI", + "readOnly": 0, + "secret": "", + "permissions": { + "ContractTrade": [ + "Order", + "Position" + ], + "Spot": [ + "SpotTrade" + ], + "Wallet": [ + "AccountTransfer", + "SubMemberTransfer" + ], + "Options": [ + "OptionsTrade" + ], + "Derivatives": [ + "DerivativesTrade" + ], + "CopyTrading": [ + "CopyTrading" + ], + "BlockTrade": [], + "Exchange": [ + "ExchangeHistory" + ], + "NFT": [] + }, + "ips": [ + "*" + ], + "type": 1, + "deadlineDay": 63, + "expiredAt": "2023-04-23T05:52:24Z", + "createdAt": "2022-06-20T13:26:50Z", + "unified": 0, + "uta": 1, + "userID": 146940, + "inviterID": 0, + "vipLevel": "No VIP", + "mktMakerLevel": "0", + "affiliateID": 0 +} \ No newline at end of file diff --git a/integrationtest/v5/user/api_key_test.go b/integrationtest/v5/user/user_test.go similarity index 74% rename from integrationtest/v5/user/api_key_test.go rename to integrationtest/v5/user/user_test.go index d49513f..7fd0777 100644 --- a/integrationtest/v5/user/api_key_test.go +++ b/integrationtest/v5/user/user_test.go @@ -10,12 +10,12 @@ import ( "github.com/stretchr/testify/require" ) -func TestGetPositionInfo(t *testing.T) { +func TestGetAPIKey(t *testing.T) { client := bybit.NewTestClient().WithAuthFromEnv() - res, err := client.V5().User().GetAPIKeyInfo() + res, err := client.V5().User().GetAPIKey() require.NoError(t, err) { - goldenFilename := "./testdata/v5-user-get-api-key-info.json" // TODO + goldenFilename := "./testdata/v5-user-get-api-key.json" testhelper.Compare(t, goldenFilename, testhelper.ConvertToJSON(res.Result)) testhelper.UpdateFile(t, goldenFilename, testhelper.ConvertToJSON(res.Result)) } diff --git a/v5_user_service.go b/v5_user_service.go index 1c13f2c..92c6e38 100644 --- a/v5_user_service.go +++ b/v5_user_service.go @@ -29,15 +29,15 @@ type V5ApiKeyResult struct { ReadOnly int `json:"readOnly"` Secret string `json:"secret"` Permissions struct { - ContractTrade []interface{} `json:"ContractTrade"` - Spot []interface{} `json:"Spot"` - Wallet []string `json:"Wallet"` - Options []interface{} `json:"Options"` - Derivatives []interface{} `json:"Derivatives"` - CopyTrading []interface{} `json:"CopyTrading"` - BlockTrade []interface{} `json:"BlockTrade"` - Exchange []interface{} `json:"Exchange"` - Nft []interface{} `json:"NFT"` + ContractTrade []string `json:"ContractTrade"` + Spot []string `json:"Spot"` + Wallet []string `json:"Wallet"` + Options []string `json:"Options"` + Derivatives []string `json:"Derivatives"` + CopyTrading []string `json:"CopyTrading"` + BlockTrade []string `json:"BlockTrade"` + Exchange []string `json:"Exchange"` + Nft []string `json:"NFT"` } `json:"permissions"` Ips []string `json:"ips"` Type int `json:"type"`