예제 #1
0
class BitbucketTests(create_oauth_tests(registry.by_id(BitbucketProvider.id))):
    def get_mocked_response(self):
        # FIXME: Replace with actual/complete Bitbucket response
        return [
            MockedResponse(
                200, r"""
[{"active": true, "email": "*****@*****.**", "primary": true},
 {"active": true, "email": "*****@*****.**", "primary": false},
 {"active": true,
  "email": "*****@*****.**",
  "primary": false}]
        """),
            MockedResponse(
                200, r"""
{"repositories": [],
 "user": {"avatar": "https://secure.gravatar.com/avatar.jpg",
           "display_name": "pennersr",
           "first_name": "",
           "is_team": false,
           "last_name": "",
           "resource_uri": "/1.0/users/pennersr",
           "username": "******"}}
 """)
        ]  # noqa

    def test_login(self):
        account = super(BitbucketTests, self).test_login()
        bb_account = account.get_provider_account()
        self.assertEqual(bb_account.get_username(), 'pennersr')
        self.assertEqual(bb_account.get_avatar_url(),
                         'https://secure.gravatar.com/avatar.jpg')
        self.assertEqual(bb_account.get_profile_url(),
                         'http://bitbucket.org/pennersr')
예제 #2
0
class StackExchangeTests(
        create_oauth2_tests(registry.by_id(StackExchangeProvider.id))):
    def get_mocked_response(self):
        return MockedResponse(
            200, """
        {
          "has_more": false,
           "items": [
              {
                "is_employee": false,
                 "last_access_date": 1356200390,
                 "display_name": "pennersr",
                 "account_id": 291652,
                 "badge_counts": {
                     "bronze": 2,
                     "silver": 2,
                     "gold": 0
                 },
                 "last_modified_date": 1356199552,
                 "profile_image": "http://www.gravatar.com/avatar/053d648486d567d3143d6bad8df8cfeb?d=identicon&r=PG",
                 "user_type": "registered",
                 "creation_date": 1296223711,
                 "reputation_change_quarter": 148,
                 "reputation_change_year": 378,
                 "reputation": 504,
                 "link": "http://stackoverflow.com/users/593944/pennersr",
                 "reputation_change_week": 0,
                 "user_id": 593944,
                 "reputation_change_month": 10,
                 "reputation_change_day": 0
              }
           ],
           "quota_max": 10000,
           "quota_remaining": 9999
        }""")
예제 #3
0
class XingTests(create_oauth_tests(registry.by_id(XingProvider.id))):
    def get_mocked_response(self):
        return [
            MockedResponse(
                200, """
{"users":[{"id":"20493333_1cd028","active_email":"*****@*****.**",
"badges":[],"birth_date":{"year":null,"month":null,"day":null},
"business_address":{"street":null,"zip_code":null,"city":null,"province":null,
"country":"NL","email":null,"fax":null,"phone":null,"mobile_phone":null},
"display_name":"Raymond Penners","educational_background":
{"primary_school_id":null,"schools":[],"qualifications":[]},
"employment_status":"EMPLOYEE","first_name":"Raymond","gender":"m",
"haves":null,"instant_messaging_accounts":{},"interests":null,"languages":
{"nl":null},"last_name":"Penners","organisation_member":null,
"page_name":"Raymond_Penners",
"permalink":"https://www.xing.com/profile/Raymond_Penners",
"photo_urls":{"thumb":"https://www.xing.com/img/n/nobody_m.30x40.jpg",
"large":"https://www.xing.com/img/n/nobody_m.140x185.jpg","mini_thumb":
"https://www.xing.com/img/n/nobody_m.18x24.jpg","maxi_thumb":
"https://www.xing.com/img/n/nobody_m.70x93.jpg","medium_thumb":
"https://www.xing.com/img/n/nobody_m.57x75.jpg"},"premium_services":[],
"private_address":{"street":null,"zip_code":null,"city":null,"province":null,
"country":null,"email":"*****@*****.**","fax":null,
"phone":null,"mobile_phone":null},"professional_experience":
{"primary_company":{"name":null,"url":null,"tag":null,"title":null,
"begin_date":null,"end_date":null,"description":null,"industry":"OTHERS",
"company_size":null,"career_level":null},"non_primary_companies":[],
"awards":[]},"time_zone":{"utc_offset":2.0,"name":"Europe/Berlin"},
"wants":null,"web_profiles":{}}]}

""")
        ]
