Beispiel #1
0
    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
Beispiel #2
0
 def setUp(self):
     super(BitbucketOAuth2Tests, self).setUp()
     self.mocks = {
         'requests':
         patch('authentication.socialaccount.providers'
               '.bitbucket_oauth2.views.requests')
     }
     self.patches = dict(
         (name, mocked.start()) for (name, mocked) in self.mocks.items())
     self.patches['requests'].get.side_effect = [
         MockedResponse(200, self.response_data),
         MockedResponse(200, self.email_response_data),
     ]
Beispiel #3
0
    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":{}}]}

""")
        ]
Beispiel #4
0
 def get_mocked_response(self):
     return MockedResponse(200, """
         {
             "avatar_url": "https://secure.gravatar.com/avatar/123",
             "bio": null,
             "can_create_group": true,
             "can_create_project": true,
             "color_scheme_id": 5,
             "confirmed_at": "2015-03-02T16:53:58.370Z",
             "created_at": "2015-03-02T16:53:58.885Z",
             "current_sign_in_at": "2018-06-12T18:44:49.985Z",
             "email": "*****@*****.**",
             "external": false,
             "id": 2,
             "identities": [],
             "last_activity_on": "2018-06-11",
             "last_sign_in_at": "2018-05-31T14:59:44.527Z",
             "linkedin": "",
             "location": null,
             "name": "Mr Bob",
             "organization": null,
             "projects_limit": 10,
             "shared_runners_minutes_limit": 2000,
             "skype": "",
             "state": "active",
             "theme_id": 6,
             "twitter": "mrbob",
             "two_factor_enabled": true,
             "username": "******",
             "web_url": "https://gitlab.example.com/u/mr.bob",
             "website_url": ""
         }
     """)
Beispiel #5
0
 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
     }""")  # noqa
Beispiel #6
0
 def get_mocked_response(self):
     return MockedResponse(
         200, """{
         "id": "123",
         "_links":{"account":{"href":"http://localhost"}},
         "name":"John Doe"
     }""")
Beispiel #7
0
 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 #8
0
 def get_mocked_response(self):
     return MockedResponse(
         200, """
     {
         "uid":"6d940dd41e636cc156074109b8092f96",
         "email":"*****@*****.**"
     }""")
Beispiel #9
0
    def test_error_response(self):
        body = json.dumps({"error": "invalid_token"})
        response = MockedResponse(400, body)

        with self.assertRaises(OAuth2Error):
            # no id, 4xx code, raises
            _check_errors(response)
Beispiel #10
0
    def test_profile_invalid_response(self):
        data = {"code": 403, "type": "Forbidden", "detail": "Account Inactive"}
        response = MockedResponse(401, json.dumps(data))

        with self.assertRaises(OAuth2Error):
            # no id, 4xx code, raises
            _check_errors(response)
Beispiel #11
0
 def get_mocked_response(self):
     payload = {
         "account_id":
         "dbid:ASDFasd3ASdfasdFAsd1AS2ASDF1aS-DfAs",
         "account_type": {
             ".tag": "basic"
         },
         "country":
         "US",
         "disabled":
         False,
         "email":
         "*****@*****.**",
         "email_verified":
         True,
         "is_paired":
         True,
         "locale":
         "en",
         "name": {
             "abbreviated_name": "AA",
             "display_name": "All Auth",
             "familiar_name": "All",
             "given_name": "All",
             "surname": "Auth"
         },
         "profile_photo_url": ("https://dl-web.dropbox.com/account_photo"
                               "/get/dbid%ASDFasd3ASdfasdFAsd1AS2ASDF1aS"
                               "-DfAs?size=128x128"),
         "referral_link":
         "https://db.tt/ASDfAsDf"
     }
     return [MockedResponse(200, json.dumps(payload))]
Beispiel #12
0
 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 #13
0
    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"
           }
        ]
     }
} }
""")
        ]
Beispiel #14
0
    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
}
""")  # noqa
Beispiel #15
0
 def get_mocked_response(self):
     return MockedResponse(
         200, """{
       "id": "acct_sometestid",
       "object": "account",
       "business_logo": null,
       "business_name": null,
       "business_url": "example.com",
       "charges_enabled": true,
       "country": "SE",
       "currencies_supported": [
         "usd",
         "eur",
         "sek"
       ],
       "default_currency": "eur",
       "details_submitted": true,
       "display_name": "Test",
       "email": "*****@*****.**",
       "managed": false,
       "metadata": {},
       "statement_descriptor": "TEST.COM",
       "support_phone": "+460123456789",
       "timezone": "Europe/Stockholm",
       "transfers_enabled": true
     }""")
