-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtestOAuth.php
54 lines (47 loc) · 1.85 KB
/
testOAuth.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?
require('OAuth.php');
/*
class Request_Test extends PHPUnit_Framework_TestCase
{
protected $request;
public function setUp() {
}
public function testNormalizedURL() {
$request = new Request("POST",
'https://www.plurk.com/OAuth/request_token', null, 'content');
$this->assertEquals('https://www.plurk.com/OAuth/request_token',
$request->normalized_url);
}
}
*/
class SignatureMethod_Test extends PHPUnit_Framework_TestCase
{
protected $request;
protected $consumer;
protected $token;
protected $signature_method;
public function setUp() {
$this->consumer = new Consumer('con_key', 'con_secret');
$this->token = new Token('auth_token', 'auth_token_secret');
}
public function tearDown() {}
public function testPOSTGetRequestToken() {
$request = new Request("POST",
'https://www.plurk.com/OAuth/request_token');
$signature_method = new SignatureMethod_HMAC_SHA1();
$request->sign_request($signature_method, $this->consumer, $this->token);
$header = $request->to_header();
$gold = array ('Authorization' => 'OAuth realm="", oauth_consumer_key="con_key", oauth_token="auth_token", oauth_signature_method="HMAC_SHA1", oauth_signature="4QJdtxu30u/YhwTgexeStWxy6Ec="');
$this->assertEquals($gold, $header);
}
public function testPOSTGetRequestToken2() {
$request = Request::from_consumer_and_token(
$this->consumer, $this->token, "POST",
'https://www.plurk.com/OAuth/request_token');
$signature_method = new SignatureMethod_HMAC_SHA1();
$request->sign_request($signature_method, $this->consumer, $this->token);
$header = $request->to_header();
$gold = array ('Authorization' => 'OAuth realm="", oauth_consumer_key="con_key", oauth_token="auth_token", oauth_signature_method="HMAC_SHA1", oauth_signature="4QJdtxu30u/YhwTgexeStWxy6Ec="');
$this->assertNotEquals($gold, $header);
}
}