summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/URLDetectionTest.php224
-rw-r--r--tests/oauth/README162
-rwxr-xr-xtests/oauth/exchangetokens.php105
-rwxr-xr-xtests/oauth/fetch_temp_creds.php106
-rwxr-xr-xtests/oauth/fetch_token_creds.php146
-rwxr-xr-xtests/oauth/getrequesttoken.php71
-rw-r--r--tests/oauth/oauth.ini.sample (renamed from tests/oauth/oauth.ini)2
-rw-r--r--tests/oauth/oauth_post_notice.php (renamed from tests/oauth/statusupdate.php)77
-rwxr-xr-xtests/oauth/oauth_verify_creds.php (renamed from tests/oauth/verifycreds.php)76
9 files changed, 599 insertions, 370 deletions
diff --git a/tests/URLDetectionTest.php b/tests/URLDetectionTest.php
index d83f9faf5..eac7ba3f5 100644
--- a/tests/URLDetectionTest.php
+++ b/tests/URLDetectionTest.php
@@ -29,73 +29,73 @@ class URLDetectionTest extends PHPUnit_Framework_TestCase
array('not a link :: no way',
'not a link :: no way'),
array('link http://www.somesite.com/xyz/35637563@N00/52803365/ link',
- 'link <a href="http://www.somesite.com/xyz/35637563@N00/52803365/" title="http://www.somesite.com/xyz/35637563@N00/52803365/" rel="external">http://www.somesite.com/xyz/35637563@N00/52803365/</a> link'),
+ 'link <a href="http://www.somesite.com/xyz/35637563@N00/52803365/" title="http://www.somesite.com/xyz/35637563@N00/52803365/" rel="nofollow external">http://www.somesite.com/xyz/35637563@N00/52803365/</a> link'),
array('http://127.0.0.1',
- '<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="external">http://127.0.0.1</a>'),
+ '<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="nofollow external">http://127.0.0.1</a>'),
array('127.0.0.1',
- '<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="external">127.0.0.1</a>'),
+ '<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="nofollow external">127.0.0.1</a>'),
array('127.0.0.1:99',
- '<a href="http://127.0.0.1:99/" title="http://127.0.0.1:99/" rel="external">127.0.0.1:99</a>'),
+ '<a href="http://127.0.0.1:99/" title="http://127.0.0.1:99/" rel="nofollow external">127.0.0.1:99</a>'),
array('127.0.0.1/Name:test.php',
- '<a href="http://127.0.0.1/Name:test.php" title="http://127.0.0.1/Name:test.php" rel="external">127.0.0.1/Name:test.php</a>'),
+ '<a href="http://127.0.0.1/Name:test.php" title="http://127.0.0.1/Name:test.php" rel="nofollow external">127.0.0.1/Name:test.php</a>'),
array('127.0.0.1/~test',
- '<a href="http://127.0.0.1/~test" title="http://127.0.0.1/~test" rel="external">127.0.0.1/~test</a>'),
+ '<a href="http://127.0.0.1/~test" title="http://127.0.0.1/~test" rel="nofollow external">127.0.0.1/~test</a>'),
array('127.0.0.1/+test',
- '<a href="http://127.0.0.1/+test" title="http://127.0.0.1/+test" rel="external">127.0.0.1/+test</a>'),
+ '<a href="http://127.0.0.1/+test" title="http://127.0.0.1/+test" rel="nofollow external">127.0.0.1/+test</a>'),
array('127.0.0.1/$test',
- '<a href="http://127.0.0.1/$test" title="http://127.0.0.1/$test" rel="external">127.0.0.1/$test</a>'),
+ '<a href="http://127.0.0.1/$test" title="http://127.0.0.1/$test" rel="nofollow external">127.0.0.1/$test</a>'),
array('127.0.0.1/\'test',
- '<a href="http://127.0.0.1/\'test" title="http://127.0.0.1/\'test" rel="external">127.0.0.1/\'test</a>'),
+ '<a href="http://127.0.0.1/\'test" title="http://127.0.0.1/\'test" rel="nofollow external">127.0.0.1/\'test</a>'),
array('127.0.0.1/"test',
- '<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="external">127.0.0.1/</a>&quot;test'),
+ '<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="nofollow external">127.0.0.1/</a>&quot;test'),
array('127.0.0.1/test"test',
- '<a href="http://127.0.0.1/test" title="http://127.0.0.1/test" rel="external">127.0.0.1/test</a>&quot;test'),
+ '<a href="http://127.0.0.1/test" title="http://127.0.0.1/test" rel="nofollow external">127.0.0.1/test</a>&quot;test'),
array('127.0.0.1/-test',
- '<a href="http://127.0.0.1/-test" title="http://127.0.0.1/-test" rel="external">127.0.0.1/-test</a>'),
+ '<a href="http://127.0.0.1/-test" title="http://127.0.0.1/-test" rel="nofollow external">127.0.0.1/-test</a>'),
array('127.0.0.1/_test',
- '<a href="http://127.0.0.1/_test" title="http://127.0.0.1/_test" rel="external">127.0.0.1/_test</a>'),
+ '<a href="http://127.0.0.1/_test" title="http://127.0.0.1/_test" rel="nofollow external">127.0.0.1/_test</a>'),
array('127.0.0.1/!test',
- '<a href="http://127.0.0.1/!test" title="http://127.0.0.1/!test" rel="external">127.0.0.1/!test</a>'),
+ '<a href="http://127.0.0.1/!test" title="http://127.0.0.1/!test" rel="nofollow external">127.0.0.1/!test</a>'),
array('127.0.0.1/*test',
- '<a href="http://127.0.0.1/*test" title="http://127.0.0.1/*test" rel="external">127.0.0.1/*test</a>'),
+ '<a href="http://127.0.0.1/*test" title="http://127.0.0.1/*test" rel="nofollow external">127.0.0.1/*test</a>'),
array('127.0.0.1/test%20stuff',
- '<a href="http://127.0.0.1/test%20stuff" title="http://127.0.0.1/test%20stuff" rel="external">127.0.0.1/test%20stuff</a>'),
+ '<a href="http://127.0.0.1/test%20stuff" title="http://127.0.0.1/test%20stuff" rel="nofollow external">127.0.0.1/test%20stuff</a>'),
array('http://[::1]:99/test.php',
- '<a href="http://[::1]:99/test.php" title="http://[::1]:99/test.php" rel="external">http://[::1]:99/test.php</a>'),
+ '<a href="http://[::1]:99/test.php" title="http://[::1]:99/test.php" rel="nofollow external">http://[::1]:99/test.php</a>'),
array('http://::1/test.php',
- '<a href="http://::1/test.php" title="http://::1/test.php" rel="external">http://::1/test.php</a>'),
+ '<a href="http://::1/test.php" title="http://::1/test.php" rel="nofollow external">http://::1/test.php</a>'),
array('http://::1',
- '<a href="http://::1/" title="http://::1/" rel="external">http://::1</a>'),
+ '<a href="http://::1/" title="http://::1/" rel="nofollow external">http://::1</a>'),
array('2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php',
- '<a href="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php" title="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php" rel="external">2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php</a>'),
+ '<a href="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php" title="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php" rel="nofollow external">2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php</a>'),
array('[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php',
- '<a href="http://[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php" title="http://[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php" rel="external">[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php</a>'),
+ '<a href="http://[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php" title="http://[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php" rel="nofollow external">[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php</a>'),
array('2001:4978:1b5:0:21d:e0ff:fe66:59ab',
- '<a href="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/" title="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/" rel="external">2001:4978:1b5:0:21d:e0ff:fe66:59ab</a>'),
+ '<a href="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/" title="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/" rel="nofollow external">2001:4978:1b5:0:21d:e0ff:fe66:59ab</a>'),
array('http://127.0.0.1',
- '<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="external">http://127.0.0.1</a>'),
+ '<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="nofollow external">http://127.0.0.1</a>'),
array('example.com',
- '<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>'),
+ '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>'),
array('example.com',
- '<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>'),
+ '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>'),
array('http://example.com',
- '<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>'),
+ '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">http://example.com</a>'),
array('http://example.com.',
- '<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>.'),
+ '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">http://example.com</a>.'),
array('/var/lib/example.so',
'/var/lib/example.so'),
array('example',
'example'),
array('user@example.com',
- '<a href="mailto:user@example.com" title="mailto:user@example.com" rel="external">user@example.com</a>'),
+ '<a href="mailto:user@example.com" title="mailto:user@example.com" rel="nofollow external">user@example.com</a>'),
array('user_name+other@example.com',
- '<a href="mailto:user_name+other@example.com" title="mailto:user_name+other@example.com" rel="external">user_name+other@example.com</a>'),
+ '<a href="mailto:user_name+other@example.com" title="mailto:user_name+other@example.com" rel="nofollow external">user_name+other@example.com</a>'),
array('mailto:user@example.com',
- '<a href="mailto:user@example.com" title="mailto:user@example.com" rel="external">mailto:user@example.com</a>'),
+ '<a href="mailto:user@example.com" title="mailto:user@example.com" rel="nofollow external">mailto:user@example.com</a>'),
array('mailto:user@example.com?subject=test',
- '<a href="mailto:user@example.com?subject=test" title="mailto:user@example.com?subject=test" rel="external">mailto:user@example.com?subject=test</a>'),
+ '<a href="mailto:user@example.com?subject=test" title="mailto:user@example.com?subject=test" rel="nofollow external">mailto:user@example.com?subject=test</a>'),
array('xmpp:user@example.com',
- '<a href="xmpp:user@example.com" title="xmpp:user@example.com" rel="external">xmpp:user@example.com</a>'),
+ '<a href="xmpp:user@example.com" title="xmpp:user@example.com" rel="nofollow external">xmpp:user@example.com</a>'),
array('#example',
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('example'))) . '" rel="tag">example</a></span>'),
array('#example.com',
@@ -103,167 +103,167 @@ class URLDetectionTest extends PHPUnit_Framework_TestCase
array('#.net',
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('.net'))) . '" rel="tag">.net</a></span>'),
array('http://example',
- '<a href="http://example/" title="http://example/" rel="external">http://example</a>'),
+ '<a href="http://example/" title="http://example/" rel="nofollow external">http://example</a>'),
array('http://3xampl3',
- '<a href="http://3xampl3/" title="http://3xampl3/" rel="external">http://3xampl3</a>'),
+ '<a href="http://3xampl3/" title="http://3xampl3/" rel="nofollow external">http://3xampl3</a>'),
array('http://example/',
- '<a href="http://example/" title="http://example/" rel="external">http://example/</a>'),
+ '<a href="http://example/" title="http://example/" rel="nofollow external">http://example/</a>'),
array('http://example/path',
- '<a href="http://example/path" title="http://example/path" rel="external">http://example/path</a>'),
+ '<a href="http://example/path" title="http://example/path" rel="nofollow external">http://example/path</a>'),
array('http://example.com',
- '<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>'),
+ '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">http://example.com</a>'),
array('https://example.com',
- '<a href="https://example.com/" title="https://example.com/" rel="external">https://example.com</a>'),
+ '<a href="https://example.com/" title="https://example.com/" rel="nofollow external">https://example.com</a>'),
array('ftp://example.com',
- '<a href="ftp://example.com/" title="ftp://example.com/" rel="external">ftp://example.com</a>'),
+ '<a href="ftp://example.com/" title="ftp://example.com/" rel="nofollow external">ftp://example.com</a>'),
array('ftps://example.com',
- '<a href="ftps://example.com/" title="ftps://example.com/" rel="external">ftps://example.com</a>'),
+ '<a href="ftps://example.com/" title="ftps://example.com/" rel="nofollow external">ftps://example.com</a>'),
array('http://user@example.com',
- '<a href="http://user@example.com/" title="http://user@example.com/" rel="external">http://user@example.com</a>'),
+ '<a href="http://user@example.com/" title="http://user@example.com/" rel="nofollow external">http://user@example.com</a>'),
array('http://user:pass@example.com',
- '<a href="http://user:pass@example.com/" title="http://user:pass@example.com/" rel="external">http://user:pass@example.com</a>'),
+ '<a href="http://user:pass@example.com/" title="http://user:pass@example.com/" rel="nofollow external">http://user:pass@example.com</a>'),
array('http://example.com:8080',
- '<a href="http://example.com:8080/" title="http://example.com:8080/" rel="external">http://example.com:8080</a>'),
+ '<a href="http://example.com:8080/" title="http://example.com:8080/" rel="nofollow external">http://example.com:8080</a>'),
array('http://example.com:8080/test.php',
- '<a href="http://example.com:8080/test.php" title="http://example.com:8080/test.php" rel="external">http://example.com:8080/test.php</a>'),
+ '<a href="http://example.com:8080/test.php" title="http://example.com:8080/test.php" rel="nofollow external">http://example.com:8080/test.php</a>'),
array('example.com:8080/test.php',
- '<a href="http://example.com:8080/test.php" title="http://example.com:8080/test.php" rel="external">example.com:8080/test.php</a>'),
+ '<a href="http://example.com:8080/test.php" title="http://example.com:8080/test.php" rel="nofollow external">example.com:8080/test.php</a>'),
array('http://www.example.com',
- '<a href="http://www.example.com/" title="http://www.example.com/" rel="external">http://www.example.com</a>'),
+ '<a href="http://www.example.com/" title="http://www.example.com/" rel="nofollow external">http://www.example.com</a>'),
array('http://example.com/',
- '<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com/</a>'),
+ '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">http://example.com/</a>'),
array('http://example.com/path',
- '<a href="http://example.com/path" title="http://example.com/path" rel="external">http://example.com/path</a>'),
+ '<a href="http://example.com/path" title="http://example.com/path" rel="nofollow external">http://example.com/path</a>'),
array('http://example.com/path.html',
- '<a href="http://example.com/path.html" title="http://example.com/path.html" rel="external">http://example.com/path.html</a>'),
+ '<a href="http://example.com/path.html" title="http://example.com/path.html" rel="nofollow external">http://example.com/path.html</a>'),
array('http://example.com/path.html#fragment',
- '<a href="http://example.com/path.html#fragment" title="http://example.com/path.html#fragment" rel="external">http://example.com/path.html#fragment</a>'),
+ '<a href="http://example.com/path.html#fragment" title="http://example.com/path.html#fragment" rel="nofollow external">http://example.com/path.html#fragment</a>'),
array('http://example.com/path.php?foo=bar&bar=foo',
- '<a href="http://example.com/path.php?foo=bar&amp;bar=foo" title="http://example.com/path.php?foo=bar&amp;bar=foo" rel="external">http://example.com/path.php?foo=bar&amp;bar=foo</a>'),
+ '<a href="http://example.com/path.php?foo=bar&amp;bar=foo" title="http://example.com/path.php?foo=bar&amp;bar=foo" rel="nofollow external">http://example.com/path.php?foo=bar&amp;bar=foo</a>'),
array('http://example.com.',
- '<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>.'),
+ '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">http://example.com</a>.'),
array('http://müllärör.de',
- '<a href="http://m&#xFC;ll&#xE4;r&#xF6;r.de/" title="http://m&#xFC;ll&#xE4;r&#xF6;r.de/" rel="external">http://müllärör.de</a>'),
+ '<a href="http://m&#xFC;ll&#xE4;r&#xF6;r.de/" title="http://m&#xFC;ll&#xE4;r&#xF6;r.de/" rel="nofollow external">http://müllärör.de</a>'),
array('http://ﺱﺲﺷ.com',
- '<a href="http://&#xFEB1;&#xFEB2;&#xFEB7;.com/" title="http://&#xFEB1;&#xFEB2;&#xFEB7;.com/" rel="external">http://ﺱﺲﺷ.com</a>'),
+ '<a href="http://&#xFEB1;&#xFEB2;&#xFEB7;.com/" title="http://&#xFEB1;&#xFEB2;&#xFEB7;.com/" rel="nofollow external">http://ﺱﺲﺷ.com</a>'),
array('http://сделаткартинки.com',
- '<a href="http://&#x441;&#x434;&#x435;&#x43B;&#x430;&#x442;&#x43A;&#x430;&#x440;&#x442;&#x438;&#x43D;&#x43A;&#x438;.com/" title="http://&#x441;&#x434;&#x435;&#x43B;&#x430;&#x442;&#x43A;&#x430;&#x440;&#x442;&#x438;&#x43D;&#x43A;&#x438;.com/" rel="external">http://сделаткартинки.com</a>'),
+ '<a href="http://&#x441;&#x434;&#x435;&#x43B;&#x430;&#x442;&#x43A;&#x430;&#x440;&#x442;&#x438;&#x43D;&#x43A;&#x438;.com/" title="http://&#x441;&#x434;&#x435;&#x43B;&#x430;&#x442;&#x43A;&#x430;&#x440;&#x442;&#x438;&#x43D;&#x43A;&#x438;.com/" rel="nofollow external">http://сделаткартинки.com</a>'),
array('http://tūdaliņ.lv',
- '<a href="http://t&#x16B;dali&#x146;.lv/" title="http://t&#x16B;dali&#x146;.lv/" rel="external">http://tūdaliņ.lv</a>'),
+ '<a href="http://t&#x16B;dali&#x146;.lv/" title="http://t&#x16B;dali&#x146;.lv/" rel="nofollow external">http://tūdaliņ.lv</a>'),
array('http://brændendekærlighed.com',
- '<a href="http://br&#xE6;ndendek&#xE6;rlighed.com/" title="http://br&#xE6;ndendek&#xE6;rlighed.com/" rel="external">http://brændendekærlighed.com</a>'),
+ '<a href="http://br&#xE6;ndendek&#xE6;rlighed.com/" title="http://br&#xE6;ndendek&#xE6;rlighed.com/" rel="nofollow external">http://brændendekærlighed.com</a>'),
array('http://あーるいん.com',
- '<a href="http://&#x3042;&#x30FC;&#x308B;&#x3044;&#x3093;.com/" title="http://&#x3042;&#x30FC;&#x308B;&#x3044;&#x3093;.com/" rel="external">http://あーるいん.com</a>'),
+ '<a href="http://&#x3042;&#x30FC;&#x308B;&#x3044;&#x3093;.com/" title="http://&#x3042;&#x30FC;&#x308B;&#x3044;&#x3093;.com/" rel="nofollow external">http://あーるいん.com</a>'),
array('http://예비교사.com',
- '<a href="http://&#xC608;&#xBE44;&#xAD50;&#xC0AC;.com/" title="http://&#xC608;&#xBE44;&#xAD50;&#xC0AC;.com/" rel="external">http://예비교사.com</a>'),
+ '<a href="http://&#xC608;&#xBE44;&#xAD50;&#xC0AC;.com/" title="http://&#xC608;&#xBE44;&#xAD50;&#xC0AC;.com/" rel="nofollow external">http://예비교사.com</a>'),
array('http://example.com.',
- '<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>.'),
+ '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">http://example.com</a>.'),
array('http://example.com?',
- '<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>?'),
+ '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">http://example.com</a>?'),
array('http://example.com!',
- '<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>!'),
+ '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">http://example.com</a>!'),
array('http://example.com,',
- '<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>,'),
+ '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">http://example.com</a>,'),
array('http://example.com;',
- '<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>;'),
+ '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">http://example.com</a>;'),
array('http://example.com:',
- '<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>:'),
+ '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">http://example.com</a>:'),
array('\'http://example.com\'',
- '\'<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>\''),
+ '\'<a href="http://example.com/" title="http://example.com/" rel="nofollow external">http://example.com</a>\''),
array('"http://example.com"',
- '&quot;<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>&quot;'),
+ '&quot;<a href="http://example.com/" title="http://example.com/" rel="nofollow external">http://example.com</a>&quot;'),
array('"http://example.com/"',
- '&quot;<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com/</a>&quot;'),
+ '&quot;<a href="http://example.com/" title="http://example.com/" rel="nofollow external">http://example.com/</a>&quot;'),
array('http://example.com',
- '<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>'),
+ '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">http://example.com</a>'),
array('(http://example.com)',
- '(<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>)'),
+ '(<a href="http://example.com/" title="http://example.com/" rel="nofollow external">http://example.com</a>)'),
array('[http://example.com]',
- '[<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>]'),
+ '[<a href="http://example.com/" title="http://example.com/" rel="nofollow external">http://example.com</a>]'),
array('<http://example.com>',
- '&lt;<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>&gt;'),
+ '&lt;<a href="http://example.com/" title="http://example.com/" rel="nofollow external">http://example.com</a>&gt;'),
array('http://example.com/path/(foo)/bar',
- '<a href="http://example.com/path/(foo)/bar" title="http://example.com/path/(foo)/bar" rel="external">http://example.com/path/(foo)/bar</a>'),
+ '<a href="http://example.com/path/(foo)/bar" title="http://example.com/path/(foo)/bar" rel="nofollow external">http://example.com/path/(foo)/bar</a>'),
array('http://example.com/path/[foo]/bar',
- '<a href="http://example.com/path/" title="http://example.com/path/" rel="external">http://example.com/path/</a>[foo]/bar'),
+ '<a href="http://example.com/path/" title="http://example.com/path/" rel="nofollow external">http://example.com/path/</a>[foo]/bar'),
array('http://example.com/path/foo/(bar)',
- '<a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>'),
+ '<a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="nofollow external">http://example.com/path/foo/(bar)</a>'),
//Not a valid url - urls cannot contain unencoded square brackets
array('http://example.com/path/foo/[bar]',
- '<a href="http://example.com/path/foo/" title="http://example.com/path/foo/" rel="external">http://example.com/path/foo/</a>[bar]'),
+ '<a href="http://example.com/path/foo/" title="http://example.com/path/foo/" rel="nofollow external">http://example.com/path/foo/</a>[bar]'),
array('Hey, check out my cool site http://example.com okay?',
- 'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a> okay?'),
+ 'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="nofollow external">http://example.com</a> okay?'),
array('What about parens (e.g. http://example.com/path/foo/(bar))?',
- 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>)?'),
+ 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="nofollow external">http://example.com/path/foo/(bar)</a>)?'),
array('What about parens (e.g. http://example.com/path/foo/(bar)?',
- 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>?'),
+ 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="nofollow external">http://example.com/path/foo/(bar)</a>?'),
array('What about parens (e.g. http://example.com/path/foo/(bar).)?',
- 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>.)?'),
+ 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="nofollow external">http://example.com/path/foo/(bar)</a>.)?'),
//Not a valid url - urls cannot contain unencoded commas
array('What about parens (e.g. http://example.com/path/(foo,bar)?',
- 'What about parens (e.g. <a href="http://example.com/path/(foo,bar)" title="http://example.com/path/(foo,bar)" rel="external">http://example.com/path/(foo,bar)</a>?'),
+ 'What about parens (e.g. <a href="http://example.com/path/(foo,bar)" title="http://example.com/path/(foo,bar)" rel="nofollow external">http://example.com/path/(foo,bar)</a>?'),
array('Unbalanced too (e.g. http://example.com/path/((((foo)/bar)?',
- 'Unbalanced too (e.g. <a href="http://example.com/path/((((foo)/bar)" title="http://example.com/path/((((foo)/bar)" rel="external">http://example.com/path/((((foo)/bar)</a>?'),
+ 'Unbalanced too (e.g. <a href="http://example.com/path/((((foo)/bar)" title="http://example.com/path/((((foo)/bar)" rel="nofollow external">http://example.com/path/((((foo)/bar)</a>?'),
array('Unbalanced too (e.g. http://example.com/path/(foo))))/bar)?',
- 'Unbalanced too (e.g. <a href="http://example.com/path/(foo))))/bar" title="http://example.com/path/(foo))))/bar" rel="external">http://example.com/path/(foo))))/bar</a>)?'),
+ 'Unbalanced too (e.g. <a href="http://example.com/path/(foo))))/bar" title="http://example.com/path/(foo))))/bar" rel="nofollow external">http://example.com/path/(foo))))/bar</a>)?'),
array('Unbalanced too (e.g. http://example.com/path/foo/((((bar)?',
- 'Unbalanced too (e.g. <a href="http://example.com/path/foo/((((bar)" title="http://example.com/path/foo/((((bar)" rel="external">http://example.com/path/foo/((((bar)</a>?'),
+ 'Unbalanced too (e.g. <a href="http://example.com/path/foo/((((bar)" title="http://example.com/path/foo/((((bar)" rel="nofollow external">http://example.com/path/foo/((((bar)</a>?'),
array('Unbalanced too (e.g. http://example.com/path/foo/(bar))))?',
- 'Unbalanced too (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>)))?'),
+ 'Unbalanced too (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="nofollow external">http://example.com/path/foo/(bar)</a>)))?'),
array('example.com',
- '<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>'),
+ '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>'),
array('example.org',
- '<a href="http://example.org/" title="http://example.org/" rel="external">example.org</a>'),
+ '<a href="http://example.org/" title="http://example.org/" rel="nofollow external">example.org</a>'),
array('example.co.uk',
- '<a href="http://example.co.uk/" title="http://example.co.uk/" rel="external">example.co.uk</a>'),
+ '<a href="http://example.co.uk/" title="http://example.co.uk/" rel="nofollow external">example.co.uk</a>'),
array('www.example.co.uk',
- '<a href="http://www.example.co.uk/" title="http://www.example.co.uk/" rel="external">www.example.co.uk</a>'),
+ '<a href="http://www.example.co.uk/" title="http://www.example.co.uk/" rel="nofollow external">www.example.co.uk</a>'),
array('farm1.images.example.co.uk',
- '<a href="http://farm1.images.example.co.uk/" title="http://farm1.images.example.co.uk/" rel="external">farm1.images.example.co.uk</a>'),
+ '<a href="http://farm1.images.example.co.uk/" title="http://farm1.images.example.co.uk/" rel="nofollow external">farm1.images.example.co.uk</a>'),
array('example.museum',
- '<a href="http://example.museum/" title="http://example.museum/" rel="external">example.museum</a>'),
+ '<a href="http://example.museum/" title="http://example.museum/" rel="nofollow external">example.museum</a>'),
array('example.travel',
- '<a href="http://example.travel/" title="http://example.travel/" rel="external">example.travel</a>'),
+ '<a href="http://example.travel/" title="http://example.travel/" rel="nofollow external">example.travel</a>'),
array('example.com.',
- '<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>.'),
+ '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>.'),
array('example.com?',
- '<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>?'),
+ '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>?'),
array('example.com!',
- '<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>!'),
+ '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>!'),
array('example.com,',
- '<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>,'),
+ '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>,'),
array('example.com;',
- '<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>;'),
+ '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>;'),
array('example.com:',
- '<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>:'),
+ '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>:'),
array('\'example.com\'',
- '\'<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>\''),
+ '\'<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>\''),
array('"example.com"',
- '&quot;<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>&quot;'),
+ '&quot;<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>&quot;'),
array('example.com',
- '<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>'),
+ '<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>'),
array('(example.com)',
- '(<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>)'),
+ '(<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>)'),
array('[example.com]',
- '[<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>]'),
+ '[<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>]'),
array('<example.com>',
- '&lt;<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>&gt;'),
+ '&lt;<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>&gt;'),
array('Hey, check out my cool site example.com okay?',
- 'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="external">example.com</a> okay?'),
+ 'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a> okay?'),
array('Hey, check out my cool site example.com.I made it.',
- 'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>.I made it.'),
+ 'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>.I made it.'),
array('Hey, check out my cool site example.com.Funny thing...',
- 'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>.Funny thing...'),
+ 'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>.Funny thing...'),
array('Hey, check out my cool site example.com.You will love it.',
- 'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>.You will love it.'),
+ 'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>.You will love it.'),
array('What about parens (e.g. example.com/path/foo/(bar))?',
- 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="external">example.com/path/foo/(bar)</a>)?'),
+ 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="nofollow external">example.com/path/foo/(bar)</a>)?'),
array('What about parens (e.g. example.com/path/foo/(bar)?',
- 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="external">example.com/path/foo/(bar)</a>?'),
+ 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="nofollow external">example.com/path/foo/(bar)</a>?'),
array('What about parens (e.g. example.com/path/foo/(bar).)?',
- 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="external">example.com/path/foo/(bar)</a>.)?'),
+ 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="nofollow external">example.com/path/foo/(bar)</a>.)?'),
array('What about parens (e.g. example.com/path/(foo,bar)?',
- 'What about parens (e.g. <a href="http://example.com/path/(foo,bar)" title="http://example.com/path/(foo,bar)" rel="external">example.com/path/(foo,bar)</a>?'),
+ 'What about parens (e.g. <a href="http://example.com/path/(foo,bar)" title="http://example.com/path/(foo,bar)" rel="nofollow external">example.com/path/(foo,bar)</a>?'),
array('file.ext',
'file.ext'),
array('file.html',
diff --git a/tests/oauth/README b/tests/oauth/README
index dd76feb0c..13f1d0c03 100644
--- a/tests/oauth/README
+++ b/tests/oauth/README
@@ -1,22 +1,160 @@
Some very rough test scripts for hitting up the OAuth endpoints.
-Note: this works best if you register an OAuth application, leaving
-the callback URL blank.
+These instructions assume you understand the basics of how OAuth
+works. You may want to read up about it first. Here are some good
+resources for learning about OAuth:
-Put your instance info and consumer key and secret in oauth.ini
+ http://hueniverse.com/oauth/
+ http://tools.ietf.org/html/rfc5849
-Example usage:
---------------
+To use these scripts (and OAuth in general) first you will need to
+register and OAuth client application with your StatusNet instance:
-php getrequesttoken.php
+ http://example.status.net/settings/oauthapps
-Gets a request token, token secret and a url to authorize it. Once
-you authorize the request token you can exchange it for an access token...
+oauth.ini
+---------
-php exchangetokens.php --oauth_token=b9a79548a88c1aa9a5bea73103c6d41d --token_secret=4a47d9337fc0202a14ab552e17a3b657
+Using oauth.ini.sample as a guide, put your StatusNet OAuth endpoints
+and consumer key and secret in a file called oauth.ini and save it
+in the same directory as these scripts.
-Once you have your access token, go ahead and try a protected API
-resource:
+fetch_temp_creds.php
+--------------------
-php verifycreds.php --oauth_token=cf2de7665f0dda0a82c2dc39b01be7f9 --token_secret=4524c3b712200138e1a4cff2e9ca83d8
+Will fetch a request token, token secret and a URL to authorize the
+token. Once you authorize the request token, you can exchange it
+for an access token.
+
+example usage:
+
+ $ php fetch_temp_creds.php
+ Request Token
+ - oauth_token = 89d481e376edc622f08da5791e6a4446
+ - oauth_token_secret = 6d028bcd1ea125cbed7da2f254219885
+ Authorize URL
+ http://example.status.net/api/oauth/authorize?oauth_token=89d481e376edc622f08da5791e6a4446
+
+ Now paste the Authorize URL into your browser and authorize your temporary credentials.
+
+fetch_token_creds.php
+---------------------
+
+After you have authorized your request token, you will be presented
+with a verifier code, or pin, in your browser, which you will need
+to get an access token. Make sure you copy it into a text buffer
+or write it down or something. Then call fetch_token_credentials.php
+to exchange your temporary credentials for real token credentials.
+
+example usage:
+
+ $ php fetch_token_creds.php -t 89d481e376edc622f08da5791e6a4446 -s 6d028bcd1ea125cbed7da2f254219885 -v 305162
+ Access Token
+ - oauth_token = 9b354df102d8e2b4621122c85d8d045c
+ - oauth_token_secret = 1800a88f1574b47d595214a74e5b1ec5
+
+
+oauth_verify_credentials.php
+----------------------------
+
+Now you should have real token credentials (an OAuth access token)
+and you can access protected API resources. This is an example
+script that calls /api/account/verify_credentials.xml.
+
+example usage:
+
+ $ php oauth_verify_creds.php -t 80305cd15c5c69834364ac02d7f9178c -s 673e3b2978b1b92c8edbfe172505fee1
+ <?xml version="1.0" encoding="UTF-8"?>
+ <user xmlns:statusnet="http://status.net/schema/api/1/">
+ <id>23</id>
+ <name>zach</name>
+ <screen_name>zach</screen_name>
+ <location></location>
+ <description></description>
+ <profile_image_url>http://example.status.net/theme/default/default-avatar-stream.png</profile_image_url>
+ <url></url>
+ <protected>false</protected>
+ <followers_count>0</followers_count>
+ <profile_background_color></profile_background_color>
+ <profile_text_color></profile_text_color>
+ <profile_link_color></profile_link_color>
+ <profile_sidebar_fill_color></profile_sidebar_fill_color>
+ <profile_sidebar_border_color></profile_sidebar_border_color>
+ <friends_count>0</friends_count>
+ <created_at>Thu Sep 30 23:11:00 +0000 2010</created_at>
+ <favourites_count>0</favourites_count>
+ <utc_offset>0</utc_offset>
+ <time_zone>UTC</time_zone>
+ <profile_background_image_url></profile_background_image_url>
+ <profile_background_tile>false</profile_background_tile>
+ <statuses_count>4</statuses_count>
+ <following>true</following>
+ <statusnet:blocking>false</statusnet:blocking>
+ <notifications>true</notifications>
+ <status>
+ <text>gar</text>
+ <truncated>false</truncated>
+ <created_at>Wed Oct 06 23:40:14 +0000 2010</created_at>
+ <in_reply_to_status_id></in_reply_to_status_id>
+ <source>web</source>
+ <id>7</id>
+ <in_reply_to_user_id></in_reply_to_user_id>
+ <in_reply_to_screen_name></in_reply_to_screen_name>
+ <geo></geo>
+ <favorited>false</favorited>
+ <statusnet:html>gar</statusnet:html>
+ </status>
+ <statusnet:profile_url>http://example.status.net/statusnet/zach</statusnet:profile_url>
+ </user>
+
+oauth_post_notice.php
+---------------------
+
+This is another test script that lets you post a notice via OAuth.
+
+example usage:
+
+ $ php oauth_post_notice.php -t 80305cd15c5c69834364ac02d7f9178c -s 673e3b2978b1b92c8edbfe172505fee1 -u 'Test test test...'
+ <?xml version="1.0" encoding="UTF-8"?>
+ <status xmlns:statusnet="http://status.net/schema/api/1/">
+ <text>Test test test...</text>
+ <truncated>false</truncated>
+ <created_at>Fri Oct 08 02:37:35 +0000 2010</created_at>
+ <in_reply_to_status_id></in_reply_to_status_id>
+ <source>&lt;a href=&quot;http://banana.com&quot; rel=&quot;nofollow&quot;&gt;Banana&lt;/a&gt;</source>
+ <id>8</id>
+ <in_reply_to_user_id></in_reply_to_user_id>
+ <in_reply_to_screen_name></in_reply_to_screen_name>
+ <geo></geo>
+ <favorited>false</favorited>
+ <user>
+ <id>23</id>
+ <name>zach</name>
+ <screen_name>zach</screen_name>
+ <location></location>
+ <description></description>
+ <profile_image_url>http://example.status.net/statusnet/theme/default/default-avatar-stream.png</profile_image_url>
+ <url></url>
+ <protected>false</protected>
+ <followers_count>0</followers_count>
+ <profile_background_color></profile_background_color>
+ <profile_text_color></profile_text_color>
+ <profile_link_color></profile_link_color>
+ <profile_sidebar_fill_color></profile_sidebar_fill_color>
+ <profile_sidebar_border_color></profile_sidebar_border_color>
+ <friends_count>0</friends_count>
+ <created_at>Thu Sep 30 23:11:00 +0000 2010</created_at>
+ <favourites_count>0</favourites_count>
+ <utc_offset>0</utc_offset>
+ <time_zone>UTC</time_zone>
+ <profile_background_image_url></profile_background_image_url>
+ <profile_background_tile>false</profile_background_tile>
+ <statuses_count>5</statuses_count>
+ <following>true</following>
+ <statusnet:blocking>false</statusnet:blocking>
+ <notifications>true</notifications>
+ <statusnet:profile_url>http://example.status.net/statusnet/zach</statusnet:profile_url>
+ </user>
+ <statusnet:html>Test test test...</statusnet:html>
+ </status>
diff --git a/tests/oauth/exchangetokens.php b/tests/oauth/exchangetokens.php
deleted file mode 100755
index 2394826c7..000000000
--- a/tests/oauth/exchangetokens.php
+++ /dev/null
@@ -1,105 +0,0 @@
-#!/usr/bin/env php
-<?php
-/*
- * StatusNet - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, StatusNet, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-define('INSTALLDIR', realpath(dirname(__FILE__) . '/../..'));
-
-require_once INSTALLDIR . '/extlib/OAuth.php';
-
-$ini = parse_ini_file("oauth.ini");
-
-$test_consumer = new OAuthConsumer($ini['consumer_key'], $ini['consumer_secret']);
-
-$at_endpoint = $ini['apiroot'] . $ini['access_token_url'];
-
-$shortoptions = 't:s:';
-$longoptions = array('oauth_token=', 'token_secret=');
-
-$helptext = <<<END_OF_ETOKENS_HELP
- exchangetokens.php [options]
- Exchange an authorized OAuth request token for an access token
-
- -t --oauth_token authorized request token
- -s --token_secret authorized request token secret
-
-END_OF_ETOKENS_HELP;
-
-require_once INSTALLDIR . '/scripts/commandline.inc';
-
-$token = null;
-$token_secret = null;
-
-if (have_option('t', 'oauth_token')) {
- $token = get_option_value('oauth_token');
-}
-
-if (have_option('s', 'token_secret')) {
- $token_secret = get_option_value('s', 'token_secret');
-}
-
-if (empty($token)) {
- print "Please specify a request token.\n";
- exit(1);
-}
-
-if (empty($token_secret)) {
- print "Please specify a request token secret.\n";
- exit(1);
-}
-
-$rt = new OAuthToken($token, $token_secret);
-common_debug("Exchange request token = " . var_export($rt, true));
-
-$parsed = parse_url($at_endpoint);
-$params = array();
-parse_str($parsed['query'], $params);
-
-$hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
-
-$req_req = OAuthRequest::from_consumer_and_token($test_consumer, $rt, "GET", $at_endpoint, $params);
-$req_req->sign_request($hmac_method, $test_consumer, $rt);
-
-$r = httpRequest($req_req->to_url());
-
-common_debug("Exchange request token = " . var_export($rt, true));
-common_debug("Exchange tokens URL: " . $req_req->to_url());
-
-$body = $r->getBody();
-
-$token_stuff = array();
-parse_str($body, $token_stuff);
-
-print 'Access token : ' . $token_stuff['oauth_token'] . "\n";
-print 'Access token secret : ' . $token_stuff['oauth_token_secret'] . "\n";
-
-function httpRequest($url)
-{
- $request = HTTPClient::start();
-
- $request->setConfig(array(
- 'follow_redirects' => true,
- 'connect_timeout' => 120,
- 'timeout' => 120,
- 'ssl_verify_peer' => false,
- 'ssl_verify_host' => false
- ));
-
- return $request->get($url);
-}
-
diff --git a/tests/oauth/fetch_temp_creds.php b/tests/oauth/fetch_temp_creds.php
new file mode 100755
index 000000000..bea512a91
--- /dev/null
+++ b/tests/oauth/fetch_temp_creds.php
@@ -0,0 +1,106 @@
+#!/usr/bin/env php
+<?php
+/*
+ * StatusNet - a distributed open-source microblogging tool
+ * Copyright (C) 2010, StatusNet, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/../..'));
+
+require_once INSTALLDIR . '/scripts/commandline.inc';
+require_once INSTALLDIR . '/extlib/OAuth.php';
+
+$ini = parse_ini_file("oauth.ini");
+
+// Check to make sure we have everything we need from the ini file
+foreach(array('consumer_key', 'consumer_secret', 'apiroot', 'request_token_url') as $inikey) {
+ if (empty($ini[$inikey])) {
+ print "You forgot to specify a $inikey in your oauth.ini file.\n";
+ exit(1);
+ }
+}
+
+$consumer = new OAuthConsumer($ini['consumer_key'], $ini['consumer_secret']);
+$endpoint = $ini['apiroot'] . $ini['request_token_url'];
+$parsed = parse_url($endpoint);
+$params = array();
+
+parse_str($parsed['query'], $params);
+$params['oauth_callback'] = 'oob'; // out-of-band
+
+$hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
+
+try {
+ $req = OAuthRequest::from_consumer_and_token(
+ $consumer,
+ null,
+ "POST",
+ $endpoint,
+ $params
+ );
+ $req->sign_request($hmac_method, $consumer, NULL);
+ $r = httpRequest($endpoint, $req->to_postdata());
+} catch (Exception $e) {
+ // oh noez
+ print $e->getMessage();
+ print "\nOAuth Request:\n";
+ var_dump($req);
+ exit(1);
+}
+
+$body = $r->getBody();
+$tokenStuff = array();
+
+parse_str($body, $tokenStuff);
+
+$tok = $tokenStuff['oauth_token'];
+$confirmed = $tokenStuff['oauth_callback_confirmed'];
+
+if (empty($tokenStuff['oauth_token'])
+ || empty($tokenStuff['oauth_token_secret'])
+ || empty($confirmed)
+ || $confirmed != 'true')
+{
+ print "Error! HTTP response body: $body\n";
+ exit(1);
+}
+
+$authurl = $ini['apiroot'] . $ini['authorize_url'] . '?oauth_token=' . $tok;
+
+print "Request Token\n";
+print ' - oauth_token = ' . $tokenStuff['oauth_token'] . "\n";
+print ' - oauth_token_secret = ' . $tokenStuff['oauth_token_secret'] . "\n";
+print "Authorize URL\n $authurl\n\n";
+print "Now paste the Authorize URL into your browser and authorize your temporary credentials.\n";
+
+function httpRequest($endpoint, $poststr)
+{
+ $request = HTTPClient::start();
+
+ $request->setConfig(
+ array(
+ 'follow_redirects' => true,
+ 'connect_timeout' => 120,
+ 'timeout' => 120,
+ 'ssl_verify_peer' => false,
+ 'ssl_verify_host' => false
+ )
+ );
+
+ // Turn signed request query string back into an array
+ parse_str($poststr, $postdata);
+ return $request->post($endpoint, null, $postdata);
+}
diff --git a/tests/oauth/fetch_token_creds.php b/tests/oauth/fetch_token_creds.php
new file mode 100755
index 000000000..a508c7240
--- /dev/null
+++ b/tests/oauth/fetch_token_creds.php
@@ -0,0 +1,146 @@
+#!/usr/bin/env php
+<?php
+/*
+ * StatusNet - a distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/../..'));
+
+require_once INSTALLDIR . '/extlib/OAuth.php';
+
+$ini = parse_ini_file("oauth.ini");
+
+// Check to make sure we have everything we need from the ini file
+foreach(array('consumer_key', 'consumer_secret', 'apiroot', 'access_token_url') as $inikey) {
+ if (empty($ini[$inikey])) {
+ print "You forgot to specify a $inikey in your oauth.ini file.\n";
+ exit(1);
+ }
+}
+
+$consumer = new OAuthConsumer($ini['consumer_key'], $ini['consumer_secret']);
+
+$endpoint = $ini['apiroot'] . $ini['access_token_url'];
+
+$shortoptions = 't:s:v:';
+$longoptions = array('oauth_token=', 'oauth_token_secret=', 'oauth_verifier=');
+
+$helptext = <<<END_OF_ETOKENS_HELP
+ fetch_token_creds.php [options]
+
+ Exchange authorized OAuth temporary credentials for token credentials
+ (an authorized request token for an access token)
+
+ -t --oauth_token authorized request token
+ -s --oauth_token_secret authorized request token secret
+ -v --oauth_verifier authorized request token verifier
+
+
+END_OF_ETOKENS_HELP;
+
+require_once INSTALLDIR . '/scripts/commandline.inc';
+
+$token = $secret = $verifier = null;
+
+if (have_option('t', 'oauth_token')) {
+ $token = get_option_value('t', 'oauth_token');
+}
+
+if (have_option('s', 'oauth_token_secret')) {
+ $secret = get_option_value('s', 'oauth_token_secret');
+}
+
+if (have_option('v', 'oauth_verifier')) {
+ $verifier = get_option_value('v', 'oauth_verifier');
+}
+
+if (empty($token)) {
+ print "Please specify the request token (--help for help).\n";
+ exit(1);
+}
+
+if (empty($secret)) {
+ print "Please specify the request token secret (--help for help).\n";
+ exit(1);
+}
+
+if (empty($verifier)) {
+ print "Please specify the request token verifier (--help for help).\n";
+ exit(1);
+}
+
+$rtok = new OAuthToken($token, $secret);
+$parsed = parse_url($endpoint);
+parse_str($parsed['query'], $params);
+
+$params['oauth_verifier'] = $verifier; // 1.0a
+
+$hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
+
+try {
+
+ $oauthReq = OAuthRequest::from_consumer_and_token(
+ $consumer,
+ $rtok,
+ "POST",
+ $endpoint,
+ $params
+ );
+
+ $oauthReq->sign_request($hmac_method, $consumer, $rtok);
+
+ $httpReq = httpRequest($endpoint, $oauthReq->to_postdata());
+ $body = $httpReq->getBody();
+
+} catch (Exception $e) {
+ // oh noez
+ print $e->getMessage();
+ print "\nOAuth Request:\n";
+ var_dump($oauthReq);
+ exit(1);
+}
+
+$tokenStuff = array();
+parse_str($body, $tokenStuff);
+
+if (empty($tokenStuff['oauth_token']) || empty($tokenStuff['oauth_token_secret'])) {
+ print "Error! HTTP response body: $body\n";
+ exit(1);
+}
+
+print "Access Token\n";
+print ' - oauth_token = ' . $tokenStuff['oauth_token'] . "\n";
+print ' - oauth_token_secret = ' . $tokenStuff['oauth_token_secret'] . "\n";
+
+function httpRequest($endpoint, $poststr)
+{
+ $request = HTTPClient::start();
+
+ $request->setConfig(
+ array(
+ 'follow_redirects' => true,
+ 'connect_timeout' => 120,
+ 'timeout' => 120,
+ 'ssl_verify_peer' => false,
+ 'ssl_verify_host' => false
+ )
+ );
+
+ parse_str($poststr, $postdata);
+ return $request->post($endpoint, null, $postdata);
+}
+
diff --git a/tests/oauth/getrequesttoken.php b/tests/oauth/getrequesttoken.php
deleted file mode 100755
index fc546a0f4..000000000
--- a/tests/oauth/getrequesttoken.php
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/usr/bin/env php
-<?php
-/*
- * StatusNet - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, StatusNet, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-define('INSTALLDIR', realpath(dirname(__FILE__) . '/../..'));
-
-require_once INSTALLDIR . '/scripts/commandline.inc';
-require_once INSTALLDIR . '/extlib/OAuth.php';
-
-$ini = parse_ini_file("oauth.ini");
-
-$test_consumer = new OAuthConsumer($ini['consumer_key'], $ini['consumer_secret']);
-
-$rt_endpoint = $ini['apiroot'] . $ini['request_token_url'];
-
-$parsed = parse_url($rt_endpoint);
-$params = array();
-
-parse_str($parsed['query'], $params);
-
-$hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
-
-$req_req = OAuthRequest::from_consumer_and_token($test_consumer, NULL, "GET", $rt_endpoint, $params);
-$req_req->sign_request($hmac_method, $test_consumer, NULL);
-
-$r = httpRequest($req_req->to_url());
-
-$body = $r->getBody();
-
-$token_stuff = array();
-parse_str($body, $token_stuff);
-
-$authurl = $ini['apiroot'] . $ini['authorize_url'] . '?oauth_token=' . $token_stuff['oauth_token'];
-
-print 'Request token : ' . $token_stuff['oauth_token'] . "\n";
-print 'Request token secret : ' . $token_stuff['oauth_token_secret'] . "\n";
-print "Authorize URL : $authurl\n";
-
-//var_dump($req_req);
-
-function httpRequest($url)
-{
- $request = HTTPClient::start();
-
- $request->setConfig(array(
- 'follow_redirects' => true,
- 'connect_timeout' => 120,
- 'timeout' => 120,
- 'ssl_verify_peer' => false,
- 'ssl_verify_host' => false
- ));
-
- return $request->get($url);
-}
-
diff --git a/tests/oauth/oauth.ini b/tests/oauth/oauth.ini.sample
index 16b747fe4..927620e2f 100644
--- a/tests/oauth/oauth.ini
+++ b/tests/oauth/oauth.ini.sample
@@ -1,5 +1,5 @@
; Setup OAuth info here
-apiroot = "http://YOURSTATUSNET/api"
+apiroot = "https://YOURSTATUSNET/api"
request_token_url = "/oauth/request_token"
authorize_url = "/oauth/authorize"
diff --git a/tests/oauth/statusupdate.php b/tests/oauth/oauth_post_notice.php
index 4aa230e28..5e9d2a7ab 100644
--- a/tests/oauth/statusupdate.php
+++ b/tests/oauth/oauth_post_notice.php
@@ -22,16 +22,16 @@ define('INSTALLDIR', realpath(dirname(__FILE__) . '/../..'));
require_once INSTALLDIR . '/extlib/OAuth.php';
-$shortoptions = 'o:s:u:';
+$shortoptions = 't:s:u:';
$longoptions = array('oauth_token=', 'token_secret=', 'update=');
$helptext = <<<END_OF_VERIFY_HELP
- statusupdate.php [options]
- Update your status using OAuth
+ oauth_post_notice.php [options]
+ Update your status via OAuth
- -o --oauth_token access token
- -s --token_secret access token secret
- -u --update status update
+ -t --oauth_token access token
+ -s --oauth_token_secret access token secret
+ -u --update status update
END_OF_VERIFY_HELP;
@@ -42,12 +42,12 @@ $update = null;
require_once INSTALLDIR . '/scripts/commandline.inc';
-if (have_option('o', 'oauth_token')) {
- $token = get_option_value('oauth_token');
+if (have_option('t', 'oauth_token')) {
+ $token = get_option_value('t', 'oauth_token');
}
-if (have_option('s', 'token_secret')) {
- $token_secret = get_option_value('s', 'token_secret');
+if (have_option('s', 'oauth_token_secret')) {
+ $token_secret = get_option_value('s', 'oauth_token_secret');
}
if (have_option('u', 'update')) {
@@ -69,47 +69,56 @@ if (empty($update)) {
exit(1);
}
-$ini = parse_ini_file("oauth.ini");
-
-$test_consumer = new OAuthConsumer($ini['consumer_key'], $ini['consumer_secret']);
-
+$ini = parse_ini_file("oauth.ini");
+$consumer = new OAuthConsumer($ini['consumer_key'], $ini['consumer_secret']);
$endpoint = $ini['apiroot'] . '/statuses/update.xml';
-print "$endpoint\n";
-
-$at = new OAuthToken($token, $token_secret);
+$atok = new OAuthToken($token, $token_secret);
$parsed = parse_url($endpoint);
-$params = array();
parse_str($parsed['query'], $params);
$params['status'] = $update;
$hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
-$req_req = OAuthRequest::from_consumer_and_token($test_consumer, $at, 'POST', $endpoint, $params);
-$req_req->sign_request($hmac_method, $test_consumer, $at);
+try {
-$r = httpRequest($req_req->to_url());
+ $oauthReq = OAuthRequest::from_consumer_and_token(
+ $consumer,
+ $atok,
+ 'POST',
+ $endpoint,
+ $params
+ );
-$body = $r->getBody();
+ $oauthReq->sign_request($hmac_method, $consumer, $atok);
-print "$body\n";
+ $httpReq = httpRequest($endpoint, $oauthReq->to_postdata());
-//print $req_req->to_url() . "\n\n";
+ print $httpReq->getBody();
-function httpRequest($url)
+} catch (Exception $e) {
+ print "Error! . $e->getMessage() . 'HTTP reponse body: " . $httpReq->getBody();
+ exit(1);
+}
+
+function httpRequest($endpoint, $poststr)
{
$request = HTTPClient::start();
- $request->setConfig(array(
- 'follow_redirects' => true,
- 'connect_timeout' => 120,
- 'timeout' => 120,
- 'ssl_verify_peer' => false,
- 'ssl_verify_host' => false
- ));
-
- return $request->post($url);
+ $request->setConfig(
+ array(
+ 'follow_redirects' => true,
+ 'connect_timeout' => 120,
+ 'timeout' => 120,
+ 'ssl_verify_peer' => false,
+ 'ssl_verify_host' => false
+ )
+ );
+
+ // Turn signed request query string back into an array
+ parse_str($poststr, $postdata);
+ return $request->post($endpoint, null, $postdata);
}
diff --git a/tests/oauth/verifycreds.php b/tests/oauth/oauth_verify_creds.php
index 873bdb8bd..7eea6e7e7 100755
--- a/tests/oauth/verifycreds.php
+++ b/tests/oauth/oauth_verify_creds.php
@@ -22,15 +22,15 @@ define('INSTALLDIR', realpath(dirname(__FILE__) . '/../..'));
require_once INSTALLDIR . '/extlib/OAuth.php';
-$shortoptions = 'o:s:';
-$longoptions = array('oauth_token=', 'token_secret=');
+$shortoptions = 't:s:';
+$longoptions = array('oauth_token=', 'oauth_token_secret=');
$helptext = <<<END_OF_VERIFY_HELP
- verifycreds.php [options]
- Use an access token to verify credentials thru the api
+ oauth_verify_creds.php [options]
+ Access /api/account/verify_credentials.xml with OAuth
- -o --oauth_token access token
- -s --token_secret access token secret
+ -t --oauth_token access token
+ -s --oauth_token_secret access token secret
END_OF_VERIFY_HELP;
@@ -39,63 +39,69 @@ $token_secret = null;
require_once INSTALLDIR . '/scripts/commandline.inc';
-if (have_option('o', 'oauth_token')) {
- $token = get_option_value('oauth_token');
+if (have_option('t', 'oauth_token')) {
+ $token = get_option_value('t', 'oauth_token');
}
if (have_option('s', 'token_secret')) {
- $token_secret = get_option_value('s', 'token_secret');
+ $token_secret = get_option_value('s', 'oauth_token_secret');
}
if (empty($token)) {
- print "Please specify an access token.\n";
+ print "Please specify an access token (--help for help).\n";
exit(1);
}
if (empty($token_secret)) {
- print "Please specify an access token secret.\n";
+ print "Please specify an access token secret (--help for help).\n";
exit(1);
}
-$ini = parse_ini_file("oauth.ini");
-
-$test_consumer = new OAuthConsumer($ini['consumer_key'], $ini['consumer_secret']);
-
+$ini = parse_ini_file("oauth.ini");
+$consumer = new OAuthConsumer($ini['consumer_key'], $ini['consumer_secret']);
$endpoint = $ini['apiroot'] . '/account/verify_credentials.xml';
-print "$endpoint\n";
-
-$at = new OAuthToken($token, $token_secret);
-
+$atok = new OAuthToken($token, $token_secret);
$parsed = parse_url($endpoint);
-$params = array();
+
parse_str($parsed['query'], $params);
-$hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
+try {
-$req_req = OAuthRequest::from_consumer_and_token($test_consumer, $at, "GET", $endpoint, $params);
-$req_req->sign_request($hmac_method, $test_consumer, $at);
+ $hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
-$r = httpRequest($req_req->to_url());
+ $oauthReq = OAuthRequest::from_consumer_and_token(
+ $consumer,
+ $atok,
+ "GET",
+ $endpoint,
+ $params
+ );
-$body = $r->getBody();
+ $oauthReq->sign_request($hmac_method, $consumer, $atok);
-print "$body\n";
+ $httpReq = httpRequest($oauthReq->to_url());
-//print $req_req->to_url() . "\n\n";
+} catch (Exception $e) {
+ print "Error! HTTP response body: " . $httpReq->getBody();
+ exit(1);
+}
+
+print $httpReq->getBody();
function httpRequest($url)
{
$request = HTTPClient::start();
- $request->setConfig(array(
- 'follow_redirects' => true,
- 'connect_timeout' => 120,
- 'timeout' => 120,
- 'ssl_verify_peer' => false,
- 'ssl_verify_host' => false
- ));
+ $request->setConfig(
+ array(
+ 'follow_redirects' => true,
+ 'connect_timeout' => 120,
+ 'timeout' => 120,
+ 'ssl_verify_peer' => false,
+ 'ssl_verify_host' => false
+ )
+ );
return $request->get($url);
}
-