mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
context: Add authenticated HTTP credentials (#892)
* gRPC: context overide * exchanges: continue update * exchange: Update context handling *Add setter methods for API credentials *Shift credentials functionality to its own file in exchanges package *Add tests *Refactor function DeployCredentialsToContext for library usage *Add function to process credential metadata from API boundary to internal use context value. *Add OTP rpc handling * exchanges: reverts to old style in GetFeeByType, reverts some code I accidently deleted. Plus things and other. XD * template: update * exchanges: fix linter issues * REMOVE THAT AWESOME NEW LINE! * gct: fix some tests * I cant spell :( * exchanges/gctscript: fix more tests * coinnut: fix tests * Update exchanges/credentials.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * Update exchanges/credentials.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * Update exchanges/credentials.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * Update exchanges/credentials.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * Update exchanges/credentials.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * glorious: nits * exchanges/gctcli: stop applying empty credentials * fix linters * exchanges: add test * rpceserver: actually check error for errors * rpcserver: fix up tests * Update exchanges/credentials.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * exchanges/creds: move tests to corresponding files, add protection and segration for Credentials struct & ptr values * exchanges/creds: allow subaccount to override default credentials via gRPC * exchanges/credentials: don't return nil in GetCredentials * creds: spelling * exchanges: fix glorious NITS! * credentials: Add in test and refactor IsEmpty method. * credentials: change type positioning (glorious) * exchange_template: Fix template changes * DOCS: Refresh * docs: fix spelling * DOCS: fix alignment and add package * DOCS: ALIGN! Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io> Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
This commit is contained in:
@@ -226,7 +226,7 @@ func configureExchangeKeys() bool {
|
||||
return false
|
||||
}
|
||||
b := ex.GetBase()
|
||||
b.SetAPIKeys(exchAPIKEY, exchAPISECRET, exchClientID)
|
||||
b.SetCredentials(exchAPIKEY, exchAPISECRET, exchClientID, "", "", "")
|
||||
b.SkipAuthCheck = true
|
||||
return b.ValidateAPICredentials()
|
||||
return b.AreCredentialsValid(context.Background())
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
objects "github.com/d5/tengo/v2"
|
||||
"github.com/thrasher-corp/gocryptotrader/common"
|
||||
"github.com/thrasher-corp/gocryptotrader/engine"
|
||||
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
|
||||
"github.com/thrasher-corp/gocryptotrader/gctscript/modules"
|
||||
"github.com/thrasher-corp/gocryptotrader/gctscript/modules/gct"
|
||||
@@ -191,9 +191,8 @@ func TestAccountInfo(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, err = gct.ExchangeAccountInfo(exch, assetType)
|
||||
if err != nil &&
|
||||
!strings.Contains(err.Error(), "unset/default API keys") {
|
||||
t.Error(err)
|
||||
if !errors.Is(err, exchange.ErrAuthenticationSupportNotEnabled) {
|
||||
t.Errorf("received: %v but expected: %v", err, exchange.ErrAuthenticationSupportNotEnabled)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,9 +237,8 @@ func TestExchangeOrderSubmit(t *testing.T) {
|
||||
|
||||
_, err = gct.ExchangeOrderSubmit(exch, currencyPair, delimiter,
|
||||
orderType, orderSide, orderPrice, orderAmount, orderID, orderAsset)
|
||||
if err != nil &&
|
||||
!strings.Contains(err.Error(), "unset/default API keys") {
|
||||
t.Error(err)
|
||||
if !errors.Is(err, exchange.ErrAuthenticationSupportNotEnabled) {
|
||||
t.Errorf("received: %v but expected: %v", err, exchange.ErrAuthenticationSupportNotEnabled)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user