Beispiel #1
0
class AsanaTests(create_oauth2_tests(registry.by_id(AsanaProvider.id))):
    def get_mocked_response(self):
        return MockedResponse(
            200, """
{"data": {"photo": null, "workspaces": [{"id": 31337, "name": "example.com"},
{"id": 3133777, "name": "Personal Projects"}], "email": "*****@*****.**",
"name": "Test Name", "id": 43748387}}""")
class GoodreadsTests(create_oauth2_tests(registry.by_id(GoodreadsProvider.id))):
    def get_mocked_response(self):
        return MockedResponse(200, """{
  "first_name": "Stefan",
  "last_name": "Wehrmeyer",
  "email": "*****@*****.**"
}""")
Beispiel #3
0
class FacebookTests(create_oauth2_tests(registry.by_id(FacebookProvider.id))):
    def get_mocked_response(self):
        return MockedResponse(
            200, """
        {
           "id": "630595557",
           "name": "Raymond Penners",
           "first_name": "Raymond",
           "last_name": "Penners",
           "link": "https://www.facebook.com/raymond.penners",
           "username": "******",
           "birthday": "07/17/1973",
           "work": [
              {
                 "employer": {
                    "id": "204953799537777",
                    "name": "IntenCT"
                 }
              }
           ],
           "timezone": 1,
           "locale": "nl_NL",
           "verified": true,
           "updated_time": "2012-11-30T20:40:33+0000"
        }""")
class EdmodoTests(create_oauth2_tests(registry.by_id(EdmodoProvider.id))):
    def get_mocked_response(self):
        return MockedResponse(
            200, """
{
  "url": "https://api.edmodo.com/users/74721257",
  "id": 74721257,
  "type": "teacher",
  "username": "******",
  "user_title": null,
  "first_name": "Edmodo Test",
  "last_name": "Teacher",
  "time_zone": "America/New_York",
  "utc_offset": -18000,
  "locale": "en",
  "gender": null,
  "start_level": null,
  "end_level": null,
  "about": null,
  "premium": false,
  "school": {"url": "https://api.edmodo.com/schools/559253", "id": 559253},
  "verified_institution_member": true,
  "coppa_verified": false,
  "subjects": null,
  "avatars": {
    "small": "https://api.edmodo.com/users/74721257/avatar?type=small&u=670329ncqnf8fxv7tya24byn5",
    "large": "https://api.edmodo.com/users/74721257/avatar?type=large&u=670329ncqnf8fxv7tya24byn5"
  },
  "email":"*****@*****.**",
  "sync_enabled": false
}
""")
Beispiel #5
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"
        }""")
Beispiel #6
0
class MeetupTests(create_oauth2_tests(registry.by_id(MeetupProvider.id))):
    def get_mocked_response(self):
        return MockedResponse(
            200,
            """
        {"id": 1, "lang": "en_US", "city": "Bhubaneswar",
        "photo": {
        "thumb_link":"",
        "photo_id": 240057062,
        "highres_link":"",
        "base_url": "http://photos2.meetupstatic.com",
        "type": "member",
        "name": "Abhishek Jaiswal", "other_services": {},
        "country": "in", "topics": [{"name": "Open Source",
        "urlkey": "opensource", "id": 563}, {"name": "Python", "urlkey":
        "python", "id": 1064}, {"name": "Software Development", "urlkey":
        "softwaredev", "id": 3833}, {"name": "Computer programming",
        "urlkey": "computer-programming", "id": 48471},
        {"name": "Python Web Development",
        "urlkey": "python-web-development", "id": 917242},
        {"name": "Data Science using Python",
        "urlkey": "data-science-using-python", "id": 1481522}],
        "lon": 85.83999633789062, "joined": 1411642310000,
        "id": 173662372, "status": "active",
        "link": "http://www.meetup.com/members/173662372",
        "hometown": "Kolkata", "lat": 20.270000457763672,
        "visited": 1488829924000, "self": {"common": {}}}}""",
        )
Beispiel #7
0
class RedditTests(create_oauth2_tests(registry.by_id(RedditProvider.id))):
    def get_mocked_response(self):
        return [MockedResponse(
            200,
            """{
        "name": "wayward710"}""",
        )]
Beispiel #8
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"
        }""")
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}

""")
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
        }""")
Beispiel #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}

""")
Beispiel #12
0
class ShopifyTests(create_oauth2_tests(registry.by_id(ShopifyProvider.id))):
    def login(self, resp_mock, process='login', with_refresh_token=True):
        resp = self.client.get(reverse(self.provider.id + '_login'), {
            'process': process,
            'shop': 'test'
        })
        p = urlparse(resp['location'])
        q = parse_qs(p.query)
        complete_url = reverse(self.provider.id + '_callback')
        self.assertGreater(q['redirect_uri'][0].find(complete_url), 0)
        response_json = self \
            .get_login_response_json(with_refresh_token=with_refresh_token)
        with mocked_response(
                MockedResponse(200, response_json,
                               {'content-type': 'application/json'}),
                resp_mock):
            resp = self.client.get(complete_url, {
                'code': 'test',
                'state': q['state'][0],
                'shop': 'test',
            })
        return resp

    def get_mocked_response(self):
        return MockedResponse(
            200, """
        {
            "shop": {
                "id": "1234566",
                "name": "Test Shop",
                "email": "*****@*****.**"
            }
        }
        """)
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"
        }""")
        ]
