};erdZeZddlZddlZddlZddlZddlmZm Z ddl m Z ddl m Z mZmZmZGdde ZGdd e ZGd d e ZGd d e ZdZy)z"Tests for the OAuth-aware classes.N) MockPatchTempDir)TestCase) AccessTokenConsumerOAuthAuthorizerSystemWideConsumerceZdZdZdZy) TestConsumerctddd}|j|jd|j|jd|j|jdy)Nkeysecret application)r assertEqualr rapplication_nameselfconsumers E/usr/lib/python3/dist-packages/lazr/restfulclient/tests/test_oauth.pytest_data_fieldszTestConsumer.test_data_fields(sNE8]; u- (3 22MBcTtdd}|j|jdyNr r)rrrrs rtest_default_application_namez*TestConsumer.test_default_application_name.s$E8, 22D9rN)__name__ __module__ __qualname__rrrrr r 's C :rr c$eZdZdZdZdZdZy)TestAccessTokenctddd}|j|jd|j|jd|j|jdy)Nr rcontext)rrr rr"r access_tokens rrz TestAccessToken.test_data_fields5sR"5(I>  ))51 ,,h7 --y9rcRtdd}|j|jyr)r assertIsNoner"r#s rtest_default_contextz$TestAccessToken.test_default_context;s""5(3  ,../rcRtdd}|jdt|y)Nlock&keysecret=password;oauth_token_secret=secret%3Dpassword&oauth_token=lock%26key)rrstrr#s r test___str__zTestAccessToken.test___str__@s(":/@A   I   rctjd}|j|jd|j|jdy)Nr+r)r*)r from_stringrr rr#s rtest_from_stringz TestAccessToken.test_from_stringGsD".. I  )):6 ,,.?@rN)rrrrr'r-r0rrrr r 4s: 0  Arr ceZdZdZdZdZy)TestSystemWideConsumerc|jtdd|jtdd|jtddtd}|j|jd y) N distro.nameFooix return_valueplatform.systemFooOSsocket.gethostnamefooapp namezSystem-wide: Fooix (foo) useFixturerr rr rs rtest_useful_distro_namez.TestSystemWideConsumer.test_useful_distro_namePs^  -gFG  "3'JK  "6UKL%j1 'ABrc|jtdd|jtdd|jtddtd}|j|jd y) Nr4r6r8BarOSr:barr<zSystem-wide: BarOS (bar)r=rs rtest_empty_distro_namez-TestSystemWideConsumer.test_empty_distro_nameYs^  -bAB  "3'JK  "6UKL%j1 'ABrc |jtdtd|jtdd|jtddtd }|j |j d y) Nr4zOh noes!) side_effectr8BazOSr6r:bazr<zSystem-wide: BazOS (baz))r>r Exceptionr rr rs rtest_broken_distro_namez.TestSystemWideConsumer.test_broken_distro_namebsh  m:1F G   "3'JK  "6UKL%j1 'ABrN)rrrr?rDrJrrrr2r2OsCC Crr2ceZdZdZdZy)TestOAuthAuthorizerzTest for the OAuth Authorizer.cT|jtj}tjj |d}t ddt dd}|j||jtjj||jtjtj|jtjtjzt j |}|j|j"j$d|j|j"j&d|j|j(j$d|j|j(j&dy)N credentialsz consumer.keyzconsumer.secretz access.keyz access.secret)consumer_secretr$)r>rpathosjoinrr save_to_path assertTrueexistsrstatS_IMODEst_modeS_IREADS_IWRITEload_from_pathrr rr$)rtemp_dircredentials_pathrNloaded_credentialss r test_save_to_and_load_from__pathz4TestOAuthAuthorizer.test_save_to_and_load_from__pathqs;??79-2277<<-@% -$\?C   !12 '789  LL!12:: ; LL4== ( -;;rlsg$)   ' :8 :AhA6CXC> ( @=r