예제 #4
0
class GitHubTests(create_oauth2_tests(registry.by_id(GitHubProvider.id))):
    def get_mocked_response(self):
        return MockedResponse(
            200, """
        {
            "type":"User",
            "organizations_url":"https://api.github.com/users/pennersr/orgs",
            "gists_url":"https://api.github.com/users/pennersr/gists{/gist_id}",
            "received_events_url":"https://api.github.com/users/pennersr/received_events",
            "gravatar_id":"8639768262b8484f6a3380f8db2efa5b",
            "followers":16,
            "blog":"http://www.intenct.info",
            "avatar_url":"https://secure.gravatar.com/avatar/8639768262b8484f6a3380f8db2efa5b?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png",
            "login":"******",
            "created_at":"2010-02-10T12:50:51Z",
            "company":"IntenCT",
            "subscriptions_url":"https://api.github.com/users/pennersr/subscriptions",
            "public_repos":14,
            "hireable":false,
            "url":"https://api.github.com/users/pennersr",
            "public_gists":0,
            "starred_url":"https://api.github.com/users/pennersr/starred{/owner}{/repo}",
            "html_url":"https://github.com/pennersr",
            "location":"The Netherlands",
            "bio":null,
            "name":"Raymond Penners",
            "repos_url":"https://api.github.com/users/pennersr/repos",
            "followers_url":"https://api.github.com/users/pennersr/followers",
            "id":201022,
            "following":0,
            "email":"*****@*****.**",
            "events_url":"https://api.github.com/users/pennersr/events{/privacy}",
            "following_url":"https://api.github.com/users/pennersr/following"
        }""")
예제 #5
0
class TwitchTests(create_oauth2_tests(registry.by_id(TwitchProvider.id))):
    def get_mocked_response(self):
        return MockedResponse(
            200,
            """{"name":"test_user1","created_at":"2011-06-03T17:49:19Z","updated_at":"2012-06-18T17:19:57Z","_links":{"self":"https://api.twitch.tv/kraken/users/test_user1"},"logo":"http://static-cdn.jtvnw.net/jtv_user_pictures/test_user1-profile_image-62e8318af864d6d7-300x300.jpeg","_id":22761313,"display_name":"test_user1","email":"*****@*****.**","partnered":true}

""")
예제 #6
0
class TumblrTests(create_oauth_tests(registry.by_id(TumblrProvider.id))):
    def get_mocked_response(self):
        return [
            MockedResponse(
                200, """
{
   "meta": {
      "status": 200,
      "msg": "OK"
   },
   "response": {
     "user": {
       "following": 263,
       "default_post_format": "html",
       "name": "derekg",
       "likes": 606,
       "blogs": [
          {
           "name": "derekg",
           "title": "Derek Gottfrid",
           "url": "http://derekg.org/",
           "tweet": "auto",
           "primary": true,
           "followers": 33004929
          },
          {
           "name": "ihatehipstrz",
           "title": "I Hate Hipstrz"
           }
        ]
     }
} }
""")
        ]
예제 #7
0
class DropboxOAuth2Tests(create_oauth2_tests(registry.by_id(
        DropboxOAuth2Provider.id))):
    def get_mocked_response(self):
        return [MockedResponse(200, """{
            "display_name": "Björn Andersson",
            "name_details": {
                "surname": "Andersson",
                "familiar_name": "Björn",
                "given_name": "Björn"
                },
            "locale": "en",
            "email": "*****@*****.**",
            "uid": 1234567890,
            "email_verified": true,
            "quota_info": {
                "shared": 3195052017,
                "datastores": 0,
                "quota": 61337501696,
                "normal": 15455059441
                },
            "is_paired": true,
            "team": null,
            "referral_link": "https://db.tt/UzhBTVjU",
            "country": "SE"
        }""")]
