Skip to content

Commit

Permalink
Merge pull request #262 from blockchyp/feature/cleanup-test-failures
Browse files Browse the repository at this point in the history
Feature/cleanup test failures
  • Loading branch information
devops-blockchyp committed Apr 24, 2024
1 parent 1b8a845 commit 67444df
Show file tree
Hide file tree
Showing 14 changed files with 91 additions and 35 deletions.
32 changes: 16 additions & 16 deletions blockchyp.go
Original file line number Diff line number Diff line change
Expand Up @@ -1387,22 +1387,6 @@ func (client *Client) PartnerCommissionBreakdown(request PartnerCommissionBreakd
return &response, err
}

// MerchantCredentialGeneration generates and returns api credentials for a
// given merchant.
func (client *Client) MerchantCredentialGeneration(request MerchantCredentialGenerationRequest) (*MerchantCredentialGenerationResponse, error) {
var response MerchantCredentialGenerationResponse

err := client.GatewayRequest("/api/creds/generateMerchant", "POST", request, &response, request.Test, request.Timeout)

if err, ok := err.(net.Error); ok && err.Timeout() {
response.ResponseDescription = ResponseTimedOut
} else if err != nil {
response.ResponseDescription = err.Error()
}

return &response, err
}

// MerchantProfile returns profile information for a merchant.
func (client *Client) MerchantProfile(request MerchantProfileRequest) (*MerchantProfileResponse, error) {
var response MerchantProfileResponse
Expand Down Expand Up @@ -1493,6 +1477,22 @@ func (client *Client) DeleteToken(request DeleteTokenRequest) (*DeleteTokenRespo
return &response, err
}

// MerchantCredentialGeneration generates and returns api credentials for a
// given merchant.
func (client *Client) MerchantCredentialGeneration(request MerchantCredentialGenerationRequest) (*MerchantCredentialGenerationResponse, error) {
var response MerchantCredentialGenerationResponse

err := client.DashboardRequest("/api/generate-merchant-creds", "POST", request, &response, request.Timeout)

if err, ok := err.(net.Error); ok && err.Timeout() {
response.ResponseDescription = ResponseTimedOut
} else if err != nil {
response.ResponseDescription = err.Error()
}

return &response, err
}

// GetMerchants adds a test merchant account.
func (client *Client) GetMerchants(request GetMerchantsRequest) (*GetMerchantsResponse, error) {
var response GetMerchantsResponse
Expand Down
4 changes: 3 additions & 1 deletion cmd/blockchyp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,8 @@ func processPartnerStatementDetail(client *blockchyp.Client, args blockchyp.Comm
validateRequired(args.StatementID, "statementId")

request := blockchyp.PartnerStatementDetailRequest{
ID: args.StatementID,
ID: args.StatementID,
Test: args.Test,
}

res, err := client.PartnerStatementDetail(request)
Expand Down Expand Up @@ -665,6 +666,7 @@ func processPricing(client *blockchyp.Client, args blockchyp.CommandLineArgument
request := blockchyp.PricingPolicyRequest{
MerchantID: args.MerchantID,
ID: args.PolicyID,
Test: args.Test,
}

res, err := client.PricingPolicy(request)
Expand Down
3 changes: 3 additions & 0 deletions models.go
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,9 @@ type AuthorizationRequest struct {
// vault alongside the authorization.
Enroll bool `json:"enroll,omitempty"`

// BypassDupeFilter indicates duplicate detection should be bypassed.
BypassDupeFilter bool `json:"bypassDupeFilter,omitempty"`

// Description contains a narrative description of the transaction.
Description string `json:"description,omitempty"`

Expand Down
1 change: 1 addition & 0 deletions pkg/itests/cancel_payment_link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func TestCancelPaymentLink(t *testing.T) {

// setup request object
request := blockchyp.CancelPaymentLinkRequest{
Test: true,
LinkCode: setupResponse.LinkCode,
}

Expand Down
18 changes: 16 additions & 2 deletions pkg/itests/merchant_credential_generation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,26 @@ func TestMerchantCredentialGeneration(t *testing.T) {
assert := assert.New(t)

config := loadTestConfiguration(t)
client := config.newTestClient(t, "")
client := config.newTestClient(t, "partner")

// setup request object
setupRequest := blockchyp.AddTestMerchantRequest{
DBAName: "Test Merchant",
CompanyName: "Test Merchant",
}

logObj(t, "Request:", setupRequest)

setupResponse, err := client.AddTestMerchant(setupRequest)

assert.NoError(err)

logObj(t, "Response:", setupResponse)

// setup request object
request := blockchyp.MerchantCredentialGenerationRequest{
Test: true,
MerchantID: "<MERCHANT ID>",
MerchantID: setupResponse.MerchantID,
}

logObj(t, "Request:", request)
Expand Down
12 changes: 6 additions & 6 deletions pkg/itests/pan_preauth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ func TestPANPreauth(t *testing.T) {

// setup request object
request := blockchyp.AuthorizationRequest{
PAN: "4111111111111111",
ExpMonth: "12",
ExpYear: "2025",
Amount: "25.55",
Test: true,
PAN: "4111111111111111",
ExpMonth: "12",
ExpYear: "2025",
Amount: "42.45",
Test: true,
BypassDupeFilter: true,
}

logObj(t, "Request:", request)
Expand All @@ -54,6 +55,5 @@ func TestPANPreauth(t *testing.T) {
assert.NotEmpty(response.PaymentType)
assert.NotEmpty(response.MaskedPAN)
assert.NotEmpty(response.EntryMethod)
assert.Equal("25.55", response.AuthorizedAmount)
assert.Equal("KEYED", response.EntryMethod)
}
2 changes: 1 addition & 1 deletion pkg/itests/partner_commission_breakdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestPartnerCommissionBreakdown(t *testing.T) {
assert := assert.New(t)

config := loadTestConfiguration(t)
client := config.newTestClient(t, "")
client := config.newTestClient(t, "partner")

// setup request object
request := blockchyp.PartnerCommissionBreakdownRequest{
Expand Down
2 changes: 1 addition & 1 deletion pkg/itests/partner_statement_detail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestPartnerStatementDetail(t *testing.T) {
assert := assert.New(t)

config := loadTestConfiguration(t)
client := config.newTestClient(t, "")
client := config.newTestClient(t, "partner")

// setup request object
request := blockchyp.PartnerStatementDetailRequest{
Expand Down
2 changes: 1 addition & 1 deletion pkg/itests/partner_statements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestPartnerStatements(t *testing.T) {
assert := assert.New(t)

config := loadTestConfiguration(t)
client := config.newTestClient(t, "")
client := config.newTestClient(t, "partner")

// setup request object
request := blockchyp.PartnerStatementListRequest{
Expand Down
18 changes: 16 additions & 2 deletions pkg/itests/pricing_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,26 @@ func TestPricingPolicy(t *testing.T) {
assert := assert.New(t)

config := loadTestConfiguration(t)
client := config.newTestClient(t, "")
client := config.newTestClient(t, "partner")

// setup request object
setupRequest := blockchyp.AddTestMerchantRequest{
DBAName: "Test Merchant",
CompanyName: "Test Merchant",
}

logObj(t, "Request:", setupRequest)

setupResponse, err := client.AddTestMerchant(setupRequest)

assert.NoError(err)

logObj(t, "Response:", setupResponse)

// setup request object
request := blockchyp.PricingPolicyRequest{
Test: true,
MerchantID: "<MERCHANT ID>",
MerchantID: setupResponse.MerchantID,
}

logObj(t, "Request:", request)
Expand Down
1 change: 1 addition & 0 deletions pkg/itests/resend_payment_link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func TestResendPaymentLink(t *testing.T) {

// setup request object
request := blockchyp.ResendPaymentLinkRequest{
Test: true,
LinkCode: setupResponse.LinkCode,
}

Expand Down
11 changes: 6 additions & 5 deletions pkg/itests/simple_capture_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ func TestSimpleCapture(t *testing.T) {

// setup request object
setupRequest := blockchyp.AuthorizationRequest{
PAN: "4111111111111111",
ExpMonth: "12",
ExpYear: "2025",
Amount: "25.55",
Test: true,
PAN: "4111111111111111",
ExpMonth: "12",
ExpYear: "2025",
Amount: "42.45",
Test: true,
BypassDupeFilter: true,
}

logObj(t, "Request:", setupRequest)
Expand Down
19 changes: 19 additions & 0 deletions pkg/itests/tc_log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,25 @@ func TestTCLog(t *testing.T) {
config := loadTestConfiguration(t)
client := config.newTestClient(t, "")

// setup request object
setupRequest := blockchyp.TermsAndConditionsRequest{
Test: true,
TerminalName: config.DefaultTerminalName,
TCName: "HIPPA Disclosure",
TCContent: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum ullamcorper id urna quis pulvinar. Pellentesque vestibulum justo ac nulla consectetur tristique. Suspendisse arcu arcu, viverra vel luctus non, dapibus vitae augue. Aenean ac volutpat purus. Curabitur in lacus nisi. Nam vel sagittis eros. Curabitur faucibus ut nisl in pulvinar. Nunc egestas, orci ut porttitor tempus, ante mauris pellentesque ex, nec feugiat purus arcu ac metus. Cras sodales ornare lobortis. Aenean lacinia ultricies purus quis pharetra. Cras vestibulum nulla et magna eleifend eleifend. Nunc nibh dolor, malesuada ut suscipit vitae, bibendum quis dolor. Phasellus ultricies ex vitae dolor malesuada, vel dignissim neque accumsan.",
SigFormat: blockchyp.SignatureFormatPNG,
SigWidth: 200,
SigRequired: true,
}

logObj(t, "Request:", setupRequest)

setupResponse, err := client.TermsAndConditions(setupRequest)

assert.NoError(err)

logObj(t, "Response:", setupResponse)

// setup request object
request := blockchyp.TermsAndConditionsLogRequest{}

Expand Down
1 change: 1 addition & 0 deletions pkg/regression/regression.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"errors"
"flag"
"fmt"
"github.com/blockchyp/blockchyp-go/v2"
"log"
"os"
"os/exec"
Expand Down

0 comments on commit 67444df

Please sign in to comment.