Skip to content

Commit

Permalink
Merge pull request #11 from brienze1/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Oct 12, 2022
2 parents b510680 + efbc13e commit e1f81b3
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 29 deletions.
9 changes: 9 additions & 0 deletions build/local/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ services:
volumes:
- ./lambda-files:/lambda-files
entrypoint: sh -c "cp crypto-robot-validator.zip /lambda-files"
biscoint-mock:
container_name: biscoint-mock
depends_on:
- awscli
image: lfbrienze/biscoint-mock:latest
ports:
- "8080:8085"
entrypoint: >
sh -c "java -jar application/target/biscoint-mock.jar"
awscli:
depends_on:
- crypto-robot-validator
Expand Down
9 changes: 9 additions & 0 deletions build/local/scripts/lambda/03-test-data-creation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@ aws dynamodb put-item \
"locked": {
"BOOL": false
},
"cash_available": {
"N": "10000.00"
},
"cash_amount": {
"N": "1000.00"
},
"cash_reserved": {
"N": "0"
},
"crypto_available": {
"N": "1.000000"
},
"crypto_amount": {
"N": "1.000000"
},
Expand Down Expand Up @@ -53,6 +59,9 @@ aws dynamodb put-item \
"month_stop_loss": {
"N": "500"
},
"operation_amount_percentage": {
"N": "5.5"
},
"month_sell_cap": {
"N": "25000"
},
Expand Down
6 changes: 3 additions & 3 deletions config/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ AWS_SECRETS_MANAGER_CACHE_SECRET_NAME=crypto_robot.secrets.cache
AWS_SECRETS_MANAGER_ENCRYPTION_SECRET_NAME=crypto_robot.secrets.encryption
CACHE_KEY_PREFIX=crypto_robot.validator.lock.
CACHE_KEY_TTL_SECONDS=60
BISCOINT_CRYPTO_URL=http://localhost:8085/v1
BISCOINT_CRYPTO_GET_CRYPTO_PATH=/ticker/price
BISCOINT_CRYPTO_GET_BALANCE_PATH=/balance
BISCOINT_CRYPTO_URL=http://localhost:8085/
BISCOINT_CRYPTO_GET_CRYPTO_PATH=v1/ticker
BISCOINT_CRYPTO_GET_BALANCE_PATH=v1/balance
6 changes: 3 additions & 3 deletions config/.env.docker
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ AWS_SECRETS_MANAGER_CACHE_SECRET_NAME=crypto_robot.secrets.cache
AWS_SECRETS_MANAGER_ENCRYPTION_SECRET_NAME=crypto_robot.secrets.encryption
CACHE_KEY_PREFIX=crypto_robot.validator.lock.
CACHE_KEY_TTL_SECONDS=60
BISCOINT_CRYPTO_URL=http://localhost:8085/v1
BISCOINT_CRYPTO_GET_CRYPTO_PATH=/ticker/price
BISCOINT_CRYPTO_GET_BALANCE_PATH=/balance
BISCOINT_CRYPTO_URL=http://localhost:8085/
BISCOINT_CRYPTO_GET_CRYPTO_PATH=v1/ticker
BISCOINT_CRYPTO_GET_BALANCE_PATH=v1/balance
6 changes: 3 additions & 3 deletions config/.env.localstack
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ AWS_SECRETS_MANAGER_CACHE_SECRET_NAME=crypto_robot.secrets.cache
AWS_SECRETS_MANAGER_ENCRYPTION_SECRET_NAME=crypto_robot.secrets.encryption
CACHE_KEY_PREFIX=crypto_robot.validator.lock.
CACHE_KEY_TTL_SECONDS=60
BISCOINT_CRYPTO_URL=http://localhost:8085/v1
BISCOINT_CRYPTO_GET_CRYPTO_PATH=/ticker/price
BISCOINT_CRYPTO_GET_BALANCE_PATH=/balance
BISCOINT_CRYPTO_URL=http://biscoint-mock:8080/
BISCOINT_CRYPTO_GET_CRYPTO_PATH=v1/ticker
BISCOINT_CRYPTO_GET_BALANCE_PATH=v1/balance
6 changes: 3 additions & 3 deletions config/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ AWS_SECRETS_MANAGER_CACHE_SECRET_NAME=crypto_robot.secrets.cache
AWS_SECRETS_MANAGER_ENCRYPTION_SECRET_NAME=crypto_robot.secrets.encryption
CACHE_KEY_PREFIX=crypto_robot.validator.lock.
CACHE_KEY_TTL_SECONDS=60
BISCOINT_CRYPTO_URL=http://localhost:8085/v1
BISCOINT_CRYPTO_GET_CRYPTO_PATH=/v1/ticker/price
BISCOINT_CRYPTO_GET_BALANCE_PATH=/v1/balance
BISCOINT_CRYPTO_URL=http://localhost:8085/
BISCOINT_CRYPTO_GET_CRYPTO_PATH=v1/ticker
BISCOINT_CRYPTO_GET_BALANCE_PATH=v1/balance
18 changes: 9 additions & 9 deletions internal/validator/integration/dto/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import (
)

