Skip to content

Commit 84d158f

Browse files
committed
E2e test for refresh_in behavior
1 parent 7ba324b commit 84d158f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/test_e2e.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,14 @@ def _test_acquire_token_interactive(
185185
self, client_id=None, authority=None, scope=None, port=None,
186186
username_uri="", # But you would want to provide one
187187
data=None, # Needed by ssh-cert feature
188+
login_hint=None,
188189
**ignored):
189190
assert client_id and authority and scope
190191
self.app = msal.PublicClientApplication(
191192
client_id, authority=authority, http_client=MinimalHttpClient())
192193
result = self.app.acquire_token_interactive(
193194
scope,
195+
login_hint=login_hint,
194196
timeout=120,
195197
port=port,
196198
welcome_template= # This is an undocumented feature for testing
@@ -212,6 +214,29 @@ def _test_acquire_token_interactive(
212214
return result # For further testing
213215

214216

217+
class RefreshInBehavior(E2eTestCase):
218+
def test_refresh_in_should_be_available(self):
219+
"""The refresh_in claim in an AT will only be issued when:
220+
221+
* An MSAL library is in allowlist
222+
* token lifetime > 2 hours. configured by token lifetime policy for your app
223+
"""
224+
result = self._test_acquire_token_interactive(
225+
client_id="880ed52d-22df-4916-8077-53b393439e02",
226+
authority="https://login.microsoftonline.com/msidlab6.onmicrosoft.com",
227+
scope=["https://msidlab6-my.sharepoint.com/.default"],
228+
username_uri="https://msidlab.com/api/user/[email protected]",
229+
login_hint="[email protected]",
230+
)
231+
self.assertNotIn("refresh_in", result.keys(), "Should filter out refresh_in")
232+
_, token_in_cache = self.app.token_cache._cache["AccessToken"].popitem()
233+
self.assertIn(
234+
"refresh_on",
235+
token_in_cache.keys(),
236+
"refresh_on should be in cached AT {}".format(
237+
json.dumps(token_in_cache, indent=4)))
238+
239+
215240
class SshCertTestCase(E2eTestCase):
216241
_JWK1 = """{"kty":"RSA", "n":"2tNr73xwcj6lH7bqRZrFzgSLj7OeLfbn8216uOMDHuaZ6TEUBDN8Uz0ve8jAlKsP9CQFCSVoSNovdE-fs7c15MxEGHjDcNKLWonznximj8pDGZQjVdfK-7mG6P6z-lgVcLuYu5JcWU_PeEqIKg5llOaz-qeQ4LEDS4T1D2qWRGpAra4rJX1-kmrWmX_XIamq30C9EIO0gGuT4rc2hJBWQ-4-FnE1NXmy125wfT3NdotAJGq5lMIfhjfglDbJCwhc8Oe17ORjO3FsB5CLuBRpYmP7Nzn66lRY3Fe11Xz8AEBl3anKFSJcTvlMnFtu3EpD-eiaHfTgRBU7CztGQqVbiQ", "e":"AQAB"}"""
217242
_JWK2 = """{"kty":"RSA", "n":"72u07mew8rw-ssw3tUs9clKstGO2lvD7ZNxJU7OPNKz5PGYx3gjkhUmtNah4I4FP0DuF1ogb_qSS5eD86w10Wb1ftjWcoY8zjNO9V3ph-Q2tMQWdDW5kLdeU3-EDzc0HQeou9E0udqmfQoPbuXFQcOkdcbh3eeYejs8sWn3TQprXRwGh_TRYi-CAurXXLxQ8rp-pltUVRIr1B63fXmXhMeCAGwCPEFX9FRRs-YHUszUJl9F9-E0nmdOitiAkKfCC9LhwB9_xKtjmHUM9VaEC9jWOcdvXZutwEoW2XPMOg0Ky-s197F9rfpgHle2gBrXsbvVMvS0D-wXg6vsq6BAHzQ", "e":"AQAB"}"""

0 commit comments

Comments
 (0)