§
    cÌcÞ>  ã                   óö   — d Z ddlmZ ddlmZ ddlZddlmZmZ ddl	m
Z
 ddlmZ d„ Zd	„ Z G d
„ dej        ¦  «        Z G d„ dej        ¦  «        Z G d„ dej        ¦  «        Z G d„ dej        ¦  «        ZdS )zTests for the wedav plugin.é    )Úparse_headers)ÚStringION)ÚerrorsÚtests)Úwebdav)Úhttp_serverc                  ó   — dS )Naï  <?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:ns0="DAV:">
    <D:response>
        <D:href>/19016477731212686926.835527/</D:href>
        <D:propstat>
            <D:prop>
            </D:prop>
            <D:status>HTTP/1.1 200 OK</D:status>
        </D:propstat>
    </D:response>
    <D:response>
        <D:href>/19016477731212686926.835527/a</D:href>
        <D:propstat>
            <D:prop>
            </D:prop>
            <D:status>HTTP/1.1 200 OK</D:status>
        </D:propstat>
    </D:response>
    <D:response>
        <D:href>/19016477731212686926.835527/b</D:href>
        <D:propstat>
            <D:prop>
            </D:prop>
            <D:status>HTTP/1.1 200 OK</D:status>
        </D:propstat>
    </D:response>
    <D:response>
        <D:href>/19016477731212686926.835527/c/</D:href>
        <D:propstat>
            <D:prop>
            </D:prop>
            <D:status>HTTP/1.1 200 OK</D:status>
        </D:propstat>
    </D:response>