예제 #8
0
class FirefoxAccountsTests(create_oauth2_tests(registry.by_id(FirefoxAccountsProvider.id))):
    def get_mocked_response(self):
        return MockedResponse(200, """
        {
            "uid":"6d940dd41e636cc156074109b8092f96",
            "email":"*****@*****.**"
        }""")
예제 #9
0
class SpotifyOAuth2Tests(
        create_oauth2_tests(registry.by_id(SpotifyOAuth2Provider.id))):
    def get_mocked_response(self):
        return MockedResponse(
            200, """{
          "birthdate": "1937-06-01",
          "country": "SE",
          "display_name": "JM Wizzler",
          "email": "*****@*****.**",
          "external_urls": {
            "spotify": "https://open.spotify.com/user/wizzler"
          },
          "followers" : {
            "href" : null,
            "total" : 3829
          },
          "href": "https://api.spotify.com/v1/users/wizzler",
          "id": "wizzler",
          "images": [
            {
              "height": null,
              "url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-frc3/t1.0-1/1970403_10152215092574354_1798272330_n.jpg",
              "width": null
            }
          ],
          "product": "premium",
          "type": "user",
          "uri": "spotify:user:wizzler"
        }""")
예제 #10
0
class SoundCloudTests(
        create_oauth2_tests(registry.by_id(SoundCloudProvider.id))):
    def get_mocked_response(self):
        return MockedResponse(
            200, """
        {
           "website": null,
            "myspace_name": null,
            "public_favorites_count": 0,
            "followings_count": 1,
            "full_name": "",
            "id": 22341947,
            "city": null,
            "track_count": 0,
            "playlist_count": 0,
            "discogs_name": null,
            "private_tracks_count": 0,
            "followers_count": 0,
            "online": true,
            "username": "******",
            "description": null,
            "kind": "user",
            "website_title": null,
            "primary_email_confirmed": false,
            "permalink_url": "http://soundcloud.com/user187631676",
            "private_playlists_count": 0,
            "permalink": "user187631676",
            "country": null,
            "uri": "https://api.soundcloud.com/users/22341947",
            "avatar_url": "https://a1.sndcdn.com/images/default_avatar_large.png?4b4189b",
            "plan": "Free"
        }""")
