ó
J~‰Pc           @   s¢   d  d l  Z  d  d l m Z m Z d  d l m Z d  d l m Z d  d l m	 Z	 d  d l
 m Z d  d l m Z d  d l m Z e d	 e f d
 „  ƒ  Yƒ Z d S(   iÿÿÿÿN(   t   datet	   timedelta(   t   settings(   t   User(   t   PasswordResetTokenGenerator(   t   skipIfCustomUser(   t   TestCase(   t   unittestt   TokenGeneratorTestc           B   sK   e  Z d  „  Z d „  Z d „  Z e j e j d  d k d ƒ d „  ƒ Z	 RS(	   c         C   sM   t  j j d d d ƒ } t ƒ  } | j | ƒ } |  j | j | | ƒ ƒ d S(   sF   
        Ensure that we can make a token and that it is valid
        t   tokentestusers   test2@example.comt   testpwN(   R   t   objectst   create_userR   t
   make_tokent
   assertTruet   check_token(   t   selft   usert   p0t   tk1(    (    s9   ../Django//lib/python/django/contrib/auth/tests/tokens.pyt   test_make_token   s    	c         C   sh   t  j j d d d ƒ } t ƒ  } | j | ƒ } t  j j d d ƒ } | j | ƒ } |  j | | ƒ d S(   su   
        Ensure that the token generated for a user created in the same request
        will work correctly.
        t   comebackkids   test3@example.comR
   t   usernameN(   R   R   R   R   R   t   gett   assertEqual(   R   R   R   R   t   reloadt   tk2(    (    s9   ../Django//lib/python/django/contrib/auth/tests/tokens.pyt
   test_10265   s    	c         C   s¾   d t  f d „  ƒ  Y} t j j d d d ƒ } t  ƒ  } | j | ƒ } | t j ƒ  t t j	 ƒ ƒ } |  j
 | j | | ƒ ƒ | t j ƒ  t t j	 d ƒ ƒ } |  j | j | | ƒ ƒ d S(   sK   
        Ensure we can use the token after n days, but no greater.
        t   Mockedc           B   s   e  Z d  „  Z d „  Z RS(   c         S   s   | |  _  d  S(   N(   t
   _today_val(   R   t   today(    (    s9   ../Django//lib/python/django/contrib/auth/tests/tokens.pyt   __init__,   s    c         S   s   |  j  S(   N(   R   (   R   (    (    s9   ../Django//lib/python/django/contrib/auth/tests/tokens.pyt   _today.   s    (   t   __name__t
   __module__R   R    (    (    (    s9   ../Django//lib/python/django/contrib/auth/tests/tokens.pyR   +   s   	R	   s   test2@example.comR
   i   N(   R   R   R   R   R   R    R   R   R   t   PASSWORD_RESET_TIMEOUT_DAYSR   R   t   assertFalse(   R   R   R   R   R   t   p1t   p2(    (    s9   ../Django//lib/python/django/contrib/auth/tests/tokens.pyt   test_timeout%   s    	#i   i   i    s   Unnecessary test with Python 3c         C   s>   t  j j d d d ƒ } t ƒ  } |  j t | j | d ƒ d S(   sV   
        Make sure we don't allow overly long dates, causing a potential DoS.
        t   ima1337h4x0rs   test4@example.comt   p4ssw0rdl   uPJè y˜ N(   R   R   R   R   t   assertRaisest
   ValueErrort   _make_token_with_timestamp(   R   R   R   (    (    s9   ../Django//lib/python/django/contrib/auth/tests/tokens.pyt   test_date_length:   s
    		(   i   i    (
   R!   R"   R   R   R'   R   t   skipIft   syst   version_infoR-   (    (    (    s9   ../Django//lib/python/django/contrib/auth/tests/tokens.pyR      s   				(   R/   t   datetimeR    R   t   django.confR   t   django.contrib.auth.modelsR   t   django.contrib.auth.tokensR   t   django.contrib.auth.tests.utilsR   t   django.testR   t   django.utilsR   R   (    (    (    s9   ../Django//lib/python/django/contrib/auth/tests/tokens.pyt   <module>   s   