</D:multistatus>© r
   ó    úI/usr/lib/python3/dist-packages/breezy/plugins/webdav/tests/test_webdav.pyÚ"_get_list_dir_apache2_depth_1_propr       s   € ð"ð "r   c                  ó   — dS )NaÐ  <?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:ns0="DAV:">
    <D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
        <D:href>/</D:href>
        <D:propstat>
            <D:prop>
                <lp1:resourcetype><D:collection/></lp1:resourcetype>
                <lp1:creationdate>2008-06-08T10:50:38Z</lp1:creationdate>
                <lp1:getlastmodified>Sun, 08 Jun 2008 10:50:38 GMT</lp1:getlastmodified>
                <lp1:getetag>"da7f5a-cc-7722db80"</lp1:getetag>
                <D:supportedlock>
                    <D:lockentry>
                        <D:lockscope><D:exclusive/></D:lockscope>
                        <D:locktype><D:write/></D:locktype>
                    </D:lockentry>
                    <D:lockentry>
                        <D:lockscope><D:shared/></D:lockscope>
                        <D:locktype><D:write/></D:locktype>
                    </D:lockentry>
                </D:supportedlock>
                <D:lockdiscovery/>
            </D:prop>
            <D:status>HTTP/1.1 200 OK</D:status>
        </D:propstat>
    </D:response>
    <D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
        <D:href>/executable</D:href>
        <D:propstat>
            <D:prop>
                <lp1:resourcetype/>
                <lp1:creationdate>2008-06-08T09:50:15Z</lp1:creationdate>
                <lp1:getcontentlength>14</lp1:getcontentlength>
                <lp1:getlastmodified>Sun, 08 Jun 2008 09:50:11 GMT</lp1:getlastmodified>
                <lp1:getetag>"da9f81-0-9ef33ac0"</lp1:getetag>
                <lp2:executable>T</lp2:executable>
                <D:supportedlock>
                    <D:lockentry>
                        <D:lockscope><D:exclusive/></D:lockscope>
                        <D:locktype><D:write/></D:locktype>
                    </D:lockentry>
                    <D:lockentry>
                        <D:lockscope><D:shared/></D:lockscope>
                        <D:locktype><D:write/></D:locktype>
                    </D:lockentry>
                </D:supportedlock>
                <D:lockdiscovery/>
            </D:prop>
            <D:status>HTTP/1.1 200 OK</D:status>
        </D:propstat>
    </D:response>
    <D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
        <D:href>/read-only</D:href>
        <D:propstat>
            <D:prop>
                <lp1:resourcetype/>
                <lp1:creationdate>2008-06-08T09:50:11Z</lp1:creationdate>
                <lp1:getcontentlength>42</lp1:getcontentlength>
                <lp1:getlastmodified>Sun, 08 Jun 2008 09:50:11 GMT</lp1:getlastmodified>
                <lp1:getetag>"da9f80-0-9ef33ac0"</lp1:getetag>
                <lp2:executable>F</lp2:executable>
                <D:supportedlock>
                    <D:lockentry>
                        <D:lockscope><D:exclusive/></D:lockscope>
                        <D:locktype><D:write/></D:locktype>
                    </D:lockentry>
                    <D:lockentry>
                        <D:lockscope><D:shared/></D:lockscope>
                        <D:locktype><D:write/></D:locktype>
                    </D:lockentry>
                </D:supportedlock>
                <D:lockdiscovery/>
            </D:prop>
            <D:status>HTTP/1.1 200 OK</D:status>
        </D:propstat>
    </D:response>
    <D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
        <D:href>/titi</D:href>
        <D:propstat>
            <D:prop>
                <lp1:resourcetype/>
                <lp1:creationdate>2008-06-08T09:49:53Z</lp1:creationdate>
                <lp1:getcontentlength>6</lp1:getcontentlength>
                <lp1:getlastmodified>Sun, 08 Jun 2008 09:49:53 GMT</lp1:getlastmodified>
                <lp1:getetag>"da8cbc-6-9de09240"</lp1:getetag>
                <lp2:executable>F</lp2:executable>
                <D:supportedlock>
                    <D:lockentry>
                        <D:lockscope><D:exclusive/></D:lockscope>
                        <D:locktype><D:write/></D:locktype>
                    </D:lockentry>
                    <D:lockentry>
                        <D:lockscope><D:shared/></D:lockscope>
                        <D:locktype><D:write/></D:locktype>
                    </D:lockentry>
                </D:supportedlock>
                <D:lockdiscovery/>
            </D:prop>
            <D:status>HTTP/1.1 200 OK</D:status>
        </D:propstat>
    </D:response>
    <D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
        <D:href>/toto/</D:href>
        <D:propstat>
            <D:prop>
                <lp1:resourcetype><D:collection/></lp1:resourcetype>
                <lp1:creationdate>2008-06-06T08:07:07Z</lp1:creationdate>
                <lp1:getlastmodified>Fri, 06 Jun 2008 08:07:07 GMT</lp1:getlastmodified>
                <lp1:getetag>"da8cb9-44-f2ac20c0"</lp1:getetag>
                <D:supportedlock>
                    <D:lockentry>
                        <D:lockscope><D:exclusive/></D:lockscope>
                        <D:locktype><D:write/></D:locktype>
                    </D:lockentry>
                    <D:lockentry>
                        <D:lockscope><D:shared/></D:lockscope>
                        <D:locktype><D:write/></D:locktype>
                    </D:lockentry>
                </D:supportedlock>
                <D:lockdiscovery/>
            </D:prop>
            <D:status>HTTP/1.1 200 OK</D:status>
        </D:propstat>
    </D:response>
</D:multistatus>
r
   r
   r   r   Ú%_get_list_dir_apache2_depth_1_allpropr   F   s   € ð|ð |r   c                   ó\   — e Zd Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ ZdS )ÚTestDavSaxParserc                 óF   — t          j        dt          |¦  «        ¦  «        S ©Nzhttp://localhost/blah)r   Ú_extract_dir_contentr   ©ÚselfÚstrs     r   Ú_extract_dir_content_from_strz.TestDavSaxParser._extract_dir_content_from_strÈ   s"   € ÝÔ*Ø#¥X¨c¡]¤]ñ4ô 4ð 	4r   c                 óF   — t          j        dt          |¦  «        ¦  «        S r   )r   Ú_extract_stat_infor   r   s     r   Ú_extract_stat_from_strz'TestDavSaxParser._extract_stat_from_strÌ   s"   € ÝÔ(Ø#¥X¨c¡]¤]ñ4ô 4ð 	4r   c                 óV   — d}|                       t          j        | j        |¦  «         d S )Nz<document/>©ÚassertRaisesr   ÚInvalidHttpResponser   ©r   Úexamples     r   Útest_unkown_format_responsez,TestDavSaxParser.test_unkown_format_responseÐ   s;   € à#ˆØ×Ò�&Ô4ØÔ<¸gñ	Gô 	Gð 	Gð 	Gð 	Gr   c                 óV   — d}|                       t          j        | j        |¦  «         d S ©Nz°<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:ns0="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