예제 #11
0
class WeiboTests(create_oauth2_tests(registry.by_id(WeiboProvider.id))):
    def get_mocked_response(self):
        return MockedResponse(
            200,
            """{"bi_followers_count": 0, "domain": "", "avatar_large": "http://tp3.sinaimg.cn/3195025850/180/0/0", "block_word": 0, "star": 0, "id": 3195025850, "city": "1", "verified": false, "follow_me": false, "verified_reason": "", "followers_count": 6, "location": "\u5317\u4eac \u4e1c\u57ce\u533a", "mbtype": 0, "profile_url": "u/3195025850", "province": "11", "statuses_count": 0, "description": "", "friends_count": 0, "online_status": 0, "mbrank": 0, "idstr": "3195025850", "profile_image_url": "http://tp3.sinaimg.cn/3195025850/50/0/0", "allow_all_act_msg": false, "allow_all_comment": true, "geo_enabled": true, "name": "pennersr", "lang": "zh-cn", "weihao": "", "remark": "", "favourites_count": 0, "screen_name": "pennersr", "url": "", "gender": "f", "created_at": "Tue Feb 19 19:43:39 +0800 2013", "verified_type": -1, "following": false}

""")
예제 #12
0
class TwitterTests(create_oauth_tests(registry.by_id(TwitterProvider.id))):
    def get_mocked_response(self):
        # FIXME: Replace with actual/complete Twitter response
        return [
            MockedResponse(
                200, r"""
{"follow_request_sent": false,
 "profile_use_background_image": true,
 "id": 45671919, "verified": false, "profile_text_color": "333333",
 "profile_image_url_https":
       "https://pbs.twimg.com/profile_images/793142149/r_normal.png",
 "profile_sidebar_fill_color": "DDEEF6",
 "is_translator": false, "geo_enabled": false, "entities":
 {"description": {"urls": []}}, "followers_count": 43, "protected": false,
 "location": "The Netherlands", "default_profile_image": false,
 "id_str": "45671919", "status": {"contributors": null, "truncated":
  false, "text": "RT @denibertovic: Okay I'm definitely using django-allauth from now on. So easy to set up, far less time consuming, and it just works. #dja\u2026", "in_reply_to_status_id": null, "id": 400658301702381568, "favorite_count": 0, "source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>", "retweeted": true, "coordinates": null, "entities": {"symbols": [], "user_mentions": [{"indices": [3, 16], "screen_name": "denibertovic", "id": 23508244, "name": "Deni Bertovic", "id_str": "23508244"}], "hashtags": [{"indices": [135, 139], "text": "dja"}], "urls": []}, "in_reply_to_screen_name": null, "id_str": "400658301702381568", "retweet_count": 6, "in_reply_to_user_id": null, "favorited": false, "retweeted_status": {"lang": "en", "favorited": false, "in_reply_to_user_id": null, "contributors": null, "truncated": false, "text": "Okay I'm definitely using django-allauth from now on. So easy to set up, far less time consuming, and it just works. #django", "created_at": "Sun Jul 28 19:56:26 +0000 2013", "retweeted": true, "in_reply_to_status_id": null, "coordinates": null, "id": 361575897674956800, "entities": {"symbols": [], "user_mentions": [], "hashtags": [{"indices": [117, 124], "text": "django"}], "urls": []}, "in_reply_to_status_id_str": null, "in_reply_to_screen_name": null, "source": "web", "place": null, "retweet_count": 6, "geo": null, "in_reply_to_user_id_str": null, "favorite_count": 8, "id_str": "361575897674956800"}, "geo": null, "in_reply_to_user_id_str": null, "lang": "en", "created_at": "Wed Nov 13 16:15:57 +0000 2013", "in_reply_to_status_id_str": null, "place": null}, "utc_offset": 3600, "statuses_count": 39, "description": "", "friends_count": 83, "profile_link_color": "0084B4", "profile_image_url": "http://pbs.twimg.com/profile_images/793142149/r_normal.png", "notifications": false, "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", "profile_background_color": "C0DEED", "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", "name": "Raymond Penners", "lang": "nl", "profile_background_tile": false, "favourites_count": 0, "screen_name": "pennersr", "url": null, "created_at": "Mon Jun 08 21:10:45 +0000 2009", "contributors_enabled": false, "time_zone": "Amsterdam", "profile_sidebar_border_color": "C0DEED", "default_profile": true, "following": false, "listed_count": 1} """
            )
        ]  # noqa

    def test_login(self):
        account = super(TwitterTests, self).test_login()
        tw_account = account.get_provider_account()
        self.assertEqual(tw_account.get_screen_name(), 'pennersr')
        self.assertEqual(
            tw_account.get_avatar_url(),
            'http://pbs.twimg.com/profile_images/793142149/r.png')
        self.assertEqual(tw_account.get_profile_url(),
                         'http://twitter.com/pennersr')
예제 #13
0
class VimeoTests(create_oauth_tests(registry.by_id(VimeoProvider.id))):
    def get_mocked_response(self):
        return [
            MockedResponse(
                200, """
{"generated_in":"0.0137","stat":"ok","person":{"created_on":"2013-04-08 14:24:47","id":"17574504","is_contact":"0","is_plus":"0","is_pro":"0","is_staff":"0","is_subscribed_to":"0","username":"******","display_name":"Raymond Penners","location":"","url":[""],"bio":"","number_of_contacts":"0","number_of_uploads":"0","number_of_likes":"0","number_of_videos":"0","number_of_videos_appears_in":"0","number_of_albums":"0","number_of_channels":"0","number_of_groups":"0","profileurl":"http:\\/\\/vimeo.com\\/user17574504","videosurl":"http:\\/\\/vimeo.com\\/user17574504\\/videos","portraits":{"portrait":[{"height":"30","width":"30","_content":"http:\\/\\/a.vimeocdn.com\\/images_v6\\/portraits\\/portrait_30_yellow.png"},{"height":"75","width":"75","_content":"http:\\/\\/a.vimeocdn.com\\/images_v6\\/portraits\\/portrait_75_yellow.png"},{"height":"100","width":"100","_content":"http:\\/\\/a.vimeocdn.com\\/images_v6\\/portraits\\/portrait_100_yellow.png"},{"height":"300","width":"300","_content":"http:\\/\\/a.vimeocdn.com\\/images_v6\\/portraits\\/portrait_300_yellow.png"}]}}}
""")
        ]
