style: formater le depot avec ruff format
QUA-002, premiere moitie. **Ce commit ne fait que reformater** : aucun changement de comportement, aucune ligne de logique touchee. 72 fichiers, 4 restaient deja conformes. Il est isole exprès, pour que `git log -p` sur les commits voisins reste lisible. `quote-style = "preserve"` etait deja pose dans pyproject.toml, ce qui evite le brassage guillemets simples / doubles : le diff porte sur les retours a la ligne, l indentation des appels longs et les virgules finales, pas sur le style de chaine. Verification : 263 tests passent avant et apres, ruff check propre. L activation en CI arrive dans le commit suivant, separement, pour que ce diff-ci ne contienne rien d autre. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
+18
-16
@@ -24,7 +24,8 @@ def discord_configured(monkeypatch):
|
||||
monkeypatch.setattr(auth_module, 'DISCORD_CLIENT_ID', '123456789012345678')
|
||||
monkeypatch.setattr(auth_module, 'DISCORD_CLIENT_SECRET', 'not-a-real-secret')
|
||||
monkeypatch.setattr(
|
||||
auth_module, 'DISCORD_REDIRECT_URI',
|
||||
auth_module,
|
||||
'DISCORD_REDIRECT_URI',
|
||||
'https://example.test/auth/discord/callback',
|
||||
)
|
||||
|
||||
@@ -50,16 +51,17 @@ class TestAuthorizationRequest:
|
||||
assert sess[auth_module.DISCORD_STATE_KEY] == sent
|
||||
|
||||
def test_two_requests_get_different_states(self, client, discord_configured):
|
||||
first = _authorize_params(
|
||||
client.get('/auth/discord/login', follow_redirects=False))['state'][0]
|
||||
second = _authorize_params(
|
||||
client.get('/auth/discord/login', follow_redirects=False))['state'][0]
|
||||
first = _authorize_params(client.get('/auth/discord/login', follow_redirects=False))[
|
||||
'state'
|
||||
][0]
|
||||
second = _authorize_params(client.get('/auth/discord/login', follow_redirects=False))[
|
||||
'state'
|
||||
][0]
|
||||
|
||||
assert first != second
|
||||
|
||||
def test_scopes_and_redirect_are_preserved(self, client, discord_configured):
|
||||
params = _authorize_params(
|
||||
client.get('/auth/discord/login', follow_redirects=False))
|
||||
params = _authorize_params(client.get('/auth/discord/login', follow_redirects=False))
|
||||
|
||||
assert params['scope'][0] == 'identify connections'
|
||||
assert params['response_type'][0] == 'code'
|
||||
@@ -87,8 +89,7 @@ class TestCallbackStateValidation:
|
||||
def test_a_callback_without_state_is_rejected(self, client, discord_configured):
|
||||
client.get('/auth/discord/login', follow_redirects=False)
|
||||
|
||||
response = client.get(
|
||||
'/auth/discord/callback?code=attacker-code', follow_redirects=False)
|
||||
response = client.get('/auth/discord/callback?code=attacker-code', follow_redirects=False)
|
||||
|
||||
assert '/auth/register' in response.headers['Location']
|
||||
|
||||
@@ -96,8 +97,8 @@ class TestCallbackStateValidation:
|
||||
client.get('/auth/discord/login', follow_redirects=False)
|
||||
|
||||
response = client.get(
|
||||
'/auth/discord/callback?code=attacker-code&state=forged',
|
||||
follow_redirects=False)
|
||||
'/auth/discord/callback?code=attacker-code&state=forged', follow_redirects=False
|
||||
)
|
||||
|
||||
assert '/auth/register' in response.headers['Location']
|
||||
with client.session_transaction() as sess:
|
||||
@@ -106,18 +107,19 @@ class TestCallbackStateValidation:
|
||||
def test_a_callback_without_a_prior_request_is_rejected(self, client, discord_configured):
|
||||
"""No /discord/login beforehand: nothing to match against."""
|
||||
response = client.get(
|
||||
'/auth/discord/callback?code=x&state=anything', follow_redirects=False)
|
||||
'/auth/discord/callback?code=x&state=anything', follow_redirects=False
|
||||
)
|
||||
|
||||
assert '/auth/register' in response.headers['Location']
|
||||
|
||||
def test_the_state_is_single_use(self, client, discord_configured):
|
||||
"""Consumed on the first callback, valid or not, so it cannot be
|
||||
replayed."""
|
||||
state = _authorize_params(
|
||||
client.get('/auth/discord/login', follow_redirects=False))['state'][0]
|
||||
state = _authorize_params(client.get('/auth/discord/login', follow_redirects=False))[
|
||||
'state'
|
||||
][0]
|
||||
|
||||
client.get(f'/auth/discord/callback?code=x&state={state}',
|
||||
follow_redirects=False)
|
||||
client.get(f'/auth/discord/callback?code=x&state={state}', follow_redirects=False)
|
||||
|
||||
with client.session_transaction() as sess:
|
||||
assert auth_module.DISCORD_STATE_KEY not in sess
|
||||
|
||||
Reference in New Issue
Block a user