<D:response>
<D:href>http://localhost/</D:href>r   r    s     r   Ú test_list_dir_malformed_responsez1TestDavSaxParser.test_list_dir_malformed_responseÖ   s?   € ð&ˆð 	×Ò�&Ô4ØÔ<¸gñ	Gô 	Gð 	Gð 	Gð 	Gr   c                 óV   — d}|                       t          j        | j        |¦  «         d S )Na8  <?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:ns0="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
<D:response>
<D:href>http://localhost/</D:href>
</D:response>
<D:response>
<D:href>http://localhost/titi</D:href>
</D:response>
<D:href>http://localhost/toto</D:href>
</D:multistatus>©r   r   ÚNotADirectoryr   r    s     r   Ú(test_list_dir_incomplete_format_responsez9TestDavSaxParser.test_list_dir_incomplete_format_responseß   s?   € ð	ˆð 	×Ò�&Ô.ØÔ;¸Wñ	Fô 	Fð 	Fð 	Fð 	Fr   c                 ón   — t          ¦   «         }|                      t          j        | j        |¦  «         d S ©N)r   r   r   r(   r   r    s     r   Útest_list_dir_apache2_examplez.TestDavSaxParser.test_list_dir_apache2_exampleî   sA   € Ý4Ñ6Ô6ˆØ×Ò�&Ô.ØÔ;¸Wñ	Fô 	Fð 	Fð 	Fð 	Fr   c                 óV   — d}|                       t          j        | j        |¦  «         d S )NaS  <?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:ns0="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
<D:response>
<D:href>http://localhost/</D:href>
</D:response>
<D:response>
<D:href>http://localhost/titi</D:href>
</D:response>
<D:response>
<D:href>http://localhost/toto</D:href>
</D:response>
</D:multistatus>r'   r    s     r   Útest_list_dir_lighttpd_examplez/TestDavSaxParser.test_list_dir_lighttpd_exampleó   s?   € ðˆð 	×Ò�&Ô.ØÔ;¸Wñ	Fô 	Fð 	Fð 	Fð 	Fr   c                 óx   — t          ¦   «         }|                      g d¢|                      |¦  «        ¦  «         d S )N))Ú
executableFé   T)z	read-onlyFé*   F)ÚtitiFé   F)ÚtotoTéÿÿÿÿF)r   ÚassertEqualr   r    s     r   Ú)test_list_dir_apache2_dir_depth_1_examplez:TestDavSaxParser.test_list_dir_apache2_dir_depth_1_example  sV   € Ý7Ñ9Ô9ˆØ×Òð 6ð 6ð 6ð ×<Ò<¸WÑEÔEñ		Gô 	Gð 	Gð 	Gð 	Gr   c                 óV   — d}|                       t          j        | j        |¦  «         d S r$   ©r   r   r   r   r    s     r   Útest_stat_malformed_responsez-TestDavSaxParser.test_stat_malformed_response  s?   € ð&ˆð 	×Ò�&Ô4ØÔ5°wñ	@ô 	@ð 	@ð 	@ð 	@r   c                 óV   — d}|                       t          j        | j        |¦  «         d S )Nz¸<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:ns0="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
<D:href>http://localhost/toto</D:href>
</D:multistatus>r:   r    s     r   Ú$test_stat_incomplete_format_responsez5TestDavSaxParser.test_stat_incomplete_format_response  s?   € ðˆð 	×Ò�&Ô4ØÔ5°wñ	@ô 	@ð 	@ð 	@ð 	@r   c                 óh  — d}|                       |¦  «        }|                      d|j        ¦  «         |                      t	          j        |j        ¦  «        ¦  «         |                      t	          j        |j        ¦  «        ¦  «         |                      |j        t          j	        z  ¦  «         d S )NaP  <?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:ns0="DAV:">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>/executable</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype/>
<lp1:creationdate>2008-06-08T09:50:15Z</lp1:creationdate>
<lp1:getcontentlength>12</lp1:getcontentlength>
<lp1:getlastmodified>Sun, 08 Jun 2008 09:50:11 GMT</lp1:getlastmodified>
<lp1:getetag>"da9f81-0-9ef33ac0"</lp1:getetag>
<lp2:executable>T</lp2:executable>
<D:supportedlock>
<D:lockentry>
<D:lockscope><D:exclusive/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope><D:shared/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</D:multistatus>é   )
r   r7   Úst_sizeÚassertFalseÚstatÚS_ISDIRÚst_modeÚ
assertTrueÚS_ISREGÚS_IXUSR©r   r!   Ústs      r   Útest_stat_apache2_file_examplez/TestDavSaxParser.test_stat_apache2_file_example"  s•   € ðˆð8 ×(Ò(¨Ñ1Ô1ˆØ×Ò˜˜RœZÑ(Ô(Ð(Ø×Ò�œ b¤jÑ1Ô1Ñ2Ô2Ð2Ø�Š�œ R¤ZÑ0Ô0Ñ1Ô1Ð1Ø�Š˜œ
¥T¤\Ñ1Ñ2Ô2Ð2Ð2Ð2r   c                 ón   — t          ¦   «         }|                      t          j        | j        |¦  «         d S r+   )r   r   r   r   r   r    s     r   Ú%test_stat_apache2_dir_depth_1_examplez6TestDavSaxParser.test_stat_apache2_dir_depth_1_exampleE  sA   € Ý7Ñ9Ô9ˆØ×Ò�&Ô4ØÔ5°wñ	@ô 	@ð 	@ð 	@ð 	@r   c                 ó  — d}|                       |¦  «        }|                      d|j        ¦  «         |                      t	          j        |j        ¦  «        ¦  «         |                      |j        t          j        z  ¦  «         d S )Na  <?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:ns0="DAV:">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>/</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype><D:collection/></lp1:resourcetype>
<lp1:creationdate>2008-06-08T10:50:38Z</lp1:creationdate>
<lp1:getlastmodified>Sun, 08 Jun 2008 10:50:38 GMT</lp1:getlastmodified>
<lp1:getetag>"da7f5a-cc-7722db80"</lp1:getetag>
<D:supportedlock>
<D:lockentry>
<D:lockscope><D:exclusive/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope><D:shared/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</D:multistatus>
r6   )r   r7   r@   rE   rB   rC   rD   rG   rH   s      r   Ú%test_stat_apache2_dir_depth_0_examplez6TestDavSaxParser.test_stat_apache2_dir_depth_0_exampleJ  su   € ðˆð6 ×(Ò(¨Ñ1Ô1ˆØ×Ò˜˜RœZÑ(Ô(Ð(Ø�Š�œ R¤ZÑ0Ô0Ñ1Ô1Ð1Ø�Š˜œ
¥T¤\Ñ1Ñ2Ô2Ð2Ð2Ð2r   N)Ú__name__Ú
__module__Ú__qualname__r   r   r"   r%   r)   r,   r.   r8   r;   r=   rJ   rL   rN   r
   r   r   r   r   Æ   só   € € € € € ð4ð 4ð 4ð4ð 4ð 4ðGð Gð GðGð Gð GðFð Fð FðFð Fð Fð
Fð Fð Fð Gð Gð Gð@ð @ð @ð@ð @ð @ð!3ð !3ð !3ðF@ð @ð @ð
3ð 3ð 3ð 3ð 3r   r   c                   ó   — e Zd ZdZd„ ZdS )ÚCannedRequestHandleraQ  Request handler for a unique and pre-defined request.

    The only thing we care about here is that a request is emitted by the
    client and we send back a syntactically correct response.

    We expect to receive a *single* request nothing more (and we won't even
    check what request it is, we just read until an empty line).
    c                 ó  — | j         j        }| j                             ¦   «         }t	          | j        ¦  «         |                     d¦  «        r| j                             ¦   «          | j                             |j        ¦  «         d S )Ns   POST)	ÚserverÚtest_case_serverÚrfileÚreadliner   Ú
