o .^@sdZeZddlZddlZddlZddlZddlmZm Z ddl m Z ddl m Z mZmZmZGddde ZGdd d e ZGd d d e ZGd d d e ZddZdS)z"Tests for the OAuth-aware classes.N) MockPatchTempDir)TestCase) AccessTokenConsumerOAuthAuthorizerSystemWideConsumerc@seZdZddZddZdS) TestConsumercC:tddd}||jd||jd||jddS)Nkeysecret application)r assertEqualr r application_nameselfconsumerrE/usr/lib/python3/dist-packages/lazr/restfulclient/tests/test_oauth.pytest_data_fields, zTestConsumer.test_data_fieldscCstdd}||jddSNr r )rrrrrrrtest_default_application_name2s z*TestConsumer.test_default_application_nameN)__name__ __module__ __qualname__rrrrrrr *s r c@s,eZdZddZddZddZddZd S) TestAccessTokencCr )Nr r context)rrr r rr access_tokenrrrr:rz TestAccessToken.test_data_fieldscCstdd}||jdSr)r assertIsNonerrrrrtest_default_context@s z$TestAccessToken.test_default_contextcCstdd}|dt|dS)Nlock&keysecret=password;oauth_token_secret=secret%3Dpassword&oauth_token=lock%26key)rrstrrrrr test___str__Es zTestAccessToken.test___str__cCs*td}||jd||jddS)Nr$r"r#)r from_stringrr r rrrrtest_from_stringKs z TestAccessToken.test_from_stringN)rrrrr!r&r(rrrrr8s  rc@s$eZdZddZddZddZdS)TestSystemWideConsumercCP|tddd|tddd|tdddtd}||jd dS) N distro.nameFooix return_valueplatform.systemFooOSsocket.gethostnamefooapp namezSystem-wide: Fooix (foo) useFixturerrrr rrrrtest_useful_distro_nameTz.TestSystemWideConsumer.test_useful_distro_namecCr*) Nr+r-r/BarOSr1barr3zSystem-wide: BarOS (bar)r4rrrrtest_empty_distro_name^r7z-TestSystemWideConsumer.test_empty_distro_namecCsT|tdtdd|tddd|tdddtd }||jd dS) Nr+zOh noes!) side_effectr/BazOSr-r1bazr3zSystem-wide: BazOS (baz))r5r Exceptionrrr rrrrtest_broken_distro_namehsz.TestSystemWideConsumer.test_broken_distro_nameN)rrrr6r;r@rrrrr)Rs r)c@seZdZdZddZdS)TestOAuthAuthorizerzTest for the OAuth Authorizer.cCs|tj}tj|d}tddtddd}|||tj || t t |j t jt jBt|}| |jjd| |jjd| |jjd| |jjddS)N credentialsz consumer.keyzconsumer.secretz access.keyz access.secret)consumer_secretr)r5rpathosjoinrr save_to_path assertTrueexistsrstatS_IMODEst_modeS_IREADS_IWRITEload_from_pathrr r r)rtemp_dircredentials_pathrBloaded_credentialsrrr test_save_to_and_load_from__pathws,   z4TestOAuthAuthorizer.test_save_to_and_load_from__pathN)rrr__doc__rSrrrrrAts rAcCsttS)N)unittest TestLoaderloadTestsFromNamerrrrr test_suitesrX)rTtype __metaclass__rEos.pathrJrUfixturesrr testtoolsr"lazr.restfulclient.authorize.oauthrrrrr rr)rArXrrrrs "