Repository URL to install this package:
| 
      
        
        
        Version: 
        
         
          
          5.0.6.dev16  ▾
        
         | 
ó
EV¥cc           @   sC   d  Z  d d l m Z d d l m Z d e j f d     YZ d S(   sI   
Tests to assert that various incorporated middleware works as expected.
iÿÿÿÿ(   t   cfg(   t   api_sample_baset   TestCORSMiddlewarec           B   sV   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   s  Provide a basic smoke test to ensure CORS middleware is active.
    The tests below provide minimal confirmation that the CORS middleware
    is active, and may be configured. For comprehensive tests, please consult
    the test suite in oslo_middleware.
    c            sG     f d   } t  j j j   _ | t  j j _ t t    j   d  S(   Nc            s    | d k r   j  |  |  Sd S(   Nt   allowed_origins   http://valid.example.com(   t   _original_call_method(   t   instancet   key(   t   self(    sJ   /usr/lib/python2.7/dist-packages/dmapi/tests/functional/test_middleware.pyt
   _mock_getattr   s    (   R    t
   ConfigOptst	   GroupAttrt   __getattr__R   t   superR   t   setUp(   R   R   (    (   R   sJ   /usr/lib/python2.7/dist-packages/dmapi/tests/functional/test_middleware.pyR
      s    c         C   s)   t  t |   j   |  j t j j _ d  S(   N(   R   R   t   tearDownR   R    R	   R
   R   (   R   (    (    sJ   /usr/lib/python2.7/dist-packages/dmapi/tests/functional/test_middleware.pyR   '   s    c         C   sd   |  j  d d i d d 6d d 6} |  j | j d  |  j d | j  |  j d | j d  d  S(	   Nt   serverst   headerss   http://valid.example.comt   Origint   GETs   Access-Control-Request-MethodiÈ   s   Access-Control-Allow-Origin(   t   _do_optionst   assertEqualt   status_codet   assertInR   (   R   t   response(    (    sJ   /usr/lib/python2.7/dist-packages/dmapi/tests/functional/test_middleware.pyt   test_valid_cors_options_request-   s    
	c         C   sM   |  j  d d i d d 6d d 6} |  j | j d  |  j d | j  d  S(	   NR   R   s   http://invalid.example.comR   R   s   Access-Control-Request-MethodiÈ   s   Access-Control-Allow-Origin(   R   R   R   t   assertNotInR   (   R   R   (    (    sJ   /usr/lib/python2.7/dist-packages/dmapi/tests/functional/test_middleware.pyt!   test_invalid_cors_options_request9   s    
c         C   sd   |  j  d d i d d 6d d 6} |  j | j d  |  j d | j  |  j d | j d  d  S(	   NR   R   s   http://valid.example.comR   R   s   Access-Control-Request-MethodiÈ   s   Access-Control-Allow-Origin(   t   _do_getR   R   R   R   (   R   R   (    (    sJ   /usr/lib/python2.7/dist-packages/dmapi/tests/functional/test_middleware.pyt   test_valid_cors_get_requestC   s    
	c         C   sM   |  j  d d i d d 6d d 6} |  j | j d  |  j d | j  d  S(	   NR   R   s   http://invalid.example.comR   R   s   Access-Control-Request-MethodiÈ   s   Access-Control-Allow-Origin(   R   R   R   R   R   (   R   R   (    (    sJ   /usr/lib/python2.7/dist-packages/dmapi/tests/functional/test_middleware.pyt   test_invalid_cors_get_requestO   s    
c         C   sj   |  j  d d t d i d d 6d d 6} |  j | j d  |  j d	 | j  |  j d | j d	  d  S(
   Nt    t
   strip_versionR   s   http://valid.example.comR   R   s   Access-Control-Request-MethodiÈ   s   Access-Control-Allow-Origin(   R   t   TrueR   R   R   R   (   R   R   (    (    sJ   /usr/lib/python2.7/dist-packages/dmapi/tests/functional/test_middleware.pyt$   test_valid_cors_get_versions_requestY   s    
	c         C   sS   |  j  d d t d i d d 6d d 6} |  j | j d  |  j d	 | j  d  S(
   NR   R   R   s   http://invalid.example.comR   R   s   Access-Control-Request-MethodiÈ   s   Access-Control-Allow-Origin(   R   R    R   R   R   R   (   R   R   (    (    sJ   /usr/lib/python2.7/dist-packages/dmapi/tests/functional/test_middleware.pyt&