https://t.me/AnonymousX5
Server : Apache
System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64
User : njnconst ( 1116)
PHP Version : 8.4.18
Disable Function : NONE
Directory :  /lib64/python2.7/site-packages/django/contrib/auth/tests/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib64/python2.7/site-packages/django/contrib/auth/tests/test_auth_backends.pyc
�
r�\c@s�ddlmZddlmZddlmZddlmZddlm	Z	m
Z
mZmZddl
mZddlmZmZmZddlmZdd	lmZmZdd
lmZmZddlmZddlmZdd
lm Z ddl!m"Z"de"fd��YZ#de$fd��YZ%ede%efd��Y�Z&e dd�de%efd��Y�Z'e dd�de%efd��Y�Z(e dd�defd��Y�Z)de$fd ��YZ*d!e$fd"��YZ+ed#efd$��Y�Z,d%efd&��YZ-ee d'g�d(efd)��Y��Z.ed*efd+��Y�Z/d,e$fd-��YZ0ed.efd/��Y�Z1d0efd1��YZ2ed2efd3��Y�Z3ed4efd5��Y�Z4d6S(7i����(tunicode_literals(tdate(tsettings(tModelBackend(tUsertGroupt
Permissiont
AnonymousUser(tskipIfCustomUser(t
ExtensionUsertCustomPermissionsUsert
CustomUser(tContentType(tImproperlyConfiguredtPermissionDenied(tauthenticatetget_user(tHttpRequest(tTestCase(toverride_settings(tMD5PasswordHashertCountingMD5PasswordHashercBseZdZdZd�ZRS(u5Hasher that counts how many times it computes a hash.icOs.t|�jd7_tt|�j||�S(Ni(ttypetcallstsuperRtencode(tselftargstkwargs((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyRs(t__name__t
__module__t__doc__RR(((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyRstBaseModelBackendTestcBsbeZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	e
dd�d
��ZRS(u�
    A base class for tests that need to validate the ModelBackend
    with different User models. Subclasses should define a class
    level UserModel attribute, and a create_users() method to
    construct two users for test purposes.
    u)django.contrib.auth.backends.ModelBackendcCs)tj|_|jft_|j�dS(N(RtAUTHENTICATION_BACKENDSt	curr_authtbackendtcreate_users(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pytsetUp%scCs|jt_tjj�dS(N(R"RR!Rtobjectstclear_cache(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyttearDown*scCs|jjjd|jj�}|j|jd�t�t|_	|j
�|j|jd�t�t|_|j
�|j|jd�t�t|_	t|_|j
�|j|jd�t�t|_	t|_t|_|j
�|j|jd�t�dS(Ntpku	auth.test(
t	UserModelt_default_managertgettuserR)tassertEqualthas_permtFalsetTruetis_stafftsavetis_superusert	is_active(RR-((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyt
test_has_perm1s"	
	
		
			
cCs5|jjjd|jj�}tjjt�}t	jj
ddd|dd�}|jj|�|j
�|jjjd|jj�}|j|j�tdg�kt�|j|j�tg��|j|jd�t�|j|jd�t�t	jj
dd	d|dd	�}|jj|�|j
�t	jj
dd
d|dd
�}|jj|�|j
�|jjjd|jj�}|j|j�tdddg��|j|jd�t�|j|jd�t�|j|jddg�t�t	jj
dd
d|dd
�}tjj
dd
�}|jj|�|j
�|jj|�|jjjd|jj�}tddddg�}|j|j�|�|j|j�tdg��|j|jddg�t�t�}|j|jd�t�|j|jddg�t�dS(NR)tnameutesttcontent_typetcodenameu	auth.testuGroupuauthutest2utest3u
auth.test2u
auth.test3u
test_groupuauth.test_group(R*R+R,R-R)RR&t
get_for_modelRRtcreatetuser_permissionstaddR3R.tget_all_permissionstsetR1tget_group_permissionsthas_module_permsR0R/t	has_permstpermissionstgroupsR(RR-R8tpermtgrouptexp((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyttest_custom_permsDsD!
%!
!
%!
	cCs�|jjjd|jj�}tjjt�}t	jj
ddd|dd�}|jj|�|j
�|j|jdd�t�|j|jd�tg��|j|jd�t�|j|j�tdg��dS(	uRegressiontest for #12462R)R7utestR8R9u	auth.testuobjectN(R*R+R,R-R)RR&R:RRR;R<R=R3R.R/R0R>R?R1(RR-R8RE((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyttest_has_no_object_permks!
cCsM|jjjd|jj�}|jt|j��ttj	j
���dS(u-A superuser has all permissions. Refs #14795.R)N(R*R+R,t	superuserR)R.tlenR>RR&tall(RR-((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyt"test_get_all_superuser_permissionsxstPASSWORD_HASHERSuFdjango.contrib.auth.tests.test_auth_backends.CountingMD5PasswordHashercCs�|jjd�|jj�dt_t|j|jj�}td|dd�|j	tjd�dt_tdddd�|j	tjd�dS(uFHasher is run once regardless of whether the user exists. Refs #20760.utestitusernametpasswordiuno_such_userN(
R-tset_passwordR3RRtgetattrR*tUSERNAME_FIELDRR.(RRO((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyttest_authentication_timing}s
		(uFdjango.contrib.auth.tests.test_auth_backends.CountingMD5PasswordHasher(RRRR#R%R(R6RHRIRMRRT(((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR s				'	
	tModelBackendTestcBseZdZeZd�ZRS(uB
    Tests for the ModelBackend using the default User model.
    cCsLtjjdddddd�|_tjjdddddd�|_dS(NROutesttemailutest@example.comRPutest2utest2@example.com(RR&tcreate_userR-tcreate_superuserRJ(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR$�s(RRRRR*R$(((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyRU�stAUTH_USER_MODELuauth.ExtensionUsertExtensionUserModelBackendTestcBseZdZeZd�ZRS(u�
    Tests for the ModelBackend using the custom ExtensionUser model.

    This isn't a perfect test, because both the User and ExtensionUser are
    synchronized to the database, which wouldn't ordinary happen in
    production. As a result, it doesn't catch errors caused by the non-
    existence of the User table.

    The specific problem is queries on .filter(groups__user) et al, which
    makes an implicit assumption that the user model is called 'User'. In
    production, the auth.User table won't exist, so the requested join
    won't exist either; in testing, the auth.User *does* exist, and
    so does the join. However, the join table won't contain any useful
    data; for testing, we check that the data we expect actually does exist.
    cCsptjjdddddddtddd	��|_tjjdd
dddddtdd
d��|_dS(NROutestRVutest@example.comRPt
date_of_birthi�iiutest2utest2@example.comi�ii(R	R+RWRR-RXRJ(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR$�s(RRRR	R*R$(((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyRZ�suauth.CustomPermissionsUsert%CustomPermissionsUserModelBackendTestcBseZdZeZd�ZRS(u
    Tests for the ModelBackend using the CustomPermissionsUser model.

    As with the ExtensionUser test, this isn't a perfect test, because both
    the User and CustomPermissionsUser are synchronized to the database,
    which wouldn't ordinary happen in production.
    c
Csdtjjdddddtddd��|_tjjdd	dddtd
dd��|_dS(
NRVutest@example.comRPutestR[i�iiutest2@example.comi�ii(R
R+RWRR-RXRJ(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR$�s(RRRR
R*R$(((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR\�suauth.CustomUsert&CustomUserModelBackendAuthenticateTestcBseZdZd�ZRS(uz
    Tests that the model backend can accept a credentials kwarg labeled with
    custom user model's USERNAME_FIELD.
    c
CsVtjjdddddtddd��}tdddd�}|j||�dS(	NRVutest@example.comRPutestR[i�ii(RR+RWRRR.(Rt	test_usertauthenticated_user((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyttest_authenticate�s(RRRR`(((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR]�stTestObjcBseZRS((RR(((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyRa�stSimpleRowlevelBackendcBs5eZdd�Zd�Zdd�Zdd�ZRS(cCsi|s
dSt|t�re|jdkr,tS|j�rH|dkrHtS|jre|dkretSntS(Nutest2uanonuinactive(t
isinstanceRaROR1tis_anonymousR5R0(RR-REtobj((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR/�scCs%|j�r|jrtS|dkS(Nuapp1(RdR5R0(RR-t	app_label((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyRAscCsW|s
gSt|t�s dgS|j�r3dgS|jdkrLddgSdgSdS(Nunoneuanonutest2usimpleuadvanced(RcRaRdRO(RR-Re((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR>s
cCs]|s
dSt|t�s dgSdg|jj�D]}|j^q3krRdgSdgSdS(Nunoneu
test_groupu
group_perm(RcRaRDRLR7(RR-ReRF((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR@s+N(RRtNoneR/RAR>R@(((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyRb�s
	tRowlevelBackendTestcBsAeZdZdZd�Zd�Zd�Zd�Zd�ZRS(uG
    Tests for auth backend that supports object level permissions
    uBdjango.contrib.auth.tests.test_auth_backends.SimpleRowlevelBackendcCs}tj|_t|j�|jft_tjjddd�|_tjjddd�|_	tjjddd�|_
dS(Nutestutest@example.comutest2utest2@example.comutest3utest3@example.com(RR!R"ttupleR#RR&RWtuser1tuser2tuser3(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR%)s
cCs|jt_tjj�dS(N(R"RR!RR&R'(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR(0scCs�|j|jjdt��t�|j|jjdt��t�|j|jjd�t�|j|jjddgt��t�|j|jjdt��t�|j|jjdt��t�|j|jjddgt��t�dS(Nupermusimpleuadvanceduanon(	R.RjR/RaR0RkR1RBRl(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR67s""(""cCsv|j|jjt��tdg��|j|jjt��tddg��|j|jj�tg��dS(Nusimpleuadvanced(R.RjR>RaR?Rk(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyttest_get_all_permissions@s(+cCsTtjjdd�}|jjj|�|j|jjt��t	dg��dS(NR7u
test_groupu
group_perm(
RR&R;RlRDR=R.R@RaR?(RRF((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyttest_get_group_permissionsEs(	RRRR#R%R(R6RmRn(((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyRh"s					tAnonymousUserBackendTestcBsJeZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	RS(u8
    Tests for AnonymousUser delegating to backend.
    uBdjango.contrib.auth.tests.test_auth_backends.SimpleRowlevelBackendcCs+tj|_|jft_t�|_dS(N(RR!R"R#RRj(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR%RscCs|jt_dS(N(R"RR!(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR(WscCsH|j|jjdt��t�|j|jjdt��t�dS(Nupermuanon(R.RjR/RaR0R1(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR6Zs"cCsQ|j|jjdgt��t�|j|jjddgt��t�dS(Nuanonuperm(R.RjRBRaR1R0(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyttest_has_perms^s%cCs<|j|jjd�t�|j|jjd�t�dS(Nuapp1uapp2(R.RjRAR1R0(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyttest_has_module_permsbscCs,|j|jjt��tdg��dS(Nuanon(R.RjR>RaR?(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyRmfs(
RRRR#R%R(R6RpRqRm(((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyRoKs					R!tNoBackendsTestcBs eZdZd�Zd�ZRS(uU
    Tests that an appropriate error is raised if no auth backends are provided.
    cCstjjddd�|_dS(Nutestutest@example.com(RR&RWR-(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR%pscCs&|jt|jjdt�f�dS(Nuperm(tassertRaisesR
R-R/Ra(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyttest_raises_exceptionss(RRRR%Rt(((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyRrjs	tInActiveUserBackendTestcBs8eZdZdZd�Zd�Zd�Zd�ZRS(u#
    Tests for a inactive user
    uBdjango.contrib.auth.tests.test_auth_backends.SimpleRowlevelBackendcCsStj|_|jft_tjjddd�|_t|j_	|jj
�dS(Nutestutest@example.com(RR!R"R#RR&RWRjR0R5R3(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR%~s
cCs|jt_dS(N(R"RR!(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR(�scCsH|j|jjdt��t�|j|jjdt��t�dS(Nupermuinactive(R.RjR/RaR0R1(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR6�s"cCs<|j|jjd�t�|j|jjd�t�dS(Nuapp1uapp2(R.RjRAR0(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyRq�s(RRRR#R%R(R6Rq(((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyRuws			tPermissionDeniedBackendcBs/eZdZeZeZeZddd�ZRS(u)
    Always raises PermissionDenied.
    cCs
t�dS(N(R(RRORP((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR�sN(	RRRR1tsupports_object_permissionstsupports_anonymous_usertsupports_inactive_userRgR(((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyRv�s
tPermissionDeniedBackendTestcBsmeZdZdZd�Zedefeej��d��Z	edeej�ef�d��Z
RS(uZ
    Tests that other backends are not checked once a backend raises PermissionDenied
    uDdjango.contrib.auth.tests.test_auth_backends.PermissionDeniedBackendcCs,tjjddd�|_|jj�dS(Nutestutest@example.com(RR&RWRjR3(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR%�sR!cCs#|jtdddd�d�dS(uHuser is not authenticated after a backend raises permission denied #2550ROutestRPN(R.RRg(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyttest_permission_denied�scCs&|jtdddd�|j�dS(NROutestRP(R.RRj(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyttest_authenticates�s(RRRR#R%RRiRR!R{R|(((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyRz�s		tNewModelBackendcBseZRS((RR(((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR}�stChangedBackendSettingsTestcBsJeZdZdZdZdZdZd�Zedef�d��Z	RS(uC
    Tests for changes in the settings.AUTHENTICATION_BACKENDS
    u<django.contrib.auth.tests.test_auth_backends.NewModelBackendu	test_useru
test_passwordutest@example.comcCs#tjj|j|j|j�dS(N(RR&RWt
TEST_USERNAMEt
TEST_EMAILt
TEST_PASSWORD(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR%�sR!cCs�|j|jjd|jd|j��t�}|jj|_|jdd��1t|�}|j	|�|j|j
��WdQXdS(u�
        Tests that removing a backend configured in AUTHENTICATION_BACKENDS
        make already logged-in users disconnect.
        RORPR!u)django.contrib.auth.backends.ModelBackendN(u)django.contrib.auth.backends.ModelBackend(t
assertTruetclienttloginRR�RtsessionRRtassertIsNotNoneRd(RtrequestR-((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyttest_changed_backend_settings�s	
		

(
RRRR#RR�R�R%RR�(((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR~�s	t!ImproperlyConfiguredUserModelTestcBs/eZdZd�Zedd�d��ZRS(u�
    Tests that an exception from within get_user_model is propagated and doesn't
    raise an UnboundLocalError.

    Regression test for ticket #21439
    cCs8tjjddd�|_|jjdddd�dS(Nutestutest@example.comRORP(RR&RWRjR�R�(R((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR%�sRYuthismodel.doesntexistcCs/t�}|jj|_|jtt|�dS(N(RR�R�RsR
R(RR�((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyttest_does_not_shadow_exception�s	(RRRR%RR�(((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyR��s	N(5t
__future__RtdatetimeRtdjango.confRtdjango.contrib.auth.backendsRtdjango.contrib.auth.modelsRRRRtdjango.contrib.auth.tests.utilsRt%django.contrib.auth.tests.custom_userR	R
Rt"django.contrib.contenttypes.modelsRtdjango.core.exceptionsR
Rtdjango.contrib.authRRtdjango.httpRtdjango.testRtdjango.test.utilsRtdjango.contrib.auth.hashersRRtobjectR RURZR\R]RaRbRhRoRrRuRvRzR}R~R�(((sN/tmp/pip-install-XxeQeY/django/django/contrib/auth/tests/test_auth_backends.pyt<module>sR"
r".(,

https://t.me/AnonymousX5 - 2025