Projet

Général

Profil

0001-tests-add-cache-clearance-autouse-fixture-41813.patch

Paul Marillonnet, 17 avril 2020 11:35

Télécharger (5,02 ko)

Voir les différences:

Subject: [PATCH] tests: add cache clearance autouse fixture (#41813)

 tests/conftest.py      |  6 ++++++
 tests/test_idp_oidc.py | 12 ------------
 2 files changed, 6 insertions(+), 12 deletions(-)
tests/conftest.py
22 22
import django_webtest
23 23

  
24 24
from django.contrib.auth import get_user_model
25
from django.core.cache import cache
25 26
from django_rbac.utils import get_ou_model, get_role_model
26 27
from django.conf import settings
27 28
from django.utils.six.moves.urllib import parse as urlparse
......
381 382
        ou=get_default_ou(),
382 383
        slug='service',
383 384
        name='Service')
385

  
386

  
387
@pytest.fixture(autouse=True)
388
def clear_cache():
389
    cache.clear()
tests/test_idp_oidc.py
1290 1290

  
1291 1291

  
1292 1292
def test_credentials_grant(app, oidc_client, admin, simple_user):
1293
    cache.clear()
1294 1293
    oidc_client.authorization_flow = OIDCClient.FLOW_RESOURCE_OWNER_CRED
1295 1294
    oidc_client.scope = 'openid'
1296 1295
    oidc_client.save()
......
1342 1341
        app, oidc_client, admin, simple_user, oidc_settings, freezer):
1343 1342
    freezer.move_to('2020-01-01')
1344 1343

  
1345
    cache.clear()
1346 1344
    oidc_client.authorization_flow = OIDCClient.FLOW_RESOURCE_OWNER_CRED
1347 1345
    oidc_client.save()
1348 1346
    token_url = make_url('oidc-token')
......
1366 1364
        app, oidc_client, admin, simple_user, oidc_settings, freezer):
1367 1365
    freezer.move_to('2020-01-01')
1368 1366

  
1369
    cache.clear()
1370 1367
    oidc_client.authorization_flow = OIDCClient.FLOW_RESOURCE_OWNER_CRED
1371 1368
    oidc_client.save()
1372 1369
    token_url = make_url('oidc-token')
......
1388 1385
        app, oidc_client, admin, simple_user, settings, freezer):
1389 1386
    freezer.move_to('2020-01-01')
1390 1387

  
1391
    cache.clear()
1392 1388
    settings.A2_LOGIN_EXPONENTIAL_RETRY_TIMEOUT_DURATION = 2
1393 1389
    oidc_client.authorization_flow = OIDCClient.FLOW_RESOURCE_OWNER_CRED
1394 1390
    oidc_client.save()
......
1419 1415

  
1420 1416
def test_credentials_grant_invalid_flow(
1421 1417
        app, oidc_client, admin, simple_user, settings):
1422
    cache.clear()
1423 1418
    params = {
1424 1419
        'client_id': oidc_client.client_id,
1425 1420
        'client_secret': oidc_client.client_secret,
......
1435 1430

  
1436 1431
def test_credentials_grant_invalid_client(
1437 1432
        app, oidc_client, admin, simple_user, settings):
1438
    cache.clear()
1439 1433
    oidc_client.authorization_flow = OIDCClient.FLOW_RESOURCE_OWNER_CRED
1440 1434
    oidc_client.save()
1441 1435
    params = {
......
1453 1447

  
1454 1448
def test_credentials_grant_unauthz_client(
1455 1449
        app, oidc_client, admin, simple_user, settings):
1456
    cache.clear()
1457 1450
    params = {
1458 1451
        'client_id': oidc_client.client_id,
1459 1452
        'client_secret': oidc_client.client_secret,
......
1469 1462

  
1470 1463
def test_credentials_grant_invalid_content_type(
1471 1464
        app, oidc_client, admin, simple_user, settings):
1472
    cache.clear()
1473 1465
    oidc_client.authorization_flow = OIDCClient.FLOW_RESOURCE_OWNER_CRED
1474 1466
    oidc_client.save()
1475 1467
    params = {
......
1490 1482

  
1491 1483
def test_credentials_grant_ou_selection_simple(
1492 1484
        app, oidc_client, admin, user_ou1, user_ou2, ou1, ou2, settings):
1493
    cache.clear()
1494 1485
    oidc_client.authorization_flow = OIDCClient.FLOW_RESOURCE_OWNER_CRED
1495 1486
    oidc_client.save()
1496 1487
    params = {
......
1511 1502

  
1512 1503
def test_credentials_grant_ou_selection_username_not_unique(
1513 1504
        app, oidc_client, admin, user_ou1, admin_ou2, ou1, ou2, settings):
1514
    cache.clear()
1515 1505
    settings.A2_USERNAME_IS_UNIQUE = False
1516 1506
    oidc_client.authorization_flow = OIDCClient.FLOW_RESOURCE_OWNER_CRED
1517 1507
    oidc_client.save()
......
1539 1529

  
1540 1530
def test_credentials_grant_ou_selection_username_not_unique_wrong_ou(
1541 1531
        app, oidc_client, admin, user_ou1, admin_ou2, ou1, ou2, settings):
1542
    cache.clear()
1543 1532
    settings.A2_USERNAME_IS_UNIQUE = False
1544 1533
    oidc_client.authorization_flow = OIDCClient.FLOW_RESOURCE_OWNER_CRED
1545 1534
    oidc_client.save()
......
1562 1551

  
1563 1552
def test_credentials_grant_ou_selection_invalid_ou(
1564 1553
        app, oidc_client, admin, user_ou1, settings):
1565
    cache.clear()
1566 1554
    params = {
1567 1555
        'client_id': oidc_client.client_id,
1568 1556
        'client_secret': oidc_client.client_secret,
1569
-