|
1 | 1 |
|
2 | 2 | import unittest
|
3 | 3 | from unittest import mock
|
| 4 | +import json |
4 | 5 |
|
5 | 6 | import requests
|
6 | 7 | from ...exceptions import Auth0Error, RateLimitError
|
@@ -74,5 +75,64 @@ def test_should_require_scope(self, mock_post):
|
74 | 75 | # Assert the error message is correct
|
75 | 76 | self.assertIn("missing 1 required positional argument: \'scope\'", str(context.exception))
|
76 | 77 |
|
| 78 | + @mock.patch("auth0.rest.RestClient.post") |
| 79 | + def test_with_authorization_details(self, mock_post): |
| 80 | + g = BackChannelLogin("my.domain.com", "cid", client_secret="clsec") |
| 81 | + g.back_channel_login( |
| 82 | + binding_message="This is a binding message.", |
| 83 | + login_hint={"format": "iss_sub", "iss": "https://my.domain.auth0.com/", "sub": "auth0|USER_ID"}, |
| 84 | + scope="openid", |
| 85 | + authorization_details=[ |
| 86 | + { |
| 87 | + "type":"payment_initiation","locations":["https://example.com/payments"], |
| 88 | + "instructedAmount": |
| 89 | + { |
| 90 | + "currency":"EUR","amount":"123.50" |
| 91 | + }, |
| 92 | + "creditorName":"Merchant A", |
| 93 | + "creditorAccount": |
| 94 | + { |
| 95 | + "bic":"ABCIDEFFXXX", |
| 96 | + "iban":"DE021001001093071118603" |
| 97 | + }, |
| 98 | + "remittanceInformationUnstructured":"Ref Number Merchant" |
| 99 | + } |
| 100 | + ], |
| 101 | + ) |
| 102 | + |
| 103 | + args, kwargs = mock_post.call_args |
| 104 | + |
| 105 | + expected_data = { |
| 106 | + "client_id": "cid", |
| 107 | + "client_secret": "clsec", |
| 108 | + "binding_message": "This is a binding message.", |
| 109 | + "login_hint": {"format": "iss_sub", "iss": "https://my.domain.auth0.com/", "sub": "auth0|USER_ID" }, |
| 110 | + "scope": "openid", |
| 111 | + "authorization_details": [ |
| 112 | + { |
| 113 | + "type":"payment_initiation","locations":["https://example.com/payments"], |
| 114 | + "instructedAmount": |
| 115 | + { |
| 116 | + "currency":"EUR","amount":"123.50" |
| 117 | + }, |
| 118 | + "creditorName":"Merchant A", |
| 119 | + "creditorAccount": |
| 120 | + { |
| 121 | + "bic":"ABCIDEFFXXX", |
| 122 | + "iban":"DE021001001093071118603" |
| 123 | + }, |
| 124 | + "remittanceInformationUnstructured":"Ref Number Merchant" |
| 125 | + }], |
| 126 | + } |
| 127 | + |
| 128 | + actual_data = kwargs["data"] |
| 129 | + |
| 130 | + self.assertEqual(args[0], "https://my.domain.com/bc-authorize") |
| 131 | + |
| 132 | + self.assertEqual( |
| 133 | + json.dumps(actual_data, sort_keys=True), |
| 134 | + json.dumps(expected_data, sort_keys=True) |
| 135 | + ) |
| 136 | + |
77 | 137 |
|
78 | 138 |
|
0 commit comments