234 |
234 |
models.FcAccount.objects.create(user=simple_user, sub=franceconnect.sub, user_info='{}')
|
235 |
235 |
|
236 |
236 |
response = franceconnect.login_with_fc(app, path='/accounts/')
|
|
237 |
response = response.maybe_follow()
|
237 |
238 |
response = response.click('Delete link')
|
238 |
239 |
response.form.set('new_password1', 'ikKL1234')
|
239 |
240 |
response.form.set('new_password2', 'ikKL1234')
|
... | ... | |
351 |
352 |
models.FcAccount.objects.create(user=user, sub=franceconnect.sub)
|
352 |
353 |
|
353 |
354 |
response = franceconnect.login_with_fc(app, path='/accounts/')
|
|
355 |
response = response.maybe_follow()
|
354 |
356 |
assert len(response.pyquery('[href*="password/change"]')) == 0
|
355 |
357 |
response = response.click('Logout')
|
356 |
358 |
response = franceconnect.handle_logout(app, response.location).follow()
|
... | ... | |
367 |
369 |
|
368 |
370 |
# Relogin with FC
|
369 |
371 |
response = franceconnect.login_with_fc(app, path='/accounts/')
|
|
372 |
response = response.maybe_follow()
|
370 |
373 |
assert len(response.pyquery('[href*="password/change"]')) == 0
|
371 |
374 |
|
372 |
375 |
# Unlink
|
... | ... | |
463 |
466 |
User.objects.create(email=franceconnect.user_info['email'], ou=ou)
|
464 |
467 |
|
465 |
468 |
response = franceconnect.login_with_fc(app, path='/accounts/')
|
466 |
|
response = response.follow()
|
467 |
469 |
|
|
470 |
response = response.maybe_follow()
|
468 |
471 |
assert 'is already used by another' in response
|
469 |
472 |
|
470 |
473 |
|
... | ... | |
498 |
501 |
'content': json.dumps({'error': 'invalid_request'}),
|
499 |
502 |
}
|
500 |
503 |
|
501 |
|
response = franceconnect.login_with_fc(app, path='/accounts/').follow()
|
|
504 |
response = franceconnect.login_with_fc(app, path='/accounts/')
|
502 |
505 |
assert re.match(r'WARNING.*token request failed.*invalid_request', caplog.text)
|
|
506 |
|
|
507 |
response = response.maybe_follow()
|
503 |
508 |
assert 'invalid_request' in response
|
504 |
509 |
|
505 |
510 |
|
... | ... | |
509 |
514 |
'content': json.dumps({'error': 'invalid_request', 'error_description': 'Requête invalide'}),
|
510 |
515 |
}
|
511 |
516 |
|
512 |
|
response = franceconnect.login_with_fc(app, path='/accounts/').follow()
|
|
517 |
response = franceconnect.login_with_fc(app, path='/accounts/')
|
513 |
518 |
assert re.match(r'WARNING.*token request failed.*invalid_request', caplog.text)
|
|
519 |
|
|
520 |
response = response.maybe_follow()
|
514 |
521 |
assert 'invalid_request' not in response
|
515 |
522 |
assert 'Requête invalide' in response
|
516 |
523 |
|
... | ... | |
553 |
560 |
franceconnect.token_endpoint_response = {'status_code': 500, 'content': 'Internal server error'}
|
554 |
561 |
|
555 |
562 |
# first error -> warning
|
556 |
|
response = franceconnect.login_with_fc(app, path='/accounts/').follow()
|
|
563 |
response = franceconnect.login_with_fc(app, path='/accounts/')
|
557 |
564 |
assert len(caplog.records) == 1
|
558 |
565 |
assert caplog.records[-1].levelname == 'WARNING'
|
|
566 |
response = response.maybe_follow()
|
559 |
567 |
assert 'Unable to connect to FranceConnect' in response
|
560 |
568 |
|
561 |
569 |
# second error, four minutes later -> warning
|
562 |
570 |
freezer.move_to(datetime.timedelta(seconds=+240))
|
563 |
|
response = franceconnect.login_with_fc(app, path='/accounts/').follow()
|
|
571 |
response = franceconnect.login_with_fc(app, path='/accounts/')
|
564 |
572 |
assert len(caplog.records) == 2
|
565 |
573 |
assert caplog.records[-1].levelname == 'WARNING'
|
|
574 |
response = response.maybe_follow()
|
566 |
575 |
assert 'Unable to connect to FranceConnect' in response
|
567 |
576 |
|
568 |
577 |
# after 5 minutes an error is logged
|
569 |
578 |
freezer.move_to(datetime.timedelta(seconds=+240))
|
570 |
|
response = franceconnect.login_with_fc(app, path='/accounts/').follow()
|
|
579 |
response = franceconnect.login_with_fc(app, path='/accounts/')
|
571 |
580 |
assert len(caplog.records) == 4
|
572 |
581 |
assert caplog.records[-1].levelname == 'ERROR'
|
|
582 |
response = response.maybe_follow()
|
573 |
583 |
assert 'Unable to connect to FranceConnect' in response
|
574 |
584 |
|
575 |
585 |
# but only every 5 minutes
|
576 |
586 |
freezer.move_to(datetime.timedelta(seconds=+60))
|
577 |
|
response = franceconnect.login_with_fc(app, path='/accounts/').follow()
|
|
587 |
response = franceconnect.login_with_fc(app, path='/accounts/')
|
578 |
588 |
assert len(caplog.records) == 5
|
579 |
589 |
assert caplog.records[-1].levelname == 'WARNING'
|
|
590 |
response = response.maybe_follow()
|
580 |
591 |
assert 'Unable to connect to FranceConnect' in response
|
581 |
592 |
|
582 |
593 |
# a success clear the down flag
|
... | ... | |
589 |
600 |
# such that 5 minutes later only a warning is emitted
|
590 |
601 |
freezer.move_to(datetime.timedelta(seconds=310))
|
591 |
602 |
franceconnect.token_endpoint_response = {'status_code': 500, 'content': 'Internal server error'}
|
592 |
|
response = franceconnect.login_with_fc(app, path='/accounts/').follow()
|
|
603 |
response = franceconnect.login_with_fc(app, path='/accounts/')
|
593 |
604 |
assert len(caplog.records) == 8
|
594 |
605 |
assert caplog.records[-1].levelname == 'WARNING'
|
|
606 |
response = response.maybe_follow()
|
595 |
607 |
assert 'Unable to connect to FranceConnect' in response
|
596 |
608 |
|
597 |
609 |
|
... | ... | |
643 |
655 |
# change sub
|
644 |
656 |
franceconnect.sub = '4567'
|
645 |
657 |
|
646 |
|
resp = franceconnect.login_with_fc_fixed_params(app).maybe_follow()
|
|
658 |
resp = franceconnect.login_with_fc_fixed_params(app)
|
647 |
659 |
|
|
660 |
resp = resp.maybe_follow()
|
648 |
661 |
# email collision, sub is different, no new user created
|
649 |
662 |
assert User.objects.count() == 1
|
650 |
663 |
assert 'another email address' in resp
|
651 |
|
-
|