Beispiel #14
0
class BasecampTests(create_oauth2_tests(registry.by_id(BasecampProvider.id))):
    def get_mocked_response(self):
        return MockedResponse(200, """
        {
            "expires_at": "2012-03-22T16:56:48-05:00",
            "identity": {
                "id": 9999999,
                "first_name": "Jason Fried",
                "last_name": "Jason Fried",
                "email_address": "*****@*****.**"
            },
            "accounts": [
                {
                    "product": "bcx",
                    "id": 88888888,
                    "name": "Wayne Enterprises, Ltd.",
                    "href": "https://basecamp.com/88888888/api/v1"
                },
                {
                    "product": "bcx",
                    "id": 77777777,
                    "name": "Veidt, Inc",
                    "href": "https://basecamp.com/77777777/api/v1"
                },
                {
                    "product": "campfire",
                    "id": 44444444,
                    "name": "Acme Shipping Co.",
                    "href": "https://acme4444444.campfirenow.com"
                }
            ]
        }""")
Beispiel #15
0
class KakaoTests(create_oauth2_tests(registry.by_id(KakaoProvider.id))):
    kakao_data = '''
        {
            "access_token": "KdXEHXV9BXjqHVAt5w48KBFVdI2YLsv2QqQdWawQQjEAAAFR59PXDg",
            "token_type": "bearer",
            "refresh_token": "elFzFKsbnzAP9LFzaiE6bv-wPH02BLINaFRVjawQQjEAAAFR59PXDA",
            "expires_in": 21599,
            "scope": "story_publish story_read profile"
        }'''

    def get_mocked_response(self, data=None):
        if data is None:
            data = self.kakao_data
        return MockedResponse(200, data)

    def test_username_conflict(self):
        User = get_user_model()
        User.objects.create(username='******')
        self.login(self.get_mocked_response())
        socialaccount = SocialAccount.objects.get(
            uid='mocked_uid')  # FIXME: mocked uid
        self.assertEqual(socialaccount.user.username,
                         'askdjango')  # FIXME: mocked username

    def test_username_based_on_provider(self):
        self.login(self.get_mocked_response())
        socialaccount = SocialAccount
Beispiel #16
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"
        }""")
Beispiel #17
0
class RobinhoodTests(create_oauth2_tests(registry.by_id(RobinhoodProvider.id))):
    def get_mocked_response(self):
        return MockedResponse(200, """
{
  "username": "******",
  "id": "1234-5678-910"
}
        """)
class FirefoxAccountsTests(
        create_oauth2_tests(registry.by_id(FirefoxAccountsProvider.id))):
    def get_mocked_response(self):
        return MockedResponse(
            200, """
        {
            "uid":"6d940dd41e636cc156074109b8092f96",
            "email":"*****@*****.**"
        }""")
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"}'
Beispiel #20
0
class FacebookTests(create_oauth2_tests(registry.by_id(FacebookProvider.id))):
    def get_mocked_response(self):
        return MockedResponse(200, """
        {
           "id": "630595557",
           "name": "Raymond Penners",
           "first_name": "Raymond",
           "last_name": "Penners",
           "link": "https://www.facebook.com/raymond.penners",
           "username": "******",
           "birthday": "07/17/1973",
           "work": [
              {
                 "employer": {
                    "id": "204953799537777",
                    "name": "IntenCT"
                 }
              }
           ],
           "timezone": 1,
           "locale": "nl_NL",
           "verified": true,
           "updated_time": "2012-11-30T20:40:33+0000"
        }""")

    def test_username_conflict(self):
        User = get_user_model()
        User.objects.create(username='******')
        self.login(self.get_mocked_response())
        socialaccount = SocialAccount.objects.get(uid='630595557')
        self.assertEqual(socialaccount.user.username, 'raymond')

    def test_username_based_on_provider(self):
        self.login(self.get_mocked_response())
        socialaccount = SocialAccount.objects.get(uid='630595557')
        self.assertEqual(socialaccount.user.username, 'raymond.penners')

    def test_media_js(self):
        provider = providers.registry.by_id(FacebookProvider.id)
        request = RequestFactory().get(reverse('account_login'))
        script = provider.media_js(request)
        self.assertTrue("appId: 'app123id'" in script)

    def test_login_by_token(self):
        with patch('allauth.socialaccount.providers.facebook.views'
                   '.requests') as requests_mock:
            requests_mock.get.return_value.json.return_value \
                = self.get_mocked_response().json()
            resp = self.client.post(reverse('facebook_login_by_token'),
                                    data={'access_token': 'dummy'})
            self.assertEqual('http://testserver/accounts/profile/',
                             resp['location'])

    def test_channel(self):
        resp = self.client.get(reverse('facebook_channel'))
        self.assertTemplateUsed(resp, 'facebook/channel.html')
Beispiel #21
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
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":"*****@*****.**"
                    }
        }""")