예제 #14
0
class VKTests(create_oauth2_tests(registry.by_id(VKProvider.id))):
    def get_mocked_response(self, verified_email=True):
        return MockedResponse(
            200, """
{"response": [{"last_name": "Penners", "university_name": "", "photo": "http://vk.com/images/camera_c.gif", "sex": 2, "photo_medium": "http://vk.com/images/camera_b.gif", "relation": "0", "timezone": 1, "photo_big": "http://vk.com/images/camera_a.gif", "uid": 219004864, "universities": [], "city": "1430", "first_name": "Raymond", "faculty_name": "", "online": 1, "counters": {"videos": 0, "online_friends": 0, "notes": 0, "audios": 0, "photos": 0, "followers": 0, "groups": 0, "user_videos": 0, "albums": 0, "friends": 0}, "home_phone": "", "faculty": 0, "nickname": "", "screen_name": "id219004864", "has_mobile": 1, "country": "139", "university": 0, "graduation": 0, "activity": "", "last_seen": {"time": 1377805189}}]}
""")

    def get_login_response_json(self, with_refresh_token=True):
        return '{"user_id": 219004864, "access_token":"testac"}'
예제 #15
0
class EvernoteTests(create_oauth_tests(registry.by_id(EvernoteProvider.id))):
    def get_mocked_response(self):
        return []

    def get_access_token_response(self):
        return MockedResponse(
            200,
            'oauth_token=S%3Ds1%3AU%3D9876%3AE%3D999999b0c50%3AC%3D14c1f89dd18%3AP%3D81%3AA%3Dpennersr%3AV%3D2%3AH%3Ddeadf00dd2d6aba7b519923987b4bf77&oauth_token_secret=&edam_shard=s1&edam_userId=591969&edam_expires=1457994271824&edam_noteStoreUrl=https%3A%2F%2Fsandbox.evernote.com%2Fshard%2Fs1%2Fnotestore&edam_webApiUrlPrefix=https%3A%2F%2Fsandbox.evernote.com%2Fshard%2Fs1%2F',  # noqa
            {'content-type': 'text/plain'})
예제 #16
0
class OdnoklassnikiTests(
        create_oauth2_tests(registry.by_id(OdnoklassnikiProvider.id))):
    def get_mocked_response(self, verified_email=True):
        return MockedResponse(
            200, """
{"uid":"561999209121","birthday":"1999-09-09","age":33,"first_name":"Ivan","last_name":"Petrov","name":"Ivan Petrov","locale":"en","gender":"male","has_email":true,"location":{"city":"Moscow","country":"RUSSIAN_FEDERATION","countryCode":"RU","countryName":"Russia"},"online":"web","pic_1":"http://i500.mycdn.me/res/stub_50x50.gif","pic_2":"http://usd1.mycdn.me/res/stub_128x96.gif"}
""")

    def get_login_response_json(self, with_refresh_token=True):
        return '{"access_token": "testac"}'  # noqa
예제 #17
0
class AmazonTests(create_oauth2_tests(registry.by_id(AmazonProvider.id))):
    def get_mocked_response(self):
        return MockedResponse(200, """
        {
          "Profile":{
                        "CustomerId":"amzn1.account.K2LI23KL2LK2",
                        "Name":"John Doe",
                        "PrimaryEmail":"*****@*****.**"
                    }
        }""")