type Operation struct {
Id string `json:"operation_id"`
Status status.Status `json:"status"`
CreatedAt time.Time `json:"created_at"`
Locked bool `json:"locked"`
Type operation_type.OperationType `json:"type"`
Amount float64 `json:"amount"`
Base symbol.Symbol `json:"base"`
Quote symbol.Symbol `json:"quote"`
StopLoss float64 `json:"stop_loss"`
Id string `dynamodbav:"operation_id"`
Status status.Status `dynamodbav:"status"`
CreatedAt time.Time `dynamodbav:"created_at"`
Locked bool `dynamodbav:"locked"`
Type operation_type.OperationType `dynamodbav:"type"`
Amount float64 `dynamodbav:"amount"`
Base symbol.Symbol `dynamodbav:"base"`
Quote symbol.Symbol `dynamodbav:"quote"`
StopLoss float64 `dynamodbav:"stop_loss"`
}

func OperationDto(operation *model.Operation) *Operation {
Expand Down
3 changes: 2 additions & 1 deletion internal/validator/integration/utils/token_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/brienze1/crypto-robot-validator/internal/validator/integration/adapters"
"github.com/brienze1/crypto-robot-validator/internal/validator/integration/exceptions"
"github.com/brienze1/crypto-robot-validator/pkg/custom_error"
"strings"
)

type tokenBuilder struct {
Expand All @@ -28,7 +29,7 @@ func (t *tokenBuilder) Build(apiSecret string, endpoint string, payload any, non
return "", t.abort(err, "Payload marshal failed")
}

strToBeSigned := endpoint + nonce + string(payloadString)
strToBeSigned := endpoint + nonce + strings.ReplaceAll(string(payloadString), "\"", "")

t.logger.Info("Build finished", endpoint, payload, nonce, payloadString, strToBeSigned)
return t.encryptionService.SHA384Encrypt(strToBeSigned, apiSecret), nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (b *biscointWebService) GetBalance(clientId string, useSimulation bool) (*m
if useSimulation {
biscointUrl = b.simulationUrl
}
request, err := http.NewRequest(http.MethodGet, biscointUrl+b.biscointGetBalancePath, nil)
request, err := http.NewRequest(http.MethodPost, biscointUrl+b.biscointGetBalancePath, nil)
if err != nil {
return nil, b.abort(err, "Error while trying to generate Biscoint get request")
}
Expand All @@ -111,7 +111,7 @@ func (b *biscointWebService) GetBalance(clientId string, useSimulation bool) (*m
}(response.Body)

if response.StatusCode != http.StatusOK {
return nil, b.abort(err, "Biscoint API status code not Ok: "+response.Status)
return nil, b.abort(err, "Biscoint API status code not Ok: "+response.Status, response.Body)
}

var balanceResponse dto.BalanceResponse
Expand Down
3 changes: 3 additions & 0 deletions scripts/docker_compose_pull
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

docker-compose pull
2 changes: 1 addition & 1 deletion test/integrated/step_definitions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func biscointApiIsUp() error {
coinResponse, _ := json.Marshal(coin)
biscointApi.GetBalanceResponse = string(balanceResponse)
biscointApi.GetCryptoResponse = string(coinResponse)
properties.Properties().BiscointUrl = biscointApi.GetUrl()
properties.Properties().BiscointUrl = biscointApi.GetUrl() + "/"
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions test/mocks/http_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ func (h *httpClient) SetupServer() {
h.Server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(h.StatusCode)
var response []byte
if r.URL.Path == properties.Properties().BiscointGetBalancePath {
if r.URL.Path == "/"+properties.Properties().BiscointGetBalancePath {
response = []byte(h.GetBalanceResponse)
} else if r.URL.Path == properties.Properties().BiscointGetCryptoPath {
} else if r.URL.Path == "/"+properties.Properties().BiscointGetCryptoPath {
response = []byte(h.GetCryptoResponse)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func setup() {
logger.Reset()
client.Reset()
client.SetupServer()
properties.Properties().BiscointUrl = client.GetUrl()
properties.Properties().SimulationUrl = client.GetUrl()
properties.Properties().BiscointUrl = client.GetUrl() + "/"
properties.Properties().SimulationUrl = client.GetUrl() + "/"
headerBuilder.Reset()

biscointWebService = webservice.BiscointWebService(logger, client, headerBuilder)
Expand Down

0 comments on commit e1f81b3

Please sign in to comment.