Ϫfl zddlmZddlmZmZddlmZddlmZddl m Z ddl m Z Gdde jZy ) ) annotations) credentialserror)FilePasswordDB)defer)unittest)tapceZdZdZdZej ddZej ddZd dZ d dZ d dZ d d Z d d Z dd Zy ) WordsTapTestsz7 Ensures that the twisted.words.tap API works. sadmin:admin joe:foo sadminsjoesbarc|j|_t|jd|_|jj |j |jj y)z/ Create a file with two users. wbN)mktempfilenameopenfilewrite PASSWD_TEXTflushselfs =/usr/lib/python3/dist-packages/twisted/words/test/test_tap.pysetUpzWordsTapTests.setUpsG  -  (() c8|jjy)z0 Close the dummy user database. N)rclosers rtearDownzWordsTapTests.tearDowns rc|tj}|jddg|j|ddy)zM Tests that the --hostname parameter gets passed to Options. z --hostnamemyhosthostnameN)r Options parseOptions assertEqualropts r test_hostnamezWordsTapTests.test_hostname%s6kkm ,12 Z(3rctj}|jd|jjg|j |y)zI Tests the --passwd command for backwards-compatibility. z--passwdNr r r!rname _loginTestr#s r test_passwdzWordsTapTests.test_passwd-s6kkm *diinn56 rctj}|jdd|jjzg|j |y)zD Tests that the --auth command generates a checker. z--authzfile:Nr'r#s r test_authzWordsTapTests.test_auth5s;kkm (Gdiinn$<=> rc"jt|dd|dd}j|jjt j dfd }|jjj|S)z This method executes both positive and negative authentication tests against whatever credentials checker has been stored in the Options class. @param opt: An instance of L{tap.Options}. credCheckersrcRj|jjy)N)r"adminusername)r2rs r _gotAvatarz,WordsTapTests._loginTest.._gotAvatarKs   Xtzz':': ;r)r2zbytes | tuple[()]returnNone) r"len assertFailurerequestAvatarIdjoeWrongrUnauthorizedLoginr1 addCallback)rr$checkerr3s` rr)zWordsTapTests._loginTest=s} S0115"%n"5a"8   # #DMM 2E4K4K  <&&tzz2>>zJJrN)r4r5)r$z tap.Optionsr4zdefer.Deferred[None])__name__ __module__ __qualname____doc__rrUsernamePasswordr1r9rrr%r*r,r)rrr r sU,K (K ( (8 rJs/#+0""AKH%%AKr