Beispiel #23
0
class MailRuTests(create_oauth2_tests(registry.by_id(MailRuProvider.id))):
    def get_mocked_response(self, verified_email=True):
        return MockedResponse(200, u"""
[ { "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
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": "*****@*****.**"
        }
        """)
Beispiel #25
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"
}
""")
Beispiel #26
0
class ShopifyTests(create_oauth2_tests(registry.by_id(ShopifyProvider.id))):
    def _complete_shopify_login(self, q, resp, resp_mock, with_refresh_token):
        complete_url = reverse(self.provider.id + "_callback")
        self.assertGreater(q["redirect_uri"][0].find(complete_url), 0)
        response_json = self.get_login_response_json(
            with_refresh_token=with_refresh_token)
        with mocked_response(
                MockedResponse(200, response_json,
                               {"content-type": "application/json"}),
                resp_mock,
        ):
            resp = self.client.get(
                complete_url,
                {
                    "code": "test",
                    "state": q["state"][0],
                    "shop": "test",
                },
            )
        return resp

    def login(self, resp_mock, process="login", with_refresh_token=True):
        resp = self.client.get(
            reverse(self.provider.id + "_login"),
            {
                "process": process,
                "shop": "test"
            },
        )
        self.assertEqual(resp.status_code, 302)
        p = urlparse(resp["location"])
        q = parse_qs(p.query)
        resp = self._complete_shopify_login(q, resp, resp_mock,
                                            with_refresh_token)
        return resp

    def get_mocked_response(self):
        return MockedResponse(
            200,
            """
        {
            "shop": {
                "id": "1234566",
                "name": "Test Shop",
                "email": "*****@*****.**"
            }
        }
        """,
        )
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"]}
""")
Beispiel #28
0
class WeixinTests(create_oauth2_tests(registry.by_id(WeixinProvider.id))):
    def get_mocked_response(self):
        return MockedResponse(200, """
{"access_token": "OezXcEiiBSKSxW0eoylIeO5cPxb4Ks1RpbXGMv9uiV35032zNHGzXcld-EKsSScE3gRZMrUU78skCbp1ShtZnR0dQB8Wr_LUf7FA-H97Lnd2HgQah_GnkQex-vPFsGEwPPcNAV6q1Vz3uRNgL0MUFg",
 "city": "Pudong New District",
 "country": "CN",
 "expires_in": 7200,
 "headimgurl": "http://wx.qlogo.cn/mmopen/VkvLVEpoJiaibYsVyW8GzxHibzlnqSM7iaX09r6TWUJXCNQHibHz37krvN65HR1ibEpgH5K5sukcIzA3r1C4KQ9qyyX9XIUdY9lNOk/0",
 "language": "zh_CN",
 "nickname": "某某某",
 "openid": "ohS-VwAJ9GEXlplngwybJ3Z-ZHrI",
 "privilege": [],
 "province": "Shanghai",
 "refresh_token": "OezXcEiiBSKSxW0eoylIeO5cPxb4Ks1RpbXGMv9uiV35032zNHGzXcld-EKsSScEbMnnMqVExcSpj7KRAuBA8BU2j2e_FK5dgBe-ro32k7OuHtznwqqBn5QR7LZGo2-P8G7gG0eitjyZ751sFlnTAw",
 "scope": "snsapi_login",
 "sex": 1,
 "unionid": "ohHrhwKnD9TOunEW0eKTS45vS5Qo"}""")  # noqa
Beispiel #29
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"}
""")
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": []}}
                                    }
                                 }
""")
Beispiel #31
0
"""Tests for FirefoxAccounts.

Uses the testing infrastructure from django-allauth.
"""

from allauth.socialaccount.tests import create_oauth2_tests
from allauth.tests import MockedResponse
from allauth.socialaccount.providers import registry
from django.core.urlresolvers import reverse


from .provider import FirefoxAccountsProvider

# Setup base class but omit from nose tests
create_oauth2_tests.__test__ = False
base_class = create_oauth2_tests(
    registry.by_id(FirefoxAccountsProvider.id))
base_class.__test__ = False


class FirefoxAccountsTest(base_class):
    __test__ = True  # Include in nose tests

    def get_mocked_response(self):
        return MockedResponse(200, """
        {
            "uid":"6d940dd41e636cc156074109b8092f96",
            "email":"*****@*****.**"
        }""")

    def test_authentication_error(self):
        """Test authentication errors.