Beispiel #16
0
 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
    def get_mocked_response(self):
        return MockedResponse(200, """
{
  "profilePicture": {
    "displayImage": "urn:li:digitalmediaAsset:12345abcdefgh-12abcd"
  },
  "id": "1234567",
  "lastName": {
    "preferredLocale": {
      "language": "en",
      "country": "US"
    },
    "localized": {
      "en_US": "Penners"
    }
  },
  "firstName": {
    "preferredLocale": {
      "language": "en",
      "country": "US"
    },
    "localized": {
      "en_US": "Raymond"
    }
  }
}
""")
Beispiel #18
0
    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"}]}}}
""")
        ]
Beispiel #19
0
 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"
     }""")  # noqa
Beispiel #20
0
    def get_mocked_response(self):
        return MockedResponse(
            200, """
{
  "username": "******",
  "id": "1234-5678-910"
}
        """)
Beispiel #21
0
    def get_mocked_response(self):
        return MockedResponse(200, """
{
"userId": "u7d47d26a6bab09b95695ff02d1a36e38",
"displayName": "\uc774\uc0c1\ud601",
"pictureUrl":
"http://dl.profile.line-cdn.net/0m055ab14d725138288331268c45ac5286a35482fb794a"
}""")
Beispiel #22
0
    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 #23
0
 def get_mocked_response(self):
     return MockedResponse(200, """
     {
       "Profile":{
                     "CustomerId":"amzn1.account.K2LI23KL2LK2",
                     "Name":"John Doe",
                     "PrimaryEmail":"*****@*****.**"
                 }
     }""")
Beispiel #24
0
 def get_mocked_response(self):
     return MockedResponse(200, """{
         "id": "80351110224678912",
         "username": "******",
         "discriminator": "1337",
         "avatar": "8342729096ea3675442027381ff50dfe",
         "verified": true,
         "email": "*****@*****.**"
     }""")
Beispiel #25
0
    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}
""")  # noqa
Beispiel #26
0
 def get_mocked_response(self):
     return MockedResponse(200, """
     {
         "profiles": [
             {"id": "56c46bdb0902f8e2", "genotyped": false}
         ],
         "id": "b4b975a5a6a1b80b"
     }
     """)
Beispiel #27
0
    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"}
""")
Beispiel #28
0
 def get_mocked_response(self):
     return MockedResponse(
         200,
         json.dumps({
             "sub": "ZLARGMFT1M",
             "email": "*****@*****.**",
             "email_verified": True,
             "given_name": "Jane",
             "family_name": "Doe",
         }))
Beispiel #29
0
    def get_mocked_response(self):
        return MockedResponse(
            200, """
        {
            "id": 41993552342,
            "npi": 1952635229,
            "firstname": "John",
            "middlename": "Henry",
            "maiden_name": null,
            "lastname": "Smith",
            "full_name": "Ahmed S Belal, MD",
            "gender": "M",
            "city": "San Francisco",
            "state": "CA",
            "zip": "94107",
            "phone": "(650) 200-3901",
            "fax": "888-416-8572",
            "email": "*****@*****.**",
            "address_1": "500 3rd St.",
            "address_2": "Suite 510",
            "lat": 42.3663926,
            "lon": -71.051395,
            "additional_locations": [{
                "address_1": "12 Main st",
                "address_2": null,
                "city": "Cambridge",
                "state": "MA",
                "phone": "555-555-5555",
                "fax": null,
                "zip": "02138"
            }],
            "credentials": "MD",
            "verified": true,
            "description": "Chief of Cardiology",
            "medical_school": "UCSF School of Medicine",
            "residencies": ["Stanford Medical Center", "Mt Sinai Hospital"],
            "specialty": "Cardiology",
            "specialty_details": {
                "abbr": "Cards",
                "code": "CA00",
                "credential_id": 4,
                "name": "Cardiology",
                "id": "CA00"
            },
            "hospitals": [{
                "name": "Mills-Peninsula Health Services",
                "aha_id": "6930315"
            }],
            "subspecialties": ["General Cardiology", "Cardiac Disease"],
            "profile_photo": "https://s3.amazonaws.com/doximity_prod_uploads\
/profile_photos/7969/normal/profile.png",
            "colleague_count": 142
        }
""")
Beispiel #30
0
 def get_mocked_response(self):
     return MockedResponse(200, """
     {"displayName": "John Smith", "mobilePhone": null,
     "preferredLanguage": "en-US", "jobTitle": "Director",
     "userPrincipalName": "*****@*****.**",
     "@odata.context":
     "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
     "officeLocation": "Paris", "businessPhones": [],
     "mail": "*****@*****.**", "surname": "Smith",
     "givenName": "John", "id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"}
     """)