startswithÚwfileÚwriteÚcanned_response)r   ÚtcsÚrequestlines      r   Ú_handle_one_requestz(CannedRequestHandler._handle_one_requestv  s|   € ð ŒkÔ*ˆØ”j×)Ò)Ñ+Ô+ˆå�d”jÑ!Ô!Ð!Ø×!Ò! 'Ñ*Ô*ð 	"ð ŒJ×ÒÑ!Ô!Ð!àŒ
×Ò˜Ô,Ñ-Ô-Ð-Ð-Ð-r   N)rO   rP   rQ   Ú__doc__r_   r
   r   r   rS   rS   l  s-   € € € € € ðð ð.ð .ð .ð .ð .r   rS   c                   ó"   ‡ — e Zd ZdZˆ fd„Zˆ xZS )ÚHatterHttpServerz‹A server giving all sort of crazy responses (like Alice's Hatter).

    This is used to test various error cases in the webdav client.
    c                 óf   •— t          ¦   «                              t          d¬¦  «         d | _        d S )NzHTTP/1.1)Úprotocol_version)ÚsuperÚ__init__rS   r\   ©r   Ú	__class__s    €r   rf   zHatterHttpServer.__init__‹  s;   ø€ Ý‰Œ×ÒÕ-Ø@Jð 	ñ 	Lô 	Lð 	Là#ˆÔÐÐr   )rO   rP   rQ   r`   rf   Ú__classcell__©rh   s   @r   rb   rb   …  sB   ø€ € € € € ðð ð
