Skip to content

Commit

Permalink
Release 5.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wallee-deployment-user committed Apr 3, 2024
1 parent 882199a commit 95d896a
Show file tree
Hide file tree
Showing 25 changed files with 288 additions and 69 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Library facilitates your interaction with various services such as transactions,
pip3 install --upgrade wallee
```

### pip3 install from source via github
### pip3 install from source via GitHub

```sh
pip3 install git+http://github.com/wallee-payment/python-sdk.git
Expand Down Expand Up @@ -49,7 +49,6 @@ You can also optionally set `default_headers` to set some headers that will be s
```python
from wallee import Configuration
from wallee.api import TransactionServiceApi, TransactionPaymentPageServiceApi
from wallee.models import LineItem, LineItemType, TransactionCreate

space_id = 405

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import setuptools

with open("README.md", "r") as fh:
with open("README.md", "r", encoding="utf8") as fh:
long_description = fh.read()

NAME = "wallee"
VERSION = "4.2.0"
VERSION = "5.0.0"

REQUIRES = [
"certifi >= 14.05.14",
Expand Down
1 change: 1 addition & 0 deletions test/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

SPACE_ID = 405


def get_transaction_create():
return TransactionCreate(
line_items=[
Expand Down
17 changes: 15 additions & 2 deletions test/test_refund.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,18 @@ def test_refund(self):
"State must be SUCCESSFUL",
)

def test_read_not_found(self):
"""read_not_found() should read not found refund as none"""

NOT_FOUND_REFUND_ID = 0

refund_read = self.refund_service.read(
space_id=SPACE_ID, id=NOT_FOUND_REFUND_ID)

self.assertIsNone(refund_read, "Return data must be None.")

def test_read(self):
"""read() should should fetch refund details"""
"""read() should fetch refund details"""

transaction = self.transaction_service.create(
space_id=SPACE_ID, transaction=get_transaction_create())
Expand Down Expand Up @@ -121,6 +131,8 @@ def test_read(self):
read_refund = self.refund_service.read(
space_id=SPACE_ID, id=refund.id)

self.assertIsNotNone(read_refund, "Return data must not be None.")

self.assertEqual(
refund.id,
read_refund.id,
Expand Down Expand Up @@ -164,7 +176,7 @@ def test_search(self):
criteria = EntityQuery(
filter=EntityQueryFilter(
field_name="id",
value=transaction_completion.id,
value=refund.id,
type=EntityQueryFilterType.LEAF,
operator=CriteriaOperator.EQUALS
)
Expand All @@ -173,6 +185,7 @@ def test_search(self):
refunds_found = self.refund_service.search(
SPACE_ID, query=criteria)

self.assertEqual(1, len(refunds_found))
for ref in refunds_found:
self.assertEqual(
refund.id,
Expand Down
3 changes: 3 additions & 0 deletions test/test_transaction_completion_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
TransactionCompletionState
)


class TransactionCompletionServiceTest(unittest.TestCase):
"""TransactionCompletionServiceApi tests"""

Expand Down Expand Up @@ -126,6 +127,8 @@ def test_read(self):
transaction_read = self.transaction_completion_service.read(
space_id=SPACE_ID, id=transaction_completion.id)

self.assertIsNotNone(transaction_read, "Return data must not be None.")

self.assertEqual(transaction_completion.id,
transaction_read.id, "Transaction ids must match", )

Expand Down
18 changes: 17 additions & 1 deletion test/test_transaction_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ def test_fetch_payment_methods(self):
self.assertTrue(len(payment_methods) > 0,
"Payment methods should be configured for a given transaction in test space", )

def test_read_not_found(self):
"""read_not_found() should read not found transaction as none"""

NOT_FOUND_TRANSACTION_ID = 0

transaction_read = self.transaction_service.read(
space_id=SPACE_ID, id=NOT_FOUND_TRANSACTION_ID)

self.assertIsNone(transaction_read, "Return data must be None.")

def test_read(self):
"""read() should read transaction details"""

Expand All @@ -164,6 +174,8 @@ def test_read(self):
transaction_read = self.transaction_service.read(
space_id=SPACE_ID, id=transaction.id)

self.assertIsNotNone(transaction_read, "Return data must not be None.")

self.assertEqual(transaction.id, transaction_read.id,
"Transaction ids should match")

Expand Down Expand Up @@ -195,6 +207,8 @@ def test_read_with_credentials(self):
transaction_read = self.transaction_service.read_with_credentials(
credentials=creds)

self.assertIsNotNone(transaction_read, "Return data must not be None.")

self.assertEqual(transaction.id, transaction_read.id,
"Transaction ids should match")

Expand Down Expand Up @@ -239,7 +253,7 @@ def test_process_without_user_interaction(self):
space_id=SPACE_ID, id=transaction.id)

self.assertEqual(
transaction.id, transaction_processed.id, "Transaction ids mush match"
transaction.id, transaction_processed.id, "Transaction ids must match"
)

def test_fetch_one_click_tokens_with_credentials_no_tokens(self):
Expand Down Expand Up @@ -318,6 +332,8 @@ def test_process_one_click_token_and_redirect_with_credentials(self):
transaction2_read = self.transaction_service.read(
space_id=SPACE_ID, id=transaction2.id)

self.assertIsNotNone(transaction2_read, "Return data must not be None.")

self.assertEqual(
TransactionState.AUTHORIZED,
transaction2_read.state,
Expand Down
78 changes: 78 additions & 0 deletions test/test_webhook_encryption_service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import unittest
from unittest.mock import patch

from constants import (
API_CONFIG
)
from wallee.api import (
WebhookEncryptionServiceApi
)
from wallee.models import (
WebhookEncryptionPublicKey
)

CONTENT_TO_VERIFY = ('{"entityId":11,"eventId":35,"listenerEntityId":1472041829003,'
'"listenerEntityTechnicalName":"Transaction","spaceId":1,"state":"PROCESSING",'
'"timestamp":"2023-12-19T13:43:35+0000","webhookListenerId":2}')

SIGNATURE_HEADER = ("algorithm=SHA256withECDSA, keyId=ab3b774e-770e-4644-9b51-885d71f973e5, "
"signature=MEYCIQCTzbMrMsOAC6T57T9kQTb1iGZVg2R7n6pY9A4ML4P31gIhAIOoav8cG8x0jpRWQztqSJIC8gXWKq+4DuENEySvmMYf")

PUBLIC_KEY_ID = "ab3b774e-770e-4644-9b51-885d71f973e5"

VALID_ENCODED_PUBLIC_KEY = "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEdWq7ZBGsjUzhBO3e6mzUBLpjpV3TQw1bL1rk3ocjn5C5qne7TY0OBBhiWgaPtWlvUcqASz903vtfeSTQma+SBA=="


class WebhookEncryptionServiceTest(unittest.TestCase):
"""WebhookEncryptionServiceApi tests"""

def setUp(self):
self.webhook_encryption_service = WebhookEncryptionServiceApi(API_CONFIG)

def tearDown(self):
pass

@patch('wallee.api.WebhookEncryptionServiceApi.read')
def test_validate_valid_content_and_signature(self, mock_webhook_encryption_service_read):
"""validate_valid_content_and_signature() should validate correct content and signature"""

mock_webhook_encryption_service_read.return_value = (
WebhookEncryptionPublicKey(id=1, public_key=VALID_ENCODED_PUBLIC_KEY))

is_content_valid = self.webhook_encryption_service.is_content_valid(SIGNATURE_HEADER, CONTENT_TO_VERIFY)

mock_webhook_encryption_service_read.assert_called_once()
self.assertIsNotNone(is_content_valid, "Return webhook encryption validation marker must not be None.")
self.assertTrue(is_content_valid, "The webhook encryption content and signature must be valid.")

@patch('wallee.api.WebhookEncryptionServiceApi.read')
def test_read_webhook_encryption_not_found(self, mock_webhook_encryption_service_read):
"""read_webhook_encryption_not_found() should fail when webhook encryption public key is none """

mock_webhook_encryption_service_read.return_value = None

with self.assertRaises(ValueError) as context:
self.webhook_encryption_service.is_content_valid(SIGNATURE_HEADER, CONTENT_TO_VERIFY)

self.assertEqual(str(context.exception), f"Could not find public key with id {PUBLIC_KEY_ID}")

mock_webhook_encryption_service_read.assert_called_once()

@patch('wallee.api.WebhookEncryptionServiceApi.read')
def test_validate_invalid_signature_header(self, mock_webhook_encryption_service_read):
"""validate_invalid_signature_header() should fail when signature header is invalid """

mock_webhook_encryption_service_read.return_value = (
WebhookEncryptionPublicKey(id=1, public_key=VALID_ENCODED_PUBLIC_KEY))

invalid_signature_header = "algorithm=SHA256withECDSA, keyId=ab3b774e-770e-4644-9b51-885d71f973e5"

with self.assertRaises(ValueError) as context:
self.webhook_encryption_service.is_content_valid(invalid_signature_header, CONTENT_TO_VERIFY)

self.assertEqual(str(context.exception), "Invalid webhook signature header. Expected format: "
"'algorithm=<algorithm>, keyId=<keyId>, signature=<signature>'")


if __name__ == "__main__":
unittest.main(failfast=True)
2 changes: 1 addition & 1 deletion wallee/api/charge_flow_service_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def fetch_charge_flow_payment_page_url_with_http_info(self, space_id, id, **kwar
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json', 'text/plain;charset=utf-8'])
['text/plain;charset=utf-8', 'application/json'])

# Authentication setting
auth_settings = []
Expand Down
2 changes: 1 addition & 1 deletion wallee/api/human_user_service_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def export_with_http_info(self, request, **kwargs):
body_params = params['request']
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json;charset=utf-8', 'text/csv'])
['text/csv', 'application/json;charset=utf-8'])

# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type(
Expand Down
24 changes: 12 additions & 12 deletions wallee/api/refund_comment_service_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def create(self, space_id, entity, **kwargs):
:param async_req bool
:param int space_id: (required)
:param RefundCommentCreate entity: (required)
:param RefundCommentCreate entity: The comment object which should be created. (required)
:return: RefundComment
If the method is called asynchronously,
returns the request thread.
Expand All @@ -161,7 +161,7 @@ def create_with_http_info(self, space_id, entity, **kwargs):
:param async_req bool
:param int space_id: (required)
:param RefundCommentCreate entity: (required)
:param RefundCommentCreate entity: The comment object which should be created. (required)
:return: RefundComment
If the method is called asynchronously,
returns the request thread.
Expand Down Expand Up @@ -309,15 +309,15 @@ def delete_with_http_info(self, space_id, id, **kwargs):
query_params = []
if 'space_id' in params:
query_params.append(('spaceId', params['space_id']))
if 'id' in params:
query_params.append(('id', params['id']))

header_params = {}

form_params = []
local_var_files = {}

body_params = None
if 'id' in params:
body_params = params['id']
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json;charset=utf-8'])
Expand Down Expand Up @@ -357,7 +357,7 @@ def pin(self, space_id, id, **kwargs):
:param async_req bool
:param int space_id: (required)
:param int id: (required)
:param int id: The id of the comment to pin to the top. (required)
:return: None
If the method is called asynchronously,
returns the request thread.
Expand All @@ -383,7 +383,7 @@ def pin_with_http_info(self, space_id, id, **kwargs):
:param async_req bool
:param int space_id: (required)
:param int id: (required)
:param int id: The id of the comment to pin to the top. (required)
:return: None
If the method is called asynchronously,
returns the request thread.
Expand Down Expand Up @@ -468,7 +468,7 @@ def read(self, space_id, id, **kwargs):
:param async_req bool
:param int space_id: (required)
:param int id: (required)
:param int id: The id of the comment which should be returned. (required)
:return: RefundComment
If the method is called asynchronously,
returns the request thread.
Expand All @@ -494,7 +494,7 @@ def read_with_http_info(self, space_id, id, **kwargs):
:param async_req bool
:param int space_id: (required)
:param int id: (required)
:param int id: The id of the comment which should be returned. (required)
:return: RefundComment
If the method is called asynchronously,
returns the request thread.
Expand Down Expand Up @@ -579,7 +579,7 @@ def unpin(self, space_id, id, **kwargs):
:param async_req bool
:param int space_id: (required)
:param int id: (required)
:param int id: The id of the comment to unpin. (required)
:return: None
If the method is called asynchronously,
returns the request thread.
Expand All @@ -605,7 +605,7 @@ def unpin_with_http_info(self, space_id, id, **kwargs):
:param async_req bool
:param int space_id: (required)
:param int id: (required)
:param int id: The id of the comment to unpin. (required)
:return: None
If the method is called asynchronously,
returns the request thread.
Expand Down Expand Up @@ -690,7 +690,7 @@ def update(self, space_id, entity, **kwargs):
:param async_req bool
:param int space_id: (required)
:param RefundCommentActive entity: (required)
:param RefundCommentActive entity: The comment object with the properties which should be updated. (required)
:return: RefundComment
If the method is called asynchronously,
returns the request thread.
Expand All @@ -716,7 +716,7 @@ def update_with_http_info(self, space_id, entity, **kwargs):
:param async_req bool
:param int space_id: (required)
:param RefundCommentActive entity: (required)
:param RefundCommentActive entity: The comment object with the properties which should be updated. (required)
:return: RefundComment
If the method is called asynchronously,
returns the request thread.
Expand Down
Loading

0 comments on commit 95d896a

Please sign in to comment.