예제 #18
0
class MailRuTests(create_oauth2_tests(registry.by_id(MailRuProvider.id))):
    def get_mocked_response(self, verified_email=True):
        return MockedResponse(200, """
[ { "uid": "15410773191172635989", "first_name": "Евгений", "last_name": "Маслов", "nick": "maslov", "email": "*****@*****.**", "sex": 0,  "birthday": "15.02.1980",  "has_pic": 1, "pic": "http://avt.appsmail.ru/mail/emaslov/_avatar",  "pic_small": "http://avt.appsmail.ru/mail/emaslov/_avatarsmall",  "pic_big": "http://avt.appsmail.ru/mail/emaslov/_avatarbig", "link": "http://my.mail.ru/mail/emaslov/", "referer_type": "", "referer_id": "", "is_online": 1, "friends_count": 145, "is_verified": 1, "vip" : 0, "app_installed": 1, "location": { "country": { "name": "Россия", "id": "24" }, "city": { "name": "Москва", "id": "25" }, "region": { "name": "Москва", "id": "999999" } } }]"""
                              )  # noqa

    def get_login_response_json(self, with_refresh_token=True):
        # FIXME: This is not an actual response. I added this in order
        # to get the test suite going but did not verify to check the
        # exact response being returned.
        return '{"access_token": "testac", "uid": "weibo", "refresh_token": "testrf", "x_mailru_vid": "1"}'  # noqa
예제 #19
0
class PaypalTests(create_oauth2_tests(registry.by_id(PaypalProvider.id))):
    def get_mocked_response(self):
        return MockedResponse(
            200, """
        {
            "user_id": "https://www.paypal.com/webapps/auth/server/64ghr894040044",
            "name": "Jane Doe",
            "given_name": "Jane",
            "family_name": "Doe",
            "email": "*****@*****.**"
        }
        """)
예제 #20
0
 def complete_login(self, request, app, token, **kwargs):
     provider = registry.by_id(app.provider)
     site = provider.get_site()
     resp = requests.get(self.profile_url,
                         params={
                             'access_token': token.token,
                             'key': app.key,
                             'site': site
                         })
     extra_data = resp.json()['items'][0]
     return self.get_provider().sociallogin_from_response(
         request, extra_data)
예제 #21
0
class LinkedInOAuth2Tests(
        create_oauth2_tests(registry.by_id(LinkedInOAuth2Provider.id))):
    def get_mocked_response(self):
        return MockedResponse(
            200, """
{
  "emailAddress": "*****@*****.**",
  "firstName": "Raymond",
  "id": "ZLARGMFT1M",
  "lastName": "Penners",
  "pictureUrl": "http://m.c.lnkd.licdn.com/mpr/mprx/0_e0hbvSLc",
  "publicProfileUrl": "http://www.linkedin.com/in/intenct"
}
""")
예제 #22
0
class LinkedInTests(create_oauth_tests(registry.by_id(LinkedInProvider.id))):
    def get_mocked_response(self):
        return [
            MockedResponse(
                200, """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<person>
  <id>oKmTqN2ffc</id>
  <first-name>R@ymØnd</first-name>
  <last-name>Pènnèrs</last-name>
  <email-address>[email protected]</email-address>
  <picture-url>http://m.c.lnkd.licdn.com/mpr/mprx/0_e0hbvSLc8QWo3ggPeVKqvaFR860d342Pogq4vakwx8IJOyR1XJrwRmr5mIx9C0DxWpGMsW9Lb8EQ</picture-url>
  <public-profile-url>http://www.linkedin.com/in/intenct</public-profile-url>
</person>
""")
        ]
