Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/keyring/tests/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyc


;Pc@sdZddlZddlZddlZddlZddlZddlZddlZddlZyddl	Z
Wnek
rddl
Z
nXddlZ
ejejZejejZdefdYZejdZdZdZedZd	Zd
ZdZdZd
ZdZ dZ!dZ"defdYZ#e
j$edde#e
j%fdYZ&e
j$edde#e
j%fdYZ'e
j$edde#e
j%fdYZ(defdYZ)defdYZ*d e
j%fd!YZ+e
j$eoSe d"d#e
j%fd$YZ,d%e#fd&YZ-d'e-e
j%fd(YZ.e
j$ed)d*e-e
j%fd+YZ/e
j$ed,d-e-e
j%fd.YZ0e
j$e!d/d0e#e
j%fd1YZ1e
j$e"d2d3e#e
j%fd4YZ2d5Z3e4d6kre
j5d7d8ndS(9sY
test_backend.py

Test case for keyring basic function

created by Kang Zhang 2009-07-14
iNtImportKillercBs>eZdZdZddZdZdZdZRS(s@Context manager to make an import of a given name or names fail.cGs
||_dS(N(tnames(tselfR((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyt__init__scCs||jkr|SdS(N(R(Rtfullnametpath((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pytfind_module!scCs%||jkstt|dS(N(RtAssertionErrortImportError(RR((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pytload_module$scCsMi|_x-|jD]"}tjj|d|j|<qWtjj|dS(N(toriginalRtsystmodulestpoptNonet	meta_pathtappend(Rtname((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyt	__enter__'s	 cGsPtjj|x9|jjD](\}}|dk	r |tj|<q q WdS(N(RRtremoveR
titemsRR(Rtargstkeytvalue((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyt__exit__,sN(	t__name__t
__module__t__doc__RRRR	RR(((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRs			cksi}x\|jD]N\}}|j|||<|dkrW||kra||=qaq|||<qWdVxI|jD];\}}|dkr||kr||=qqw|||<qwWdS(sHelper context manager to make and unmake changes to a dict.

    A None is not a valid value for the destination, and so means that the
    associated name should be removed.N(RtgetR(tdestinationtchangesR
RR((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pytNoNoneDictMutator3s

cKsttj|S(s6A context manager to temporarily change the os.environ(Rtostenviron(R((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pytEnvironJscOs4x!|D]}tj|||<qWttj|S(sDA context manager to temporarily make it possible to import a module(ttypest
ModuleTypeRRR(RRR((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyt
ImportBlesserOs
cCs7d}x*td|D]}|tj|7}qW|S(s2Generate a random string with length <i>k</i>
    ti(trangetrandomtchoice(tktsourcetresultti((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyt
random_stringVscCsFytdWntk
r"tSXtjdkoEtjddkS(Nskeyring.backends.win32_cryptotwin32ii(swin32(t
__import__RtFalseRtplatformtgetwindowsversion(((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pytis_win32_crypto_supported_s

cCs
tjdkS(Ntmactdarwin(R5sdarwin(RR2(((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pytis_osx_keychain_supportedfscCs)tjjj}|dkr%tStS(Ni(tkeyringtbackendt
KDEKWallett	supportedR1tTrue(R;((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pytis_kwallet_supportediscCs;y"tdtdtdWntk
r6tSXtS(NsCrypto.Cipher.AESsCrypto.Protocol.KDFs
Crypto.Random(R0RR1R<(((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pytis_crypto_supportedos


cCs)tjjj}|dkr%tStS(Ni(R8R9tGnomeKeyringR;R1R<(R;((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pytis_gnomekeyring_supportedxscCs'ytdWntk
r"tSXtS(NsPyQt4.QtGui(R0RR1R<(((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pytis_qt4_supported~s

cCsVytdt}Wntk
r-t}nXtjdkoUtjjdkoU|S(Nt	win32credR/i(swin32(R0R<RR1RR2R3tmajor(thas_pywin32((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pytis_winvault_supporteds



$cCs'ytdWntk
r"tSXtS(Ntdbus(R0RR1R<(((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pytis_dbus_supporteds

tBackendBasicTestscBsDeZdZdZdZdZdZdZdZRS(sITest for the keyring's basic funtions. password_set and password_get
    cCs|j|_t|_dS(N(tinit_keyringR8tsettcredentials_created(R((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pytsetUpscCs0|jj||||jj||fdS(N(R8tset_passwordRKtadd(Rtservicetusernametpassword((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRMscCs|j}|j|j||d|j||||j|j||||j||d|j|j||ddS(NR&(R8tassertEqualtget_passwordRRM(RRORPRQR8((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyt
check_set_gets	cCs;td}td}td}|j|||dS(Ni(R.RT(RRQRPRO((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyttest_password_set_getscCsDtdt}tdt}tdt}|j|||dS(Ni(R.tDIFFICULT_CHARSRT(RRQRPRO((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyttest_difficult_charsscCs|j}|jddd|jddd|j|jddd|j|jddd|jddd|j|jdddd	S(
s
        Issue #47 reports that WinVault isn't storing passwords for
        multiple users. This test exercises that test for each of the
        backends.
        tservice1tuser1t	password1tuser2t	password2tservice2tuser3t	password3N(R8RMRRRS(RR8((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyttest_different_users	(	RRRRLRMRTRURWR`(((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRHs					s	Need OS XtOSXKeychainTestCasecBseZdZRS(cCs
tjjS(N(R8R9tOSXKeychain(R((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRIs(RRRI(((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRassNeed GnomeKeyringtGnomeKeyringTestCasecBsGeZdZdZdZdZdZdZdZRS(cCstddddddS(NtGNOME_KEYRING_CONTROLt1tDISPLAYtDBUS_SESSION_BUS_ADDRESS(tdict(R((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyR!scCstjj}d|_|S(Ntsession(R8R9R?tKEYRING_NAME(RR*((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRIs	cCsItd7t|j|jd|jjWdQXWdQXdS(Ntgnomekeyringi(R%R"R!RRR8R;(R((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyttest_supporteds
cCsItd7t|j|jd|jjWdQXWdQXdS(NRki(RR"R!RRR8R;(R((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyttest_supported_no_modules
cCsYtdG|j}d|d<t||jd|jjWdQXWdQXdS(NRkRdi(R%R!RR"RRR8R;(RR!((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyttest_supported_no_keyrings



cCsYtdG|j}d|d<t||jd|jjWdQXWdQXdS(NRkRfi(R%R!RR"RRR8R;(RR!((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyttest_supported_no_displays



cCsYtdG|j}d|d<t||jd|jjWdQXWdQXdS(NRkRgi(R%R!RR"RRR8R;(RR!((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyttest_supported_no_sessions



(	RRR!RIRlRmRnRoRp(((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRcs							sNeed KWallettKDEKWalletTestCasecBseZdZRS(cCs
tjjS(N(R8R9R:(R((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRIs(RRRI(((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRqstUnOpenableKWalletcBs&eZdZdZdZdZRS(s7A module-like object used to test KDE wallet fall-back.cGsdS(N(R(RR((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyt
openWalletscCsdS(N(R(R((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyt
NetworkWalletsN(RRRRtSynchronousRsRt(((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRrs	t	FauxQtGuicBsMeZdZdddYZdefdYZdefdYZRS(sDA fake module-like object used in testing the open_kwallet function.tqAppcBseZedZRS(cCsdS(N((((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pytinstance#s(RRtstaticmethodRx(((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRw"stQApplicationcBseZdZdZRS(cGsdS(N((RR((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyR(scCsdS(N((R((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pytexit+s(RRRR{(((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRz's	tQWidgetcBseZdZdZRS(cGsdS(N((RR((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyR/scCsdS(N((R((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pytwinId2s(RRRR}(((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyR|.s	((RRRRwtobjectRzR|(((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRvstKDEWalletCanceledTestCasecBseZdZRS(cCs)|jtjjttddS(N(RRR8R9topen_kwalletRrRvR(R((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyttest_user_canceled7s(RRR(((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyR5ssNeed KWallet and Qt4tKDEKWalletInQApplicationcBseZdZRS(cCsy$ddlm}ddlm}WndSX|g}tjj}|jt||j	ddt
||jdS(Ni(tKWallet(Rztmsgs?The object wallet should be type <KWallet.Wallet> but it is: %s(tPyKDE4.kdeuiRtPyQt4.QtGuiRzR8R9Rt
assertTruet
isinstancetWallettreprR{(RRRztapptwallet((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyttest_QApplicationFs(RRR(((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRBstFileKeyringTestscBs#eZdZdZdZRS(cCsNtt|j|j|_tjjtj	d|j_
|_dS(Ns
test_pass.cfg(tsuperRRLRIR8R Rtjointtempfiletmkdtempt	file_pathttmp_keyring_file(R((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRLWs	cCsCytj|jWn(tk
r>}|jdkr?q?nXdS(Ni(R tunlinkRtOSErrorterrno(Rte((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyttearDown]s
cCsMtd}|jd}|jj|}|j||jj|dS(Nisutf-8(R.tencodeR8tencryptRRtdecrypt(RRQt	encrypted((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyttest_encrypt_decryptds(RRRLRR(((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRUs		tUncryptedFileKeyringTestCasecBseZdZRS(cCs
tjjS(N(R8R9tUncryptedFileKeyring(R((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRIos(RRRI(((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRmssNeed Crypto moduletCryptedFileKeyringTestCasecBs#eZdZdZdZRS(cCs2t|j|jtj|_dt_dS(Nc_sdS(Ntabcdef((Rtkwargs((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyt<lambda>{s(Rt	__class__RLtgetpasstgetpass_orig(R((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRLwscCs|jt_|`dS(N(RR(R((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyR}scCs
tjjS(N(R8R9tCryptedFileKeyring(R((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRIs(RRRLRRI(((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRss		sNeed WindowstWin32CryptoKeyringTestCasecBseZdZRS(cCs
tjjS(N(R8R9tWin32CryptoKeyring(R((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRIs(RRRI(((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRss
Need WinVaulttWinVaultKeyringTestCasecBseZdZdZRS(cCsOxH|jD]=}y|jj|Wq
tk
rF}tj|IJq
Xq
WdS(N(RKR8tdelete_passwordt	ExceptionRtstderr(RtcredR((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRs
cCs
tjjS(N(R8R9tWinVaultKeyring(R((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRIs(RRRRI(((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRs	s$DBus needed for SecretServiceKeyringtSecretServiceKeyringTestCasecBs)eZeZdZdZdZRS(cCstddddS(NRfReRg(Rh(R((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyR!scCstjdIJtjjS(NsMTesting SecretServiceKeyring, following password prompts are for this keyring(RRR8R9tSecretServiceKeyring(R((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRIs
cCsItd7t|j|jd|jjWdQXWdQXdS(NRFi(RR"R!RRR8R;(R((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRms
(RRR<t__test__R!RIRm(((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyRs		cCstj}|jtjt|jtjt|jtjt|jtjt|jtjt|jtjt	|jtjt
|jtjt|jtjt|jtjt
|S(N(tunittestt	TestSuitetaddTestt	makeSuiteRaRcRRRqRRRRR(tsuite((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyt
test_suitest__main__tdefaultTestR(6Rt
contextlibR R(tstringRRR#Rt	unittest2RRtkeyring.backendR8t
ascii_letterstdigitstALPHABETt
whitespacetpunctuationRVR~RtcontextmanagerRR"R%R.R4R7R=R>R@RARERGRHt
skipUnlesstTestCaseRaRcRqRrRvRRRRRRRRRRtmain(((s>/usr/lib/python2.7/dist-packages/keyring/tests/test_backend.pyt<module>s|
												:		0