-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from eurofurence/issue-66-ef-2024
Issue 66 ef 2024
- Loading branch information
Showing
10 changed files
with
133 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,6 +137,66 @@ func TestWebhook_DownstreamError(t *testing.T) { | |
tstRequireErrorResponse(t, response, http.StatusBadGateway, "webhook.downstream.error", nil) | ||
} | ||
|
||
func TestWebhook_Success_Status_WrongPrefix(t *testing.T) { | ||
tstSetup(tstConfigFile) | ||
defer tstShutdown() | ||
|
||
docs.Given("given the payment provider has a transaction in status confirmed") | ||
|
||
docs.Given("and an anonymous caller who knows the secret url") | ||
url := "/api/rest/v1/webhook/demosecret" | ||
|
||
docs.When("when they trigger our webhook endpoint with the wrong prefix") | ||
request := ` | ||
{ | ||
"transaction": { | ||
"id": 1892362736, | ||
"invoice": { | ||
"paymentRequestId": 4242, | ||
"referenceId": "230001-122218-000001" | ||
} | ||
} | ||
} | ||
` | ||
response := tstPerformPost(url, request, tstNoToken()) | ||
|
||
docs.Then("then the request is successful") | ||
require.Equal(t, http.StatusOK, response.status) | ||
|
||
docs.Then("and the expected downstream requests have been made to the concardis api") | ||
tstRequireConcardisRecording(t, | ||
"QueryPaymentLink 4242", | ||
) | ||
|
||
docs.Then("and no requests to the payment service have been made") | ||
tstRequirePaymentServiceRecording(t, nil) | ||
|
||
docs.Then("and the expected error notification emails have been sent") | ||
tstRequireMailServiceRecording(t, []mailservice.MailSendDto{ | ||
{ | ||
CommonID: "payment-cncrd-adapter-error", | ||
Lang: "en-US", | ||
To: []string{ | ||
"[email protected]", | ||
}, | ||
Variables: map[string]string{ | ||
"status": "ref-id-prefix", | ||
"operation": "webhook", | ||
"referenceId": "230001-122218-000001", | ||
}, | ||
}, | ||
}) | ||
|
||
docs.Then("and the expected protocol entries have been written") | ||
tstRequireProtocolEntries(t, entity.ProtocolEntry{ | ||
ReferenceId: "230001-122218-000001", | ||
ApiId: 4242, | ||
Kind: "error", | ||
Message: "webhook ref-id-prefix", | ||
Details: "ref-id=230001-122218-000001", | ||
}) | ||
} | ||
|
||
// --- helpers --- | ||
|
||
func tstWebhookSuccessCase(t *testing.T, status string, expectedPaymentServiceRecording []paymentservice.Transaction, expectedMailRecording []mailservice.MailSendDto, expectedProtocol []entity.ProtocolEntry) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters