#NEWLINE# def test_backend_authentication_do_not_create_user( monkeypatch , django_user_model , settings ) : #NEWLINE# #INDENT# '\n    Test the case where CAS authentication is creating a new user.\n    ' #NEWLINE# factory = RequestFactory ( ) #NEWLINE# request = factory . get ( '/login/' ) #NEWLINE# request . session = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# def mock_verify( ticket , service ) : #NEWLINE# #INDENT# return ( 'test@example.com' , { #NEWLINE# #INDENT# 'ticket' : ticket , #NEWLINE# 'service' : service , #NEWLINE# #UNINDENT# } , None ) #NEWLINE# #UNINDENT# monkeypatch . setattr ( 'cas.CASClientV2.verify_ticket' , mock_verify ) #NEWLINE# assert ( not django_user_model . objects . filter ( username = 'test@example.com' ) . exists ( ) ) #NEWLINE# settings . CAS_CREATE_USER = False #NEWLINE# backend = backends . CASBackend ( ) #NEWLINE# user = backend . authenticate ( ticket = 'fake-ticket' , service = 'fake-service' , request = request ) #NEWLINE# assert ( user is None ) #NEWLINE# assert ( not django_user_model . objects . filter ( username = 'test@example.com' ) . exists ( ) )