Skip to content

Commit 85cd08c

Browse files
committed
Historically we exposed self.session so we keep it
1 parent 124cbd2 commit 85cd08c

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

oauth2cli/oauth2.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ def encode_saml_assertion(assertion):
3333
CLIENT_ASSERTION_TYPE_SAML2 = "urn:ietf:params:oauth:client-assertion-type:saml2-bearer"
3434
client_assertion_encoders = {CLIENT_ASSERTION_TYPE_SAML2: encode_saml_assertion}
3535

36+
@property
37+
def session(self):
38+
warnings.warn("Will be gone in next major release", DeprecationWarning)
39+
return self._http_client
40+
41+
@session.setter
42+
def session(self, value):
43+
warnings.warn("Will be gone in next major release", DeprecationWarning)
44+
self._http_client = value
45+
46+
3647
def __init__(
3748
self,
3849
server_configuration, # type: dict

tests/test_client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,11 @@ def test_device_flow(self):
174174
assertion=lambda: self.assertIn('access_token', result),
175175
skippable_errors=self.client.DEVICE_FLOW_RETRIABLE_ERRORS)
176176

177+
178+
class TestSessionAccessibility(unittest.TestCase):
179+
def test_accessing_session_property_for_backward_compatibility(self):
180+
client = Client({}, "client_id")
181+
client.session
182+
client.session.close()
183+
client.session = "something"
184+

0 commit comments

Comments
 (0)