$ð $ð $ð $ð $ð $ð $ð $ð $r   rb   c                   ó*   ‡ — e Zd Zˆ fd„Zd„ Zd„ Zˆ xZS )ÚTestDAVErrorsc                 ó   •— t          ¦   «                              ¦   «          t          j        | _        t          ¦   «         | _        | j                             ¦   «          |                      | j        j	        ¦  «         d S r+   )
re   ÚsetUpr   ÚHttpDavTransportÚ
_transportrb   rU   Ústart_serverÚ
addCleanupÚstop_serverrg   s    €r   rn   zTestDAVErrors.setUp“  s\   ø€ Ý‰Œ�Š‰ŒˆÝ Ô1ˆŒÝ&Ñ(Ô(ˆŒØŒ× Ò Ñ"Ô"Ð"Ø�Š˜œÔ/Ñ0Ô0Ð0Ð0Ð0r   c                 ó^   — |                       | j                             ¦   «         ¦  «        }|S r+   )rp   rU   Úget_url©r   Úts     r   Úget_transportzTestDAVErrors.get_transportš  s&   € Ø�OŠO˜DœK×/Ò/Ñ1Ô1Ñ2Ô2ˆØˆr   c                 ó’   — d| j         _        |                      ¦   «         }|                      t          j        |j        d¦  «         dS )z/A bogus return code for delete raises an error.sV   HTTP/1.1 202 OK
Date: Tue, 10 Aug 2013 14:38:56 GMT
Server: Apache/42 (Wonderland)
ÚwhateverN)rU   r\   rx   r   r   r   Údeleterv   s     r   Útest_delete_replies_202z%TestDAVErrors.test_delete_replies_202ž  sD   € ð'ˆŒÔ#ð ×ÒÑ Ô ˆØ×Ò�&Ô4°a´hÀ
ÑKÔKÐKÐKÐKr   )rO   rP   rQ   rn   rx   r|   ri   rj   s   @r   rl   rl   ‘  s]   ø€ € € € € ð1ð 1ð 1ð 1ð 1ðð ð ðLð Lð Lð Lð Lð Lð Lr   rl   )r`   Úhttp.clientr   Úior   rB   Úbreezyr   r   Úbreezy.plugins.webdavr   Úbreezy.testsr   r   r   ÚTestCaser   ÚTestingHTTPRequestHandlerrS   Ú
HttpServerrb   rl   r
   r   r   ú<module>r…      sz  ðð" "Ð !à %Ð %Ð %Ð %Ð %Ð %Ø Ð Ð Ð Ð Ð Ø €€€ðð ð ð ð ð ð ð ð )Ð (Ð (Ð (Ð (Ð (Ø $Ð $Ð $Ð $Ð $Ð $ð#ð #ð #ðL}ð }ð }ð@c3ð c3ð c3ð c3ð c3�u”~ñ c3ô c3ð c3ðL.ð .ð .ð .ð .˜;Ô@ñ .ô .ð .ð2	$ð 	$ð 	$ð 	$ð 	$�{Ô-ñ 	$ô 	$ð 	$ðLð Lð Lð Lð L�E”Nñ Lô Lð Lð Lð Lr   