add linkedin tests
This commit is contained in:
Родитель
2578afcc77
Коммит
a43d17a9d2
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"status": 302
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"protocol": "http",
|
||||
"reason": "automatic success save",
|
||||
"uri": "https://api.linkedin.com/uas/oauth/requestToken"
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
GET /uas/oauth/requestToken
|
||||
accept-encoding: gzip, deflate
|
||||
authorization: OAuth realm="", oauth_body_hash="2jmj7l5rSw0yVb%2FvlWAYkK%2FYBwk%3D", oauth_nonce="9999999", oauth_timestamp="1303186687", oauth_consumer_key="the_key", oauth_signature_method="HMAC-SHA1", oauth_version="1.0", oauth_signature="the_sig%3D", oauth_callback="http%3A%2F%2Flinkdrop.caraveo.com%3A5000%2Fapi%2Faccount%2Fverify%3Fprovider%3Dlinkedin.com"
|
||||
user-agent: Python-httplib2/$Rev$
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
HTTP/1.1 200 OK
|
||||
status: 200
|
||||
content-location: https://api.linkedin.com/uas/oauth/requestToken
|
||||
vary: Accept-Encoding
|
||||
server: Apache-Coyote/1.1
|
||||
-content-encoding: gzip
|
||||
date: Tue, 19 Apr 2011 04:19:01 GMT
|
||||
content-type: text/plain
|
||||
|
||||
oauth_token=the_token&oauth_token_secret=the_secret&oauth_callback_confirmed=true&xoauth_request_auth_url=https%3A%2F%2Fapi.linkedin.com%2Fuas%2Foauth%2Fauthorize&oauth_expires_in=599
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"error": null,
|
||||
"result": {
|
||||
"entry": [
|
||||
{
|
||||
"accounts": [
|
||||
{
|
||||
"domain": "linkedin.com",
|
||||
"userid": "11111111",
|
||||
"username": ""
|
||||
}
|
||||
],
|
||||
"displayName": "Jean Reilly",
|
||||
"urls": [
|
||||
{
|
||||
"primary": true,
|
||||
"type": "profile",
|
||||
"value": "http://www.linkedin.com/profile?viewProfile=&key=999999&authToken=xxxx&authType=name&trk=api*xxx*xxx*"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"itemsPerPage": 1,
|
||||
"startIndex": 0,
|
||||
"totalResults": 1
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"protocol": "http",
|
||||
"reason": "automatic success save",
|
||||
"uri": "http://api.linkedin.com/v1/people/~/connections?count=500"
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
GET /v1/people/~/connections?count=500
|
||||
x-li-format: json
|
||||
accept-encoding: gzip, deflate
|
||||
user-agent: Python-httplib2/$Rev$
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
HTTP/1.1 200 OK
|
||||
status: 200
|
||||
content-location: http://api.linkedin.com/v1/people/~/connections?count=500&oauth_body_hash=K%2BiMpCQsduglOsYkdIUQZQMtaDM%3D&oauth_nonce999999&oauth_timestamp=1303186697&oauth_consumer_key=the_key&oauth_signature_method=HMAC-SHA1&oauth_version=1.0&oauth_token=the_token&oauth_signature=the_sig%3D
|
||||
vary: x-li-format,Accept-Encoding
|
||||
server: Apache-Coyote/1.1
|
||||
-content-encoding: gzip
|
||||
date: Tue, 19 Apr 2011 04:19:09 GMT
|
||||
x-li-format: json
|
||||
content-type: application/json;charset=UTF-8
|
||||
|
||||
{
|
||||
"values": [{
|
||||
"headline": "Banking Professional",
|
||||
"id": "11111111",
|
||||
"lastName": "Reilly",
|
||||
"location": {
|
||||
"name": "Vancouver, Canada Area",
|
||||
"country": {"code": "ca"}
|
||||
},
|
||||
"siteStandardProfileRequest": {"url": "http://www.linkedin.com/profile?viewProfile=&key=999999&authToken=xxxx&authType=name&trk=api*xxx*xxx*"},
|
||||
"apiStandardProfileRequest": {
|
||||
"headers": {
|
||||
"values": [{
|
||||
"name": "x-li-auth-token",
|
||||
"value": "name:TVgH"
|
||||
}],
|
||||
"_total": 1
|
||||
},
|
||||
"url": "http://api.linkedin.com/v1/people/11111111"
|
||||
},
|
||||
"industry": "Banking",
|
||||
"firstName": "Jean"
|
||||
}],
|
||||
"_total": 1
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"error": null,
|
||||
"result": {
|
||||
"date": "Tue, 19 Apr 2011 05:24:44 GMT",
|
||||
"from": null,
|
||||
"location": "http://api.linkedin.com/v1/people/ppppppp/shares/sssssss",
|
||||
"server": "Apache-Coyote/1.1",
|
||||
"shorturl": null,
|
||||
"status": "201",
|
||||
"to": "anyone",
|
||||
"vary": "Accept-Encoding"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{"domain": "linkedin.com",
|
||||
"shareType": "public",
|
||||
"to": "anyone",
|
||||
"message": "nerdy for anyone",
|
||||
"link": "http://slashdot.org/",
|
||||
"title": "Slashdot: News for nerds, stuff that matters",
|
||||
"account": {"oauth_token": "foo", "oauth_token_secret": "bar", "username": "mylinkedinid"}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"protocol": "http",
|
||||
"reason": "automatic success save",
|
||||
"uri": "http://api.linkedin.com/v1/people/~/shares"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
POST /v1/people/~/shares
|
||||
x-li-format: json
|
||||
content-type: application/json
|
||||
authorization: OAuth realm="http://api.linkedin.com", oauth_body_hash="the_hash_value", oauth_nonce="111111", oauth_timestamp="1303190627", oauth_consumer_key="the_consumer_key", oauth_signature_method="HMAC-SHA1", oauth_version="1.0", oauth_token="the_token", oauth_signature="the_sig%3D"
|
||||
user-agent: Python-httplib2/$Rev$
|
||||
|
||||
{"comment": "nerdy for anyone", "content": {"submitted-image-url": "", "description": "", "submitted-url": "http://slashdot.org/", "title": ""}, "visibility": {"code": "anyone"}}
|
|
@ -0,0 +1,7 @@
|
|||
HTTP/1.1 201 Created
|
||||
status: 201
|
||||
vary: Accept-Encoding
|
||||
server: Apache-Coyote/1.1
|
||||
location: http://api.linkedin.com/v1/people/ppppppp/shares/sssssss
|
||||
date: Tue, 19 Apr 2011 05:24:44 GMT
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"error": null,
|
||||
"result": {
|
||||
"content-length": "0",
|
||||
"date": "Tue, 19 Apr 2011 07:11:40 GMT",
|
||||
"from": null,
|
||||
"location": "http://api.linkedin.com/v1/people/pppppppp/shares/ssssssss",
|
||||
"server": "Apache-Coyote/1.1",
|
||||
"shorturl": null,
|
||||
"status": "201",
|
||||
"to": "connections-only",
|
||||
"vary": "Accept-Encoding"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{"domain": "linkedin.com",
|
||||
"shareType": "myConnections",
|
||||
"to": "connections-only",
|
||||
"message": "nerdy for my connections!",
|
||||
"link": "http://slashdot.org/",
|
||||
"title": "Slashdot: News for nerds, stuff that matters",
|
||||
"account": {"oauth_token": "foo", "oauth_token_secret": "bar", "username": "mylinkedinid"}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"protocol": "http",
|
||||
"reason": "automatic success save",
|
||||
"uri": "http://api.linkedin.com/v1/people/~/shares"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
POST /v1/people/~/shares
|
||||
x-li-format: json
|
||||
content-type: application/json
|
||||
authorization: OAuth realm="http://api.linkedin.com", oauth_body_hash="the_hash%3D", oauth_nonce="9999999", oauth_timestamp="1303197039", oauth_consumer_key="the_key", oauth_signature_method="HMAC-SHA1", oauth_version="1.0", oauth_token="the_token", oauth_signature="the_sig%3D"
|
||||
user-agent: Python-httplib2/$Rev$
|
||||
|
||||
{"comment": "nerdy for my connections!", "content": {"submitted-image-url": "", "description": "", "submitted-url": "http://slashdot.org/", "title": ""}, "visibility": {"code": "connections-only"}}
|
|
@ -0,0 +1,8 @@
|
|||
HTTP/1.1 201 Created
|
||||
status: 201
|
||||
content-length: 0
|
||||
vary: Accept-Encoding
|
||||
server: Apache-Coyote/1.1
|
||||
location: http://api.linkedin.com/v1/people/pppppppp/shares/ssssssss
|
||||
date: Tue, 19 Apr 2011 07:11:40 GMT
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"error": null,
|
||||
"result": {
|
||||
"content-length": "0",
|
||||
"date": "Tue, 19 Apr 2011 07:14:32 GMT",
|
||||
"from": null,
|
||||
"server": "Apache-Coyote/1.1",
|
||||
"shorturl": null,
|
||||
"status": "201",
|
||||
"to": "ppppp",
|
||||
"vary": "Accept-Encoding"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
{"domain": "linkedin.com",
|
||||
"shareType": "contact",
|
||||
"to": "ppppp",
|
||||
"message": "nerdy just for you!",
|
||||
"link": "http://slashdot.org/",
|
||||
"title": "Slashdot: News for nerds, stuff that matters",
|
||||
"account": {"oauth_token": "foo",
|
||||
"oauth_token_secret": "bar",
|
||||
"username": "mylinkedinid",
|
||||
"verifiedEmail": "me@somewhere.com"}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"protocol": "http",
|
||||
"reason": "automatic success save",
|
||||
"uri": "http://api.linkedin.com/v1/people/~/mailbox"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
POST /v1/people/~/mailbox
|
||||
x-li-format: json
|
||||
content-type: application/json
|
||||
authorization: OAuth realm="http://api.linkedin.com", oauth_body_hash="the_hash%3D", oauth_nonce="999999", oauth_timestamp="1303197211", oauth_consumer_key="the_key", oauth_signature_method="HMAC-SHA1", oauth_version="1.0", oauth_token="the_token", oauth_signature="the_sig%3D"
|
||||
user-agent: Python-httplib2/$Rev$
|
||||
|
||||
{"body": "nerdy just for you!\n\n*Slashdot: News for nerds, stuff that matters*\n\nhttp://slashdot.org/\n\n\n\n--\nshared via Mozilla F1 for Firefox -- http://f1.mozillamessaging.com/\n:: share links with the people that matter to you ::\n", "recipients": {"values": [{"person": {"_path": "/people/ppppp"}}]}, "subject": "A web link has been shared with you"}
|
|
@ -0,0 +1,7 @@
|
|||
HTTP/1.1 201 Created
|
||||
date: Tue, 19 Apr 2011 07:14:32 GMT
|
||||
status: 201
|
||||
content-length: 0
|
||||
vary: Accept-Encoding
|
||||
server: Apache-Coyote/1.1
|
||||
|
|
@ -53,8 +53,16 @@ def assert_messages_equal(got, expected):
|
|||
got_items = dict(parse_qsl(gotpl))
|
||||
expected_items = dict(parse_qsl(expectedpl))
|
||||
assert_dicts_with_oauth_equal(got_items, expected_items)
|
||||
elif got.get_content_type() == "application/json":
|
||||
got_items = json.loads(gotpl)
|
||||
expected_items = json.loads(expectedpl)
|
||||
assert_dicts_equal(got_items, expected_items)
|
||||
elif gotpl is None:
|
||||
assert expectedpl is None
|
||||
else:
|
||||
eq_(gotpl, expectedpl)
|
||||
# rstrip the payloads as some of our corpus items have trailing
|
||||
# newlines to stop git/hg/etc complaining...
|
||||
eq_(gotpl.rstrip(), expectedpl.rstrip())
|
||||
|
||||
|
||||
# Somewhat analogous to a protocap.ProtocolCapturingBase object - but
|
||||
|
@ -94,7 +102,7 @@ class HttpReplayer(ProtocolReplayer):
|
|||
# any blow up as being non-ascii, we have a deeper problem...
|
||||
gotheadersstr = "\r\n".join(
|
||||
["%s: %s" % (n, v.encode("ascii")) for n, v in headers.iteritems()])
|
||||
bodystr = gotheadersstr + "\r\n" + (body or '')
|
||||
bodystr = gotheadersstr + "\r\n\r\n" + (body or '')
|
||||
gotob = email.message_from_string(bodystr)
|
||||
if headers:
|
||||
if 'content-type' in gotob:
|
||||
|
@ -364,6 +372,28 @@ class GoogleReplayTestCase(ServiceReplayTestCase):
|
|||
raise AssertionError(req_type)
|
||||
|
||||
|
||||
class LinkedinReplayTestCase(ServiceReplayTestCase):
|
||||
def getDefaultRequest(self, req_type):
|
||||
# No 'send' - all send tests have an f1-request.json file...
|
||||
if req_type == "contacts":
|
||||
account = {"oauth_token": "foo", "oauth_token_secret": "bar",
|
||||
"profile": {"emails": [{'value': 'me@example.com'}],
|
||||
"displayName": "Me",
|
||||
},
|
||||
}
|
||||
return {'username': 'me',
|
||||
'userid': '123',
|
||||
'keys': "1,2,3",
|
||||
'account': json.dumps(account),
|
||||
'domain': 'linkedin.com',
|
||||
'maxresults': 500,
|
||||
}
|
||||
if req_type == "auth":
|
||||
return {'domain': 'linkedin.com', 'username': 'foo',
|
||||
'userid': 'bar'}
|
||||
raise AssertionError(req_type)
|
||||
|
||||
|
||||
def setupReplayers():
|
||||
import linkoauth.facebook_
|
||||
linkoauth.facebook_.HttpRequestor = HttpReplayer
|
||||
|
@ -374,6 +404,8 @@ def setupReplayers():
|
|||
linkoauth.google_.OAuth2Requestor = HttpReplayer
|
||||
import linkoauth.twitter_
|
||||
linkoauth.twitter_.OAuth2Requestor = HttpReplayer
|
||||
import linkoauth.linkedin_
|
||||
linkoauth.linkedin_.OAuth2Requestor = HttpReplayer
|
||||
import linkoauth.base
|
||||
linkoauth.base.HttpRequestor = HttpReplayer
|
||||
HttpReplayer.to_playback = []
|
||||
|
@ -394,6 +426,8 @@ def teardownReplayers():
|
|||
linkoauth.google_.OAuth2Requestor = linkoauth.protocap.OAuth2Requestor
|
||||
import linkoauth.twitter_
|
||||
linkoauth.twitter_.OAuth2Requestor = linkoauth.protocap.OAuth2Requestor
|
||||
import linkoauth.linkedin_
|
||||
linkoauth.linkedin_.OAuth2Requestor = linkoauth.protocap.OAuth2Requestor
|
||||
import linkoauth.base
|
||||
linkoauth.base.HttpRequestor = linkoauth.protocap.HttpRequestor
|
||||
|
||||
|
@ -406,6 +440,7 @@ host_to_test = {
|
|||
'social.yahooapis.com': YahooReplayTestCase,
|
||||
'api.twitter.com': TwitterReplayTestCase,
|
||||
'twitter.com': TwitterReplayTestCase,
|
||||
'api.linkedin.com': LinkedinReplayTestCase,
|
||||
}
|
||||
|
||||
|
||||
|
|
6
test.ini
6
test.ini
|
@ -67,6 +67,12 @@ oauth.yahoo.com.app_id = FILL_ME_IN
|
|||
# set to true if you have completed domain verification with Yahoo
|
||||
oauth.yahoo.com.verified = 0
|
||||
|
||||
oauth.linkedin.com.consumer_key = A_BIT_OF_A_SECRET
|
||||
oauth.linkedin.com.consumer_secret = TOP_SECRET
|
||||
oauth.linkedin.com.request = https://api.linkedin.com/uas/oauth/requestToken
|
||||
oauth.linkedin.com.access = https://api.linkedin.com/uas/oauth/accessToken
|
||||
oauth.linkedin.com.authorize = https://api.linkedin.com/uas/oauth/authorize
|
||||
|
||||
[server:main]
|
||||
use = egg:Paste#http
|
||||
host = 127.0.0.1
|
||||
|
|
Загрузка…
Ссылка в новой задаче