예제 #23
0
class AngelListTests(create_oauth2_tests(registry.by_id(AngelListProvider.id))
                     ):
    def get_mocked_response(self):
        return MockedResponse(
            200, """
{"name":"pennersr","id":424732,"bio":"","follower_count":0,
"angellist_url":"https://angel.co/dsxtst",
"image":"https://angel.co/images/shared/nopic.png",
"email":"*****@*****.**","blog_url":null,
"online_bio_url":null,"twitter_url":"https://twitter.com/dsxtst",
"facebook_url":null,"linkedin_url":null,"aboutme_url":null,
"github_url":null,"dribbble_url":null,"behance_url":null,
"what_ive_built":null,"locations":[],"roles":[],"skills":[],
"investor":false,"scopes":["message","talent","dealflow","comment",
"email"]}
""")
예제 #24
0
class DoubanTests(create_oauth2_tests(registry.by_id(DoubanProvider.id))):
    def get_mocked_response(self):
        return MockedResponse(
            200, """
            {"name": "guoqiao",
             "created": "2009-02-18 01:07:52",
             "is_suicide": false,
             "alt": "http://www.douban.com/people/qguo/",
             "avatar": "http://img3.douban.com/icon/u3659811-3.jpg",
             "signature": "",
             "uid": "qguo",
             "is_banned": false,
             "desc": "\u4e0d\u662f\u5f88\u7231\u8bfb\u4e66",
             "type": "user",
             "id": "3659811",
             "large_avatar": "http://img3.douban.com/icon/up3659811-3.jpg"}
""")
예제 #25
0
class FeedlyTests(create_oauth2_tests(registry.by_id(FeedlyProvider.id))):
    def get_mocked_response(self):
        return MockedResponse(200, """
        {
          "id": "c805fcbf-3acf-4302-a97e-d82f9d7c897f",
          "email": "*****@*****.**",
          "givenName": "Jim",
          "familyName": "Smith",
          "picture": "https://www.google.com/profile_images/1771656873/bigger.jpg",
          "gender": "male",
          "locale": "en",
          "reader": "9080770707070700",
          "google": "115562565652656565656",
          "twitter": "jimsmith",
          "facebook": "",
          "wave": "2013.7"
        }""")
예제 #26
0
class FoursquareTests(
        create_oauth2_tests(registry.by_id(FoursquareProvider.id))):
    def get_mocked_response(self):
        return MockedResponse(
            200, """
                              {
                                "notifications": [{"item": {"unreadCount": 0}, "type": "notificationTray"}],
                                "meta": {"code": 200},
                                "response":
                                {
                                    "user":
                                    {
                                        "photo": {"prefix": "https://irs0.4sqi.net/img/user/", "suffix": "/blank_boy.png"},
                                        "pings": false,
                                        "homeCity": "Athens, ESYE31",
                                        "id": "76077726",
                                        "badges": {"count": 0, "items": []},
                                        "referralId": "u-76077726",
                                        "friends":
                                        {
                                            "count": 0,
                                            "groups": [{"count": 0, "items": [], "type": "friends", "name": "Mutual friends"}, {"count": 0, "items": [], "type": "others", "name": "Other friends"}]
                                        },
                                        "createdAt": 1389624445,
                                        "tips": {"count": 0},
                                        "type": "user",
                                        "bio": "",
                                        "relationship": "self",
                                        "lists":
                                        {
                                            "count": 1,
                                            "groups": [{"count": 1, "items": [{"description": "", "collaborative": false, "url": "/user/76077726/list/todos", "editable": false, "listItems": {"count": 0}, "id": "76077726/todos", "followers": {"count": 0}, "user": {"gender": "male", "firstName": "\u03a1\u03c9\u03bc\u03b1\u03bd\u03cc\u03c2", "relationship": "self", "photo": {"prefix": "https://irs0.4sqi.net/img/user/", "suffix": "/blank_boy.png"}, "lastName": "\u03a4\u03c3\u03bf\u03c5\u03c1\u03bf\u03c0\u03bb\u03ae\u03c2", "id": "76077726"}, "public": false, "canonicalUrl": "https://foursquare.com/user/76077726/list/todos", "name": "My to-do list"}], "type": "created"}, {"count": 0, "items": [], "type": "followed"}]
                                        },
                                        "photos": {"count": 0, "items": []},
                                        "checkinPings": "off",
                                        "scores": {"max": 0, "checkinsCount": 0, "goal": 50, "recent": 0},
                                        "checkins": {"count": 0, "items": []},
                                        "firstName": "\u03a1\u03c9\u03bc\u03b1\u03bd\u03cc\u03c2",
                                        "gender": "male",
                                        "contact": {"email": "*****@*****.**"},
                                        "lastName": "\u03a4\u03c3\u03bf\u03c5\u03c1\u03bf\u03c0\u03bb\u03ae\u03c2",
                                        "following": {"count": 0, "groups": [{"count": 0, "items": [], "type": "following", "name": "Mutual following"}, {"count": 0, "items": [], "type": "others", "name": "Other following"}]},
                                        "requests": {"count": 0}, "mayorships": {"count": 0, "items": []}}
                                    }
                                 }
""")
예제 #27
0
class HubicTests(create_oauth2_tests(registry.by_id(HubicProvider.id))):
    def get_mocked_response(self):
        return MockedResponse(
            200, """
{
    "email": "*****@*****.**",
    "firstname": "Test",
    "activated": true,
    "creationDate": "2014-04-17T17:04:01+02:00",
    "language": "en",
    "status": "ok",
    "offer": "25g",
    "lastname": "User"
}
""")

    def get_login_response_json(self, with_refresh_token=True):
        return '{\
예제 #28
0
class BitlyTests(create_oauth2_tests(registry.by_id(BitlyProvider.id))):
    def get_mocked_response(self):
        return MockedResponse(
            200, """{
            "data": {
                "apiKey": "R_f6397a37e765574f2e198dba5bb59522",
                "custom_short_domain": null,
                "display_name": null,
                "full_name": "Bitly API Oauth Demo Account",
                "is_enterprise": false,
                "login": "******",
                "member_since": 1331567982,
                "profile_image": "http://bitly.com/u/bitlyapioauthdemo.png",
                "profile_url": "http://bitly.com/u/bitlyapioauthdemo",
                "share_accounts": [],
                "tracking_domains": []
            },
            "status_code": 200,
            "status_txt": "OK"
        }""")
예제 #29
0
class FlickrTests(create_oauth_tests(registry.by_id(FlickrProvider.id))):
    def get_mocked_response(self):
        #
        return [
            MockedResponse(
                200, r"""
 {"stat": "ok", "user": {"username": {"_content": "pennersr"}, "id": "12345678@N00"}}
"""),  # noqa
            MockedResponse(
                200, r"""
{"person": {"username": {"_content": "pennersr"}, "photosurl": {"_content": "http://www.flickr.com/photos/12345678@N00/"}, "nsid": "12345678@N00", "path_alias": null, "photos": {"count": {"_content": 0}, "firstdatetaken": {"_content": null}, "views": {"_content": "28"}, "firstdate": {"_content": null}}, "iconserver": "0", "description": {"_content": ""}, "mobileurl": {"_content": "http://m.flickr.com/photostream.gne?id=6294613"}, "profileurl": {"_content": "http://www.flickr.com/people/12345678@N00/"}, "mbox_sha1sum": {"_content": "5e5b359c123e54f95236209c8808d607a5cdd21e"}, "ispro": 0, "location": {"_content": ""}, "id": "12345678@N00", "realname": {"_content": "raymond penners"}, "iconfarm": 0}, "stat": "ok"}
""")
        ]  # noqa

    def test_login(self):
        account = super(FlickrTests, self).test_login()
        f_account = account.get_provider_account()
        self.assertEqual(account.user.first_name, 'raymond')
        self.assertEqual(account.user.last_name, 'penners')
        self.assertEqual(f_account.get_profile_url(),
                         'http://www.flickr.com/people/12345678@N00/')
예제 #30
0
class CoinbaseTests(create_oauth2_tests(registry.by_id(CoinbaseProvider.id))):
    def get_mocked_response(self):
        return MockedResponse(
            200, """
{
  "users": [
    {
      "user": {
        "id": "512db383f8182bd24d000001",
        "name": "User One",
        "email": "*****@*****.**",
        "time_zone": "Pacific Time (US & Canada)",
        "native_currency": "USD",
        "balance": {
          "amount": "49.76000000",
          "currency": "BTC"
        },
        "merchant": {
          "company_name": "Company Name, Inc.",
          "logo": {
            "small": "http://smalllogo.example",
            "medium": "http://mediumlogo.example",
            "url": "http://logo.example"
          }
        },
        "buy_level": 1,
        "sell_level": 1,
        "buy_limit": {
          "amount": "10.00000000",
          "currency": "BTC"
        },
        "sell_limit": {
          "amount": "100.00000000",
          "currency": "BTC"
        }
      }
    }
  ]
}
        """)